本文整理汇总了C++中Local::SetAccessor方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::SetAccessor方法的具体用法?C++ Local::SetAccessor怎么用?C++ Local::SetAccessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::SetAccessor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scope
void JNIV8ClassInfo::_registerAccessor(JNIV8ObjectAccessorHolder *holder) {
Isolate* isolate = engine->getIsolate();
HandleScope scope(isolate);
Local<FunctionTemplate> ft = Local<FunctionTemplate>::New(isolate, functionTemplate);
accessorHolders.push_back(holder);
Local<External> data = External::New(isolate, (void*)holder);
AccessorNameSetterCallback finalSetter = 0;
v8::PropertyAttribute settings = v8::PropertyAttribute::None;
if(holder->setterCallback.i || holder->setterCallback.s) {
finalSetter = v8AccessorSetterCallback;
} else {
settings = v8::PropertyAttribute::ReadOnly;
}
if(holder->isStatic) {
Local<Function> f = ft->GetFunction();
f->SetAccessor(engine->getContext(), String::NewFromUtf8(isolate, holder->propertyName.c_str()),
v8AccessorGetterCallback, finalSetter,
data, DEFAULT, settings);
} else {
Local<ObjectTemplate> instanceTpl = ft->InstanceTemplate();
instanceTpl->SetAccessor(String::NewFromUtf8(isolate, holder->propertyName.c_str()),
v8AccessorGetterCallback, finalSetter,
data, DEFAULT, settings);
}
}
示例2: context_scope
v8::Handle<v8::Object> WrapScreen(ScriptSystem* ss)
{
HandleScope handle_scope;
Handle<Context> context = ss->GetGlobalContext();
Context::Scope context_scope(context);
Handle<FunctionTemplate> templt = FunctionTemplate::New();
templt->SetClassName(String::New("Screen"));
Handle<ObjectTemplate> proto = templt->PrototypeTemplate();
proto->Set("toString", FunctionTemplate::New(SCRToString));
proto->Set("getPickRay", FunctionTemplate::New(SCRGetPickRay));
proto->Set("intersect", FunctionTemplate::New(SCRIntersect));
proto->Set("pickEntity", FunctionTemplate::New(SCRPickEntity));
proto->Set("convertWorldToScreenCoords", FunctionTemplate::New(SCRConvertWorldToScreenCoords));
proto->Set("openWindow", FunctionTemplate::New(SCROpenWindow));
proto->Set("closeWindow", FunctionTemplate::New(SCRCloseWindow));
proto->Set("getWindowGeometry", FunctionTemplate::New(SCRGetWindowGeometry));
proto->Set("setWindowGeometry", FunctionTemplate::New(SCRSetWindowGeometry));
Local<Object> instance = templt->GetFunction()->NewInstance();
instance->SetAccessor(String::New("lockCursor"), SCRGetLockCursor, SCRSetLockCursor);
instance->SetAccessor(String::New("showCursor"), SCRGetShowCursor, SCRSetShowCursor);
instance->SetAccessor(String::New("width"), SCRGetWidth);
instance->SetAccessor(String::New("height"), SCRGetHeight);
instance->SetAccessor(String::New("fullScreen"), SCRGetFullScreen, SCRSetFullScreen);
return handle_scope.Close(instance);
}
示例3: handle_scope
Local<ObjectTemplate> JsHttpRequestProcessor::MakeRequestTemplate(
Isolate* isolate) {
EscapableHandleScope handle_scope(isolate);
Local<ObjectTemplate> result = ObjectTemplate::New(isolate);
result->SetInternalFieldCount(1);
// Add accessors for each of the fields of the request.
result->SetAccessor(
String::NewFromUtf8(isolate, "path", NewStringType::kInternalized)
.ToLocalChecked(),
GetPath);
result->SetAccessor(
String::NewFromUtf8(isolate, "referrer", NewStringType::kInternalized)
.ToLocalChecked(),
GetReferrer);
result->SetAccessor(
String::NewFromUtf8(isolate, "host", NewStringType::kInternalized)
.ToLocalChecked(),
GetHost);
result->SetAccessor(
String::NewFromUtf8(isolate, "userAgent", NewStringType::kInternalized)
.ToLocalChecked(),
GetUserAgent);
// Again, return the result through the current handle scope.
return handle_scope.Escape(result);
}
示例4: if
Local<Object> PairNodeIterator::New(int type, MapType::const_iterator new_iter, MapType::const_iterator new_end) {
Handle<FunctionTemplate> tmplt;
if ((PairNodeIterator::KEY_TYPE & type) && (PairNodeIterator::VALUE_TYPE & type)) {
tmplt = NanNew<FunctionTemplate>(key_value_tmplt);
} else if (KEY_TYPE & type) {
tmplt = NanNew<FunctionTemplate>(key_tmplt);
} else {
tmplt = NanNew<FunctionTemplate>(value_tmplt);
}
Local<Object> obj = tmplt->InstanceTemplate()->NewInstance();
PairNodeIterator *iter = new PairNodeIterator(new_iter, new_end);
iter->Wrap(obj);
Local<String> key = NanNew<String>("key");
Local<String> value = NanNew<String>("value");
Local<String> done = NanNew<String>("done");
if (PairNodeIterator::KEY_TYPE & type) {
obj->SetAccessor(key, GetKey);
}
if (PairNodeIterator::VALUE_TYPE & type) {
obj->SetAccessor(value, GetValue);
}
obj->SetAccessor(done, GetDone);
return obj;
}
示例5:
Handle<FunctionTemplate> PushbotsModule::getProxyTemplate()
{
if (!proxyTemplate.IsEmpty()) {
return proxyTemplate;
}
LOGD(TAG, "GetProxyTemplate");
javaClass = titanium::JNIUtil::findClass("com/pushbots/android/PushbotsModule");
HandleScope scope;
// use symbol over string for efficiency
Handle<String> nameSymbol = String::NewSymbol("Pushbots");
Handle<FunctionTemplate> t = titanium::Proxy::inheritProxyTemplate(
titanium::KrollModule::getProxyTemplate()
, javaClass, nameSymbol);
proxyTemplate = Persistent<FunctionTemplate>::New(t);
proxyTemplate->Set(titanium::Proxy::inheritSymbol,
FunctionTemplate::New(titanium::Proxy::inherit<PushbotsModule>)->GetFunction());
titanium::ProxyFactory::registerProxyPair(javaClass, *proxyTemplate);
// Method bindings --------------------------------------------------------
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "setPushEnabled", PushbotsModule::setPushEnabled);
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "tag", PushbotsModule::tag);
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "example", PushbotsModule::example);
Local<ObjectTemplate> prototypeTemplate = proxyTemplate->PrototypeTemplate();
Local<ObjectTemplate> instanceTemplate = proxyTemplate->InstanceTemplate();
// Delegate indexed property get and set to the Java proxy.
instanceTemplate->SetIndexedPropertyHandler(titanium::Proxy::getIndexedProperty,
titanium::Proxy::setIndexedProperty);
// Constants --------------------------------------------------------------
// Dynamic properties -----------------------------------------------------
instanceTemplate->SetAccessor(String::NewSymbol("alias"),
titanium::Proxy::getProperty
, PushbotsModule::setter_alias
, Handle<Value>(), DEFAULT);
instanceTemplate->SetAccessor(String::NewSymbol("enabled"),
PushbotsModule::getter_enabled
, PushbotsModule::setter_enabled
, Handle<Value>(), DEFAULT);
instanceTemplate->SetAccessor(String::NewSymbol("exampleProp"),
PushbotsModule::getter_exampleProp
, PushbotsModule::setter_exampleProp
, Handle<Value>(), DEFAULT);
// Accessors --------------------------------------------------------------
return proxyTemplate;
}
示例6: HttpClientInitBinding
void HttpClientInitBinding(Handle<Object> target) {
NanScope();
Local<FunctionTemplate> ctor = NanNew<FunctionTemplate>(newHttpClient);
NanAssignPersistent(constructor, ctor);
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(NanNew("HttpClient"));
Local<ObjectTemplate> proto = ctor->PrototypeTemplate();
proto->SetAccessor(NanNew("url"), HttpClientGetUrl, HttpClientSetUrl);
proto->SetAccessor(NanNew("returnType"), HttpClientGetReturnType, HttpClientSetReturnType);
proto->SetAccessor(NanNew("method"), HttpClientGetMethod, HttpClientSetMethod);
proto->SetAccessor(NanNew("requestHeaders"), HttpClientGetRequestHeaders, HttpClientSetRequestHeaders);
proto->SetAccessor(NanNew("requestData"), HttpClientGetRequestData, HttpClientSetRequestData);
proto->SetAccessor(NanNew("status"), HttpClientGetStatus, HttpClientSetStatus);
proto->SetAccessor(NanNew("statusText"), HttpClientGetStatusText, HttpClientSetStatusText);
proto->SetAccessor(NanNew("responseHeaders"), HttpClientGetResponseHeaders, HttpClientSetResponseHeaders);
proto->SetAccessor(NanNew("responseText"), HttpClientGetResponseText, HttpClientSetResponseText);
NAN_SET_PROTOTYPE_METHOD(ctor, "send", HttpClientSend);
target->Set(NanNew("HttpClient"), ctor->GetFunction());
HttpClient::init();
}
示例7:
Handle<FunctionTemplate> ExampleProxy::getProxyTemplate()
{
if (!proxyTemplate.IsEmpty()) {
return proxyTemplate;
}
LOGD(TAG, "GetProxyTemplate");
javaClass = titanium::JNIUtil::findClass("ro/mihaiblaga/imei/ExampleProxy");
HandleScope scope;
// use symbol over string for efficiency
Handle<String> nameSymbol = String::NewSymbol("Example");
Handle<FunctionTemplate> t = titanium::Proxy::inheritProxyTemplate(
titanium::TiViewProxy::getProxyTemplate()
, javaClass, nameSymbol);
proxyTemplate = Persistent<FunctionTemplate>::New(t);
proxyTemplate->Set(titanium::Proxy::inheritSymbol,
FunctionTemplate::New(titanium::Proxy::inherit<ExampleProxy>)->GetFunction());
titanium::ProxyFactory::registerProxyPair(javaClass, *proxyTemplate);
// Method bindings --------------------------------------------------------
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "setMessage", ExampleProxy::setMessage);
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "getMessage", ExampleProxy::getMessage);
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "printMessage", ExampleProxy::printMessage);
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "getImei", ExampleProxy::getImei);
Local<ObjectTemplate> prototypeTemplate = proxyTemplate->PrototypeTemplate();
Local<ObjectTemplate> instanceTemplate = proxyTemplate->InstanceTemplate();
// Delegate indexed property get and set to the Java proxy.
instanceTemplate->SetIndexedPropertyHandler(titanium::Proxy::getIndexedProperty,
titanium::Proxy::setIndexedProperty);
// Constants --------------------------------------------------------------
// Dynamic properties -----------------------------------------------------
instanceTemplate->SetAccessor(String::NewSymbol("message"),
ExampleProxy::getter_message
, ExampleProxy::setter_message
, Handle<Value>(), DEFAULT);
instanceTemplate->SetAccessor(String::NewSymbol("imei"),
ExampleProxy::getter_imei
, titanium::Proxy::onPropertyChanged
, Handle<Value>(), DEFAULT);
// Accessors --------------------------------------------------------------
return proxyTemplate;
}
示例8:
Handle<FunctionTemplate> NfcTagProxy::getProxyTemplate()
{
if (!proxyTemplate.IsEmpty()) {
return proxyTemplate;
}
LOGD(TAG, "GetProxyTemplate");
javaClass = titanium::JNIUtil::findClass("ta/nfc/NfcTagProxy");
HandleScope scope;
// use symbol over string for efficiency
Handle<String> nameSymbol = String::NewSymbol("NfcTag");
Handle<FunctionTemplate> t = titanium::Proxy::inheritProxyTemplate(
titanium::KrollProxy::getProxyTemplate()
, javaClass, nameSymbol);
proxyTemplate = Persistent<FunctionTemplate>::New(t);
proxyTemplate->Set(titanium::Proxy::inheritSymbol,
FunctionTemplate::New(titanium::Proxy::inherit<NfcTagProxy>)->GetFunction());
titanium::ProxyFactory::registerProxyPair(javaClass, *proxyTemplate);
// Method bindings --------------------------------------------------------
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "getId", NfcTagProxy::getId);
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "getTechList", NfcTagProxy::getTechList);
Local<ObjectTemplate> prototypeTemplate = proxyTemplate->PrototypeTemplate();
Local<ObjectTemplate> instanceTemplate = proxyTemplate->InstanceTemplate();
// Delegate indexed property get and set to the Java proxy.
instanceTemplate->SetIndexedPropertyHandler(titanium::Proxy::getIndexedProperty,
titanium::Proxy::setIndexedProperty);
// Constants --------------------------------------------------------------
// Dynamic properties -----------------------------------------------------
instanceTemplate->SetAccessor(String::NewSymbol("id"),
NfcTagProxy::getter_id
, titanium::Proxy::onPropertyChanged
, Handle<Value>(), DEFAULT);
instanceTemplate->SetAccessor(String::NewSymbol("techList"),
NfcTagProxy::getter_techList
, titanium::Proxy::onPropertyChanged
, Handle<Value>(), DEFAULT);
// Accessors --------------------------------------------------------------
return proxyTemplate;
}
示例9:
Handle<Object> FixSession::wrapFixSession(FixSession* fixSession) {
Local<FunctionTemplate> ctor = NanNew<FunctionTemplate>();
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(NanNew("FixSession"));
Local<ObjectTemplate> proto = ctor->PrototypeTemplate();
NODE_SET_PROTOTYPE_METHOD(ctor, "disconnect", disconnect);
NODE_SET_PROTOTYPE_METHOD(ctor, "getSessionID", getSessionID);
NODE_SET_PROTOTYPE_METHOD(ctor, "isEnabled", isEnabled);
NODE_SET_PROTOTYPE_METHOD(ctor, "isLoggedOn", isLoggedOn);
NODE_SET_PROTOTYPE_METHOD(ctor, "logon", logon);
NODE_SET_PROTOTYPE_METHOD(ctor, "logout", logout);
NODE_SET_PROTOTYPE_METHOD(ctor, "refresh", refresh);
NODE_SET_PROTOTYPE_METHOD(ctor, "reset", reset);
proto->SetAccessor(NanNew("senderSeqNum"), getSenderSeqNum, setSenderSeqNum);
proto->SetAccessor(NanNew("targetSeqNum"), getTargetSeqNum, setTargetSeqNum);
Handle<Object> obj = ctor->InstanceTemplate()->NewInstance();
//obj->SetAlignedPointerInInternalField(0, NanNew<External>(fixSession));
fixSession->Wrap(obj);
return obj;
}
示例10: Init
void Init(Isolate * isolate)
{
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
tpl->SetClassName(v8::String::NewFromUtf8(isolate, "Transformable"));
tpl->InstanceTemplate()->SetInternalFieldCount(2);
Local<ObjectTemplate> proto = tpl->PrototypeTemplate();
// proto->SetInternalFieldCount(1);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "x"), GetX, SetX);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "y"), GetY, SetY);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "rotation"), GetRotation, SetRotation);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "scaleX"), GetScaleX, SetScaleX);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "scaleY"), GetScaleY, SetScaleY);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "originX"), GetOriginX, SetOriginX);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "originY"), GetOriginY, SetOriginY);
tpl_ref.Reset(isolate, tpl);
}
示例11: initClass
static v8::Local<v8::Function> initClass(v8::Handle<v8::FunctionTemplate>& temp) {
HandleScope scope;
Local<ObjectTemplate> obj = temp->PrototypeTemplate();
obj->SetAccessor(String::New("height"), height);
obj->SetAccessor(String::New("ascender"), ascender);
obj->SetAccessor(String::New("descender"), descender);
EXPOSE_METHOD(obj, load, ReadOnly | DontDelete);
EXPOSE_METHOD(obj, measure, ReadOnly | DontDelete);
EXPOSE_METHOD(obj, glyphs, ReadOnly | DontDelete);
EXPOSE_METHOD(obj, outline_type, ReadOnly | DontDelete);
EXPOSE_METHOD(obj, outline_thickness, ReadOnly | DontDelete);
return scope.Close(temp->GetFunction());
}
示例12: InjectPrototype
void MetadataNode::InjectPrototype(Local<Object>& target, Local<Object>& implementationObject)
{
auto isolate = Isolate::GetCurrent();
implementationObject->SetAccessor(ConvertToV8String("super"), SuperAccessorGetterCallback, nullptr, implementationObject);
implementationObject->SetPrototype(target->GetPrototype());
target->SetPrototype(implementationObject);
}
示例13: scope
void CanvasRenderingContext2D::Create(const v8::FunctionCallbackInfo<v8::Value>& args)
{
auto isolate = args.GetIsolate();
HandleScope scope(isolate);
Local<ObjectTemplate> contextTemplate = ObjectTemplate::New(isolate);
contextTemplate->SetInternalFieldCount(1);
contextTemplate->Set(ConvertToV8String("__draw"), FunctionTemplate::New(isolate, &Draw));
contextTemplate->Set(ConvertToV8String("__sizeChanged"), FunctionTemplate::New(isolate, &SizeChanged));
contextTemplate->SetAccessor(ConvertToV8String("fillStyle"), &GetFillStyle, &SetFillStyle);
contextTemplate->SetAccessor(ConvertToV8String("strokeStyle"), &GetStrokeStyle, &SetStrokeStyle);
contextTemplate->Set(ConvertToV8String("arc"), FunctionTemplate::New(isolate, &Arc));
contextTemplate->Set(ConvertToV8String("beginPath"), FunctionTemplate::New(isolate, &BeginPath));
contextTemplate->Set(ConvertToV8String("bezierCurveTo"), FunctionTemplate::New(isolate, &BezierCurveTo));
contextTemplate->Set(ConvertToV8String("clearRect"), FunctionTemplate::New(isolate, &ClearRect));
contextTemplate->Set(ConvertToV8String("closePath"), FunctionTemplate::New(isolate, &ClosePath));
contextTemplate->Set(ConvertToV8String("drawImage"), FunctionTemplate::New(isolate, &DrawImage));
contextTemplate->Set(ConvertToV8String("fill"), FunctionTemplate::New(isolate, &Fill));
contextTemplate->Set(ConvertToV8String("fillRect"), FunctionTemplate::New(isolate, &FillRect));
contextTemplate->Set(ConvertToV8String("fillText"), FunctionTemplate::New(isolate, &FillText));
contextTemplate->Set(ConvertToV8String("getImageData"), FunctionTemplate::New(isolate, &GetImageData));
contextTemplate->Set(ConvertToV8String("lineTo"), FunctionTemplate::New(isolate, &LineTo));
contextTemplate->Set(ConvertToV8String("measureText"), FunctionTemplate::New(isolate, &MeasureText));
contextTemplate->Set(ConvertToV8String("moveTo"), FunctionTemplate::New(isolate, &MoveTo));
contextTemplate->Set(ConvertToV8String("quadraticCurveTo"), FunctionTemplate::New(isolate, &QuadraticCurveTo));
contextTemplate->Set(ConvertToV8String("restore"), FunctionTemplate::New(isolate, &Restore));
contextTemplate->Set(ConvertToV8String("rotate"), FunctionTemplate::New(isolate, &Rotate));
contextTemplate->Set(ConvertToV8String("save"), FunctionTemplate::New(isolate, &Save));
contextTemplate->Set(ConvertToV8String("stroke"), FunctionTemplate::New(isolate, &Stroke));
contextTemplate->Set(ConvertToV8String("translate"), FunctionTemplate::New(isolate, &Translate));
Local<Object> newContext = contextTemplate->NewInstance();
newContext->ForceSet(ConvertToV8String("canvas"), args[0]);
newContext->ForceSet(ConvertToV8String("__kind"), ConvertToV8String("2d"));
auto nativeContext = new CanvasRenderingContext2D();
newContext->SetInternalField(0, External::New(isolate, nativeContext));
Persistent<Object> persistentHandle(isolate, newContext);
persistentHandle.SetWeak(nativeContext, &Deallocate);
args.GetReturnValue().Set(newContext);
}
示例14: RegisterMyClass
void RegisterMyClass(Isolate* isolate, Local<ObjectTemplate> global)
{
Local<ObjectTemplate> localTemplate = ObjectTemplate::New(isolate);
localTemplate->SetInternalFieldCount(1);
localTemplate->SetAccessor(
String::NewFromUtf8(isolate, "num", NewStringType::kInternalized)
.ToLocalChecked(),
jsMyClassGetNumber,
jsMyClassSetNumber);
localTemplate->SetAccessor(
String::NewFromUtf8(isolate, "name", NewStringType::kInternalized)
.ToLocalChecked(),
jsMyClassGetName,
jsMyClassSetName);
localTemplate->Set(
String::NewFromUtf8(isolate, "Method1", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, jsMyClassMethod1));
localTemplate->Set(
String::NewFromUtf8(isolate, "Method2", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, jsMyClassMethod2));
gMyClassTemplate.Reset(isolate, localTemplate);
global->Set(
String::NewFromUtf8(isolate, "MyClass", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, jsCreateMyClass));
global->Set(
String::NewFromUtf8(isolate, "jsMyFunction", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, jsMyFunction));
global->Set(
String::NewFromUtf8(isolate, "jsMyFunction1", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, jsMyFunction1));
global->Set(
String::NewFromUtf8(isolate, "jsMyFunction2", NewStringType::kNormal)
.ToLocalChecked(),
FunctionTemplate::New(isolate, jsMyFunction2));
}
示例15: initClass
static v8::Local<v8::Function> initClass(v8::Handle<v8::FunctionTemplate>& temp) {
HandleScope scope;
Local<ObjectTemplate> obj = temp->PrototypeTemplate();
obj->SetAccessor(String::New("byteLength"), byteLength);
EXPOSE_METHOD(obj, slice, ReadOnly | DontDelete);
EXPOSE_METHOD(obj, isView, ReadOnly | DontDelete);
obj->Set(String::New("clone"), FunctionTemplate::New(ClassWrap<NodeBuffer>::clone));
return scope.Close(temp->GetFunction());
}