|
|
@ -970,10 +970,10 @@ static duk_ret_t fileio_write_file(duk_context *ctx) { |
|
|
|
#endif /* DUK_CMDLINE_FILEIO */ |
|
|
|
|
|
|
|
/*
|
|
|
|
* String.fromBuffer() |
|
|
|
* String.fromBufferRaw() |
|
|
|
*/ |
|
|
|
|
|
|
|
static duk_ret_t string_frombuffer(duk_context *ctx) { |
|
|
|
static duk_ret_t string_frombufferraw(duk_context *ctx) { |
|
|
|
duk_buffer_to_string(ctx, 0); |
|
|
|
return 1; |
|
|
|
} |
|
|
@ -1142,8 +1142,8 @@ static duk_context *create_duktape_heap(int alloc_provider, int debugger, int aj |
|
|
|
duk_print_alert_init(ctx, 0 /*flags*/); |
|
|
|
#endif |
|
|
|
|
|
|
|
/* Register String.fromBuffer() which does a 1:1 buffer-to-string
|
|
|
|
* coercion needed by testcases. String.fromBuffer() is -not- a |
|
|
|
/* Register String.fromBufferRaw() which does a 1:1 buffer-to-string
|
|
|
|
* coercion needed by testcases. String.fromBufferRaw() is -not- a |
|
|
|
* default built-in! For stripped builds the 'String' built-in |
|
|
|
* doesn't exist and we create it here; for ROM builds it may be |
|
|
|
* present but unwritable (which is ignored). |
|
|
@ -1151,9 +1151,9 @@ static duk_context *create_duktape_heap(int alloc_provider, int debugger, int aj |
|
|
|
duk_eval_string(ctx, |
|
|
|
"(function(v){" |
|
|
|
"if (typeof String === 'undefined') { String = {}; }" |
|
|
|
"Object.defineProperty(String, 'fromBuffer', {value:v, configurable:true});" |
|
|
|
"Object.defineProperty(String, 'fromBufferRaw', {value:v, configurable:true});" |
|
|
|
"})"); |
|
|
|
duk_push_c_function(ctx, string_frombuffer, 1 /*nargs*/); |
|
|
|
duk_push_c_function(ctx, string_frombufferraw, 1 /*nargs*/); |
|
|
|
(void) duk_pcall(ctx, 1); |
|
|
|
duk_pop(ctx); |
|
|
|
|
|
|
|