本文整理汇总了C++中Handle::GetIsolate方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::GetIsolate方法的具体用法?C++ Handle::GetIsolate怎么用?C++ Handle::GetIsolate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::GetIsolate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
// Add wrapper class to runtime environment
void BookWrap::Init(Handle<Object> exports) {
Isolate* isolate = exports->GetIsolate();
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, BookWrap::New);
tpl->SetClassName(String::NewFromUtf8(isolate, "Book"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
NODE_SET_PROTOTYPE_METHOD(tpl, "add", Add);
NODE_SET_PROTOTYPE_METHOD(tpl, "length", Length);
NODE_SET_PROTOTYPE_METHOD(tpl, "lookup", Lookup);
NODE_SET_PROTOTYPE_METHOD(tpl, "each", Each);
NODE_SET_PROTOTYPE_METHOD(tpl, "apply", Apply);
tpl->InstanceTemplate()->SetIndexedPropertyHandler(Getter, Setter, 0, Deleter, Enumerator);
Constructor.Reset(isolate, tpl->GetFunction());
exports->Set(String::NewFromUtf8(isolate, "Book"), tpl->GetFunction());
}
示例2: CallJavascriptFunction
void CallJavascriptFunction(Handle<Context> context, Handle<Value> This, UFunction* SignatureFunction, Handle<Function> func, void* Parms)
{
SCOPE_CYCLE_COUNTER(STAT_JavascriptFunctionCallToJavascript);
auto isolate = context->GetIsolate();
HandleScope handle_scope(isolate);
auto Buffer = reinterpret_cast<uint8*>(Parms);
enum { MaxArgs = 32 };
Handle<Value> argv[MaxArgs];
int argc = 0;
TFieldIterator<UProperty> Iter(SignatureFunction);
for (; Iter && argc < MaxArgs && (Iter->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm; ++Iter)
{
UProperty* Param = *Iter;
argv[argc++] = ReadProperty(isolate, Param, Buffer, FNoPropertyOwner());
}
UProperty* ReturnParam = nullptr;
for (; Iter; ++Iter)
{
UProperty* Param = *Iter;
if (Param->GetPropertyFlags() & CPF_ReturnParm)
{
ReturnParam = Param;
break;
}
}
TryCatch try_catch;
auto value = func->Call(This, argc, argv);
if (try_catch.HasCaught())
{
FV8Exception::Report(try_catch);
}
bool bHasAnyOutParams = false;
if (SignatureFunction && SignatureFunction->HasAnyFunctionFlags(FUNC_HasOutParms))
{
// Iterate over input parameters
for (TFieldIterator<UProperty> It(SignatureFunction); It && (It->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm; ++It)
{
// This is 'out ref'!
if ((It->PropertyFlags & (CPF_ConstParm | CPF_OutParm)) == CPF_OutParm)
{
bHasAnyOutParams = true;
break;
}
}
}
if (bHasAnyOutParams)
{
FIsolateHelper I(isolate);
if (value.IsEmpty() || !value->IsObject())
{
I.Throw(TEXT("..."));
return;
}
auto Object = value->ToObject();
// Iterate over parameters again
for (TFieldIterator<UProperty> It(SignatureFunction); It; ++It)
{
UProperty* Param = *It;
auto PropertyFlags = Param->GetPropertyFlags();
// pass return parameter as '$'
if (PropertyFlags & CPF_ReturnParm)
{
auto sub_value = Object->Get(I.Keyword("$"));
WriteProperty(isolate, ReturnParam, Buffer, sub_value);
}
// rejects 'const T&' and pass 'T&' as its name
else if ((PropertyFlags & (CPF_ConstParm | CPF_OutParm)) == CPF_OutParm)
{
auto sub_value = Object->Get(I.Keyword(Param->GetName()));
if (!sub_value.IsEmpty())
{
// value can be null if isolate is in trouble
WriteProperty(isolate, Param, Buffer, sub_value);
}
}
}
}
else
{
if (ReturnParam)
{
WriteProperty(isolate, ReturnParam, Buffer, value);
//.........这里部分代码省略.........