diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-08-07 14:02:29 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-07 14:02:29 -0400 |
commit | e438ac2c74c823882dc9c9ecde2a9e9ed7bcfb4b (patch) | |
tree | 480b2daa83e31b26c5d611feff021674d289e492 /core/libdeno/binding.cc | |
parent | 5350abbc7ffdba6d17166fa00ad89e86979a43f7 (diff) |
Add op_id throughout op API (#2734)
Removes the magic number hack to switch between flatbuffers and the
minimal dispatcher.
Adds machinery to pass the op_id through the shared_queue.
Diffstat (limited to 'core/libdeno/binding.cc')
-rw-r--r-- | core/libdeno/binding.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/core/libdeno/binding.cc b/core/libdeno/binding.cc index da582a3bf..291e62f01 100644 --- a/core/libdeno/binding.cc +++ b/core/libdeno/binding.cc @@ -223,22 +223,29 @@ void Send(const v8::FunctionCallbackInfo<v8::Value>& args) { v8::HandleScope handle_scope(isolate); deno_buf control = {nullptr, 0}; - if (args[0]->IsArrayBufferView()) { - auto view = v8::Local<v8::ArrayBufferView>::Cast(args[0]); + + int32_t op_id = 0; + if (args[0]->IsInt32()) { + auto context = d->context_.Get(isolate); + op_id = args[0]->Int32Value(context).FromJust(); + } + + if (args[1]->IsArrayBufferView()) { + auto view = v8::Local<v8::ArrayBufferView>::Cast(args[1]); auto data = reinterpret_cast<uint8_t*>(view->Buffer()->GetContents().Data()); control = {data + view->ByteOffset(), view->ByteLength()}; } PinnedBuf zero_copy = - args[1]->IsArrayBufferView() - ? PinnedBuf(v8::Local<v8::ArrayBufferView>::Cast(args[1])) + args[2]->IsArrayBufferView() + ? PinnedBuf(v8::Local<v8::ArrayBufferView>::Cast(args[2])) : PinnedBuf(); DCHECK_NULL(d->current_args_); d->current_args_ = &args; - d->recv_cb_(d->user_data_, control, zero_copy.IntoRaw()); + d->recv_cb_(d->user_data_, op_id, control, zero_copy.IntoRaw()); if (d->current_args_ == nullptr) { // This indicates that deno_repond() was called already. |