Browse Source
import dutape js engine from https://github.com/svaarala/duktape 4781b33420eba0f0dd4f9caa10dfc17622d3925e python tools/configure.py --source-directory src-input --output-directory src-lowmemory \ --option-file config/examples/low_memory.yaml --architecture arm32 --compiler gcc Signed-off-by: surenyi <surenyi82@163.com>master
surenyi
5 years ago
9 changed files with 103108 additions and 0 deletions
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,28 @@ |
|||
#include <stdio.h> |
|||
#include "duktape.h" |
|||
#include "cmd.h" |
|||
|
|||
static duk_ret_t native_print(duk_context *ctx) |
|||
{ |
|||
duk_push_string(ctx, " "); |
|||
duk_insert(ctx, 0); |
|||
duk_join(ctx, duk_get_top(ctx) - 1); |
|||
printf("%s\n", duk_safe_to_string(ctx, -1)); |
|||
return 0; |
|||
} |
|||
|
|||
static int do_jshello(cmd_tbl_t s, int argc, char *argv[]) |
|||
{ |
|||
duk_context *ctx = duk_create_heap_default(); |
|||
|
|||
duk_push_c_function(ctx, native_print, DUK_VARARGS); |
|||
duk_put_global_string(ctx, "print"); |
|||
|
|||
duk_eval_string(ctx, "print('welcome to use duktape!')"); |
|||
duk_destroy_heap(ctx); |
|||
|
|||
return 0; |
|||
} |
|||
|
|||
CON_CMD(jshello, "hello from js", NULL, do_jshello); |
|||
|
Loading…
Reference in new issue