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


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

本文整理汇总了C++中Local::InstanceTemplate方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::InstanceTemplate方法的具体用法?C++ Local::InstanceTemplate怎么用?C++ Local::InstanceTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Local的用法示例。


在下文中一共展示了Local::InstanceTemplate方法的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);
    }
}
开发者ID:godmodelabs,项目名称:ejecta-v8,代码行数:29,代码来源:JNIV8ClassInfo.cpp

示例2:

Local<Object> ItemObject::createInstance()
{
	HandleScope handleScope;
	
	// Create the function template
	
	Local<FunctionTemplate> functionTemplate = FunctionTemplate::New();
	functionTemplate->SetClassName(String::New("Item"));
	
	// Create the object template
	
	Local<ObjectTemplate> objectTemplate = functionTemplate->InstanceTemplate();
	objectTemplate->SetInternalFieldCount(1);
	
	// Create an object instance
	
	Local<Object> objectInstance = objectTemplate->NewInstance();
	objectInstance->SetInternalField(0, External::New(this));
	
	// Add functions to object instance
	
	/*
	Local<FunctionTemplate> printTemplate = FunctionTemplate::New(print);
	Local<Function> printFunction = printTemplate->GetFunction();
	objectInstance->Set(String::New("print"), printFunction);
	
	Local<FunctionTemplate> inputTemplate = FunctionTemplate::New(input);
	Local<Function> inputFunction = inputTemplate->GetFunction();
	objectInstance->Set(String::New("input"), inputFunction);
	*/
	
	return handleScope.Close(objectInstance);
}
开发者ID:Marviel,项目名称:BitRPG,代码行数:33,代码来源:ItemObject.cpp

示例3: 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

示例4: Init

void ElementCriterionJs::Init(Handle<Object> target)
{
  vector<string> opNames =
    Factory::getInstance().getObjectNamesByBase(ElementCriterion::className());

  for (size_t i = 0; i < opNames.size(); i++)
  {
    QByteArray utf8 = QString::fromStdString(opNames[i]).replace("hoot::", "").toUtf8();
    const char* n = utf8.data();

    // Prepare constructor template
    Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
    tpl->SetClassName(String::NewSymbol(opNames[i].data()));
    tpl->InstanceTemplate()->SetInternalFieldCount(2);
    // Prototype
    tpl->PrototypeTemplate()->Set(String::NewSymbol("addCriterion"),
        FunctionTemplate::New(addCriterion)->GetFunction());
    tpl->PrototypeTemplate()->Set(String::NewSymbol("isSatisfied"),
        FunctionTemplate::New(isSatisfied)->GetFunction());
    tpl->PrototypeTemplate()->Set(PopulateConsumersJs::baseClass(),
                                  String::New(ElementCriterion::className().data()));

    Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction());
    target->Set(String::NewSymbol(n), constructor);
  }
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:26,代码来源:ElementCriterionJs.cpp

示例5: Init

void Cache::Init(Local<Object> exports) {
  NanScope();

  Local<FunctionTemplate> cacheConstructorTemplate =
    NanNew<FunctionTemplate>(Cache::New);

  cacheConstructorTemplate->SetClassName(NanNew("Cache"));
  cacheConstructorTemplate->InstanceTemplate()->SetInternalFieldCount(1);

  NanSetPrototypeTemplate(cacheConstructorTemplate, "close",
      NanNew<FunctionTemplate>(Cache::Close)->GetFunction());
  NanSetPrototypeTemplate(cacheConstructorTemplate, "executeFunction",
      NanNew<FunctionTemplate>(Cache::ExecuteFunction)->GetFunction());
  NanSetPrototypeTemplate(cacheConstructorTemplate, "executeQuery",
      NanNew<FunctionTemplate>(Cache::ExecuteQuery)->GetFunction());
  NanSetPrototypeTemplate(cacheConstructorTemplate, "createRegion",
      NanNew<FunctionTemplate>(Cache::CreateRegion)->GetFunction());
  NanSetPrototypeTemplate(cacheConstructorTemplate, "getRegion",
      NanNew<FunctionTemplate>(Cache::GetRegion)->GetFunction());
  NanSetPrototypeTemplate(cacheConstructorTemplate, "rootRegions",
      NanNew<FunctionTemplate>(Cache::RootRegions)->GetFunction());
  NanSetPrototypeTemplate(cacheConstructorTemplate, "inspect",
      NanNew<FunctionTemplate>(Cache::Inspect)->GetFunction());

  exports->Set(NanNew("Cache"), cacheConstructorTemplate->GetFunction());
}
开发者ID:mross-pivotal,项目名称:node-gemfire,代码行数:26,代码来源:cache.cpp

