• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ duk_push_object函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中duk_push_object函数的典型用法代码示例。如果您正苦于以下问题:C++ duk_push_object函数的具体用法?C++ duk_push_object怎么用?C++ duk_push_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了duk_push_object函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: test_is_prototype_of

static duk_ret_t test_is_prototype_of(duk_context *ctx, void *udata) {
	(void) udata;

	prep(ctx);

	/* obj0.isPrototypeOf(dummy) -> false, traverses prototype chain of dummy */
	duk_eval_string(ctx, "Object.prototype.isPrototypeOf");
	duk_dup(ctx, 0);
	duk_push_object(ctx);
	duk_call_method(ctx, 1);
	printf("Object.prototype.isPrototypeOf result: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	/* obj0.isPrototypeOf(obj1) -> true, traverses prototype chain of obj1 */
	duk_eval_string(ctx, "Object.prototype.isPrototypeOf");
	duk_dup(ctx, 0);
	duk_dup(ctx, 1);
	duk_call_method(ctx, 1);
	printf("Object.prototype.isPrototypeOf result: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	/* dummy.isPrototypeOf(obj0) -> traverses prototype chain of obj0 and throws */
	duk_eval_string(ctx, "Object.prototype.isPrototypeOf");
	duk_push_object(ctx);
	duk_dup(ctx, 0);
	duk_call_method(ctx, 1);
	printf("Object.prototype.isPrototypeOf result: %s\n", duk_safe_to_string(ctx, -1));
	duk_pop(ctx);

	return 0;
}
开发者ID:GarethNelson,项目名称:duktape,代码行数:31,代码来源:test-dev-prototype-loop.c


示例2: duk_push_sphere_bytearray

void
duk_push_sphere_bytearray(duk_context* ctx, bytearray_t* array)
{
	duk_push_object(ctx);
	duk_push_string(ctx, "bytearray"); duk_put_prop_string(ctx, -2, "\xFF" "sphere_type");
	duk_push_pointer(ctx, array); duk_put_prop_string(ctx, -2, "\xFF" "ptr");
	duk_push_c_function(ctx, js_ByteArray_finalize, DUK_VARARGS); duk_set_finalizer(ctx, -2);
	duk_push_c_function(ctx, js_ByteArray_toString, DUK_VARARGS); duk_put_prop_string(ctx, -2, "toString");
	duk_push_c_function(ctx, js_ByteArray_concat, DUK_VARARGS); duk_put_prop_string(ctx, -2, "concat");
	duk_push_c_function(ctx, js_ByteArray_slice, DUK_VARARGS); duk_put_prop_string(ctx, -2, "slice");
	duk_push_string(ctx, "length"); duk_push_int(ctx, array->size);
	duk_def_prop(ctx, -3,
		DUK_DEFPROP_HAVE_CONFIGURABLE | 0
		| DUK_DEFPROP_HAVE_WRITABLE | 0
		| DUK_DEFPROP_HAVE_VALUE);

	// return proxy object so we can catch array accesses
	duk_push_global_object(ctx);
	duk_get_prop_string(ctx, -1, "Proxy");
	duk_dup(ctx, -3);
	duk_push_object(ctx);
	duk_push_c_function(ctx, js_ByteArray_getProp, DUK_VARARGS); duk_put_prop_string(ctx, -2, "get");
	duk_push_c_function(ctx, js_ByteArray_setProp, DUK_VARARGS); duk_put_prop_string(ctx, -2, "set");
	duk_new(ctx, 2);
	duk_remove(ctx, -2);
	duk_remove(ctx, -2);
}
开发者ID:carriercomm,项目名称:minisphere,代码行数:27,代码来源:bytearray.c


示例3: Expose_Light

void Expose_Light(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, Light_StaticFunctions);
    duk_push_number(ctx, 0);
    duk_put_prop_string(ctx, -2, "PointLight");
    duk_push_number(ctx, 1);
    duk_put_prop_string(ctx, -2, "Spotlight");
    duk_push_number(ctx, 2);
    duk_put_prop_string(ctx, -2, "DirectionalLight");
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, Light_Functions);
    DefineProperty(ctx, "ComponentNameChanged", Light_Get_ComponentNameChanged, nullptr);
    DefineProperty(ctx, "ParentEntitySet", Light_Get_ParentEntitySet, nullptr);
    DefineProperty(ctx, "ParentEntityAboutToBeDetached", Light_Get_ParentEntityAboutToBeDetached, nullptr);
    DefineProperty(ctx, "typeName", Light_TypeName, nullptr);
    DefineProperty(ctx, "typeId", Light_TypeId, nullptr);
    DefineProperty(ctx, "name", Light_Name, Light_SetName_String);
    DefineProperty(ctx, "replicated", Light_IsReplicated, Light_SetReplicated_bool);
    DefineProperty(ctx, "local", Light_IsLocal, nullptr);
    DefineProperty(ctx, "unacked", Light_IsUnacked, nullptr);
    DefineProperty(ctx, "updateMode", Light_UpdateMode, Light_SetUpdateMode_AttributeChange__Type);
    DefineProperty(ctx, "id", Light_Id, nullptr);
    DefineProperty(ctx, "temporary", Light_IsTemporary, Light_SetTemporary_bool);
    DefineProperty(ctx, "viewEnabled", Light_ViewEnabled, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, Light_ID);
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:28,代码来源:LightBindings.cpp


示例4: duk__push_module_object

static void duk__push_module_object(duk_context *ctx, const char *id, duk_bool_t main) {
	duk_push_object(ctx);

	/* Set this as the main module, if requested */
	if (main) {
		duk_push_global_stash(ctx);
		duk_dup(ctx, -2);
		duk_put_prop_string(ctx, -2, "\xff" "mainModule");
		duk_pop(ctx);
	}

	/* Node.js uses the canonicalized filename of a module for both module.id
	 * and module.filename.  We have no concept of a file system here, so just
	 * use the module ID for both values.
	 */
	duk_push_string(ctx, id);
	duk_dup(ctx, -1);
	duk_put_prop_string(ctx, -3, "filename");
	duk_put_prop_string(ctx, -2, "id");

	/* module.exports = {} */
	duk_push_object(ctx);
	duk_put_prop_string(ctx, -2, "exports");

	/* module.loaded = false */
	duk_push_false(ctx);
	duk_put_prop_string(ctx, -2, "loaded");

	/* module.require */
	duk__push_require_function(ctx, id);
	duk_put_prop_string(ctx, -2, "require");
}
开发者ID:davidluca3000,项目名称:vscp_software,代码行数:32,代码来源:duk_module_node.c


示例5: sjs_mod_init

DUK_EXTERNAL duk_ret_t sjs_mod_init(duk_context* ctx) {
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, module_funcs);
    duk_push_object(ctx);
    duk_put_number_list(ctx, -1, module_consts);
    duk_put_prop_string(ctx, -2, "c");
    return 1;
}
开发者ID:cjihrig,项目名称:sjs,代码行数:8,代码来源:_io.c


