当前位置: 首页>>代码示例>>C++>>正文


C++ Local::Inherit方法代码示例

本文整理汇总了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());
}
开发者ID:ayeung,项目名称:titanium_mobile,代码行数:25,代码来源:Proxy.cpp

示例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());
}
开发者ID:liuzhiping,项目名称:nodejs-module-webos-sysbus,代码行数:27,代码来源:node_ls2_handle.cpp

示例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;
}
开发者ID:bright-sparks,项目名称:android-runtime,代码行数:52,代码来源:MetadataNode.cpp

示例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);
}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:15,代码来源:gdal_multipoint.cpp

示例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);
  }
开发者ID:toshok,项目名称:echojs,代码行数:15,代码来源:dibuilder.cpp

示例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);
}
开发者ID:mojodna,项目名称:node-gdal,代码行数:16,代码来源:gdal_multilinestring.cpp

示例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));
}
开发者ID:seobyeongky,项目名称:gunman,代码行数:17,代码来源:v8_sprite.cpp

示例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);
}
开发者ID:ayeung,项目名称:titanium_mobile,代码行数:17,代码来源:Proxy.cpp

示例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);
}
开发者ID:mojodna,项目名称:node-gdal,代码行数:18,代码来源:gdal_polygon.cpp

示例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);
  }
开发者ID:toshok,项目名称:echojs,代码行数:19,代码来源:instruction.cpp

示例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());
}
开发者ID:node-migrator-bot,项目名称:termutil,代码行数:20,代码来源:termutil.cpp

示例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);
}
开发者ID:drownedout,项目名称:datamap,代码行数:20,代码来源:gdal_point.cpp

示例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());
}
开发者ID:cheekiatng,项目名称:titanium_mobile,代码行数:41,代码来源:APIModule.cpp

示例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);
  }
开发者ID:toshok,项目名称:echojs,代码行数:23,代码来源:functiontype.cpp


注:本文中的Local::Inherit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。