示例6: NanAssignPersistent

/*! Initialize our node object */
void Audio::AudioEngine::Init( v8::Handle<v8::Object> target ) {
	// Prepare constructor template
	Local<FunctionTemplate> functionTemplate = NanNew<FunctionTemplate> (Audio::AudioEngine::New );
	functionTemplate->SetClassName( NanNew<String>("AudioEngine") );
	functionTemplate->InstanceTemplate()->SetInternalFieldCount( 1 );


    //Local<FunctionTemplate> constructorHandle = NanNew(constructor);
    //target->Set(NanNew<String>("AudioEngine"), functionTemplate->GetFunction());
	
    // Get
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("isActive"), NanNew<FunctionTemplate>(Audio::AudioEngine::isActive)->GetFunction() );
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("getDeviceName"), NanNew<FunctionTemplate>(Audio::AudioEngine::getDeviceName)->GetFunction() );
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("getNumDevices"), NanNew<FunctionTemplate>(Audio::AudioEngine::getNumDevices)->GetFunction() );
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "isActive", Audio::AudioEngine::isActive);
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "getDeviceName", Audio::AudioEngine::getDeviceName);
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "getNumDevices", Audio::AudioEngine::getNumDevices);

	// Set
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("setOptions"), NanNew<FunctionTemplate>(Audio::AudioEngine::setOptions)->GetFunction() );
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("getOptions"), NanNew<FunctionTemplate>(Audio::AudioEngine::getOptions)->GetFunction() );
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("write"), NanNew<FunctionTemplate>(Audio::AudioEngine::write)->GetFunction() );
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("read"), NanNew<FunctionTemplate>(Audio::AudioEngine::read)->GetFunction() );
	//functionTemplate->PrototypeTemplate()->Set( NanNew<String>("isBufferEmpty"), NanNew<FunctionTemplate>(Audio::AudioEngine::isBufferEmpty)->GetFunction() );
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "setOptions", Audio::AudioEngine::setOptions);
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "getOptions", Audio::AudioEngine::getOptions);
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "write", Audio::AudioEngine::write);
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "read", Audio::AudioEngine::read);
    NODE_SET_PROTOTYPE_METHOD(functionTemplate, "isBufferEmpty", Audio::AudioEngine::isBufferEmpty);

	//constructor = Persistent<Function>::New( functionTemplate->GetFunction() );
    //Local<FunctionTemplate> tpl = NanNew<FunctionTemplate>(EOLFinder::New);
    NanAssignPersistent(constructor, functionTemplate->GetFunction());
} // end AudioEngine::Init()
开发者ID:MrZunz,项目名称:AVA-Home,代码行数:35,代码来源:AudioEngine.cpp

示例7: handleScope

// Install the constructor in the global scope so Path2Ds can be constructed
// in JS.
void Path2D::AddToGlobal(Global* global) {
    gGlobal = global;

    // Create a stack-allocated handle scope.
    HandleScope handleScope(gGlobal->getIsolate());

    Handle<Context> context = gGlobal->getContext();

    // Enter the scope so all operations take place in the scope.
    Context::Scope contextScope(context);

    Local<FunctionTemplate> constructor = FunctionTemplate::New(
            gGlobal->getIsolate(), Path2D::ConstructPath);
    constructor->InstanceTemplate()->SetInternalFieldCount(1);

    ADD_METHOD("closePath", ClosePath);
    ADD_METHOD("moveTo", MoveTo);
    ADD_METHOD("lineTo", LineTo);
    ADD_METHOD("quadraticCurveTo", QuadraticCurveTo);
    ADD_METHOD("bezierCurveTo", BezierCurveTo);
    ADD_METHOD("arc", Arc);
    ADD_METHOD("rect", Rect);
    ADD_METHOD("oval", Oval);
    ADD_METHOD("conicTo", ConicTo);

    context->Global()->Set(String::NewFromUtf8(
            gGlobal->getIsolate(), "Path2D"), constructor->GetFunction());
}
开发者ID:Adenilson,项目名称:skia,代码行数:30,代码来源:Path2D.cpp