示例6: dukopen_nsp_texture

duk_ret_t dukopen_nsp_texture(duk_context *ctx) {
    duk_idx_t idx = duk_push_object(ctx);
    duk_idx_t stats_constr = duk_push_c_function(ctx, nsp_texture_constructor, DUK_VARARGS);
    duk_idx_t stats_prot = duk_push_object(ctx);
    duk_put_function_list(ctx, stats_prot, nsp_texture_methods);
    duk_put_prop_string(ctx, stats_constr, "prototype");
    duk_put_prop_string(ctx, idx, "Texture");
    return 1;
}
开发者ID:fgalliat,项目名称:duktape-nspire,代码行数:9,代码来源:nsp_texture.c


示例7: init_binding_worker

static int init_binding_worker(duk_context *ctx) {
    duk_push_global_stash(ctx);
    duk_push_object(ctx);
    duk_put_prop_string(ctx, -2, "comoWorkersCallBack");
    duk_pop(ctx);

    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, como_worker_funcs);
    return 1;
}
开发者ID:catoc,项目名称:Comojs,代码行数:10,代码来源:worker.c


示例8: dukopen_logger

duk_ret_t dukopen_logger(duk_context *ctx) noexcept
{
	dukx_assert_begin(ctx);
	duk_push_object(ctx);
	duk_push_object(ctx);
	duk_put_function_list(ctx, -1, loggerFunctions);
	duk_put_prop_string(ctx, -2, "Logger");
	dukx_assert_end(ctx, 1);

	return 1;
}
开发者ID:bdrewery,项目名称:irccd,代码行数:11,代码来源:JsLogger.cpp


