本文整理汇总了C++中v8::Handle::GetIsolate方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::GetIsolate方法的具体用法?C++ Handle::GetIsolate怎么用?C++ Handle::GetIsolate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Handle
的用法示例。
在下文中一共展示了Handle::GetIsolate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scope
bool V8PerContextDebugData::setContextDebugData(v8::Handle<v8::Context> context, const char* worldName, int debugId)
{
if (!debugData(context)->IsUndefined())
return false;
v8::HandleScope scope(context->GetIsolate());
v8::Handle<v8::Value> debugData = createDebugData(worldName, debugId, context->GetIsolate());
setDebugData(context, debugData);
return true;
}
示例2: Init
//Init
void DeviceNode::Init(v8::Handle<v8::Object> exports) {
Isolate* isolate = exports->GetIsolate();
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
tpl->SetClassName(String::NewFromUtf8(isolate, "DeviceNode"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
NODE_SET_PROTOTYPE_METHOD(tpl, "getName", DeviceNode::GetName);
NODE_SET_PROTOTYPE_METHOD(tpl, "getId", DeviceNode::GetId);
NODE_SET_PROTOTYPE_METHOD(tpl, "getModel", DeviceNode::GetModel);
NODE_SET_PROTOTYPE_METHOD(tpl, "getProtocol", DeviceNode::GetProtocol);
NODE_SET_PROTOTYPE_METHOD(tpl, "getDeviceType", DeviceNode::GetDeviceType);
NODE_SET_PROTOTYPE_METHOD(tpl, "getLastSentValue", DeviceNode::GetLastSentValue);
NODE_SET_PROTOTYPE_METHOD(tpl, "getMethods", DeviceNode::GetMethods);
NODE_SET_PROTOTYPE_METHOD(tpl, "getDimValue", DeviceNode::GetDimValue);
NODE_SET_PROTOTYPE_METHOD(tpl, "isOn", DeviceNode::IsOn);
NODE_SET_PROTOTYPE_METHOD(tpl, "isDimmable", DeviceNode::IsDimmable);
NODE_SET_PROTOTYPE_METHOD(tpl, "turnOff", DeviceNode::TurnOff);
NODE_SET_PROTOTYPE_METHOD(tpl, "turnOn", DeviceNode::TurnOn);
NODE_SET_PROTOTYPE_METHOD(tpl, "dim", DeviceNode::Dim);
constructor.Reset(isolate, tpl->GetFunction());
exports->Set(String::NewFromUtf8(isolate, "DeviceNode"),
tpl->GetFunction());
}
示例3: CustomElementBindingMap
V8PerContextData::V8PerContextData(v8::Handle<v8::Context> context)
: m_wrapperBoilerplates(context->GetIsolate())
, m_constructorMap(context->GetIsolate())
, m_isolate(context->GetIsolate())
, m_contextHolder(adoptPtr(new gin::ContextHolder(context->GetIsolate())))
, m_context(m_isolate, context)
, m_customElementBindings(adoptPtr(new CustomElementBindingMap()))
{
m_contextHolder->SetContext(context);
v8::Context::Scope contextScope(context);
ASSERT(m_errorPrototype.isEmpty());
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(v8AtomicString(m_isolate, "Error")));
ASSERT(!object.IsEmpty());
v8::Handle<v8::Value> prototypeValue = object->Get(v8AtomicString(m_isolate, "prototype"));
ASSERT(!prototypeValue.IsEmpty());
m_errorPrototype.set(m_isolate, prototypeValue);
}
示例4: ASSERT
ScriptState::ScriptState(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
: m_isolate(context->GetIsolate())
, m_context(m_isolate, context)
, m_world(world)
, m_perContextData(V8PerContextData::create(context))
{
ASSERT(m_world);
m_context.setWeak(this, &weakCallback);
context->SetAlignedPointerInEmbedderData(v8ContextPerContextDataIndex, this);
}
示例5: makeContextWeak
void DOMWrapperWorld::makeContextWeak(v8::Handle<v8::Context> context)
{
ASSERT(isIsolatedWorld());
ASSERT(isolatedWorld(context) == this);
v8::Isolate* isolate = context->GetIsolate();
v8::Persistent<v8::Context> persistent = v8::Persistent<v8::Context>::New(isolate, context);
WeakHandleListener<DOMWrapperWorld>::makeWeak(isolate, persistent, this);
// Matching deref is in weak callback.
this->ref();
}
示例6: RunShell
// The read-eval-execute loop of the shell.
void RunShell(v8::Handle<v8::Context> context) {
fprintf(stderr, "V8 version %s [sample shell]\n", v8::V8::GetVersion());
static const int kBufferSize = 256;
// Enter the execution environment before evaluating any code.
v8::Context::Scope context_scope(context);
v8::Local<v8::String> name(
v8::String::NewFromUtf8(context->GetIsolate(), "(shell)"));
while (true) {
char buffer[kBufferSize];
fprintf(stderr, "> ");
char* str = fgets(buffer, kBufferSize, stdin);
if (str == NULL) break;
v8::HandleScope handle_scope(context->GetIsolate());
ExecuteString(context->GetIsolate(),
v8::String::NewFromUtf8(context->GetIsolate(), str),
name,
true,
true);
}
fprintf(stderr, "\n");
}
示例7: contextScope
V8PerContextData::V8PerContextData(v8::Handle<v8::Context> context)
: m_isolate(context->GetIsolate())
, m_wrapperBoilerplates(m_isolate)
, m_constructorMap(m_isolate)
, m_contextHolder(adoptPtr(new gin::ContextHolder(m_isolate)))
, m_context(m_isolate, context)
, m_activityLogger(0)
, m_compiledPrivateScript(m_isolate)
{
m_contextHolder->SetContext(context);
v8::Context::Scope contextScope(context);
ASSERT(m_errorPrototype.isEmpty());
v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(context->Global()->Get(v8AtomicString(m_isolate, "Error")));
ASSERT(!object.IsEmpty());
v8::Handle<v8::Value> prototypeValue = object->Get(v8AtomicString(m_isolate, "prototype"));
ASSERT(!prototypeValue.IsEmpty());
m_errorPrototype.set(m_isolate, prototypeValue);
}
示例8: Register
// Registers this module with Node
static void Register (v8::Handle <v8::Object> target)
{
auto isolate = target->GetIsolate ();
// Prepare constructor template
auto function_template = v8::FunctionTemplate::New (isolate, Create);
function_template->SetClassName (v8::String::NewFromUtf8 (isolate, descriptor.GetName ().c_str ()));
function_template->InstanceTemplate ()->SetInternalFieldCount (1);
// add GetModuleInfo function
descriptor.AddFunction ("getModuleInfo", GetModuleInfo, "Retrieves framework information about this module.", NO_PARAMETERS, RETURNS_AN OBJECT);
// Set up exported function prototypes
for (auto function : descriptor.GetFunctions ())
{
NODE_SET_PROTOTYPE_METHOD (function_template, function.name.c_str (), function.callback);
}
constructor.Reset (isolate, function_template->GetFunction ());
target->Set (v8::String::NewFromUtf8 (isolate, descriptor.GetName ().c_str ()), function_template->GetFunction ());
}
示例9: handle_scope
CContext::CContext(v8::Handle<v8::Context> context)
{
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
m_context.Reset(context->GetIsolate(), context);
}
示例10: __registerModule
void __registerModule(v8::Handle<v8::Object> target)
{
v8::Isolate* isolate = target->GetIsolate();
target->Set(JSTRING("ModuleName"), JSTRING("Example Addon"));
}