示例8: Initialize

// Sets up everything for the Logger object when the addon is initialized
void Logger::Initialize(Handle<Object> target) {
    NanScope();

    Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Logger::New);
    lcons->InstanceTemplate()->SetInternalFieldCount(1);
    lcons->SetClassName(NanNew("Logger"));

    // Static methods
    NODE_SET_METHOD(lcons->GetFunction(), "getSeverity", Logger::get_severity);
    NODE_SET_METHOD(lcons->GetFunction(), "setSeverity", Logger::set_severity);

    // Constants
    NODE_MAPNIK_DEFINE_CONSTANT(lcons->GetFunction(),"NONE",mapnik::logger::severity_type::none);
    NODE_MAPNIK_DEFINE_CONSTANT(lcons->GetFunction(),"ERROR",mapnik::logger::severity_type::error);
    NODE_MAPNIK_DEFINE_CONSTANT(lcons->GetFunction(),"DEBUG",mapnik::logger::severity_type::debug);
    NODE_MAPNIK_DEFINE_CONSTANT(lcons->GetFunction(),"WARN",mapnik::logger::severity_type::warn);

    // What about booleans like:
    // ENABLE_STATS
    // ENABLE_LOG
    // DEFAULT_LOG_SEVERITY
    // RENDERING_STATS
    // DEBUG

    // Not sure if needed...
    target->Set(NanNew("Logger"),lcons->GetFunction());
    NanAssignPersistent(constructor, lcons);

}
开发者ID:cuulee,项目名称:self-hosted-vector-tiles,代码行数:30,代码来源:mapnik_logger.cpp

示例9:

// Called during add-on initialization to add the "Message" template function
// to the target object.
void LS2Message::Initialize (Handle<Object> target)
{
    HandleScope scope;

    Local<FunctionTemplate> t = FunctionTemplate::New(New);

    t->SetClassName(String::New("palmbus/Message"));

    gMessageTemplate = Persistent<FunctionTemplate>::New(t);

    t->InstanceTemplate()->SetInternalFieldCount(1);

    NODE_SET_PROTOTYPE_METHOD(t, "payload", PayloadWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "responseToken", ResponseTokenWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "print", PrintWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "method", MethodWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "applicationID", ApplicationIDWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "sender", SenderWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "senderServiceName", SenderServiceNameWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "uniqueToken", UniqueTokenWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "kind", KindWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "category", CategoryWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "token", TokenWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "isSubscription", IsSubscriptionWrapper);
    NODE_SET_PROTOTYPE_METHOD(t, "respond", RespondWrapper);

    target->Set(String::NewSymbol("Message"), t->GetFunction());
}
开发者ID:liuzhiping,项目名称:nodejs-module-webos-sysbus,代码行数:30,代码来源:node_ls2_message.cpp

示例10: Initialize

void ScrollView::Initialize(Handle<Object> target)
{
    HandleScope scope;

    Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
    tpl->InstanceTemplate()->SetInternalFieldCount(1);
    Local<String> name = String::NewSymbol("ScrollView");

    /* Methods */
    Bin::PrototypeMethodsInit(tpl);

    tpl->InstanceTemplate()->SetAccessor(String::NewSymbol("policy_horizontal"), ScrollView::PolicyHorizontalGetter, ScrollView::PolicyHorizontalSetter);
    tpl->InstanceTemplate()->SetAccessor(String::NewSymbol("policy_vertical"), ScrollView::PolicyVerticalGetter, ScrollView::PolicyVerticalSetter);

    target->Set(name, tpl->GetFunction());
}
开发者ID:cfsghost,项目名称:jsdx-toolkit,代码行数:16,代码来源:scrollview.cpp

