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

C++ duk_push_null函数代码示例

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

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



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

示例1: 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


示例2: test_1

static duk_ret_t test_1(duk_context *ctx) {
	duk_size_t i, n;
	char *buf;

	duk_set_top(ctx, 0);

	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_true(ctx);
	duk_push_false(ctx);
	duk_push_nan(ctx);
	duk_push_number(ctx, -INFINITY);
	duk_push_number(ctx, +INFINITY);
	duk_push_number(ctx, -0.0);
	duk_push_number(ctx, +0.0);
	duk_push_int(ctx, 123);

	duk_push_string(ctx, "foo");
	duk_push_lstring(ctx, "foo\0bar", 7);  /* internal NULs are kept */
	duk_push_object(ctx);
	buf = (char *) duk_push_fixed_buffer(ctx, 0);
	buf = (char *) duk_push_fixed_buffer(ctx, 16);
	for (i = 0; i < 16; i++) {
		buf[i] = i;
	}
	buf = (char *) duk_push_dynamic_buffer(ctx, 0);
	buf = (char *) duk_push_dynamic_buffer(ctx, 16);
	for (i = 0; i < 16; i++) {
		buf[i] = i;
	}
	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_int_t t1, t2;
		void *ptr;
		duk_size_t sz;

		duk_dup(ctx, i);
		t1 = duk_get_type(ctx, -1);
		sz = (duk_size_t) 0xdeadbeef;
		ptr = duk_to_buffer(ctx, -1, &sz);
		t2 = duk_get_type(ctx, -1);
		printf("index %ld, type %ld -> %ld, ptr-is-NULL %d, size %lu\n",
		       (long) i, (long) t1, (long) t2,
		       (sz == 0 ? -1 : (ptr == NULL ? 1 : 0)),
		       (unsigned long) sz);
		dump_buffer(ctx);
		duk_pop(ctx);

		/* just check that this doesn't break */
		duk_dup(ctx, i);
		ptr = duk_to_buffer(ctx, -1, NULL);
		duk_pop(ctx);
	}

	return 0;
}
开发者ID:black13,项目名称:duktape_games,代码行数:60,代码来源:test-to-buffer.cpp


示例3: 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


示例4: duk_bi_object_getprototype_shared

/* Shared helper to implement Object.getPrototypeOf and the ES6
 * Object.prototype.__proto__ getter.
 *
 * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-object.prototype.__proto__
 */
duk_ret_t duk_bi_object_getprototype_shared(duk_context *ctx) {
	duk_hobject *h;

	/* magic: 0=getter call, 1=Object.getPrototypeOf */
	if (duk_get_current_magic(ctx) == 0) {
		duk_push_this_coercible_to_object(ctx);
		duk_insert(ctx, 0);
	}

	h = duk_require_hobject(ctx, 0);
	DUK_ASSERT(h != NULL);

	/* XXX: should the API call handle this directly, i.e. attempt
	 * to duk_push_hobject(ctx, null) would push a null instead?
	 * (On the other hand 'undefined' would be just as logical, but
	 * not wanted here.)
	 */

	if (h->prototype) {
		duk_push_hobject(ctx, h->prototype);
	} else {
		duk_push_null(ctx);
	}
	return 1;
}
开发者ID:cherry-wb,项目名称:duktape,代码行数:30,代码来源:duk_bi_object.c


示例5: test

void test(duk_context *ctx) {
	int i, n;

	duk_push_c_function(ctx, func, 0);

	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_true(ctx);
	duk_push_false(ctx);
	duk_push_number(ctx, 123.456);
	duk_push_string(ctx, "foo");
	duk_push_object(ctx);
	duk_push_array(ctx);
	duk_push_fixed_buffer(ctx, 16);
	duk_push_pointer(ctx, (void *) 0xdeadbeef);

	n = duk_get_top(ctx);
	printf("top: %d\n", n);
	for (i = 1; i < n; i++) {
		duk_dup(ctx, 0);
		duk_dup(ctx, i);
		duk_call_method(ctx, 0);  /* [ ... func this ] -> [ ret ] */
		duk_pop(ctx);
	}
}
开发者ID:BpLife,项目名称:duktape,代码行数:25,代码来源:test-push-this.c


示例6: test_basic

