diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-06-14 01:40:35 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-06-14 14:19:17 +0200 |
commit | f92f10b848d1be439094a84d5115e0100d685f6f (patch) | |
tree | 5f47ef930cdd56b51a17b306a939cc018be6aff0 /deno2/main.cc | |
parent | ec65717c59082c98c93c0ce2ded265861e20b48d (diff) |
deno2: pass argv to js
Diffstat (limited to 'deno2/main.cc')
-rw-r--r-- | deno2/main.cc | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/deno2/main.cc b/deno2/main.cc index 37e271951..342b957b9 100644 --- a/deno2/main.cc +++ b/deno2/main.cc @@ -5,30 +5,43 @@ #include <unistd.h> #include <string> -#include "v8/src/base/logging.h" #include "./msg.pb.h" #include "include/deno.h" +#include "v8/src/base/logging.h" + +static char** global_argv; +static int global_argc; void MessagesFromJS(Deno* d, const char* channel, deno_buf buf) { printf("MessagesFromJS %s\n", channel); - char cwdbuf[1024]; - std::string cwd(getcwd(cwdbuf, sizeof(cwdbuf))); - deno::Msg response; response.set_command(deno::Msg_Command_START); + + char cwdbuf[1024]; + std::string cwd(getcwd(cwdbuf, sizeof(cwdbuf))); response.set_start_cwd(cwd); + for (int i = 0; i < global_argc; ++i) { + printf("arg %d %s\n", i, global_argv[i]); + response.add_start_argv(global_argv[i]); + } + printf("response.start_argv_size %d \n", response.start_argv_size()); + std::string output; CHECK(response.SerializeToString(&output)); - auto bufout = deno_buf{output.c_str(), output.length()}; + deno_buf bufout{output.c_str(), output.length()}; deno_set_response(d, bufout); } int main(int argc, char** argv) { deno_init(); + deno_set_flags(&argc, argv); + global_argv = argv; + global_argc = argc; + Deno* d = deno_new(NULL, MessagesFromJS); bool r = deno_execute(d, "deno_main.js", "denoMain();"); if (!r) { |