diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-06-11 18:17:28 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-06-11 18:17:28 +0200 |
commit | cbbe8ad9992765bc0883759e4075cf7a4a1918ff (patch) | |
tree | 844555d6da87fc08e4ffb3f98a9c9d2742a41dd3 /deno2/deno.cc | |
parent | 0e07e16dd63992f5f989dc99c891d53d930a2d5b (diff) |
Add deno_send tests.
Diffstat (limited to 'deno2/deno.cc')
-rw-r--r-- | deno2/deno.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/deno2/deno.cc b/deno2/deno.cc index 7bca590a7..4fa5b2101 100644 --- a/deno2/deno.cc +++ b/deno2/deno.cc @@ -274,9 +274,10 @@ bool deno_load(Deno* d, const char* name_s, const char* source_s) { return deno::Load(context, name_s, source_s); } -// Called from golang. Must route message to javascript lang. -// non-zero return value indicates error. check deno_last_exception(). -int deno_send(Deno* d, deno_buf buf) { +// Routes message to the javascript callback set with deno_recv(). +// False return value indicates error. Check deno_last_exception() for exception +// text. +bool deno_send(Deno* d, deno_buf buf) { v8::Locker locker(d->isolate); v8::Isolate::Scope isolate_scope(d->isolate); v8::HandleScope handle_scope(d->isolate); @@ -289,8 +290,8 @@ int deno_send(Deno* d, deno_buf buf) { v8::Local<v8::Function> recv = v8::Local<v8::Function>::New(d->isolate, d->recv); if (recv.IsEmpty()) { - d->last_exception = "V8Deno2.recv has not been called."; - return 1; + d->last_exception = "deno_recv has not been called."; + return false; } v8::Local<v8::Value> args[1]; @@ -303,10 +304,10 @@ int deno_send(Deno* d, deno_buf buf) { if (try_catch.HasCaught()) { deno::HandleException(context, try_catch.Exception()); - return 2; + return false; } - return 0; + return true; } void deno_dispose(Deno* d) { |