diff options
Diffstat (limited to 'deno2/main.cc')
-rw-r--r-- | deno2/main.cc | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/deno2/main.cc b/deno2/main.cc index 2c0b1b298..506469dfa 100644 --- a/deno2/main.cc +++ b/deno2/main.cc @@ -3,13 +3,33 @@ #include <assert.h> #include <stdio.h> #include <stdlib.h> +#include <unistd.h> +#include <string> +#include "./msg.pb.h" #include "include/deno.h" +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); + response.set_start_cwd(cwd); + + std::string output; + assert(response.SerializeToString(&output) == true); + + auto bufout = deno_buf{output.c_str(), output.length()}; + deno_set_response(d, bufout); +} + int main(int argc, char** argv) { deno_init(); - Deno* d = deno_new(NULL, NULL); + Deno* d = deno_new(NULL, MessagesFromJS); bool r = deno_execute(d, "deno_main.js", "denoMain();"); if (!r) { printf("Error! %s\n", deno_last_exception(d)); |