本文整理汇总了C++中Isolate::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ Isolate::GetData方法的具体用法?C++ Isolate::GetData怎么用?C++ Isolate::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Isolate
的用法示例。
在下文中一共展示了Isolate::GetData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scope
static void
gum_v8_script_backend_emit_debug_message (const Debug::Message & message)
{
Isolate * isolate = message.GetIsolate ();
GumV8ScriptBackend * self = GUM_V8_SCRIPT_BACKEND (isolate->GetData (0));
GumV8ScriptBackendPrivate * priv = self->priv;
HandleScope scope (isolate);
Local<String> json = message.GetJSON ();
String::Utf8Value json_str (json);
GUM_V8_SCRIPT_BACKEND_LOCK ();
GMainContext * context = (priv->debug_handler_context != NULL)
? g_main_context_ref (priv->debug_handler_context)
: NULL;
GUM_V8_SCRIPT_BACKEND_UNLOCK ();
if (context == NULL)
return;
GumEmitDebugMessageData * d = g_slice_new (GumEmitDebugMessageData);
d->backend = self;
g_object_ref (self);
d->message = g_strdup (*json_str);
GSource * source = g_idle_source_new ();
g_source_set_callback (source,
(GSourceFunc) gum_v8_script_backend_do_emit_debug_message,
d,
(GDestroyNotify) gum_emit_debug_message_data_free);
g_source_attach (source, context);
g_source_unref (source);
g_main_context_unref (context);
}
示例2: V8DispatchDebugMessages
void V8DispatchDebugMessages()
{
Isolate* isolate = Isolate::GetCurrent();
Persistent<Context> *persistent_contect = (Persistent<Context> *)isolate->GetData(1);
HandleScope handle_scope(isolate);
Local<Context> context = Local<Context>::New(isolate, *persistent_contect);
Context::Scope scope(context);
Debug::ProcessDebugMessages();
}
示例3: handle_scope
/* for geomtransform, we don't have the mapObj */
shapeObj *msV8TransformShape(shapeObj *shape, const char* filename)
{
TryCatch try_catch;
Isolate *isolate = Isolate::GetCurrent();
V8Context *v8context = (V8Context*)isolate->GetData();
HandleScope handle_scope(v8context->isolate);
/* execution context */
Local<Context> context = Local<Context>::New(v8context->isolate, v8context->context);
Context::Scope context_scope(context);
Handle<Object> global = context->Global();
Shape* shape_ = new Shape(shape);
shape_->setLayer(v8context->layer);
shape_->disableMemoryHandler();
Handle<Value> ext = External::New(shape_);
global->Set(String::New("shape"),
Shape::Constructor()->NewInstance(1, &ext));
msV8ExecuteScript(filename);
Handle<Value> value = global->Get(String::New("geomtransform"));
if (value->IsUndefined()) {
msDebug("msV8TransformShape: Function 'geomtransform' is missing.\n");
return NULL;
}
Handle<Function> func = Handle<Function>::Cast(value);
Handle<Value> result = func->Call(global, 0, 0);
if (result.IsEmpty() && try_catch.HasCaught()) {
msV8ReportException(&try_catch);
}
if (!result.IsEmpty() && result->IsObject()) {
Handle<Object> obj = result->ToObject();
if (obj->GetConstructorName()->Equals(String::New("shapeObj"))) {
Shape* new_shape = ObjectWrap::Unwrap<Shape>(result->ToObject());
if (shape == new_shape->get()) {
shapeObj *new_shape_ = (shapeObj *)msSmallMalloc(sizeof(shapeObj));
msInitShape(new_shape_);
msCopyShape(shape, new_shape_);
return new_shape_;
}
else {
new_shape->disableMemoryHandler();
return new_shape->get();
}
}
}
return NULL;
}
示例4: Init
void SideNotification::Init(Handle<Object> exports){
Isolate* isolate = Isolate::GetCurrent();
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate);
tpl->SetClassName(String::NewFromUtf8(isolate, SideNotification::NAME.c_str()));
tpl->InstanceTemplate()->SetAccessor(String::NewFromUtf8(isolate, "side"),
SideGetter);
tpl->InstanceTemplate()->SetInternalFieldCount(1);
JavaScriptMessageProvider* provider=static_cast<JavaScriptMessageProvider*>(isolate->GetData(0));
provider->setObjectConstructor(SideNotification::NAME, tpl->GetFunction());
provider->setObjectTemplate(SideNotification::NAME, tpl->InstanceTemplate());
exports->Set(String::NewFromUtf8(isolate, SideNotification::NAME.c_str()), tpl->GetFunction());
}
示例5: ThrowException
/* Execute a javascript file */
static Handle<Value> msV8ExecuteScript(const char *path, int throw_exception = MS_FALSE)
{
char fullpath[MS_MAXPATHLEN];
map<string, Persistent<Script> >::iterator it;
Isolate *isolate = Isolate::GetCurrent();
V8Context *v8context = (V8Context*)isolate->GetData();
/* construct the path */
msBuildPath(fullpath, v8context->paths.top().c_str(), path);
char *filepath = msGetPath((char*)fullpath);
v8context->paths.push(filepath);
free(filepath);
Handle<Script> script;
it = v8context->scripts.find(fullpath);
if (it == v8context->scripts.end()) {
Handle<Value> source = msV8ReadFile(v8context, fullpath);
Handle<String> script_name = String::New(msStripPath((char*)path));
script = msV8CompileScript(source->ToString(), script_name);
if (script.IsEmpty()) {
v8context->paths.pop();
if (throw_exception) {
return ThrowException(String::New("Error compiling script"));
}
}
/* cache the compiled script */
Persistent<Script> pscript;
pscript.Reset(isolate, script);
v8context->scripts[fullpath] = pscript;
} else {
script = v8context->scripts[fullpath];
}
Handle<Value> result = msV8RunScript(script);
v8context->paths.pop();
if (result.IsEmpty() && throw_exception) {
return ThrowException(String::New("Error running script"));
}
return result;
}