static int NativeI2cTransfer(duk_context* ctx) { AJ_Status status; uint8_t addr = duk_require_int(ctx, 0); uint8_t* txBuf = NULL; uint8_t* rxBuf = NULL; duk_size_t txLen = 0; duk_size_t rxLen = 0; uint8_t rxBytes = 0; if (duk_is_undefined(ctx, 2)) { duk_push_undefined(ctx); } else { rxLen = duk_require_uint(ctx, 2); rxBuf = duk_push_dynamic_buffer(ctx, rxLen); } if (duk_is_null(ctx, 1)) { duk_push_undefined(ctx); } else { txBuf = SerializeToBuffer(ctx, 1, &txLen); } status = AJS_TargetIO_I2cTransfer(PinCtxPtr(ctx), addr, txBuf, txLen, rxBuf, rxLen, &rxBytes); if (status != AJ_OK) { duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "I2C transfer failed %s\n", AJ_StatusText(status)); } duk_pop(ctx); if (rxLen) { duk_resize_buffer(ctx, -1, rxBytes); } return 1; }
/* Underlying buffer doesn't cover logical slice. */ static duk_ret_t test_uncovered_buffer(duk_context *ctx) { unsigned char *p; duk_size_t sz; duk_push_dynamic_buffer(ctx, 64); /* 16x4 elements */ duk_eval_string(ctx, "(function (plain_buffer) {\n" " var b = new ArrayBuffer(plain_buffer);\n" " return new Uint32Array(b).subarray(1,5);\n" "})"); duk_dup(ctx, 0); duk_call(ctx, 1); /* -> [ plain_buffer Uint32Array ] */ /* Initially OK. */ sz = (duk_size_t) 0xdeadbeefUL; p = duk_get_buffer_data(ctx, -1, &sz); if (p) { printf("p is not NULL, sz=%ld\n", (long) sz); } else { printf("p is NULL\n"); } /* Resize; slice still covered. */ duk_resize_buffer(ctx, 0, 20); /* 5x4 = 20, subarray is [1*4, 5*4[ */ sz = (duk_size_t) 0xdeadbeefUL; p = duk_get_buffer_data(ctx, -1, &sz); if (p) { printf("p is not NULL, sz=%ld\n", (long) sz); } else { printf("p is NULL\n"); } /* Resize; no longer covered. */ duk_resize_buffer(ctx, 0, 19); sz = (duk_size_t) 0xdeadbeefUL; p = duk_get_buffer_data(ctx, -1, &sz); if (p) { printf("p is not NULL, sz=%ld\n", (long) sz); } else { printf("p is NULL\n"); } printf("final top: %ld\n", (long) duk_get_top(ctx)); return 0; }
static int NativeUartRead(duk_context* ctx) { duk_size_t len = duk_require_int(ctx, 0); len = AJS_TargetIO_UartRead(PinCtxPtr(ctx), duk_push_dynamic_buffer(ctx, len), len); duk_resize_buffer(ctx, -1, len); return 1; }
static duk_ret_t test_typedarray_set_1(duk_context *ctx, void *udata) { int i, dst, src; unsigned char *data; (void) udata; data = (unsigned char *) duk_push_dynamic_buffer(ctx, 10); /* index 0 */ for (i = 0; i < 10; i++) { data[i] = 0x40 + i; } /* Some combinations are not set() compatible and cause a RangeError * (source longer than target). But this set should exercise byte copy, * fast copy, and slow copy code paths. */ setup_typedarray(ctx, 0, "Uint8Array"); /* index 1, length 10 */ setup_typedarray_slice(ctx, 0, "Uint8Array", 2, 5); /* index 2, length 5 */ setup_typedarray(ctx, 0, "Uint16Array"); /* index 3, length 5 */ setup_typedarray_slice(ctx, 0, "Uint16Array", 2, 3); /* index 4, length 3 */ duk_eval_string(ctx, "[ 1, 2, 3, 4, 5 ]"); /* index 5, length 5 */ for (i = 10; i >= 0; i--) { duk_resize_buffer(ctx, 0, i); /* Various copy combinations. Resulting buffer is omitted; * when both dst and src are typedarrays they share the same * underlying buffer. so the results are a bit confusing (and * not important to memory safety). */ for (dst = 1; dst <= 4; dst++) { for (src = 1; src <= 5; src++) { printf("%d %d %d\n", i, dst, src); duk_eval_string(ctx, "(function (dst, src) {\n" " for (var i = 0; i < dst.length; i++) { dst[i] = 0x11; }\n" " try { dst.set(src); } catch (e) { print(e.name); }\n" "})\n"); duk_dup(ctx, dst); duk_dup(ctx, src); duk_call(ctx, 2); duk_pop(ctx); } } } printf("final top: %ld\n", (long) duk_get_top(ctx)); return 0; }
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; }
static duk_ret_t test_nodejs_buffer_write_1(duk_context *ctx, void *udata) { int i, dst, src; unsigned char *data; (void) udata; data = (unsigned char *) duk_push_dynamic_buffer(ctx, 10); /* index 0 */ for (i = 0; i < 10; i++) { data[i] = 0x40 + i; } setup_nodejs_buffer(ctx, 0); /* index 1 */ setup_nodejs_buffer_slice(ctx, 0, 1, 4); /* index 2 */ setup_nodejs_buffer_slice(ctx, 0, 3, 7); /* index 3 */ setup_nodejs_buffer_slice(ctx, 0, 6, 9); /* index 4 */ duk_push_string(ctx, ""); /* index 5 */ duk_push_string(ctx, "fo"); /* index 6 */ duk_push_string(ctx, "bar"); /* index 7 */ duk_push_string(ctx, "quux"); /* index 8 */ for (i = 10; i >= 0; i--) { duk_resize_buffer(ctx, 0, i); /* The resulting buffers are not printed here; they're not very * intuitive because both the source and the destination share * the same underlying buffer. */ for (dst = 1; dst <= 4; dst++) { for (src = 5; src <= 8; src++) { printf("%d %d %d\n", i, dst, src); duk_eval_string(ctx, "(function (dst, src) {\n" " for (var i = 0; i < dst.length; i++) { dst[i] = 0x11; }\n" " dst.write(src);\n" " for (var i = 0; i < dst.length; i++) { dst[i] = 0x11; }\n" " dst.write(src, 1);\n" "})"); duk_dup(ctx, dst); duk_dup(ctx, src); duk_call(ctx, 2); duk_pop(ctx); } } } printf("final top: %ld\n", (long) duk_get_top(ctx)); return 0; }
static int test_nodejs_buffer_copy_1(duk_context *ctx) { int i, dst, src; unsigned char *data; data = (unsigned char *) duk_push_dynamic_buffer(ctx, 10); /* index 0 */ for (i = 0; i < 10; i++) { data[i] = 0x40 + i; } setup_nodejs_buffer(ctx, 0); setup_nodejs_buffer_slice(ctx, 0, 1, 4); setup_nodejs_buffer_slice(ctx, 0, 3, 7); setup_nodejs_buffer_slice(ctx, 0, 6, 9); for (i = 10; i >= 0; i--) { duk_resize_buffer(ctx, 0, i); /* The resulting buffers are not printed here; they're not very * intuitive because both the source and the destination share * the same underlying buffer. */ for (dst = 1; dst <= 4; dst++) { for (src = 1; src <= 4; src++) { printf("%d %d %d\n", i, dst, src); duk_eval_string(ctx, "(function (dst, src) {\n" " for (var i = 0; i < dst.length; i++) { dst[i] = 0x11; }\n" " for (var i = 0; i < src.length; i++) { src[i] = 0x22; }\n" " src.copy(dst);\n" " for (var i = 0; i < dst.length; i++) { dst[i] = 0x11; }\n" " for (var i = 0; i < src.length; i++) { src[i] = 0x22; }\n" " src.copy(dst, 4, 1);\n" "})"); duk_dup(ctx, dst); duk_dup(ctx, src); duk_call(ctx, 2); duk_pop(ctx); } } } printf("final top: %ld\n", (long) duk_get_top(ctx)); return 0; }
static void shared_read_write_index(duk_context *ctx, duk_size_t resize_to) { /* [ plain_buffer buffer ] */ duk_eval_string(ctx, "(function (buf) {\n" " print('length', buf.length);\n" " print(buf[0] = 1);\n" " print(buf[99] = 2);\n" " print(buf[100] = 3);\n" /* outside 'limit', not virtual -> becomes concrete property */ " print(0, buf[0]);\n" /* in buffer */ " print(99, buf[99]);\n" /* in buffer */ " print(100, buf[100]);\n" /* outside duk_hbufferobject 'limit', not virtual */ "})\n"); duk_dup(ctx, 1); duk_call(ctx, 1); duk_pop(ctx); /* Resize to fewer number of bytes. */ duk_resize_buffer(ctx, 0, resize_to); /* Reads inside the duk_hbufferobject limit but outside the underlying * buffer return zero; writes are ignored. */ duk_eval_string(ctx, "(function (buf) {\n" " print('length', buf.length);\n" " print(buf[0] = 10);\n" " print(buf[94] = 11);\n" " print(buf[95] = 12);\n" " print(buf[99] = 13);\n" " print(buf[100] = 14);\n" " print(0, buf[0]);\n" /* in buffer */ " print(94, buf[94]);\n" /* in buffer */ " print(95, buf[95]);\n" /* inside duk_hbufferobject 'limit', but outside buffer */ " print(99, buf[99]);\n" /* inside duk_hbufferobject 'limit', but outside buffer */ " print(100, buf[100]);\n" /* outside duk_hbufferobject 'limit', not virtual */ "})\n"); duk_dup(ctx, 1); duk_call(ctx, 1); duk_pop(ctx); }
static duk_ret_t test_typedarray_constructor_copy_1(duk_context *ctx, void *udata) { int i; unsigned char *data; (void) udata; data = (unsigned char *) duk_push_dynamic_buffer(ctx, 10); /* index 0 */ for (i = 0; i < 10; i++) { data[i] = 0x40 + i; } setup_typedarray(ctx, 0, "Uint8Array"); /* index 1 */ for (i = 10; i >= 0; i--) { duk_resize_buffer(ctx, 0, i); /* Compatible copy, uses byte copy when buffer is covered. */ duk_eval_string(ctx, "(function (src) {\n" " var buf = new Uint8Array(src);\n" " print(Duktape.enc('jx', buf));\n" "})\n"); duk_dup(ctx, 1); duk_call(ctx, 1); duk_pop(ctx); /* Incompatible copy, uses "fast copy" when buffer is covered. * Endian specific output. */ duk_eval_string(ctx, "(function (src) {\n" " var buf = new Uint16Array(src);\n" " print(Duktape.enc('jx', buf));\n" "})\n"); duk_dup(ctx, 1); duk_call(ctx, 1); duk_pop(ctx); } printf("final top: %ld\n", (long) duk_get_top(ctx)); return 0; }
static duk_ret_t test_nodejs_buffer_compare_1(duk_context *ctx, void *udata) { int i, dst, src; unsigned char *data; (void) udata; /* There are two relevant methods: Buffer.compare and Buffer.prototype.compare() */ data = (unsigned char *) duk_push_dynamic_buffer(ctx, 10); /* index 0 */ for (i = 0; i < 10; i++) { data[i] = 0x40 + i; } setup_nodejs_buffer(ctx, 0); setup_nodejs_buffer_slice(ctx, 0, 1, 4); setup_nodejs_buffer_slice(ctx, 0, 3, 7); setup_nodejs_buffer_slice(ctx, 0, 6, 9); for (i = 10; i >= 0; i--) { duk_resize_buffer(ctx, 0, i); for (dst = 1; dst <= 4; dst++) { for (src = 1; src <= 4; src++) { printf("%d %d %d\n", i, dst, src); duk_eval_string(ctx, "(function (dst, src) {\n" " print(Buffer.compare(dst, src), dst.compare(src));\n" "})"); duk_dup(ctx, dst); duk_dup(ctx, src); duk_call(ctx, 2); duk_pop(ctx); } } } printf("final top: %ld\n", (long) duk_get_top(ctx)); return 0; }
/* * Read data from a file. Args: * - 0: FILE * - 1: nread (a number or a Buffer-ish object) */ static duk_ret_t io_fread(duk_context* ctx) { FILE* f; size_t nread, r; char* buf; int create_buf = 0; f = duk_require_pointer(ctx, 0); if (duk_is_number(ctx, 1)) { nread = duk_require_int(ctx, 1); buf = duk_push_dynamic_buffer(ctx, nread); create_buf = 1; } else { buf = duk_require_buffer_data(ctx, 1, &nread); if (buf == NULL || nread == 0) { duk_error(ctx, DUK_ERR_TYPE_ERROR, "invalid buffer"); return -42; /* control never returns here */ } } r = fread(buf, 1, nread, f); if (ferror(f)) { if (create_buf) { duk_pop(ctx); } clearerr(f); SJS_THROW_ERRNO_ERROR2(EIO); return -42; /* control never returns here */ } if (create_buf) { /* return the string we read */ duk_resize_buffer(ctx, -1, r); } else { /* the data was written to the buffer, return how much we read */ duk_push_int(ctx, r); } return 1; }
static duk_ret_t test_nodejs_buffer_concat_1(duk_context *ctx, void *udata) { int i; unsigned char *data; (void) udata; data = (unsigned char *) duk_push_dynamic_buffer(ctx, 10); /* index 0 */ for (i = 0; i < 10; i++) { data[i] = 0x40 + i; } setup_nodejs_buffer(ctx, 0); setup_nodejs_buffer_slice(ctx, 0, 1, 6); setup_nodejs_buffer_slice(ctx, 0, 3, 7); setup_nodejs_buffer_slice(ctx, 0, 6, 9); setup_nodejs_buffer_slice(ctx, 0, 1, 8); for (i = 10; i >= 0; i--) { duk_resize_buffer(ctx, 0, i); printf("%d\n", i); duk_eval_string(ctx, "(function (arg1, arg2, arg3, arg4, arg5) {\n" " var res = Buffer.concat([ arg1, arg2, arg3, arg4, arg5 ]);\n" " print(Duktape.enc('jx', res));\n" "})"); duk_dup(ctx, 1); duk_dup(ctx, 2); duk_dup(ctx, 3); duk_dup(ctx, 4); duk_dup(ctx, 5); duk_call(ctx, 5); duk_pop(ctx); } printf("final top: %ld\n", (long) duk_get_top(ctx)); return 0; }
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; }
//void *duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size); void *aperl_duk_resize_buffer(duk_context *ctx, duk_idx_t index, duk_size_t new_size) { void *ret = duk_resize_buffer(ctx, index, new_size); return ret; }