Skip to content

Commit

Permalink
Merge branch 'master' into internal-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith authored Oct 16, 2021
2 parents 4b7b080 + f75f288 commit 1bc4f79
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
2 changes: 0 additions & 2 deletions cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import "C"
import (
_ "rogchap.com/v8go/deps/darwin_x86_64"
_ "rogchap.com/v8go/deps/include"
_ "rogchap.com/v8go/deps/include/cppgc"
_ "rogchap.com/v8go/deps/include/libplatform"
_ "rogchap.com/v8go/deps/linux_x86_64"
_ "rogchap.com/v8go/deps/windows_x86_64"
)
5 changes: 5 additions & 0 deletions deps/include/vendor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Package include is required to provide support for vendoring modules
// DO NOT REMOVE
package include

import (
_ "rogchap.com/v8go/deps/include/cppgc"
_ "rogchap.com/v8go/deps/include/libplatform"
)
8 changes: 4 additions & 4 deletions promise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func TestPromiseRejected(t *testing.T) {
t.Fatalf("expected [%v], was: %+v", val2, thenInfo.Args())
}

if then2Fulfilled {
t.Fatalf("unexpectedly called onFulfilled")
if !then2Fulfilled {
t.Fatalf("expected call to onFulfilled, got none")
}
if !then2Rejected {
t.Fatalf("expected call to onRejected, got none")
if then2Rejected {
t.Fatalf("unexpectedly called onRejected")
}
}

Expand Down
40 changes: 19 additions & 21 deletions v8go.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct _EXCEPTION_POINTERS;

#include "libplatform/libplatform.h"
#include "v8.h"
#include "_cgo_export.h"

using namespace v8;

Expand Down Expand Up @@ -294,7 +295,6 @@ static void FunctionTemplateCallback(const FunctionCallbackInfo<Value>& info) {
// we can use the context registry to match the Context on the Go side
Local<Context> local_ctx = iso->GetCurrentContext();
int ctx_ref = local_ctx->GetEmbedderData(1).As<Integer>()->Value();
ContextPtr goContext(int ctxref);
m_ctx* ctx = goContext(ctx_ref);

int callback_ref = info.Data().As<Integer>()->Value();
Expand All @@ -318,8 +318,6 @@ static void FunctionTemplateCallback(const FunctionCallbackInfo<Value>& info) {
args[i] = tracked_value(ctx, val);
}

ValuePtr goFunctionCallback(int ctxref, int cbref,
const ValuePtr* thisAndArgs, int args_count);
ValuePtr val =
goFunctionCallback(ctx_ref, callback_ref, thisAndArgs, args_count);
if (val != nullptr) {
Expand Down Expand Up @@ -1218,12 +1216,12 @@ RtnValue PromiseThen(ValuePtr ptr, int callback_ref) {
rtn.error = ExceptionError(try_catch, iso, local_ctx);
return rtn;
}
m_value* promise_val = new m_value;
promise_val->iso = iso;
promise_val->ctx = ctx;
promise_val->ptr =
Persistent<Value, CopyablePersistentTraits<Value>>(iso, promise);
rtn.value = tracked_value(ctx, promise_val);
m_value* result_val = new m_value;
result_val->iso = iso;
result_val->ctx = ctx;
result_val->ptr =
Persistent<Value, CopyablePersistentTraits<Value>>(iso, result);
rtn.value = tracked_value(ctx, result_val);
return rtn;
}

Expand Down Expand Up @@ -1251,12 +1249,12 @@ RtnValue PromiseThen2(ValuePtr ptr, int on_fulfilled_ref, int on_rejected_ref) {
rtn.error = ExceptionError(try_catch, iso, local_ctx);
return rtn;
}
m_value* promise_val = new m_value;
promise_val->iso = iso;
promise_val->ctx = ctx;
promise_val->ptr =
Persistent<Value, CopyablePersistentTraits<Value>>(iso, promise);
rtn.value = tracked_value(ctx, promise_val);
m_value* result_val = new m_value;
result_val->iso = iso;
result_val->ctx = ctx;
result_val->ptr =
Persistent<Value, CopyablePersistentTraits<Value>>(iso, result);
rtn.value = tracked_value(ctx, result_val);
return rtn;
}

Expand All @@ -1276,12 +1274,12 @@ RtnValue PromiseCatch(ValuePtr ptr, int callback_ref) {
rtn.error = ExceptionError(try_catch, iso, local_ctx);
return rtn;
}
m_value* promise_val = new m_value;
promise_val->iso = iso;
promise_val->ctx = ctx;
promise_val->ptr =
Persistent<Value, CopyablePersistentTraits<Value>>(iso, promise);
rtn.value = tracked_value(ctx, promise_val);
m_value* result_val = new m_value;
result_val->iso = iso;
result_val->ctx = ctx;
result_val->ptr =
Persistent<Value, CopyablePersistentTraits<Value>>(iso, result);
rtn.value = tracked_value(ctx, result_val);
return rtn;
}

Expand Down

0 comments on commit 1bc4f79

Please sign in to comment.