本文整理汇总了C++中Handle::SetNamedPropertyHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::SetNamedPropertyHandler方法的具体用法?C++ Handle::SetNamedPropertyHandler怎么用?C++ Handle::SetNamedPropertyHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::SetNamedPropertyHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BinaryTypes
Handle<Object> SorrowContext::SetupInternals(int argc, const char *argv[]) {
HandleScope scope;
Local<FunctionTemplate> internals_template = FunctionTemplate::New();
internals = Persistent<Object>::New(internals_template->GetFunction()->NewInstance());
Local<Object> global = Context::GetCurrent()->Global();
SET_METHOD(global, "quit", Quit)
SET_METHOD(global, "version", Version)
SET_METHOD(internals, "compile", CompileScript)
if (argc) {
Local<Array> lineArgs = Array::New(argc-1);
for (int i = 0; i +1 < argc; i++) {
lineArgs->Set(Integer::New(i), V8_STR(argv[i+1]));
}
internals->Set(V8_STR("args"), lineArgs);
} else {
internals->Set(V8_STR("args"), Array::New());
}
Handle<Object> libsObject = Object::New();
LoadNativeLibraries(libsObject);
internals->Set(V8_STR("stdlib"), libsObject);
Handle<ObjectTemplate> env = ObjectTemplate::New();
env->SetNamedPropertyHandler(EnvGetter);
internals->Set(V8_STR("env"), env->NewInstance());
internals->Set(V8_STR("global"), global);
binarytypes = new BinaryTypes(internals);
iostreams = new IOStreams(internals);
Filesystem::Initialize(internals);
Extensions::Initialize(internals);
TryCatch tryCatch;
Local<Value> func = ExecuteString(V8_STR(sorrow_native), V8_STR("sorrow.js"));
if (tryCatch.HasCaught()) {
ReportException(&tryCatch);
exit(10);
}
ASSERT_PIN(func->IsFunction(), "sorrow.js main function not found");
Local<Function> f = Local<Function>::Cast(func);
Local<Value> args[1] = { Local<Value>::New(internals) };
f->Call(global, 1, args);
if (tryCatch.HasCaught()) {
ReportException(&tryCatch);
exit(11);
}
return internals;
} // SetupInternals
示例2: PrepareTemplate
static Handle<ObjectTemplate> PrepareTemplate()
{
HandleScope handle_scope;
Handle<ObjectTemplate> result = ObjectTemplate::New();
result->SetInternalFieldCount(2);
result->SetNamedPropertyHandler(ObjectGet, ObjectSet);
return handle_scope.Close(result);
}