Beispiel #1
0
/* duk_del_prop_index(), success cases */
static duk_ret_t test_delpropindex_a_safecall(duk_context *ctx, void *udata) {
	duk_ret_t rc;

	(void) udata;

	prep(ctx);

	rc = duk_del_prop_index(ctx, 0, 31337);
	printf("delete obj[31337] -> rc=%d\n", (int) rc);

	rc = duk_del_prop_index(ctx, 0, 123);
	printf("delete obj[123] -> rc=%d\n", (int) rc);

	rc = duk_del_prop_index(ctx, 1, 31337);
	printf("delete arr[31337] -> rc=%d\n", (int) rc);

	rc = duk_del_prop_index(ctx, 1, 2);
	printf("delete arr[2] -> rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("final object: %s\n", duk_to_string(ctx, 0));
	duk_json_encode(ctx, 1);
	printf("final array: %s\n", duk_to_string(ctx, 1));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
Beispiel #2
0
/* duk_del_prop_index(), success cases */
int test_3a(duk_context *ctx) {
	int rc;

	prep(ctx);

	rc = duk_del_prop_index(ctx, 0, 31337);
	printf("delete obj[31337] -> rc=%d\n", rc);

	rc = duk_del_prop_index(ctx, 0, 123);
	printf("delete obj[123] -> rc=%d\n", rc);

	rc = duk_del_prop_index(ctx, 1, 31337);
	printf("delete arr[31337] -> rc=%d\n", rc);

	rc = duk_del_prop_index(ctx, 1, 2);
	printf("delete arr[2] -> rc=%d\n", rc);

	rc = duk_del_prop_index(ctx, 2, 5);
	printf("delete 'test_string'[5] -> rc=%d\n", rc);

	duk_json_encode(ctx, 0);
	printf("final object: %s\n", duk_to_string(ctx, 0));
	duk_json_encode(ctx, 1);
	printf("final array: %s\n", duk_to_string(ctx, 1));

	printf("final top: %d\n", duk_get_top(ctx));
	return 0;
}
Beispiel #3
0
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;
}
Beispiel #4
0
/* duk_del_prop_string(), success cases */
static duk_ret_t test_delpropstring_a_safecall(duk_context *ctx, void *udata) {
	duk_ret_t rc;

	(void) udata;

	prep(ctx);

	rc = duk_del_prop_string(ctx, 0, "foo");
	printf("delete obj.foo -> rc=%d\n", (int) rc);

	rc = duk_del_prop_string(ctx, 0, "nonexistent");
	printf("delete obj.nonexistent -> rc=%d\n", (int) rc);

	rc = duk_del_prop_string(ctx, 0, "123");
	printf("delete obj['123'] -> rc=%d\n", (int) rc);

	rc = duk_del_prop_string(ctx, 1, "nonexistent");
	printf("delete arr.nonexistent -> rc=%d\n", (int) rc);

	rc = duk_del_prop_string(ctx, 1, "2");
	printf("delete arr['2'] -> rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("final object: %s\n", duk_to_string(ctx, 0));
	duk_json_encode(ctx, 1);
	printf("final array: %s\n", duk_to_string(ctx, 1));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
Beispiel #5
0
/* duk_del_prop(), success cases */
int test_1a(duk_context *ctx) {
	int rc;

	prep(ctx);

	/* existing, configurable */
	duk_push_string(ctx, "foo");
	rc = duk_del_prop(ctx, 0);
	printf("delete obj.foo -> rc=%d\n", rc);

	/* nonexistent */
	duk_push_string(ctx, "nonexistent");
	rc = duk_del_prop(ctx, 0);
	printf("delete obj.nonexistent -> rc=%d\n", rc);

 	/* nonexistent */
	duk_push_int(ctx, 123);
	rc = duk_del_prop(ctx, 0);
	printf("delete obj[123] -> rc=%d\n", rc);

	/* nonexistent, array */
	duk_push_string(ctx, "nonexistent");
	rc = duk_del_prop(ctx, 1);
	printf("delete arr.nonexistent -> rc=%d\n", rc);

	/* existing, configurable, array */
	duk_push_int(ctx, 2);
	rc = duk_del_prop(ctx, 1);
	printf("delete arr[2] -> rc=%d\n", rc);

	/* non-configurable property, but called from outside a Duktape/C
	 * activation, so obeys non-strict semantics.
	 */
	duk_push_string(ctx, "length");
	rc = duk_del_prop(ctx, 1);
	printf("delete arr.length -> rc=%d\n", rc);

	/* non-configurable virtual property of a string, non-strict mode.
	 */
	duk_push_int(ctx, 5);
	rc = duk_del_prop(ctx, 2);
	printf("delete 'test_string'['5'] -> rc=%d\n", rc);

	/* non-configurable virtual property of a string, non-strict mode.
	 */
	duk_push_string(ctx, "length");
	rc = duk_del_prop(ctx, 2);
	printf("delete 'test_string'.length -> rc=%d\n", rc);

	duk_json_encode(ctx, 0);
	printf("final object: %s\n", duk_to_string(ctx, 0));
	duk_json_encode(ctx, 1);
	printf("final array: %s\n", duk_to_string(ctx, 1));

	printf("final top: %d\n", duk_get_top(ctx));
	return 0;
}
Beispiel #6
0
/* strict: error
 * (non-strict: return 0)
 */
static duk_ret_t test_ex_accessor_wo_setter(duk_context *ctx) {
	const char *src;
	duk_ret_t rc;

	printf("strict: %d\n", (int) duk_is_strict_call(ctx));

	src = "(function () {\n"
	      "    var o = {};\n"
	      "    Object.defineProperty(o, 'foo', {\n"
	      "        configurable: true,\n"
	      "        extensible: true,\n"
	      "        get: function() { print('getter'); }\n"
	      "        // no setter\n"
	      "    });\n"
	      "    return o;\n"
	      "})()";

	duk_set_top(ctx, 0);
	duk_push_string(ctx, src);
	printf("eval:\n%s\n", duk_get_string(ctx, -1));
	duk_eval(ctx);
	printf("top after eval: %ld\n", (long) duk_get_top(ctx));

	duk_push_string(ctx, "foo");
	duk_push_string(ctx, "bar");
	rc = duk_put_prop(ctx, -3);
	printf("put rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("result: %s\n", duk_to_string(ctx, 0));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
void test(duk_context *ctx) {
	duk_idx_t arr_idx;

	duk_push_int(ctx, 123);  /* dummy */

	arr_idx = duk_push_bare_array(ctx);
	printf("arr_idx = %ld\n", (long) arr_idx);
	duk_get_prototype(ctx, -1);
	printf("prototype is undefined: %ld\n", (long) duk_is_undefined(ctx, -1));
	duk_pop(ctx);

	duk_push_string(ctx, "foo");
	duk_put_prop_index(ctx, arr_idx, 0);
	duk_push_string(ctx, "bar");
	duk_put_prop_index(ctx, arr_idx, 1);

	/* Array is now: [ "foo", "bar" ], and array.length is 2 (automatically
	 * updated for ECMAScript arrays).  The array being bare does not affect
	 * JSON serialization.
	 */

	printf("duk_is_array(%ld) = %d\n", (long) arr_idx, (int) duk_is_array(ctx, arr_idx));

	duk_eval_string_noresult(ctx, "Array.prototype[5] = 'inherit';");
	(void) duk_get_prop_index(ctx, arr_idx, 5);
	printf("arr[5] = '%s'\n", duk_to_string(ctx, -1));
	duk_pop(ctx);

	duk_json_encode(ctx, arr_idx);  /* in-place */
	printf("json encoded: %s\n", duk_get_string(ctx, arr_idx));

	printf("top=%ld\n", (long) duk_get_top(ctx));
}
Beispiel #8
0
/* strict: error
 * (non-strict: return 0)
 */
static duk_ret_t test_new_not_extensible(duk_context *ctx) {
	const char *src;
	duk_ret_t rc;

	printf("strict: %d\n", (int) duk_is_strict_call(ctx));

	src = "(function () { var o = { foo: 1 }; Object.preventExtensions(o); return o; })()";

	duk_set_top(ctx, 0);
	duk_push_string(ctx, src);
	printf("eval:\n%s\n", duk_get_string(ctx, -1));
	duk_eval(ctx);
	printf("top after eval: %ld\n", (long) duk_get_top(ctx));

	duk_push_string(ctx, "bar");
	duk_push_string(ctx, "quux");
	rc = duk_put_prop(ctx, -3);
	printf("put rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("result: %s\n", duk_to_string(ctx, 0));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
Beispiel #9
0
/* duk_del_prop(), success cases */
static duk_ret_t test_delprop_a_safecall(duk_context *ctx, void *udata) {
	duk_ret_t rc;

	(void) udata;

	prep(ctx);

	/* existing, configurable */
	duk_push_string(ctx, "foo");
	rc = duk_del_prop(ctx, 0);
	printf("delete obj.foo -> rc=%d\n", (int) rc);

	/* nonexistent */
	duk_push_string(ctx, "nonexistent");
	rc = duk_del_prop(ctx, 0);
	printf("delete obj.nonexistent -> rc=%d\n", (int) rc);

	/* nonexistent */
	duk_push_int(ctx, 123);
	rc = duk_del_prop(ctx, 0);
	printf("delete obj[123] -> rc=%d\n", (int) rc);

	/* nonexistent, array */
	duk_push_string(ctx, "nonexistent");
	rc = duk_del_prop(ctx, 1);
	printf("delete arr.nonexistent -> rc=%d\n", (int) rc);

	/* existing, configurable, array */
	duk_push_int(ctx, 2);
	rc = duk_del_prop(ctx, 1);
	printf("delete arr[2] -> rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("final object: %s\n", duk_to_string(ctx, 0));
	duk_json_encode(ctx, 1);
	printf("final array: %s\n", duk_to_string(ctx, 1));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
Beispiel #10
0
/* duk_del_prop_lstring(), success case */
static duk_ret_t test_delproplstring_a(duk_context *ctx) {
	duk_ret_t rc;
	prep(ctx);

	rc = duk_del_prop_lstring(ctx, 0, "nul" "\x00" "keyx", 7);
	printf("delete obj.nul<NUL>key -> rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("%s\n", duk_to_string(ctx, 0));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
Beispiel #11
0
/* duk_del_prop_string(), success cases */
int test_2a(duk_context *ctx) {
	int rc;

	prep(ctx);

	rc = duk_del_prop_string(ctx, 0, "foo");
	printf("delete obj.foo -> rc=%d\n", rc);

	rc = duk_del_prop_string(ctx, 0, "nonexistent");
	printf("delete obj.nonexistent -> rc=%d\n", rc);

	rc = duk_del_prop_string(ctx, 0, "123");
	printf("delete obj['123'] -> rc=%d\n", rc);

	rc = duk_del_prop_string(ctx, 1, "nonexistent");
	printf("delete arr.nonexistent -> rc=%d\n", rc);

	rc = duk_del_prop_string(ctx, 1, "2");
	printf("delete arr['2'] -> rc=%d\n", rc);

	/* non-configurable property, but running in non-strict mode */
	rc = duk_del_prop_string(ctx, 1, "length");
	printf("delete arr.length -> rc=%d\n", rc);

	/* non-configurable property, but running in non-strict mode */
	rc = duk_del_prop_string(ctx, 2, "5");
	printf("delete 'test_string'['5'] -> rc=%d\n", rc);

	rc = duk_del_prop_string(ctx, 2, "length");
	printf("delete 'test_string'.length -> rc=%d\n", rc);

	duk_json_encode(ctx, 0);
	printf("final object: %s\n", duk_to_string(ctx, 0));
	duk_json_encode(ctx, 1);
	printf("final array: %s\n", duk_to_string(ctx, 1));

	printf("final top: %d\n", duk_get_top(ctx));
	return 0;
}
Beispiel #12
0
CEJsValue js_to_cejs_value(duk_context* ctx, int index)
{
    if (duk_is_number(ctx, index))
        return JS_NUMBER(duk_to_number(ctx, index));
    
    if (duk_is_boolean(ctx, index))
        return JS_BOOL(duk_to_boolean(ctx, index));
    
    if (duk_is_string(ctx, index))
        return JS_STRING(duk_to_string(ctx, index));
    
    if (duk_is_array(ctx, index))
        return JS_STRING(duk_json_encode(ctx, index));
    
    if (duk_is_object(ctx, index))
        return JS_STRING(duk_json_encode(ctx, index));
    
    if (duk_is_undefined(ctx, index)) {
        return JS_UNDEFINED;
    }
    
    return JS_NULL;
}
static duk_ret_t test_json_serialize_1(duk_context *ctx, void *udata) {
	unsigned char *data;
	int i;
	duk_uarridx_t arridx = 0;

	(void) udata;

	data = (unsigned char *) duk_push_dynamic_buffer(ctx, 20);
	for (i = 0; i < 20; i++) {
		data[i] = 0x40 + i;
	}

	duk_push_array(ctx);  /* index 1 */
	setup_duktape_buffer(ctx, 0);
	duk_put_prop_index(ctx, 1, arridx++);
	setup_nodejs_buffer(ctx, 0);
	duk_put_prop_index(ctx, 1, arridx++);
	setup_nodejs_buffer_slice(ctx, 0, 3, 5);
	duk_put_prop_index(ctx, 1, arridx++);
	setup_arraybuffer(ctx, 0);
	duk_put_prop_index(ctx, 1, arridx++);
	setup_typedarray(ctx, 0, "Uint8Array");
	duk_put_prop_index(ctx, 1, arridx++);
	setup_typedarray_slice(ctx, 0, "Uint8Array", 2, 6);
	duk_put_prop_index(ctx, 1, arridx++);
	setup_typedarray(ctx, 0, "Uint32Array");
	duk_put_prop_index(ctx, 1, arridx++);
	setup_typedarray_slice(ctx, 0, "Uint32Array", 4, 1);
	duk_put_prop_index(ctx, 1, arridx++);

	/* Serialize with a full backing buffer first. */

	for (i = 20; i >= 0; i--) {
		printf("resize to %d\n", i);
		duk_resize_buffer(ctx, 0, i);

		duk_dup(ctx, 1);
		duk_json_encode(ctx, -1);
		printf("%s\n", duk_to_string(ctx, -1));
		duk_pop(ctx);
		duk_eval_string(ctx, "(function (v) { print(Duktape.enc('jx', v)); })");
		duk_dup(ctx, 1);
		duk_call(ctx, 1);
		duk_pop(ctx);
	}

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
Beispiel #14
0
    int w_LocalStorage_prototype_removeItem(duk_context *ctx)
    {
        const char *key = duk_require_string(ctx, 0);

        duk_push_this(ctx); /* this */
        duk_get_prop_string(ctx, -1, "__MURAL_DATA__"); /* this, __MURAL_DATA__ */
        duk_del_prop_string(ctx, -1, key); /* this, __MURAL_DATA__ */

        LocalStorage *inst = getNativePointer<LocalStorage>(ctx);
        duk_json_encode(ctx, -1); /* this, JSON(__MURAL_DATA__) */
        inst->setData(duk_to_string(ctx, -1)); /* this, string(JSON(__MURAL_DATA__)) */

        duk_pop_2(ctx);

        return 0;
    }
Beispiel #15
0
static duk_ret_t test_putprop_shorthand_a(duk_context *ctx) {
	duk_eval_string(ctx, "({ foo: 123 })");

	duk_push_uint(ctx, 123);
	duk_put_prop_string(ctx, -2, "bar" "\x00" "quux");

	duk_push_uint(ctx, 234);
	duk_put_prop_index(ctx, -2, 2001);

	duk_push_uint(ctx, 345);
	duk_put_prop_lstring(ctx, -2, "nul" "\x00" "keyx", 7);

	duk_json_encode(ctx, -1);
	printf("%s\n", duk_to_string(ctx, -1));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
void test(duk_context *ctx) {
	duk_idx_t obj_idx;

	duk_push_int(ctx, 123);  /* dummy */

	obj_idx = duk_push_object(ctx);
	duk_push_int(ctx, 42);
	duk_put_prop_string(ctx, obj_idx, "meaningOfLife");

	/* object is now: { "meaningOfLife": 42 } */

	printf("duk_is_object(%ld) = %d\n", (long) obj_idx, (int) duk_is_object(ctx, obj_idx));

	duk_json_encode(ctx, obj_idx);  /* in-place */

	printf("json encoded: %s\n", duk_get_string(ctx, obj_idx));

	printf("top=%ld\n", (long) duk_get_top(ctx));
}
Beispiel #17
0
    int w_LocalStorage_prototype_setItem(duk_context *ctx)
    {
        const char *key = duk_require_string(ctx, 0);
        // Make sure value is string
        duk_to_string(ctx, 1);
        const char *value = duk_require_string(ctx, 1);

        duk_push_this(ctx); /* this */
        duk_get_prop_string(ctx, -1, "__MURAL_DATA__"); /* this, __MURAL_DATA__ */
        duk_push_string(ctx, value); /* this, __MURAL_DATA__, value */
        duk_put_prop_string(ctx, -2, key); /* this, __MURAL_DATA__ */

        LocalStorage *inst = getNativePointer<LocalStorage>(ctx);
        duk_json_encode(ctx, -1); /* this, JSON(__MURAL_DATA__) */
        inst->setData(duk_to_string(ctx, -1)); /* this, string(JSON(__MURAL_DATA__)) */

        duk_pop_2(ctx);

        return 0;
    }
Beispiel #18
0
/* success */
static duk_ret_t test_new_extensible(duk_context *ctx) {
	duk_ret_t rc;

	printf("strict: %d\n", (int) duk_is_strict_call(ctx));

	duk_set_top(ctx, 0);
	duk_push_string(ctx, "{ \"foo\": 1 }");
	duk_json_decode(ctx, 0);

	duk_push_string(ctx, "bar");
	duk_push_string(ctx, "quux");
	rc = duk_put_prop(ctx, -3);
	printf("put rc=%d\n", (int) rc);

	duk_json_encode(ctx, 0);
	printf("result: %s\n", duk_to_string(ctx, 0));

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
Beispiel #19
0
comoQueue *como_duk_val_to_queue (duk_context *ctx, duk_idx_t index) {

    const char *string = NULL;

    comoQueue *queue = malloc(sizeof(*queue));
    memset(queue, 0, sizeof(*queue));
    QUEUE_INIT(&queue->queue);

    queue->type = duk_get_type(ctx, index);
    queue->data = NULL;

    switch(queue->type){
        case DUK_TYPE_UNDEFINED :
        case DUK_TYPE_NULL :
            break;

        case DUK_TYPE_NUMBER :
            COMO_FATAL_ERROR("NUMBERS SUPPORT IN PROGRESS");
            break;

        case DUK_TYPE_OBJECT :
            string = duk_json_encode(ctx, index);
            break;

        case DUK_TYPE_POINTER :
            queue->data = duk_get_pointer(ctx, index);
            break;

        case DUK_TYPE_STRING :
            string = duk_get_string(ctx, index);
            break;
    }

    if (string != NULL){
        queue->data = malloc( strlen(string) + 1);
        strcpy(queue->data, (char *)string);
    }

    return queue;
}
static duk_ret_t test_func(duk_context *ctx, void *udata) {
	(void) udata;

	if (ctx) {
		printf("dummy - return here\n"); fflush(stdout);
		return 0;
	}

	/* Up-to-date for Duktape 1.3.0, alphabetical order:
	 * $ cd website/api; ls *.yaml
	 */

	(void) duk_alloc_raw(ctx, 0);
	(void) duk_alloc(ctx, 0);
	(void) duk_base64_decode(ctx, 0);
	(void) duk_base64_encode(ctx, 0);
	(void) duk_buffer_to_string(ctx, 0);
	(void) duk_call_method(ctx, 0);
	(void) duk_call_prop(ctx, 0, 0);
	(void) duk_call(ctx, 0);
	(void) duk_char_code_at(ctx, 0, 0);
	(void) duk_check_stack_top(ctx, 0);
	(void) duk_check_stack(ctx, 0);
	(void) duk_check_type_mask(ctx, 0, 0);
	(void) duk_check_type(ctx, 0, 0);
	(void) duk_compact(ctx, 0);
	(void) duk_compile_lstring_filename(ctx, 0, "dummy", 0);
	(void) duk_compile_lstring(ctx, 0, "dummy", 0);
	(void) duk_compile_string_filename(ctx, 0, "dummy");
	(void) duk_compile_string(ctx, 0, "dummy");
	(void) duk_compile(ctx, 0);
	(void) duk_concat(ctx, 0);
	(void) duk_config_buffer(ctx, 0, NULL, 0);
	(void) duk_copy(ctx, 0, 0);
	(void) duk_create_heap_default();
	(void) duk_create_heap(NULL, NULL, NULL, NULL, NULL);
	(void) duk_debugger_attach(ctx, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	(void) duk_debugger_cooperate(ctx);
	(void) duk_debugger_detach(ctx);
	(void) duk_debugger_notify(ctx, 0);
	(void) duk_debugger_pause(ctx);
	(void) duk_decode_string(ctx, 0, NULL, NULL);
	(void) duk_def_prop(ctx, 0, 0);
	(void) duk_del_prop_index(ctx, 0, 0);
	(void) duk_del_prop_string(ctx, 0, "dummy");
	(void) duk_del_prop(ctx, 0);
	(void) duk_destroy_heap(ctx);
	(void) duk_dump_function(ctx);
	(void) duk_dup_top(ctx);
	(void) duk_dup(ctx, 0);
	(void) duk_enum(ctx, 0, 0);
	(void) duk_equals(ctx, 0, 0);
	duk_error_va(ctx, 0, NULL, NULL);
	duk_error(ctx, 0, "dummy");  /* (void) cast won't work without variadic macros */
	(void) duk_eval_lstring_noresult(ctx, "dummy", 0);
	(void) duk_eval_lstring(ctx, "dummy", 0);
	(void) duk_eval_noresult(ctx);
	(void) duk_eval_string_noresult(ctx, "dummy");
	(void) duk_eval_string(ctx, "dummy");
	(void) duk_eval(ctx);
	(void) duk_fatal(ctx, "dummy");
	(void) duk_free_raw(ctx, NULL);
	(void) duk_free(ctx, NULL);
	(void) duk_gc(ctx, 0);
	(void) duk_get_boolean(ctx, 0);
	(void) duk_get_buffer_data(ctx, 0, NULL);
	(void) duk_get_buffer(ctx, 0, NULL);
	(void) duk_get_c_function(ctx, 0);
	(void) duk_get_context(ctx, 0);
	(void) duk_get_current_magic(ctx);
	(void) duk_get_error_code(ctx, 0);
	(void) duk_get_finalizer(ctx, 0);
	(void) duk_get_global_string(ctx, 0);
	(void) duk_get_heapptr(ctx, 0);
	(void) duk_get_int(ctx, 0);
	(void) duk_get_length(ctx, 0);
	(void) duk_get_lstring(ctx, 0, NULL);
	(void) duk_get_magic(ctx, 0);
	(void) duk_get_memory_functions(ctx, NULL);
	(void) duk_get_number(ctx, 0);
	(void) duk_get_pointer(ctx, 0);
	(void) duk_get_prop_index(ctx, 0, 0);
	(void) duk_get_prop_string(ctx, 0, "dummy");
	(void) duk_get_prop(ctx, 0);
	(void) duk_get_prototype(ctx, 0);
	(void) duk_get_string(ctx, 0);
	(void) duk_get_top_index(ctx);
	(void) duk_get_top(ctx);
	(void) duk_get_type_mask(ctx, 0);
	(void) duk_get_type(ctx, 0);
	(void) duk_get_uint(ctx, 0);
	(void) duk_has_prop_index(ctx, 0, 0);
	(void) duk_has_prop_string(ctx, 0, "dummy");
	(void) duk_has_prop(ctx, 0);
	(void) duk_hex_decode(ctx, 0);
	(void) duk_hex_encode(ctx, 0);
	(void) duk_insert(ctx, 0);
	(void) duk_instanceof(ctx, 0, 0);
	(void) duk_is_array(ctx, 0);
	(void) duk_is_boolean(ctx, 0);
	(void) duk_is_bound_function(ctx, 0);
	(void) duk_is_buffer(ctx, 0);
	(void) duk_is_callable(ctx, 0);
	(void) duk_is_c_function(ctx, 0);
	(void) duk_is_constructor_call(ctx);
	(void) duk_is_dynamic_buffer(ctx, 0);
	(void) duk_is_ecmascript_function(ctx, 0);
	(void) duk_is_error(ctx, 0);
	(void) duk_is_eval_error(ctx, 0);
	(void) duk_is_fixed_buffer(ctx, 0);
	(void) duk_is_function(ctx, 0);
	(void) duk_is_lightfunc(ctx, 0);
	(void) duk_is_nan(ctx, 0);
	(void) duk_is_null_or_undefined(ctx, 0);
	(void) duk_is_null(ctx, 0);
	(void) duk_is_number(ctx, 0);
	(void) duk_is_object_coercible(ctx, 0);
	(void) duk_is_object(ctx, 0);
	(void) duk_is_pointer(ctx, 0);
	(void) duk_is_primitive(ctx, 0);
	(void) duk_is_range_error(ctx, 0);
	(void) duk_is_reference_error(ctx, 0);
	(void) duk_is_strict_call(ctx);
	(void) duk_is_string(ctx, 0);
	(void) duk_is_syntax_error(ctx, 0);
	(void) duk_is_thread(ctx, 0);
	(void) duk_is_type_error(ctx, 0);
	(void) duk_is_undefined(ctx, 0);
	(void) duk_is_uri_error(ctx, 0);
	(void) duk_is_valid_index(ctx, 0);
	(void) duk_join(ctx, 0);
	(void) duk_json_decode(ctx, 0);
	(void) duk_json_encode(ctx, 0);
	(void) duk_load_function(ctx);
	(void) duk_map_string(ctx, 0, NULL, NULL);
	(void) duk_new(ctx, 0);
	(void) duk_next(ctx, 0, 0);
	(void) duk_normalize_index(ctx, 0);
	(void) duk_pcall_method(ctx, 0);
	(void) duk_pcall_prop(ctx, 0, 0);
	(void) duk_pcall(ctx, 0);
	(void) duk_pcompile_lstring_filename(ctx, 0, "dummy", 0);
	(void) duk_pcompile_lstring(ctx, 0, "dummy", 0);
	(void) duk_pcompile_string_filename(ctx, 0, "dummy");
	(void) duk_pcompile_string(ctx, 0, "dummy");
	(void) duk_pcompile(ctx, 0);
	(void) duk_peval_lstring_noresult(ctx, "dummy", 0);
	(void) duk_peval_lstring(ctx, "dummy", 0);
	(void) duk_peval_noresult(ctx);
	(void) duk_peval_string_noresult(ctx, "dummy");
	(void) duk_peval_string(ctx, "dummy");
	(void) duk_peval(ctx);
	(void) duk_pnew(ctx, 0);
	(void) duk_pop_2(ctx);
	(void) duk_pop_3(ctx);
	(void) duk_pop_n(ctx, 0);
	(void) duk_pop(ctx);
	(void) duk_push_array(ctx);
	(void) duk_push_boolean(ctx, 0);
	(void) duk_push_buffer_object(ctx, 0, 0, 0, 0);
	(void) duk_push_buffer(ctx, 0, 0);
	(void) duk_push_c_function(ctx, NULL, 0);
	(void) duk_push_c_lightfunc(ctx, NULL, 0, 0, 0);
	(void) duk_push_context_dump(ctx);
	(void) duk_push_current_function(ctx);
	(void) duk_push_current_thread(ctx);
	(void) duk_push_dynamic_buffer(ctx, 0);
	(void) duk_push_error_object_va(ctx, 0, NULL, NULL);
	(void) duk_push_error_object(ctx, 0, "dummy");
	(void) duk_push_external_buffer(ctx);
	(void) duk_push_false(ctx);
	(void) duk_push_fixed_buffer(ctx, 0);
	(void) duk_push_global_object(ctx);
	(void) duk_push_global_stash(ctx);
	(void) duk_push_heap_stash(ctx);
	(void) duk_push_heapptr(ctx, NULL);
	(void) duk_push_int(ctx, 0);
	(void) duk_push_lstring(ctx, "dummy", 0);
	(void) duk_push_nan(ctx);
	(void) duk_push_null(ctx);
	(void) duk_push_number(ctx, 0.0);
	(void) duk_push_object(ctx);
	(void) duk_push_pointer(ctx, NULL);
	(void) duk_push_sprintf(ctx, "dummy");
	(void) duk_push_string(ctx, "dummy");
	(void) duk_push_this(ctx);
	(void) duk_push_thread_new_globalenv(ctx);
	(void) duk_push_thread_stash(ctx, NULL);
	(void) duk_push_thread(ctx);
	(void) duk_push_true(ctx);
	(void) duk_push_uint(ctx, 0);
	(void) duk_push_undefined(ctx);
	(void) duk_push_vsprintf(ctx, "dummy", NULL);
	(void) duk_put_function_list(ctx, 0, NULL);
	(void) duk_put_global_string(ctx, NULL);
	(void) duk_put_number_list(ctx, 0, NULL);
	(void) duk_put_prop_index(ctx, 0, 0);
	(void) duk_put_prop_string(ctx, 0, "dummy");
	(void) duk_put_prop(ctx, 0);
	(void) duk_realloc_raw(ctx, NULL, 0);
	(void) duk_realloc(ctx, NULL, 0);
	(void) duk_remove(ctx, 0);
	(void) duk_replace(ctx, 0);
	(void) duk_require_boolean(ctx, 0);
	(void) duk_require_buffer_data(ctx, 0, NULL);
	(void) duk_require_buffer(ctx, 0, NULL);
	(void) duk_require_c_function(ctx, 0);
	(void) duk_require_callable(ctx, 0);
	(void) duk_require_context(ctx, 0);
	(void) duk_require_function(ctx, 0);
	(void) duk_require_heapptr(ctx, 0);
	(void) duk_require_int(ctx, 0);
	(void) duk_require_lstring(ctx, 0, NULL);
	(void) duk_require_normalize_index(ctx, 0);
	(void) duk_require_null(ctx, 0);
	(void) duk_require_number(ctx, 0);
	(void) duk_require_object_coercible(ctx, 0);
	(void) duk_require_pointer(ctx, 0);
	(void) duk_require_stack_top(ctx, 0);
	(void) duk_require_stack(ctx, 0);
	(void) duk_require_string(ctx, 0);
	(void) duk_require_top_index(ctx);
	(void) duk_require_type_mask(ctx, 0, 0);
	(void) duk_require_uint(ctx, 0);
	(void) duk_require_undefined(ctx, 0);
	(void) duk_require_valid_index(ctx, 0);
	(void) duk_resize_buffer(ctx, 0, 0);
	(void) duk_safe_call(ctx, NULL, NULL, 0, 0);
	(void) duk_safe_to_lstring(ctx, 0, NULL);
	(void) duk_safe_to_string(ctx, 0);
	(void) duk_set_finalizer(ctx, 0);
	(void) duk_set_global_object(ctx);
	(void) duk_set_magic(ctx, 0, 0);
	(void) duk_set_prototype(ctx, 0);
	(void) duk_set_top(ctx, 0);
	(void) duk_steal_buffer(ctx, 0, NULL);
	(void) duk_strict_equals(ctx, 0, 0);
	(void) duk_substring(ctx, 0, 0, 0);
	(void) duk_swap_top(ctx, 0);
	(void) duk_swap(ctx, 0, 0);
	(void) duk_throw(ctx);
	(void) duk_to_boolean(ctx, 0);
	(void) duk_to_buffer(ctx, 0, NULL);
	(void) duk_to_defaultvalue(ctx, 0, 0);
	(void) duk_to_dynamic_buffer(ctx, 0, NULL);
	(void) duk_to_fixed_buffer(ctx, 0, NULL);
	(void) duk_to_int32(ctx, 0);
	(void) duk_to_int(ctx, 0);
	(void) duk_to_lstring(ctx, 0, NULL);
	(void) duk_to_null(ctx, 0);
	(void) duk_to_number(ctx, 0);
	(void) duk_to_object(ctx, 0);
	(void) duk_to_pointer(ctx, 0);
	(void) duk_to_primitive(ctx, 0, 0);
	(void) duk_to_string(ctx, 0);
	(void) duk_to_uint16(ctx, 0);
	(void) duk_to_uint32(ctx, 0);
	(void) duk_to_uint(ctx, 0);
	(void) duk_to_undefined(ctx, 0);
	(void) duk_trim(ctx, 0);
	(void) duk_xcopy_top(ctx, NULL, 0);
	(void) duk_xmove_top(ctx, NULL, 0);

	printf("never here\n"); fflush(stdout);
	return 0;
}
//const char *duk_json_encode(duk_context *ctx, duk_idx_t index);
const char *aperl_duk_json_encode(duk_context *ctx, duk_idx_t index) {
	const char *ret = duk_json_encode(ctx, index);
	return ret;
}