示例9: main

int main(int argc, char *argv[]) {
	int i, rc;
	
	prg.argc = argc;
	prg.argv = argv;
	prg.name = argv[1];

	duk_context *ctx = duk_create_heap_default();

	duk_push_global_object(ctx);
	duk_push_object(ctx);  /* -> [ ... global obj ] */
	sys1(ctx);

	for(i=1;i<argc;i++) {
		duk_push_string(ctx, argv[i]);
		duk_put_prop_index(ctx, -2, i-1);
	}
	duk_push_number(ctx, argc-1);
	duk_put_prop_string(ctx, -2, "argc");

	duk_put_prop_string(ctx, -2, "Sys1");  /* -> [ ... global ] */

	duk_push_object(ctx);  /* -> [ ... global obj ] */
	prg1(ctx);
	duk_put_prop_string(ctx, -2, "Prg1");  /* -> [ ... global ] */

	prg_push_modsearch(ctx);
	
	duk_pop(ctx);

	prg_parse_appfile(&prg);
	
	// push file
	duk_push_lstring(ctx, prg.main->buf, prg.main->size);
	duk_push_string(ctx, argv[1]);
	
	// execute file (compile + call)
	prg_register(&prg);
	rc = duk_safe_call(ctx, prg_wrapped_compile_execute, 2 /*nargs*/, 1 /*nret*/);
	if (rc != DUK_EXEC_SUCCESS) {
		print_error(ctx, stderr);
		exit(2);
	}
	duk_pop(ctx);  /* pop eval result */
	
	duk_destroy_heap(ctx);

	return prg.status;
}
开发者ID:jelaas,项目名称:sysjs,代码行数:49,代码来源:sysjs.c


示例10: duk_create_heap_default

StyleContext::StyleContext() {
    m_ctx = duk_create_heap_default();

    //// Create global geometry constants
    // TODO make immutable
    duk_push_number(m_ctx, GeometryType::points);
    duk_put_global_string(m_ctx, "point");

    duk_push_number(m_ctx, GeometryType::lines);
    duk_put_global_string(m_ctx, "line");

    duk_push_number(m_ctx, GeometryType::polygons);
    duk_put_global_string(m_ctx, "polygon");

    //// Create global 'feature' object
    // Get Proxy constructor
    // -> [cons]
    duk_eval_string(m_ctx, "Proxy");

    // Add feature object
    // -> [cons, { __obj: this }]
    duk_idx_t featureObj = duk_push_object(m_ctx);
    duk_push_pointer(m_ctx, this);
    duk_put_prop_string(m_ctx, featureObj, INSTANCE_ID);

    // Add handler object
    // -> [cons, {...}, { get: func, has: func }]
    duk_idx_t handlerObj = duk_push_object(m_ctx);
    // Add 'get' property to handler
    duk_push_c_function(m_ctx, jsGetProperty, 3 /*nargs*/);
    duk_put_prop_string(m_ctx, handlerObj, "get");
    // Add 'has' property to handler
    duk_push_c_function(m_ctx, jsHasProperty, 2 /*nargs*/);
    duk_put_prop_string(m_ctx, handlerObj, "has");

    // Call proxy constructor
    // [cons, feature, handler ] -> [obj|error]
    if (duk_pnew(m_ctx, 2) == 0) {
        // put feature proxy object in global scope
        if (!duk_put_global_string(m_ctx, "feature")) {
            LOGE("Initialization failed");
        }
    } else {
        LOGE("Failure: %s", duk_safe_to_string(m_ctx, -1));
        duk_pop(m_ctx);
    }

    DUMP("init\n");
}
开发者ID:NabilNoaman,项目名称:tangram-es,代码行数:49,代码来源:styleContext.cpp


示例11: Expose_IAssetTransfer