static duk_ret_t test_basic(duk_context *ctx, void *udata) {
	duk_idx_t i, n;
	duk_int_t rc;

	(void) udata;

	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_true(ctx);
	duk_push_false(ctx);
	duk_push_string(ctx, "foo");
	duk_push_int(ctx, 123);
	duk_push_object(ctx);
	duk_push_pointer(ctx, (void *) NULL);
	duk_push_pointer(ctx, (void *) 0xdeadbeefUL);

	n = duk_get_top(ctx);
	printf("top: %ld\n", (long) n);
	for (i = 0; i <= n; i++) {
		rc = duk_safe_call(ctx, safe_helper, (void *) i, 0, 1);
		if (rc != DUK_EXEC_SUCCESS) {
			printf("index %ld: %s\n", (long) i, duk_safe_to_string(ctx, -1));
		}
		duk_pop(ctx);
	}

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:fatcerberus,项目名称:duktape,代码行数:29,代码来源:test-opt-pointer.c


示例7: test

void test(duk_context *ctx) {
	duk_idx_t i, n;

	duk_push_undefined(ctx);
	duk_push_null(ctx);
	duk_push_true(ctx);
	duk_push_false(ctx);
	duk_push_string(ctx, "foo");
	duk_push_string(ctx, "123");
	duk_push_number(ctx, -INFINITY);
	duk_push_number(ctx, -123456789.0);
	duk_push_number(ctx, -0.0);
	duk_push_number(ctx, +0.0);
	duk_push_number(ctx, +123456789.0);
	duk_push_number(ctx, +INFINITY);
	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++) {
		double d = duk_get_number(ctx, i);
		int c = fpclassify(d);
		printf("index %ld: number %lf, FP_NAN=%d, FP_INFINITE=%d, FP_ZERO=%d, FP_SUBNORMAL=%d, FP_NORMAL=%d, signbit=%d\n",
		       (long) i, d, (c == FP_NAN ? 1 : 0), (c == FP_INFINITE ? 1 : 0), (c == FP_ZERO ? 1 : 0),
		       (c == FP_SUBNORMAL ? 1 : 0), (c == FP_NORMAL ? 1 : 0), (signbit(d) ? 1 : 0));
	}
}
开发者ID:BrandonTheHamm,项目名称:duktape,代码行数:28,代码来源:test-get-number.c


示例8: test_lstring

static duk_ret_t test_lstring(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++) {
		const char *buf;
		size_t len;

		len = (size_t) 0xdeadbeefUL;
		buf = duk_get_lstring_default(ctx, i, &len, "default!", 7);
		printf("index %ld: length %lu: ",
		       (long) i, (unsigned long) len);
		dump((const unsigned char *) buf);

		buf = duk_get_lstring_default(ctx, i, NULL, "default!", 7);
		printf("index %ld: ", (long) i);
		dump((const unsigned char *) buf);
	}

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


示例9: test

void test(duk_context *ctx) {
	duk_idx_t i, n;

	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_int(ctx, 123);
	duk_push_object(ctx);
	duk_push_fixed_buffer(ctx, 0);
	duk_push_fixed_buffer(ctx, 1024);
	duk_push_dynamic_buffer(ctx, 0);
	duk_push_dynamic_buffer(ctx, 2048);

	n = duk_get_top(ctx);
	printf("top: %ld\n", (long) n);
	for (i = 0; i < n; i++) {
		void *buf;
		duk_size_t len;

		len = (duk_size_t) 0xdeadbeef;
		buf = duk_get_buffer(ctx, i, &len);
		if (len == 0) {
			/* avoid printing 'buf' if len is zero, as it is not predictable */
			printf("index %ld: length 0\n", (long) i);
		} else {
			printf("index %ld: length %lu, ptr-is-NULL %d\n",
			       (long) i, (unsigned long) len, (buf == NULL ? 1 : 0));
		}
	}
}
开发者ID:BrandonTheHamm,项目名称:duktape,代码行数:33,代码来源:test-get-buffer.c


示例10: test_1

