mirror of
https://github.com/denoland/deno.git
synced 2025-02-08 07:16:56 -05:00
Don't use bool in deno.h to support C.
This commit is contained in:
parent
4f6c8ba54b
commit
b2694ecbd8
2 changed files with 10 additions and 8 deletions
|
@ -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(); }
|
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;
|
auto* isolate = d->isolate;
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::Isolate::Scope isolate_scope(isolate);
|
v8::Isolate::Scope isolate_scope(isolate);
|
||||||
v8::HandleScope handle_scope(isolate);
|
v8::HandleScope handle_scope(isolate);
|
||||||
auto context = d->context.Get(d->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::Locker locker(d->isolate);
|
||||||
v8::Isolate::Scope isolate_scope(d->isolate);
|
v8::Isolate::Scope isolate_scope(d->isolate);
|
||||||
v8::HandleScope handle_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);
|
auto sub = d->sub.Get(d->isolate);
|
||||||
if (sub.IsEmpty()) {
|
if (sub.IsEmpty()) {
|
||||||
d->last_exception = "deno_sub has not been called.";
|
d->last_exception = "deno_sub has not been called.";
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ry) support zero-copy.
|
// TODO(ry) support zero-copy.
|
||||||
|
@ -325,10 +325,10 @@ bool deno_pub(Deno* d, const char* channel, deno_buf buf) {
|
||||||
|
|
||||||
if (try_catch.HasCaught()) {
|
if (try_catch.HasCaught()) {
|
||||||
deno::HandleException(context, try_catch.Exception());
|
deno::HandleException(context, try_catch.Exception());
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deno_set_response(Deno* d, deno_buf buf) {
|
void deno_set_response(Deno* d, deno_buf buf) {
|
||||||
|
|
|
@ -30,11 +30,13 @@ void deno_delete(Deno* d);
|
||||||
|
|
||||||
// Returns false on error.
|
// Returns false on error.
|
||||||
// Get error text with deno_last_exception().
|
// 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
|
// Routes message to the javascript callback set with deno_sub(). A false return
|
||||||
// value indicates error. Check deno_last_exception() for exception text.
|
// 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.
|
// 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
|
// If this is not called during the life time of a deno_sub_cb callback
|
||||||
|
|
Loading…
Add table
Reference in a new issue