void Expose_IAssetTransfer(duk_context* ctx)
{
    duk_push_object(ctx);
    duk_push_object(ctx);
    duk_put_function_list(ctx, -1, IAssetTransfer_Functions);
    DefineProperty(ctx, "asset", IAssetTransfer_Get_asset, IAssetTransfer_Set_asset);
    DefineProperty(ctx, "source", IAssetTransfer_Get_source, IAssetTransfer_Set_source);
    DefineProperty(ctx, "assetType", IAssetTransfer_Get_assetType, IAssetTransfer_Set_assetType);
    DefineProperty(ctx, "internalResourceName", IAssetTransfer_Get_internalResourceName, IAssetTransfer_Set_internalResourceName);
    DefineProperty(ctx, "Downloaded", IAssetTransfer_Get_Downloaded, nullptr);
    DefineProperty(ctx, "Succeeded", IAssetTransfer_Get_Succeeded, nullptr);
    DefineProperty(ctx, "Failed", IAssetTransfer_Get_Failed, nullptr);
    duk_put_prop_string(ctx, -2, "prototype");
    duk_put_global_string(ctx, IAssetTransfer_ID);
}
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:15,代码来源:IAssetTransferBindings.cpp


示例12: duk_push_object

duk_ret_t JsLibrarian::Constructor(duk_context* duktapeContext)
{
   try {
      if (duk_get_top(duktapeContext) != 0) JavaScriptHelper::Throw(duktapeContext, "No arguments for Librarian constructor expected");

      if (duk_is_constructor_call(duktapeContext)) duk_push_this(duktapeContext);
      else duk_push_object(duktapeContext);

      duk_push_pointer(duktapeContext, new JsLibrarian);
      duk_put_prop_string(duktapeContext, -2, "__Ptr");

      duk_push_c_function(duktapeContext, JsLibrarian::Destructor, 1);
      duk_set_finalizer(duktapeContext, -2);

      duk_push_c_function(duktapeContext, JsLibrarian::Files, DUK_VARARGS);
      duk_put_prop_string(duktapeContext, -2, "Files");

      duk_push_c_function(duktapeContext, JsLibrarian::DependencyCheck, DUK_VARARGS);
      duk_put_prop_string(duktapeContext, -2, "DependencyCheck");

      duk_push_c_function(duktapeContext, JsLibrarian::Output, DUK_VARARGS);
      duk_put_prop_string(duktapeContext, -2, "Output");

      duk_push_c_function(duktapeContext, JsLibrarian::BeforeLink, DUK_VARARGS);
      duk_put_prop_string(duktapeContext, -2, "BeforeLink");

      duk_push_c_function(duktapeContext, JsLibrarian::Create, DUK_VARARGS);
      duk_put_prop_string(duktapeContext, -2, "Create");

      return 1;
   }
   catch (std::exception& e) {
      JavaScriptHelper::Throw(duktapeContext, e.what());
   }
}
开发者ID:FBarwich,项目名称:FBuild,代码行数:35,代码来源:JsLibrarian.cpp


示例13: test

static duk_ret_t test(duk_context *ctx) {
	duk_push_object(ctx);                           /* [ ... obj ] */
	duk_push_int(ctx, 42);                          /* [ ... obj 42 ] */
	duk_put_prop_string(ctx, -2, "meaningOfLife");  /* [ ... obj ] */

	/* compaction has no external impact */
	duk_compact(ctx, -1);                           /* [ ... obj ] */
	duk_dup_top(ctx);
	printf("%s\n", duk_json_encode(ctx, -1));
	duk_pop(ctx);

	/* compaction doesn't prevent new properties from being added */
	duk_push_string(ctx, "bar");                    /* [ ... obj "bar" ] */
	duk_put_prop_string(ctx, -2, "foo");            /* [ ... obj ] */
	duk_dup_top(ctx);
	printf("%s\n", duk_json_encode(ctx, -1));
	duk_pop(ctx);

	/* compaction can be done multiple times */
	duk_compact(ctx, -1);                           /* [ ... obj ] */
	duk_dup_top(ctx);
	printf("%s\n", duk_json_encode(ctx, -1));
	duk_pop(ctx);
	return 0;
}
开发者ID:black13,项目名称:duktape_games,代码行数:25,代码来源:test-compact.cpp


示例14: NativeInfoGetter

/*
 * Returns information about this pin
 */
