本文整理汇总了C++中Local::Inherit方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::Inherit方法的具体用法?C++ Local::Inherit怎么用?C++ Local::Inherit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::Inherit方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bindProxy
void Proxy::bindProxy(Handle<Object> exports)
{
javaClassSymbol = SYMBOL_LITERAL("__javaClass__");
constructorSymbol = SYMBOL_LITERAL("constructor");
inheritSymbol = SYMBOL_LITERAL("inherit");
propertiesSymbol = SYMBOL_LITERAL("_properties");
lengthSymbol = SYMBOL_LITERAL("length");
sourceUrlSymbol = SYMBOL_LITERAL("sourceUrl");
Local<FunctionTemplate> proxyTemplate = FunctionTemplate::New();
Local<String> proxySymbol = String::NewSymbol("Proxy");
proxyTemplate->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount);
proxyTemplate->SetClassName(proxySymbol);
proxyTemplate->Inherit(EventEmitter::constructorTemplate);
proxyTemplate->Set(javaClassSymbol, External::Wrap(JNIUtil::krollProxyClass),
PropertyAttribute(DontDelete | DontEnum));
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "_hasListenersForEventType", hasListenersForEventType);
DEFINE_PROTOTYPE_METHOD(proxyTemplate, "onPropertiesChanged", proxyOnPropertiesChanged);
baseProxyTemplate = Persistent<FunctionTemplate>::New(proxyTemplate);
exports->Set(proxySymbol, proxyTemplate->GetFunction());
}
示例2:
// Called during add-on initialization to add the "Handle" template function
// to the target object.
void LS2Handle::Initialize(Handle<Object> target)
{
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->SetClassName(String::New("palmbus/Handle"));
t->Inherit(EventEmitter::constructor_template);
t->InstanceTemplate()->SetInternalFieldCount(1);
NODE_SET_PROTOTYPE_METHOD(t, "call", CallWrapper);
NODE_SET_PROTOTYPE_METHOD(t, "watch", WatchWrapper);
NODE_SET_PROTOTYPE_METHOD(t, "subscribe", SubscribeWrapper);
NODE_SET_PROTOTYPE_METHOD(t, "registerMethod", RegisterMethodWrapper);
NODE_SET_PROTOTYPE_METHOD(t, "subscriptionAdd", SubscriptionAddWrapper);
NODE_SET_PROTOTYPE_METHOD(t, "cancel", CancelWrapper);
NODE_SET_PROTOTYPE_METHOD(t, "pushRole", PushRoleWrapper);
NODE_SET_PROTOTYPE_METHOD(t, "unregister", UnregisterWrapper);
cancel_symbol = NODE_PSYMBOL("cancel");
request_symbol = NODE_PSYMBOL("request");
target->Set(String::NewSymbol("Handle"), t->GetFunction());
}
示例3: ctorCacheItem
Local<FunctionTemplate> MetadataNode::GetConstructorFunctionTemplate(Isolate *isolate, MetadataTreeNode *treeNode, vector<MethodCallbackData*>& instanceMethodsCallbackData)
{
SET_PROFILER_FRAME();
Local<FunctionTemplate> ctorFuncTemplate;
auto itFound = s_ctorFuncCache.find(treeNode);
if (itFound != s_ctorFuncCache.end())
{
auto& ctorCacheItem = itFound->second;
instanceMethodsCallbackData = ctorCacheItem.instanceMethodCallbacks;
ctorFuncTemplate = Local<FunctionTemplate>::New(isolate, *ctorCacheItem.ft);
return ctorFuncTemplate;
}
auto node = GetOrCreateInternal(treeNode);
auto ctorCallbackData = External::New(isolate, node);
auto isInterface = s_metadataReader.IsNodeTypeInterface(treeNode->type);
auto funcCallback = isInterface ? InterfaceConstructorCallback : ClassConstructorCallback;
ctorFuncTemplate = FunctionTemplate::New(isolate, funcCallback, ctorCallbackData);
ctorFuncTemplate->InstanceTemplate()->SetInternalFieldCount(static_cast<int>(ObjectManager::MetadataNodeKeys::END));
auto baseClass = s_metadataReader.GetBaseClassNode(treeNode);
Local<Function> baseCtorFunc;
vector<MethodCallbackData*> baseInstanceMethodsCallbackData;
if ((baseClass != treeNode) && (baseClass != nullptr) && (baseClass->offsetValue > 0))
{
auto baseFuncTemplate = GetConstructorFunctionTemplate(isolate, baseClass, baseInstanceMethodsCallbackData);
if (!baseFuncTemplate.IsEmpty())
{
ctorFuncTemplate->Inherit(baseFuncTemplate);
baseCtorFunc = baseFuncTemplate->GetFunction();
}
}
auto prototypeTemplate = ctorFuncTemplate->PrototypeTemplate();
auto ctorFunc = node->SetMembers(isolate, ctorFuncTemplate, prototypeTemplate, instanceMethodsCallbackData, baseInstanceMethodsCallbackData, treeNode);
if (!baseCtorFunc.IsEmpty())
{
ctorFunc->SetPrototype(baseCtorFunc);
}
auto pft = new Persistent<FunctionTemplate>(isolate, ctorFuncTemplate);
CtorCacheItem ctorCacheItem(pft, instanceMethodsCallbackData);
s_ctorFuncCache.insert(make_pair(treeNode, ctorCacheItem));
SetInnnerTypes(isolate, ctorFunc, treeNode);
SetTypeMetadata(isolate, ctorFunc, new TypeMetadata(s_metadataReader.ReadTypeName(treeNode)));
return ctorFuncTemplate;
}
示例4: Initialize
void MultiPoint::Initialize(Local<Object> target)
{
Nan::HandleScope scope;
Local<FunctionTemplate> lcons = Nan::New<FunctionTemplate>(MultiPoint::New);
lcons->Inherit(Nan::New(GeometryCollection::constructor));
lcons->InstanceTemplate()->SetInternalFieldCount(1);
lcons->SetClassName(Nan::New("MultiPoint").ToLocalChecked());
Nan::SetPrototypeMethod(lcons, "toString", toString);
target->Set(Nan::New("MultiPoint").ToLocalChecked(), lcons->GetFunction());
constructor.Reset(lcons);
}
示例5: Init
void DILexicalBlock::Init(Handle<Object> target) {
Nan::HandleScope scope;
Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(New);
constructor.Reset(ctor);
ctor->Inherit (Nan::New<v8::FunctionTemplate>(DIScope::constructor));
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(Nan::New("DILexicalBlock").ToLocalChecked());
Local<v8::Function> ctor_func = ctor->GetFunction();
constructor_func.Reset(ctor_func);
target->Set(Nan::New("DILexicalBlock").ToLocalChecked(), ctor_func);
}
示例6: Initialize
void MultiLineString::Initialize(Handle<Object> target)
{
NanScope();
Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(MultiLineString::New);
lcons->Inherit(NanNew(GeometryCollection::constructor));
lcons->InstanceTemplate()->SetInternalFieldCount(1);
lcons->SetClassName(NanNew("MultiLineString"));
NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString);
NODE_SET_PROTOTYPE_METHOD(lcons, "polygonize", polygonize);
target->Set(NanNew("MultiLineString"), lcons->GetFunction());
NanAssignPersistent(constructor, lcons);
}
示例7: Init
void JsSprite::Init(Isolate * isolate, Handle<ObjectTemplate> exports)
{
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
tpl->SetClassName(v8::String::NewFromUtf8(isolate, "Sprite"));
tpl->InstanceTemplate()->SetInternalFieldCount(2);
tpl->Inherit(v8_transformable::GetFunctionTemplate(isolate));
// Prototype
Local<ObjectTemplate> proto = tpl->PrototypeTemplate();
// proto->SetInternalFieldCount(1);
proto->SetAccessor(v8::String::NewFromUtf8(isolate, "texture"), JS_GetTexture, JS_SetTexture);
constructor.Reset(isolate, tpl);
exports->Set(v8::String::NewFromUtf8(isolate, "Sprite"), PersistentToLocal(isolate, constructor));
}
示例8: PropertyAttribute
Handle<FunctionTemplate> Proxy::inheritProxyTemplate(
Handle<FunctionTemplate> superTemplate, jclass javaClass,
Handle<String> className, Handle<Function> callback)
{
HandleScope scope;
Local<Value> wrappedClass = External::Wrap(javaClass);
Local<FunctionTemplate> inheritedTemplate = FunctionTemplate::New(proxyConstructor, callback);
inheritedTemplate->Set(javaClassSymbol, wrappedClass, PropertyAttribute(DontDelete | DontEnum));
inheritedTemplate->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount);
inheritedTemplate->SetClassName(className);
inheritedTemplate->Inherit(superTemplate);
return scope.Close(inheritedTemplate);
}
示例9: Initialize
void Polygon::Initialize(Handle<Object> target)
{
NanScope();
Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Polygon::New);
lcons->Inherit(NanNew(Geometry::constructor));
lcons->InstanceTemplate()->SetInternalFieldCount(1);
lcons->SetClassName(NanNew("Polygon"));
NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString);
NODE_SET_PROTOTYPE_METHOD(lcons, "getArea", getArea);
ATTR(lcons, "rings", ringsGetter, READ_ONLY_SETTER);
target->Set(NanNew("Polygon"), lcons->GetFunction());
NanAssignPersistent(constructor, lcons);
}
示例10: Init
void Instruction::Init(Handle<Object> target) {
Nan::HandleScope scope;
Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(New);
constructor.Reset(ctor);
ctor->Inherit (Nan::New<v8::FunctionTemplate>(Value::constructor));
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(Nan::New("Instruction").ToLocalChecked());
#if false
Nan::SetPrototypeMethod (ctor, "setDebugLoc", Instruction::SetDebugLoc);
#endif
Local<v8::Function> ctor_func = ctor->GetFunction();
constructor_func.Reset(ctor_func);
target->Set(Nan::New("Instruction").ToLocalChecked(), ctor_func);
}
示例11: AddonInitialize
void AddonInitialize(v8::Handle<v8::Object> target)
{
using namespace v8;
//HandleScope scope;
static Termios termios;
termios.no_canonical();
Terminfo::initialize();
keyinput_symbol = NODE_PSYMBOL("keyinput");
// javascript class Term
Local<FunctionTemplate> t = FunctionTemplate::New(Term::New);
t->InstanceTemplate()->SetInternalFieldCount(1);
t->Inherit(node::EventEmitter::constructor_template);
NODE_SET_PROTOTYPE_METHOD(t, "listen", Term::listen);
NODE_SET_PROTOTYPE_METHOD(t, "tcmd", Term::tcmd);
NODE_SET_PROTOTYPE_METHOD(t, "size", Term::size);
target->Set(String::NewSymbol("Term"), t->GetFunction());
}
示例12: Initialize
void Point::Initialize(Handle<Object> target)
{
NanScope();
Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Point::New);
lcons->Inherit(NanNew(Geometry::constructor));
lcons->InstanceTemplate()->SetInternalFieldCount(1);
lcons->SetClassName(NanNew("Point"));
NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString);
// properties
ATTR(lcons, "x", xGetter, xSetter);
ATTR(lcons, "y", yGetter, ySetter);
ATTR(lcons, "z", zGetter, zSetter);
target->Set(NanNew("Point"), lcons->GetFunction());
NanAssignPersistent(constructor, lcons);
}
示例13: Initialize
void APIModule::Initialize(Local<Object> target, Local<Context> context)
{
Isolate* isolate = context->GetIsolate();
HandleScope scope(isolate);
Local<FunctionTemplate> constructor = FunctionTemplate::New(isolate);
constructor->SetClassName(NEW_SYMBOL(isolate, "API"));
constructorTemplate.Reset(isolate, constructor);
// Hook methods to the API prototype, notice these aren't hooked to API
// itself, instead we return a singleton of an API instance and export it
// as Ti.API
// Not sure why we then hook apiName as instance proprty, since
// the difference is made moot by the singleton!
SetProtoMethod(isolate, constructor, "debug", logDebug);
SetProtoMethod(isolate, constructor, "info", logInfo);
SetProtoMethod(isolate, constructor, "warn", logWarn);
SetProtoMethod(isolate, constructor, "error", logError);
SetProtoMethod(isolate, constructor, "trace", logTrace);
SetProtoMethod(isolate, constructor, "notice", logNotice);
SetProtoMethod(isolate, constructor, "critical", logCritical);
SetProtoMethod(isolate, constructor, "fatal", logFatal);
SetProtoMethod(isolate, constructor, "log", log);
SetProtoMethod(isolate, constructor, "getApiName", APIModule::getApiName);
// Add an "apiName" property to instances, which delegates to APIModule::getter_apiName
// TODO Use a constant here?
Local<ObjectTemplate> instanceTemplate = constructor->InstanceTemplate();
instanceTemplate->SetAccessor(NEW_SYMBOL(isolate, "apiName"), APIModule::getter_apiName);
// Expose a method for terminating the application for the debugger.
// Debugger will send an evaluation request calling this method
// when it wants the application to terminate immediately.
if (V8Runtime::debuggerEnabled) {
SetProtoMethod(isolate, constructor, "terminate", terminate);
SetProtoMethod(isolate, constructor, "debugBreak", debugBreak);
}
// Make API extend from KrollModule
constructor->Inherit(KrollModule::getProxyTemplate(isolate));
// export an instance of API as "API" (basically make a static singleton)
target->Set(NEW_SYMBOL(isolate, "API"), constructor->GetFunction(context).ToLocalChecked()->NewInstance(context).ToLocalChecked());
}
示例14: Init
void FunctionType::Init(Handle<Object> target) {
Nan::HandleScope scope;
Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(New);
constructor.Reset(ctor);
ctor->Inherit (Nan::New<v8::FunctionTemplate>(Type::constructor));
ctor->InstanceTemplate()->SetInternalFieldCount(1);
ctor->SetClassName(Nan::New("FunctionType").ToLocalChecked());
Nan::SetMethod(ctor, "get", FunctionType::Get);
Nan::SetPrototypeMethod(ctor, "getReturnType", FunctionType::GetReturnType);
Nan::SetPrototypeMethod(ctor, "getParamType", FunctionType::GetParamType);
Nan::SetPrototypeMethod(ctor, "dump", FunctionType::Dump);
Nan::SetPrototypeMethod(ctor, "toString", FunctionType::ToString);
Local<v8::Function> ctor_func = ctor->GetFunction();
constructor_func.Reset(ctor_func);
target->Set(Nan::New("FunctionType").ToLocalChecked(), ctor_func);
}