int test_1(duk_context *ctx) {
    int i, n;

    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: %d\n", n);
    for (i = 0; i < n; i++) {
        duk_to_undefined(ctx, i);
        printf("index %d, is-undefined: %d\n", i, duk_is_undefined(ctx, i));
    }

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


示例11: nsp_texture_constructor

static duk_ret_t nsp_texture_constructor(duk_context *ctx) {
    int width = duk_require_int(ctx, 0);
    int height = duk_require_int(ctx, 1);
    if (width < 1 || height < 1) {
	duk_push_error_object(ctx, DUK_ERR_RANGE_ERROR, "Width and height must be positive");
	duk_throw(ctx);
    }
    bool has_transparency;
    uint16_t transparent_color;
    if ((has_transparency = duk_is_number(ctx, 2))) {
	transparent_color = (uint16_t)duk_get_int(ctx, 2);
    }
    duk_push_this(ctx);
    duk_push_fixed_buffer(ctx, width * height * 2);
    duk_put_prop_string(ctx, -2, "bitmap");
    duk_push_int(ctx, width);
    duk_put_prop_string(ctx, -2, "width");
    duk_push_int(ctx, height);
    duk_put_prop_string(ctx, -2, "height");
    if (has_transparency) {
	duk_push_int(ctx, transparent_color);
    } else {
	duk_push_null(ctx);
    }
    duk_put_prop_string(ctx, -2, "transparentColor");
    return 0;
}
开发者ID:fgalliat,项目名称:duktape-nspire,代码行数:27,代码来源:nsp_texture.c


示例12: como_push_worker_value

void como_push_worker_value (duk_context *ctx, comoQueue *queue){
    switch(queue->type){
        case DUK_TYPE_UNDEFINED :
            duk_push_undefined(ctx);
            break;

        case DUK_TYPE_NULL :
                duk_push_null(ctx);
                break;

        case DUK_TYPE_OBJECT :
            duk_push_string(ctx, queue->data);
            duk_json_decode(ctx, -1);
            break;

        case DUK_TYPE_POINTER :
            duk_push_pointer(ctx, queue->data);
            break;

        case DUK_TYPE_STRING :
            duk_push_string(ctx, queue->data);
            break;
        
        default :
            assert(0 && "Duk Type Error");
    }
}
开发者ID:catoc,项目名称:Comojs,代码行数:27,代码来源:worker.c


示例13: test_nargs_minus1

static duk_ret_t test_nargs_minus1(duk_context *ctx, void *udata) {
	duk_int_t rc;

	(void) udata;

	duk_push_null(ctx);
	duk_push_null(ctx);
	duk_push_null(ctx);
	printf("top before: %ld\n", (long) duk_get_top(ctx));

	rc = duk_safe_call(ctx, dummy, NULL, -1 /*nargs, negative*/, 0 /*nrets*/);
	printf("duk_safe_call rc: %ld\n", (long) rc);

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:fatcerberus,项目名称:duktape,代码行数:16,代码来源:test-safe-call-invalid-nargs.c


示例14: test_2b

int test_2b(duk_context *ctx) {
	duk_set_top(ctx, 0);
	duk_push_null(ctx);
	duk_to_object(ctx, 0);
	printf("index 0 OK\n");
	return 0;
}
开发者ID:BpLife,项目名称:duktape,代码行数:7,代码来源:test-to-object.c


示例15: convert_to_context

JNIEXPORT jobject JNICALL Java_com_furture_react_DuktapeEngine_nativeCallJs
  (JNIEnv *env, jobject thisObject, jlong ptr, jstring jsTarget, jstring jsMethod, jobjectArray args){
	duk_context *ctx  = convert_to_context(ptr);
	jboolean iscopy = JNI_FALSE;
    const char* targetName = ((*env)->GetStringUTFChars(env, jsTarget, &iscopy));
    DEBUG_LOG("ScriptEngine","Java_com_furture_react_DuktapeEngine_nativeCallJs call on %s", targetName);
	duk_push_global_object(ctx);
    if(duk_get_prop_string(ctx, -1, targetName)){
    	    const char* methodName = ((*env)->GetStringUTFChars(env, jsMethod, &iscopy));
	    duk_push_string(ctx, methodName);
	    jsize length = duk_push_java_object_array(ctx, env, args);
	    DEBUG_LOG("ScriptEngine","Java_com_furture_react_DuktapeEngine_nativeCallJs call  Function %d", length);
	    if(duk_pcall_prop(ctx, -2 - length, length) != DUK_EXEC_SUCCESS){
	     	LOGE("ScriptEngine","ScriptEngine CallJS %s.%s() method %s", targetName, methodName, duk_js_error_to_string(ctx, -1));
	        duk_pop(ctx);
	        duk_push_null(ctx);
	    }
 	    (*env)->ReleaseStringUTFChars(env, jsTarget, targetName);
	    (*env)->ReleaseStringUTFChars(env, jsMethod, methodName);
	    jobject  value =  duk_to_java_object(ctx, env, -1);
	    duk_pop_2(ctx);
	    return value;
    }
    (*env)->ReleaseStringUTFChars(env, jsTarget, targetName);
    duk_pop_2(ctx);
    return NULL;

}
开发者ID:ewrfedf,项目名称:DuktapeJava,代码行数:28,代码来源:DuktapeEngine.c


示例16: 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


示例17: 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


示例18: java_object_to_string

static int java_object_to_string(duk_context *ctx) {
	int n = duk_get_top(ctx);
	DEBUG_LOG("ScriptEngine",  "java_object_to_string enter %d", n);
	duk_push_this(ctx);
	if(duk_get_prop_string(ctx, -1, JAVA_OBJECT_MARK)){
		DEBUG_LOG("ScriptEngine",  "java_object_to_string enter java object ");
		jobject  ref = duk_to_pointer(ctx, -1);
		if(ref == NULL){
			 duk_push_null(ctx);
			 return 1;
		}
		JNIEnv*  env =  get_java_jni_env();
		DEBUG_LOG("ScriptEngine",  "java_object_to_string enter java end");
		jclass   refClass = (*env)->GetObjectClass(env, ref);
		jmethodID method = (*env)->GetMethodID(env, refClass, "toString", "()Ljava/lang/String;");
		jstring  value =  (*env)->CallObjectMethod(env, ref, method);
		jboolean iscopy = JNI_FALSE;
		const char* src =  ((*env)->GetStringUTFChars(env, value, &iscopy));
		DEBUG_LOG("ScriptEngine",  "java_object_to_string src %s", src );
        duk_push_string(ctx, src);
        (*env)->ReleaseStringUTFChars(env, value, src);
		(*env)->DeleteLocalRef(env, value);
		(*env)->DeleteLocalRef(env, refClass);
		DEBUG_LOG("ScriptEngine",  "java_object_to_string success");
		return 1;
	}else{
		DEBUG_LOG("ScriptEngine",  "java_object_to_string error");
	}
	return 0;
}
开发者ID:ewrfedf,项目名称:DuktapeJava,代码行数:30,代码来源:DuktapeEngine.c


示例19: duk_bi_object_getprototype_shared

/* Shared helper to implement Object.getPrototypeOf and the ES6
 * Object.prototype.__proto__ getter.
 *
 * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-object.prototype.__proto__
 */
DUK_INTERNAL duk_ret_t duk_bi_object_getprototype_shared(duk_context *ctx) {
	duk_hobject *h;
	duk_hobject *proto;

	/* magic: 0=getter call, 1=Object.getPrototypeOf */
	if (duk_get_current_magic(ctx) == 0) {
		duk_push_this_coercible_to_object(ctx);
		duk_insert(ctx, 0);
	}

	h = duk_require_hobject_or_lfunc(ctx, 0);
	/* h is NULL for lightfunc */

	/* XXX: should the API call handle this directly, i.e. attempt
	 * to duk_push_hobject(ctx, null) would push a null instead?
	 * (On the other hand 'undefined' would be just as logical, but
	 * not wanted here.)
	 */

	if (h == NULL) {
		duk_push_hobject_bidx(ctx, DUK_BIDX_FUNCTION_PROTOTYPE);
	} else {
		proto = DUK_HOBJECT_GET_PROTOTYPE(h);
		if (proto) {
			duk_push_hobject(ctx, proto);
		} else {
			duk_push_null(ctx);
		}
	}
	return 1;
}
开发者ID:CarterTsai,项目名称:duktape,代码行数:36,代码来源:duk_bi_object.c


示例20: test_invalid_null

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

	duk_push_null(ctx);
	duk_push_buffer_object(ctx, -1, 7, 512, DUK_BUFOBJ_UINT32ARRAY);
	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
开发者ID:jmptrader,项目名称:duktape,代码行数:8,代码来源:test-push-buffer-object.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ duk_push_number函数代码示例发布时间:2022-05-30
下一篇:
C++ duk_push_int函数代码示例发布时间: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