static int NativeInfoGetter(duk_context* ctx)
{
    int idx;
    uint32_t pin;
    const AJS_IO_Info* info;

    duk_push_this(ctx);
    pin = GetPinId(ctx, -1, 0);
    duk_pop(ctx);

    info = AJS_TargetIO_GetInfo(pin);
    if (!info) {
        duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Undefined I/O pin%d", pin);
        return 0;
    }
    duk_push_string(ctx, ", ");

    idx = duk_push_object(ctx);
    duk_push_int(ctx, info->physicalPin);
    duk_put_prop_string(ctx, idx, "physicalPin");
    duk_push_string(ctx, info->schematicId);
    duk_put_prop_string(ctx, idx, "schematicId");
    duk_push_string(ctx, info->datasheetId);
    duk_put_prop_string(ctx, idx, "datasheetId");
    duk_push_string(ctx, info->description);
    duk_put_prop_string(ctx, idx, "description");
    /*
     * Return the object we just created
     */
    return 1;
}
开发者ID:avernon,项目名称:asl_distribution,代码行数:34,代码来源:ajs_io.c


示例15: test_string

static duk_ret_t test_string(duk_context *ctx, void *udata) {
	duk_idx_t i, n;

	(void) udata;

	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_true(ctx);
	duk_push_false(ctx);
	duk_push_string(ctx, "");
	duk_push_string(ctx, "foo");
	duk_push_lstring(ctx, "foo\0bar", 7);
	duk_push_string(ctx, "\xe1\x88\xb4xyz");  /* 4 chars, first char utf-8 encoded U+1234 */
	duk_push_nan(ctx);
	duk_push_object(ctx);

	n = duk_get_top(ctx);
	printf("top: %ld\n", (long) n);
	for (i = 0; i <= n; i++) {
		printf("index %ld: ", (long) i);
		dump((const unsigned char *) duk_get_string_default(ctx, i, "default"));
	}

	return 0;
}
开发者ID:fatcerberus,项目名称:duktape,代码行数:25,代码来源:test-get-string-default.c


示例16: _gum_duk_create_subclass

void
_gum_duk_create_subclass (duk_context * ctx,
                          const gchar * parent,
                          const gchar * name,
                          duk_c_function constructor,
                          gint constructor_nargs,
                          duk_c_function finalize)
{
  duk_push_global_object (ctx);
  duk_get_prop_string (ctx, -1, "Object");
  duk_get_prop_string (ctx, -1, "create");

  duk_get_prop_string (ctx, -3, parent);
  duk_get_prop_string (ctx, -1, "prototype");
  duk_dup (ctx, -3);
  duk_dup (ctx, -2);
  duk_call (ctx, 1);

  if (constructor != NULL)
    duk_push_c_function (ctx, constructor, constructor_nargs);
  else
    duk_push_object (ctx);

  duk_dup (ctx, -2);
  if (finalize != NULL)
  {
    duk_push_c_function (ctx, finalize, 2);
    duk_set_finalizer (ctx, -2);
  }
  duk_put_prop_string (ctx, -2, "prototype");
  duk_put_prop_string (ctx, -7, name);
  duk_pop_n (ctx, 6);
}
开发者ID:TechLord-Forever,项目名称:frida-gum,代码行数:33,代码来源:gumdukvalue.c


示例17: test_1

static duk_ret_t test_1(duk_context *ctx, void *udata) {
	duk_idx_t i, n;

	(void) udata;

	duk_set_top(ctx, 0);
	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_true(ctx);
	duk_push_false(ctx);
	duk_push_int(ctx, 0);
	duk_push_int(ctx, 1);
	duk_push_nan(ctx);
	duk_push_number(ctx, INFINITY);
	duk_push_string(ctx, "");
	duk_push_string(ctx, "foo");
	duk_push_object(ctx);
	duk_push_thread(ctx);
	duk_push_fixed_buffer(ctx, 0);
	duk_push_fixed_buffer(ctx, 1024);
	duk_push_dynamic_buffer(ctx, 0);
	duk_push_dynamic_buffer(ctx, 1024);
	duk_push_pointer(ctx, (void *) NULL);
	duk_push_pointer(ctx, (void *) 0xdeadbeef);

	n = duk_get_top(ctx);
	printf("top: %ld\n", (long) n);
	for (i = 0; i < n; i++) {
		duk_to_null(ctx, i);
		printf("index %ld, is-null: %d\n", (long) i, (int) duk_is_null(ctx, i));
	}

	return 0;
}
开发者ID:GarethNelson,项目名称:duktape,代码行数:34,代码来源:test-to-null.c


