0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 12:16:11 -05:00

Don't use bool in deno.h to support C.

This commit is contained in:
Ryan Dahl 2018-06-15 15:12:32 +02:00
parent 4f6c8ba54b
commit b2694ecbd8
2 changed files with 10 additions and 8 deletions

View file

@ -288,16 +288,16 @@ void deno_set_flags(int* argc, char** argv) {
const char* deno_last_exception(Deno* d) { return d->last_exception.c_str(); }
bool deno_execute(Deno* d, const char* js_filename, const char* js_source) {
int deno_execute(Deno* d, const char* js_filename, const char* js_source) {
auto* isolate = d->isolate;
v8::Locker locker(isolate);
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
auto context = d->context.Get(d->isolate);
return deno::Execute(context, js_filename, js_source);
return deno::Execute(context, js_filename, js_source) ? 1 : 0;
}
bool deno_pub(Deno* d, const char* channel, deno_buf buf) {
int deno_pub(Deno* d, const char* channel, deno_buf buf) {
v8::Locker locker(d->isolate);
v8::Isolate::Scope isolate_scope(d->isolate);
v8::HandleScope handle_scope(d->isolate);
@ -310,7 +310,7 @@ bool deno_pub(Deno* d, const char* channel, deno_buf buf) {
auto sub = d->sub.Get(d->isolate);
if (sub.IsEmpty()) {
d->last_exception = "deno_sub has not been called.";
return false;
return 0;
}
// TODO(ry) support zero-copy.
@ -325,10 +325,10 @@ bool deno_pub(Deno* d, const char* channel, deno_buf buf) {
if (try_catch.HasCaught()) {
deno::HandleException(context, try_catch.Exception());
return false;
return 0;
}
return true;
return 1;
}
void deno_set_response(Deno* d, deno_buf buf) {

View file

@ -30,11 +30,13 @@ void deno_delete(Deno* d);
// Returns false on error.
// Get error text with deno_last_exception().
bool deno_execute(Deno* d, const char* js_filename, const char* js_source);
// 0 = fail, 1 = success
int deno_execute(Deno* d, const char* js_filename, const char* js_source);
// Routes message to the javascript callback set with deno_sub(). A false return
// value indicates error. Check deno_last_exception() for exception text.
bool deno_pub(Deno* d, const char* channel, deno_buf buf);
// 0 = fail, 1 = success
int deno_pub(Deno* d, const char* channel, deno_buf buf);
// Call this inside a deno_sub_cb to respond synchronously to messages.
// If this is not called during the life time of a deno_sub_cb callback