示例11:

void
NodeSandbox::Init(Handle<Object> exports)
{
  Local<FunctionTemplate> tpl = FunctionTemplate::New(node_new);
  tpl->SetClassName(String::NewSymbol("Sandbox"));
  tpl->InstanceTemplate()->SetInternalFieldCount(2);
  node::SetPrototypeMethod(tpl, "spawn", node_spawn);
  node::SetPrototypeMethod(tpl, "kill", node_kill);
  node::SetPrototypeMethod(tpl, "finishIPC", node_finish_ipc);
  node::SetPrototypeMethod(tpl, "finishVFS", node_finish_vfs);
  s_constructor = Persistent<Function>::New(tpl->GetFunction());
  exports->Set(String::NewSymbol("Sandbox"), s_constructor);

  Local<FunctionTemplate> channelTpl = FunctionTemplate::New(node_new);
  channelTpl->SetClassName (String::NewSymbol ("Channel"));
  channelTpl->InstanceTemplate()->SetInternalFieldCount (2);
}
开发者ID:codius,项目名称:codius-sandbox,代码行数:17,代码来源:sandbox-node-module.cpp

示例12: Init

void Watch::Init() {
	Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
	tpl->SetClassName(String::NewSymbol("Watch"));
	tpl->InstanceTemplate()->SetInternalFieldCount(1);

	tpl->PrototypeTemplate()->Set(String::NewSymbol("cancel"), FunctionTemplate::New(Cancel)->GetFunction());

	constructor = Persistent<Function>::New(tpl->GetFunction());
}
开发者ID:jasonmimick,项目名称:key-value-database-benchmark,代码行数:9,代码来源:Transaction.cpp

示例13: Init

	void Buffer::Init(Isolate* isolate) {
		Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
		tpl->SetClassName(String::NewFromUtf8(isolate, "Vulkan::Buffer"));
		tpl->InstanceTemplate()->SetInternalFieldCount(1);

		//NODE_SET_PROTOTYPE_METHOD(tpl, "getMemoryProperties", getMemoryProperties);

		constructor.Set(isolate, tpl->GetFunction());
	}
开发者ID:codepilot,项目名称:vulkan,代码行数:9,代码来源:Buffer.cpp

示例14: Init

// Add wrapper class to runtime environment
void BookWrap::Init(Handle<Object> exports) {
    Isolate* isolate = exports->GetIsolate();
    
    Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, BookWrap::New);
    tpl->SetClassName(String::NewFromUtf8(isolate, "Book"));
    tpl->InstanceTemplate()->SetInternalFieldCount(1);

    NODE_SET_PROTOTYPE_METHOD(tpl, "add",      Add);
    NODE_SET_PROTOTYPE_METHOD(tpl, "length",   Length);
    NODE_SET_PROTOTYPE_METHOD(tpl, "lookup",   Lookup);
    NODE_SET_PROTOTYPE_METHOD(tpl, "each",     Each);
    NODE_SET_PROTOTYPE_METHOD(tpl, "apply",    Apply);

    tpl->InstanceTemplate()->SetIndexedPropertyHandler(Getter, Setter, 0, Deleter, Enumerator);

    Constructor.Reset(isolate, tpl->GetFunction());
    exports->Set(String::NewFromUtf8(isolate, "Book"), tpl->GetFunction());
}
开发者ID:kneth,项目名称:DemoNodeExtension,代码行数:19,代码来源:book_wrap.cpp

示例15: Init

 void MessageProducer::Init( v8::Handle<v8::Object> exports ) 
 {
     Local<FunctionTemplate> tpl = FunctionTemplate::New( New ) ;
     tpl->SetClassName( NanNew( "FgiMessageProducer" ) );
     tpl->InstanceTemplate()->SetInternalFieldCount( 1 );
     NODE_SET_PROTOTYPE_METHOD( tpl, "send", Send );
     NanAssignPersistent( constructor, tpl->GetFunction() );
     exports->Set( NanNew( "FgiMessageProducer"), constructor );
 }
开发者ID:rduppen,项目名称:fintegrator.js,代码行数:9,代码来源:fgi_nodejs_MessageProducer.cpp


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