示例18: duv_setup_request

duk_ret_t duv_setup_request(duk_context *ctx, uv_req_t* req, int callback) {
  // Create a new container object for the request with request methods
  duk_push_object(ctx);
  duk_push_heap_stash(ctx);
  duk_get_prop_string(ctx, -1, "req-prototype");
  duk_remove(ctx, -2);
  duk_set_prototype(ctx, -2);

  // Set buffer as uv-data internal property.
  duk_insert(ctx, -2);
  duk_put_prop_string(ctx, -2, "\xff""uv-data");

  // Store the request type.
  duk_push_int(ctx, req->type);
  duk_put_prop_string(ctx, -2, "\xff""req-type");

  // Store a reference to the lua callback
  duk_dup(ctx, callback);
  duk_put_prop_string(ctx, -2, "\xff""uv-callback");

  // Store this object in the heap stack keyed by the request's pointer address.
  // This will prevent it from being garbage collected and allow us to find
  // it with nothing more than the request's address.
  duv_store_handle(ctx, req);

  // Store the context in the handle so it can use duktape APIs.
  req->data = ctx;

  // TODO: is this still on the stack?
  return 1;
}
开发者ID:nucleus-js,项目名称:seaduk,代码行数:31,代码来源:utils.c


示例19: test_2a

static duk_ret_t test_2a(duk_context *ctx, void *udata) {
	(void) udata;

	/* Test first with nothing on stack index -3. */
	duk_safe_call(ctx, test__null, NULL, 0, 1); printf("%s\n", duk_safe_to_string(ctx, 0));
	duk_pop(ctx);

	duk_set_top(ctx, 0); duk_push_undefined(ctx); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_null(ctx); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_true(ctx); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_false(ctx); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_number(ctx, 123.0); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_string(ctx, "foo\x00" "bar"); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_fixed_buffer(ctx, 16); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_pointer(ctx, NULL); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_pointer(ctx, (void *) 0xdeadbeefUL); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_object(ctx); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_array(ctx); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_c_function(ctx, dummy_func, 0); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_c_lightfunc(ctx, dummy_func, 0, 0, 0); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_eval_string(ctx, "(function dummy(){})"); test__require_calls(ctx);
	duk_set_top(ctx, 0); duk_push_thread(ctx); test__require_calls(ctx);

	printf("done\n");
	return 0;
}
开发者ID:fatcerberus,项目名称:duktape,代码行数:26,代码来源:test-dev-api-verbose-error-messages-gh441.c


示例20: duk_push_java_object

void duk_push_java_object(duk_context *ctx, JNIEnv *env, jobject object){
	if(object == NULL){
		duk_push_null(ctx);
		return;
	}
	if((*env)->IsInstanceOf(env, object, js_ref_class)){
		jint  ref = (*env)->CallIntMethod(env, object, js_ref_get_ref_method);
		duk_push_js_ref(ctx, ref);
		return;
	}
	if((*env)->IsInstanceOf(env, object, java_number_class)){
		jdouble num = (*env)->CallDoubleMethod(env, object, java_number_get_double_value_method);
		duk_push_global_object(ctx);
		duk_get_prop_string(ctx, -1, "Number");
		duk_push_number(ctx, num);
		duk_new(ctx, 1);
		duk_mark_jsobject_to_java_object(ctx, -1, env, object);
		duk_remove(ctx, -2);
        return;
	}
	if((*env)->IsInstanceOf(env, object, java_boolean_class)){
		jboolean value = (*env)->CallBooleanMethod(env, object, java_boolean_get_boolean_value_method);
		if(value){
			duk_push_true(ctx);
		}else{
			duk_push_false(ctx);
		}
		return;
	}
	duk_push_object(ctx);  //empty target
	duk_mark_jsobject_to_java_object(ctx, -1, env, object);
}
开发者ID:ewrfedf,项目名称:DuktapeJava,代码行数:32,代码来源:DuktapeEngine.c



注:本文中的duk_push_object函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ duk_push_string函数代码示例发布时间:2022-05-30
下一篇:
C++ duk_push_number函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap