本文整理汇总了C++中Local::PrototypeTemplate方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::PrototypeTemplate方法的具体用法?C++ Local::PrototypeTemplate怎么用?C++ Local::PrototypeTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::PrototypeTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: Init
void ALCaptureDevice::Init(Handle<Object> exports) {
// Prepare constructor template
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
tpl->SetClassName(Nan::New<String>("CaptureDevice").ToLocalChecked());
tpl->InstanceTemplate()->SetInternalFieldCount(1);
tpl->PrototypeTemplate()->Set(Nan::New<String>("on").ToLocalChecked(), Nan::New<FunctionTemplate>(On)->GetFunction());
tpl->PrototypeTemplate()->Set(Nan::New<String>("start").ToLocalChecked(), Nan::New<FunctionTemplate>(Start)->GetFunction());
tpl->PrototypeTemplate()->Set(Nan::New<String>("stop").ToLocalChecked(), Nan::New<FunctionTemplate>(Stop)->GetFunction());
exports->Set(Nan::New<String>("CaptureDevice").ToLocalChecked(), tpl->GetFunction());
}
示例3: Init
void ResourcesDictionaryDriver::Init()
{
// prepare the form xobject driver interfrace template
Local<FunctionTemplate> ft = FunctionTemplate::New(New);
ft->SetClassName(String::NewSymbol("ResourcesDictionary"));
ft->InstanceTemplate()->SetInternalFieldCount(1);
ft->PrototypeTemplate()->Set(String::NewSymbol("addFormXObjectMapping"),FunctionTemplate::New(AddFormXObjectMapping)->GetFunction());
ft->PrototypeTemplate()->Set(String::NewSymbol("addImageXObjectMapping"),FunctionTemplate::New(AddImageXObjectMapping)->GetFunction());
ft->PrototypeTemplate()->Set(String::NewSymbol("addProcsetResource"),FunctionTemplate::New(AddProcsetResource)->GetFunction());
constructor = Persistent<Function>::New(ft->GetFunction());
}
示例4:
void nj::ScriptEncapsulated::Init(Handle<Object> exports)
{
Local<FunctionTemplate> T = FunctionTemplate::New(New);
T->SetClassName(String::NewSymbol("Script"));
T->InstanceTemplate()->SetInternalFieldCount(1);
T->PrototypeTemplate()->Set(String::NewSymbol("getPath"),FunctionTemplate::New(getPath)->GetFunction());
T->PrototypeTemplate()->Set(String::NewSymbol("getModuleName"),FunctionTemplate::New(getModuleName)->GetFunction());
T->PrototypeTemplate()->Set(String::NewSymbol("exec"),FunctionTemplate::New(exec)->GetFunction());
constructor = Persistent<Function>::New(T->GetFunction());
exports->Set(String::NewSymbol("Script"),constructor);
}
示例5: Init
void PDFDateDriver::Init(Handle<Object> inExports)
{
// prepare the page interfrace template
Local<FunctionTemplate> t = FunctionTemplate::New(New);
t->SetClassName(String::NewSymbol("PDFDate"));
t->InstanceTemplate()->SetInternalFieldCount(1);
t->PrototypeTemplate()->Set(String::NewSymbol("toString"),FunctionTemplate::New(ToString)->GetFunction());
t->PrototypeTemplate()->Set(String::NewSymbol("setToCurrentTime"),FunctionTemplate::New(SetToCurrentTime)->GetFunction());
constructor = Persistent<Function>::New(t->GetFunction());
inExports->Set(String::NewSymbol("PDFDate"),constructor);
}
示例6: Init
// --------------------------------------------------------
void NodeOpenALSource::Init(Handle<Object> exports) {
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
tpl->SetClassName(String::NewSymbol("Source"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
tpl->PrototypeTemplate()->Set(String::NewSymbol("Play"), FunctionTemplate::New(Play)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("SetPosition"), FunctionTemplate::New(SetPosition)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("SetLoop"), FunctionTemplate::New(SetLoop)->GetFunction());
Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction());
exports->Set(String::NewSymbol("Source"), constructor);
}
示例7: Init
void OsmMapJs::Init(Handle<Object> target) {
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
tpl->SetClassName(String::NewSymbol("OsmMap"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
tpl->PrototypeTemplate()->Set(String::NewSymbol("clone"),
FunctionTemplate::New(clone)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("getElement"),
FunctionTemplate::New(getElement)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("getElementCount"),
FunctionTemplate::New(getElementCount)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("getParents"),
FunctionTemplate::New(getParents)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("removeElement"),
FunctionTemplate::New(removeElement)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("visit"),
FunctionTemplate::New(visit)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("setIdGenerator"),
FunctionTemplate::New(setIdGenerator)->GetFunction());
tpl->PrototypeTemplate()->Set(PopulateConsumersJs::baseClass(),
String::New(OsmMap::className().data()));
_constructor = Persistent<Function>::New(tpl->GetFunction());
target->Set(String::NewSymbol("OsmMap"), _constructor);
}
示例8: Init
void PageContentContextDriver::Init()
{
// prepare the context driver interfrace template
Local<FunctionTemplate> t = FunctionTemplate::New(New);
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->SetClassName(String::NewSymbol("PageContentContext"));
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
AbstractContentContextDriver::Init(constructor_template);
t->PrototypeTemplate()->Set(String::NewSymbol("getCurrentPageContentStream"),FunctionTemplate::New(GetCurrentPageContentStream)->GetFunction());
t->PrototypeTemplate()->Set(String::NewSymbol("getAssociatedPage"),FunctionTemplate::New(GetAssociatedPage)->GetFunction());
constructor = Persistent<Function>::New(constructor_template->GetFunction());
}
示例9: Init
// --------------------------------------------------------
void NodeOpenALStream::Init(Handle<Object> exports) {
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
tpl->SetClassName(String::NewSymbol("Stream"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
tpl->PrototypeTemplate()->Set(String::NewSymbol("Ready"), FunctionTemplate::New(Ready)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("Buffer"), FunctionTemplate::New(Buffer)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("SetPosition"), FunctionTemplate::New(SetPosition)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("GetPosition"), FunctionTemplate::New(GetPosition)->GetFunction());
tpl->PrototypeTemplate()->Set(String::NewSymbol("SetGain"), FunctionTemplate::New(SetGain)->GetFunction());
Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction());
exports->Set(String::NewSymbol("Stream"), constructor);
}
示例10: init
void NodeMap::init(Local<Object> target) {
Nan::HandleScope scope;
Local<FunctionTemplate> constructor = Nan::New<FunctionTemplate>(Constructor);
// got to do the Symbol.iterator function by hand, no Nan support
Local<Symbol> symbol_iterator = Symbol::GetIterator(Isolate::GetCurrent());
Local<FunctionTemplate> entries_templt = Nan::New<FunctionTemplate>(
Entries
, Local<Value>()
, Nan::New<Signature>(constructor));
constructor->PrototypeTemplate()->Set(symbol_iterator, entries_templt);
entries_templt->SetClassName(Nan::New("Symbol(Symbol.iterator)").ToLocalChecked());
constructor->SetClassName(Nan::New("NodeMap").ToLocalChecked());
constructor->InstanceTemplate()->SetInternalFieldCount(1);
Nan::SetPrototypeMethod(constructor, "set", Set);
Nan::SetPrototypeMethod(constructor, "get", Get);
Nan::SetPrototypeMethod(constructor, "has", Has);
Nan::SetPrototypeMethod(constructor, "entries", Entries);
Nan::SetPrototypeMethod(constructor, "keys", Keys);
Nan::SetPrototypeMethod(constructor, "values", Values);
Nan::SetPrototypeMethod(constructor, "delete", Delete);
Nan::SetPrototypeMethod(constructor, "clear", Clear);
Nan::SetPrototypeMethod(constructor, "forEach", ForEach);
Nan::SetAccessor(constructor->InstanceTemplate(), Nan::New("size").ToLocalChecked(), Size);
target->Set(Nan::New("NodeMap").ToLocalChecked(), constructor->GetFunction());
PairNodeIterator::init(target);
}
示例11: Init
void HoneydProfileBinding::Init(v8::Handle<Object> target)
{
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
tpl->SetClassName(String::NewSymbol("HoneydProfileBinding"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
// Prototype
Local<Template> proto = tpl->PrototypeTemplate();
proto->Set("SetPersonality", FunctionTemplate::New(InvokeMethod<bool, HoneydProfileBinding, std::string, &HoneydProfileBinding::SetPersonality>));
proto->Set("SetCount", FunctionTemplate::New(InvokeMethod<bool, HoneydProfileBinding, int, &HoneydProfileBinding::SetCount>));
proto->Set("AddPortSet", FunctionTemplate::New(InvokeMethod<int, HoneydProfileBinding, &HoneydProfileBinding::AddPortSet>));
proto->Set("ClearPorts", FunctionTemplate::New(InvokeMethod<bool, HoneydProfileBinding, &HoneydProfileBinding::ClearPorts>));
proto->Set("SetIsPersonalityInherited", FunctionTemplate::New(InvokeMethod<bool, HoneydProfileBinding, bool, &HoneydProfileBinding::SetIsPersonalityInherited>));
proto->Set("SetIsDropRateInherited", FunctionTemplate::New(InvokeMethod<bool, HoneydProfileBinding, bool, &HoneydProfileBinding::SetIsDropRateInherited>));
proto->Set("SetIsUptimeInherited", FunctionTemplate::New(InvokeMethod<bool, HoneydProfileBinding, bool, &HoneydProfileBinding::SetIsUptimeInherited>));
proto->Set("Save", FunctionTemplate::New(InvokeMethod<bool, HoneydProfileBinding, &HoneydProfileBinding::Save>));
proto->Set("SetUptimeMin", FunctionTemplate::New(InvokeWrappedMethod<bool, HoneydProfileBinding, Profile, uint, &Profile::SetUptimeMin>));
proto->Set("SetUptimeMax", FunctionTemplate::New(InvokeWrappedMethod<bool, HoneydProfileBinding, Profile, uint, &Profile::SetUptimeMax>));
proto->Set("SetDropRate", FunctionTemplate::New(InvokeWrappedMethod<bool, HoneydProfileBinding, Profile, std::string, &Profile::SetDropRate>));
//Odd ball out, because it needs 5 parameters. More than InvoleWrappedMethod can handle
proto->Set(String::NewSymbol("AddPort"),FunctionTemplate::New(AddPort)->GetFunction());
proto->Set(String::NewSymbol("SetVendors"),FunctionTemplate::New(SetVendors)->GetFunction());
proto->Set(String::NewSymbol("SetPortSetBehavior"),FunctionTemplate::New(SetPortSetBehavior)->GetFunction());
Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction());
target->Set(String::NewSymbol("HoneydProfileBinding"), constructor);
}
示例12:
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;
}
示例13: initJsApi
void JsVlcVideo::initJsApi()
{
JsVlcDeinterlace::initJsApi();
using namespace v8;
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope( isolate );
Local<FunctionTemplate> constructorTemplate = FunctionTemplate::New( isolate, jsCreate );
constructorTemplate->SetClassName(
String::NewFromUtf8( isolate, "VlcVideo", v8::String::kInternalizedString ) );
Local<ObjectTemplate> protoTemplate = constructorTemplate->PrototypeTemplate();
Local<ObjectTemplate> instanceTemplate = constructorTemplate->InstanceTemplate();
instanceTemplate->SetInternalFieldCount( 1 );
SET_RO_PROPERTY( instanceTemplate, "count", &JsVlcVideo::count );
SET_RO_PROPERTY( instanceTemplate, "deinterlace", &JsVlcVideo::deinterlace );
SET_RW_PROPERTY( instanceTemplate, "track", &JsVlcVideo::track, &JsVlcVideo::setTrack );
Local<Function> constructor = constructorTemplate->GetFunction();
_jsConstructor.Reset( isolate, constructor );
}
示例14: 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();
}
示例15: scope
void JNIV8ClassInfo::_registerJavaMethod(JNIV8ObjectJavaCallbackHolder *holder) {
Isolate* isolate = engine->getIsolate();
HandleScope scope(isolate);
Local<FunctionTemplate> ft = Local<FunctionTemplate>::New(isolate, functionTemplate);
JNIEnv *env = JNIWrapper::getEnvironment();
holder->javaClass = (jclass)env->NewGlobalRef(env->FindClass(container->canonicalName.c_str()));;
javaCallbackHolders.push_back(holder);
Local<External> data = External::New(isolate, (void*)holder);
if(holder->isStatic) {
Local<Function> f = ft->GetFunction();
f->Set(String::NewFromUtf8(isolate, holder->methodName.c_str()), FunctionTemplate::New(isolate, v8JavaMethodCallback, data, Local<Signature>(), 0, ConstructorBehavior::kThrow)->GetFunction());
} else {
// ofc functions belong on the prototype, and not on the actual instance for performance/memory reasons
// but interestingly enough, we MUST store them there because they simply are not "copied" from the InstanceTemplate when using inherit later
// but other properties and accessors are copied without problems.
// Thought: it is not allowed to store actual Functions on these templates - only FunctionTemplates
// functions can only exist in a context once and probaly can not be duplicated/copied in the same way as scalars and accessors, so there IS a difference.
// maybe when doing inherit the function template is instanced, and then inherit copies over properties to its own instance template which can not be done for instanced functions..
Local<ObjectTemplate> instanceTpl = ft->PrototypeTemplate();
instanceTpl->Set(String::NewFromUtf8(isolate, holder->methodName.c_str()),
FunctionTemplate::New(isolate, v8JavaMethodCallback, data, Signature::New(isolate, ft), 0, ConstructorBehavior::kThrow));
}
}