void FieldDefn::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(FieldDefn::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(NanNew("FieldDefn")); ATTR(lcons, "name", nameGetter, nameSetter); ATTR(lcons, "type", typeGetter, typeSetter); ATTR(lcons, "justification", justificationGetter, justificationSetter); ATTR(lcons, "width", widthGetter, widthSetter); ATTR(lcons, "precision", precisionGetter, precisionSetter); ATTR(lcons, "ignored", ignoredGetter, ignoredSetter); target->Set(NanNew("FieldDefn"), lcons->GetFunction()); NanAssignPersistent(constructor, lcons); }
/* DESCRIPTION Init function of the Pool class. Initiates and maps the functions and properties of Pool class. */ void Pool::Init(Handle<Object> target) { Nan::HandleScope scope; Local<FunctionTemplate> temp = Nan::New<FunctionTemplate>(New); temp->InstanceTemplate()->SetInternalFieldCount(1); temp->SetClassName(Nan::New<v8::String>("Pool").ToLocalChecked()); Nan::SetPrototypeMethod(temp, "terminate", Terminate); Nan::SetPrototypeMethod(temp, "getConnection", GetConnection); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("poolMax").ToLocalChecked(), Pool::GetPoolMax, Pool::SetPoolMax ); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("poolMin").ToLocalChecked(), Pool::GetPoolMin, Pool::SetPoolMin ); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("poolIncrement").ToLocalChecked(), Pool::GetPoolIncrement, Pool::SetPoolIncrement ); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("poolTimeout").ToLocalChecked(), Pool::GetPoolTimeout, Pool::SetPoolTimeout ); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("connectionsOpen").ToLocalChecked(), Pool::GetConnectionsOpen, Pool::SetConnectionsOpen ); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("connectionsInUse").ToLocalChecked(), Pool::GetConnectionsInUse, Pool::SetConnectionsInUse ); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("stmtCacheSize").ToLocalChecked(), Pool::GetStmtCacheSize, Pool::SetStmtCacheSize ); poolTemplate_s.Reset( temp ); Nan::Set(target, Nan::New<v8::String>("Pool").ToLocalChecked(), temp->GetFunction()); }
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); }
/* DESCRIPTION Init function of the ResultSet class. Initiates and maps the functions and properties of ResultSet class. */ void ResultSet::Init(Handle<Object> target) { NanScope(); Local<FunctionTemplate> temp = NanNew<FunctionTemplate>(New); temp->InstanceTemplate()->SetInternalFieldCount(1); temp->SetClassName(NanNew<v8::String>("ResultSet")); NODE_SET_PROTOTYPE_METHOD(temp, "close", Close); NODE_SET_PROTOTYPE_METHOD(temp, "getRow", GetRow); NODE_SET_PROTOTYPE_METHOD(temp, "getRows", GetRows); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("metaData"), ResultSet::GetMetaData, ResultSet::SetMetaData ); NanAssignPersistent( resultSetTemplate_s, temp); target->Set(NanNew<v8::String>("ResultSet"),temp->GetFunction()); }
void Text::Initialize(Handle<Object> target) { HandleScope scope; Local<FunctionTemplate> tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); Local<String> name = String::NewSymbol("Text"); /* Methods */ Actor::PrototypeMethodsInit(tpl); NODE_SET_PROTOTYPE_METHOD(tpl, "setColor", Text::SetColor); NODE_SET_PROTOTYPE_METHOD(tpl, "getColor", Text::GetColor); NODE_SET_PROTOTYPE_METHOD(tpl, "setText", Text::SetText); NODE_SET_PROTOTYPE_METHOD(tpl, "getText", Text::GetText); NODE_SET_PROTOTYPE_METHOD(tpl, "setFontName", Text::SetFontName); NODE_SET_PROTOTYPE_METHOD(tpl, "getFontName", Text::GetFontName); target->Set(name, tpl->GetFunction()); }
void DIBuilder::Init(Handle<Object> target) { Nan::HandleScope scope; Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(New); constructor.Reset(ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(Nan::New("DIBuilder").ToLocalChecked()); Nan::SetPrototypeMethod(ctor, "createCompileUnit", DIBuilder::CreateCompileUnit); Nan::SetPrototypeMethod(ctor, "createFile", DIBuilder::CreateFile); Nan::SetPrototypeMethod(ctor, "createFunction", DIBuilder::CreateFunction); Nan::SetPrototypeMethod(ctor, "createLexicalBlock", DIBuilder::CreateLexicalBlock); Nan::SetPrototypeMethod(ctor, "finalize", DIBuilder::Finalize); Local<v8::Function> ctor_func = ctor->GetFunction(); constructor_func.Reset(ctor_func); target->Set(Nan::New("DIBuilder").ToLocalChecked(), ctor_func); }
void CustomizeTrainingBinding::Init(v8::Handle<Object> target) { // Prepare constructor template Local<FunctionTemplate> tpl = FunctionTemplate::New(New); tpl->SetClassName(String::NewSymbol("CustomizeTrainingBinding")); tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetDescriptions"),FunctionTemplate::New(GetDescriptions)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetUIDs"),FunctionTemplate::New(GetUIDs)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetHostile"),FunctionTemplate::New(GetHostile)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("SetIncluded"),FunctionTemplate::New(SetIncluded)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("Save"),FunctionTemplate::New(Save)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetCaptureIPs"),FunctionTemplate::New(GetCaptureIPs)->GetFunction()); // Prototype Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction()); target->Set(String::NewSymbol("CustomizeTrainingBinding"), constructor); }
/* DESCRIPTION Init function of the Pool class. Initiates and maps the functions and properties of Pool class. */ void Pool::Init(Handle<Object> target) { NanScope(); Local<FunctionTemplate> temp = NanNew<FunctionTemplate>(New); temp->InstanceTemplate()->SetInternalFieldCount(1); temp->SetClassName(NanNew<v8::String>("Pool")); NODE_SET_PROTOTYPE_METHOD(temp, "terminate", Terminate); NODE_SET_PROTOTYPE_METHOD(temp, "getConnection", GetConnection); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("poolMax"), Pool::GetPoolMax, Pool::SetPoolMax ); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("poolMin"), Pool::GetPoolMin, Pool::SetPoolMin ); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("poolIncrement"), Pool::GetPoolIncrement, Pool::SetPoolIncrement ); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("poolTimeout"), Pool::GetPoolTimeout, Pool::SetPoolTimeout ); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("connectionsOpen"), Pool::GetConnectionsOpen, Pool::SetConnectionsOpen ); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("connectionsInUse"), Pool::GetConnectionsInUse, Pool::SetConnectionsInUse ); temp->InstanceTemplate()->SetAccessor( NanNew<v8::String>("stmtCacheSize"), Pool::GetStmtCacheSize, Pool::SetStmtCacheSize ); NanAssignPersistent( poolTemplate_s, temp ); target->Set(NanNew<v8::String>("Pool"),temp->GetFunction()); }
Handle<Value> mongoInject(const Arguments& args){ jsassert( args.Length() == 1 , "mongoInject takes exactly 1 argument" ); jsassert( args[0]->IsObject() , "mongoInject needs to be passed a prototype" ); Local<v8::Object> o = args[0]->ToObject(); o->Set( String::New( "init" ) , FunctionTemplate::New( mongoInit )->GetFunction() ); o->Set( String::New( "find" ) , FunctionTemplate::New( mongoFind )->GetFunction() ); o->Set( String::New( "insert" ) , FunctionTemplate::New( mongoInsert )->GetFunction() ); o->Set( String::New( "remove" ) , FunctionTemplate::New( mongoRemove )->GetFunction() ); o->Set( String::New( "update" ) , FunctionTemplate::New( mongoUpdate )->GetFunction() ); Local<FunctionTemplate> t = FunctionTemplate::New( internalCursorCons ); t->PrototypeTemplate()->Set( String::New("next") , FunctionTemplate::New( internalCursorNext ) ); t->PrototypeTemplate()->Set( String::New("hasNext") , FunctionTemplate::New( internalCursorHasNext ) ); o->Set( String::New( "internalCursor" ) , t->GetFunction() ); return v8::Undefined(); }
/* static */ void V8Runtime::bootstrap(Local<Context> context) { Isolate* isolate = context->GetIsolate(); EventEmitter::initTemplate(context); Local<Object> global = Object::New(isolate); krollGlobalObject.Reset(isolate, global); Local<Array> mc = Array::New(isolate); moduleContexts.Reset(isolate, mc); KrollBindings::initFunctions(global, context); SetMethod(isolate, global, "log", krollLog); // Move this into the EventEmitter::initTemplate call? Local<FunctionTemplate> eect = Local<FunctionTemplate>::New(isolate, EventEmitter::constructorTemplate); global->Set(NEW_SYMBOL(isolate, "EventEmitter"), eect->GetFunction()); global->Set(NEW_SYMBOL(isolate, "runtime"), STRING_NEW(isolate, "v8")); global->Set(NEW_SYMBOL(isolate, "DBG"), v8::Boolean::New(isolate, V8Runtime::DBG)); global->Set(NEW_SYMBOL(isolate, "moduleContexts"), mc); LOG_TIMER(TAG, "Executing kroll.js"); TryCatch tryCatch(isolate); Local<Value> result = V8Util::executeString(isolate, KrollBindings::getMainSource(isolate), STRING_NEW(isolate, "ti:/kroll.js")); if (tryCatch.HasCaught()) { V8Util::reportException(isolate, tryCatch, true); } if (!result->IsFunction()) { LOGF(TAG, "kroll.js result is not a function"); V8Util::reportException(isolate, tryCatch, true); } Local<Function> mainFunction = result.As<Function>(); Local<Value> args[] = { global }; mainFunction->Call(context, context->Global(), 1, args); if (tryCatch.HasCaught()) { V8Util::reportException(isolate, tryCatch, true); LOGE(TAG, "Caught exception while bootstrapping Kroll"); } }
void ILob::Init(Handle<Object> target) { Nan::HandleScope scope; Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(Nan::New<v8::String>("ILob").ToLocalChecked()); Nan::SetPrototypeMethod(tpl, "release", Release); Nan::SetPrototypeMethod(tpl, "read", Read); Nan::SetPrototypeMethod(tpl, "write", Write); Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New<v8::String>("chunkSize").ToLocalChecked(), ILob::GetChunkSize, ILob::SetChunkSize); Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New<v8::String>("length").ToLocalChecked(), ILob::GetLength, ILob::SetLength); Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New<v8::String>("pieceSize").ToLocalChecked(), ILob::GetPieceSize, ILob::SetPieceSize); Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New<v8::String>("offset").ToLocalChecked(), ILob::GetOffset, ILob::SetOffset); Nan::SetAccessor(tpl->InstanceTemplate(), Nan::New<v8::String>("type").ToLocalChecked(), ILob::GetType, ILob::SetType); iLobTemplate_s.Reset(tpl); Nan::Set(target, Nan::New<v8::String>("ILob").ToLocalChecked(), tpl->GetFunction()); }
void NovaConfigBinding::Init(Handle<Object> target) { // Prepare constructor template Local<FunctionTemplate> tpl = FunctionTemplate::New(New); tpl->SetClassName(String::NewSymbol("NovaConfigBinding")); tpl->InstanceTemplate()->SetInternalFieldCount(1); // Prototype tpl->PrototypeTemplate()->Set(String::NewSymbol("ListInterfaces"),FunctionTemplate::New(InvokeWrappedMethod<std::vector<std::string>, NovaConfigBinding, Config, &Config::ListInterfaces>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetGroup"),FunctionTemplate::New(InvokeWrappedMethod<std::string, NovaConfigBinding, Config, &Config::GetGroup>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("ListLoopbacks"),FunctionTemplate::New(InvokeWrappedMethod<std::vector<std::string>, NovaConfigBinding, Config, &Config::ListLoopbacks>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetInterfaces"),FunctionTemplate::New(InvokeWrappedMethod<std::vector<std::string>, NovaConfigBinding, Config, &Config::GetInterfaces>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetDoppelInterface"),FunctionTemplate::New(InvokeWrappedMethod<std::string, NovaConfigBinding, Config, &Config::GetDoppelInterface>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetUseAllInterfacesBinding"),FunctionTemplate::New(InvokeWrappedMethod<std::string, NovaConfigBinding, Config, &Config::GetUseAllInterfacesBinding>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("SetDoppelInterface"),FunctionTemplate::New(SetDoppelInterface)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("AddIface"),FunctionTemplate::New(AddIface)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("SetSMTPUseAuth"),FunctionTemplate::New(SetSMTPUseAuth)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("ClearInterfaces"),FunctionTemplate::New(ClearInterfaces)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("UseAllInterfaces"),FunctionTemplate::New(UseAllInterfaces)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetUseAnyLoopback"),FunctionTemplate::New(InvokeWrappedMethod<bool, NovaConfigBinding, Config, &Config::GetUseAnyLoopback>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("SetGroup"),FunctionTemplate::New(SetGroup)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("UseAnyLoopback"),FunctionTemplate::New(UseAnyLoopback)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("ReadSetting"),FunctionTemplate::New(ReadSetting)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("WriteSetting"),FunctionTemplate::New(WriteSetting)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("ReloadConfiguration"),FunctionTemplate::New(ReloadConfiguration)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetVersionString"),FunctionTemplate::New(InvokeWrappedMethod<string, NovaConfigBinding, Config, &Config::GetVersionString>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetPathConfigHoneydHS"),FunctionTemplate::New(InvokeWrappedMethod<string, NovaConfigBinding, Config, &Config::GetPathConfigHoneydHS>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetPathHome"),FunctionTemplate::New(InvokeWrappedMethod<string, NovaConfigBinding, Config, &Config::GetPathHome>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetPathShared"),FunctionTemplate::New(InvokeWrappedMethod<string, NovaConfigBinding, Config, &Config::GetPathShared>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetCurrentConfig"),FunctionTemplate::New(InvokeWrappedMethod<string, NovaConfigBinding, Config, &Config::GetCurrentConfig>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("SetSMTPUser"),FunctionTemplate::New(InvokeWrappedMethod<bool, NovaConfigBinding, Config, std::string, &Config::SetSMTPUser>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("SetCurrentConfig"),FunctionTemplate::New(InvokeWrappedMethod<bool, NovaConfigBinding, Config, std::string, &Config::SetCurrentConfig>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("SetSMTPPass"),FunctionTemplate::New(InvokeWrappedMethod<bool, NovaConfigBinding, Config, std::string, &Config::SetSMTPPass>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetSMTPUser"),FunctionTemplate::New(InvokeWrappedMethod<string, NovaConfigBinding, Config, &Config::GetSMTPUser>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetSMTPPass"),FunctionTemplate::New(InvokeWrappedMethod<string, NovaConfigBinding, Config, &Config::GetSMTPPass>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetSMTPUseAuth"),FunctionTemplate::New(InvokeWrappedMethod<bool, NovaConfigBinding, Config, &Config::GetSMTPUseAuth>)); tpl->PrototypeTemplate()->Set(String::NewSymbol("GetIpAddresses"),FunctionTemplate::New(InvokeMethod<std::vector<std::string>, std::string, Config::GetIpAddresses>)); Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction()); target->Set(String::NewSymbol("NovaConfigBinding"), constructor); }
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()); }
/* DESCRIPTION Init function of the ResultSet class. Initiates and maps the functions and properties of ResultSet class. */ void ResultSet::Init(Handle<Object> target) { Nan::HandleScope scope; Local<FunctionTemplate> temp = Nan::New<FunctionTemplate>(New); temp->InstanceTemplate()->SetInternalFieldCount(1); temp->SetClassName(Nan::New<v8::String>("ResultSet").ToLocalChecked()); Nan::SetPrototypeMethod(temp, "close", Close); Nan::SetPrototypeMethod(temp, "getRow", GetRow); Nan::SetPrototypeMethod(temp, "getRows", GetRows); Nan::SetAccessor(temp->InstanceTemplate(), Nan::New<v8::String>("metaData").ToLocalChecked(), ResultSet::GetMetaData, ResultSet::SetMetaData ); resultSetTemplate_s.Reset( temp); Nan::Set(target, Nan::New<v8::String>("ResultSet").ToLocalChecked(), temp->GetFunction()); }
void Image::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New); NanAssignPersistent(constructor_template, t); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(NanNew<String>("Image")); NODE_SET_PROTOTYPE_METHOD(t, "unload", unload); NODE_SET_PROTOTYPE_METHOD(t, "save", save); NODE_SET_PROTOTYPE_METHOD(t, "saveToMemory", saveToMemory); NODE_SET_PROTOTYPE_METHOD(t, "convertTo32Bits", convertTo32Bits); NODE_SET_PROTOTYPE_METHOD(t, "convertTo24Bits", convertTo24Bits); NODE_SET_PROTOTYPE_METHOD(t, "flipHorizontal", flipHorizontal); NODE_SET_PROTOTYPE_METHOD(t, "flipVertical", flipVertical); target->Set(NanNew<String>("Image"), t->GetFunction()); }
void Tail::Init(Handle<Object> target) { v8::HandleScope scope; data_symbol = NODE_PSYMBOL("data"); error_symbol = NODE_PSYMBOL("error"); end_symbol = NODE_PSYMBOL("end"); // Prepare constructor template Local<FunctionTemplate> tpl = FunctionTemplate::New(New); tpl->SetClassName(String::NewSymbol("Tail")); tpl->InstanceTemplate()->SetInternalFieldCount(3); // Prototype tpl->InstanceTemplate()->Set(String::NewSymbol("close"), FunctionTemplate::New(close)->GetFunction()); tpl->InstanceTemplate()->SetAccessor(String::NewSymbol("readable"), Tail::GetReadable); tpl->InstanceTemplate()->SetAccessor(String::NewSymbol("writable"), Tail::GetWritable); Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction()); target->Set(String::NewSymbol("Tail"), constructor); }
void Texture::Initialize(Handle<Object> target) { HandleScope scope; Local<FunctionTemplate> tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); Local<String> name = String::NewSymbol("Texture"); JSDX_TOOLKIT_DEFINE_CONSTANT(tpl, "QUALITY_LOW", CLUTTER_TEXTURE_QUALITY_LOW); JSDX_TOOLKIT_DEFINE_CONSTANT(tpl, "QUALITY_MEDIUM", CLUTTER_TEXTURE_QUALITY_MEDIUM); JSDX_TOOLKIT_DEFINE_CONSTANT(tpl, "QUALITY_HIGH", CLUTTER_TEXTURE_QUALITY_HIGH); /* Event */ JSDX_TOOLKIT_DEFINE_CONSTANT(tpl, "EVENT_LOAD_FINISHED", JSDX_TOOLKIT_TEXTURE_EVENT_LOAD_FINISHED); /* Methods */ PrototypeMethodsInit(tpl); target->Set(name, tpl->GetFunction()); }
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); }
void LineString::Initialize(Local<Object> target) { Nan::HandleScope scope; Local<FunctionTemplate> lcons = Nan::New<FunctionTemplate>(LineString::New); lcons->Inherit(Nan::New(Geometry::constructor)); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(Nan::New("LineString").ToLocalChecked()); Nan::SetPrototypeMethod(lcons, "toString", toString); Nan::SetPrototypeMethod(lcons, "getLength", getLength); Nan::SetPrototypeMethod(lcons, "value", value); Nan::SetPrototypeMethod(lcons, "addSubLineString", addSubLineString); ATTR(lcons, "points", pointsGetter, READ_ONLY_SETTER); target->Set(Nan::New("LineString").ToLocalChecked(), lcons->GetFunction()); constructor.Reset(lcons); }
/*! Initialize our node object */ void Audio::AudioEngine::Init( v8::Handle<v8::Object> target ) { // Prepare constructor template Local<FunctionTemplate> functionTemplate = FunctionTemplate::New (Audio::AudioEngine::New ); functionTemplate->SetClassName( String::NewSymbol("AudioEngine") ); functionTemplate->InstanceTemplate()->SetInternalFieldCount( 1 ); // Get functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("isActive"), FunctionTemplate::New(Audio::AudioEngine::isActive)->GetFunction() ); functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("getDeviceName"), FunctionTemplate::New(Audio::AudioEngine::getDeviceName)->GetFunction() ); functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("getNumDevices"), FunctionTemplate::New(Audio::AudioEngine::getNumDevices)->GetFunction() ); // Set functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("setOptions"), FunctionTemplate::New(Audio::AudioEngine::setOptions)->GetFunction() ); functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("getOptions"), FunctionTemplate::New(Audio::AudioEngine::getOptions)->GetFunction() ); functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("write"), FunctionTemplate::New(Audio::AudioEngine::write)->GetFunction() ); functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("read"), FunctionTemplate::New(Audio::AudioEngine::read)->GetFunction() ); functionTemplate->PrototypeTemplate()->Set( String::NewSymbol("isBufferEmpty"), FunctionTemplate::New(Audio::AudioEngine::isBufferEmpty)->GetFunction() ); constructor = Persistent<Function>::New( functionTemplate->GetFunction() ); } // end AudioEngine::Init()
void #else int #endif AsyncStackedVideo::Initialize(Handle<Object> target) { HandleScope scope; Local<FunctionTemplate> t = FunctionTemplate::New(New); t->InstanceTemplate()->SetInternalFieldCount(1); NODE_SET_PROTOTYPE_METHOD(t, "push", Push); NODE_SET_PROTOTYPE_METHOD(t, "endPush", EndPush); NODE_SET_PROTOTYPE_METHOD(t, "setOutputFile", SetOutputFile); NODE_SET_PROTOTYPE_METHOD(t, "setQuality", SetQuality); NODE_SET_PROTOTYPE_METHOD(t, "setFrameRate", SetFrameRate); NODE_SET_PROTOTYPE_METHOD(t, "setKeyFrameInterval", SetKeyFrameInterval); NODE_SET_PROTOTYPE_METHOD(t, "setTmpDir", SetTmpDir); NODE_SET_PROTOTYPE_METHOD(t, "encode", Encode); target->Set(String::NewSymbol("AsyncStackedVideo"), t->GetFunction()); }
void JSZCluster::initJsObjectsTemplate(v8::Isolate *isolate, v8::Handle<v8::Object> &global) { Local<String> jszClusterClassName = String::NewFromUtf8(isolate, JSZCLUSTER); // methods Local<String> getProperyByIdMethod = String::NewFromUtf8(isolate, GET_PROPERTY_BY_ID); Local<String> executeCmdByIdMethod = String::NewFromUtf8(isolate, EXECUTE_CMD_BY_ID); Local<FunctionTemplate> zClusterFunctionTemplate = FunctionTemplate::New(isolate, constructor, External::New(isolate, this)); zClusterFunctionTemplate->SetClassName(jszClusterClassName); Local<ObjectTemplate> zClusterInstanceTemplate = zClusterFunctionTemplate->InstanceTemplate(); zClusterInstanceTemplate->SetInternalFieldCount(3); // attributes // functions zClusterInstanceTemplate->Set(getProperyByIdMethod, FunctionTemplate::New(isolate, jsGetPropertyById)); zClusterInstanceTemplate->Set(executeCmdByIdMethod, FunctionTemplate::New(isolate, jsExecuteCmdById)); global->Set(jszClusterClassName, zClusterFunctionTemplate->GetFunction()); functionTemplate.Reset(isolate, zClusterFunctionTemplate); }
template <class K, class V> void db<K, V>::setup_export(Handle<Object>& exports) { char class_name[64]; sprintf(class_name, "DB_%s_%s", K::type_name, V::type_name); // Prepare constructor template Local<FunctionTemplate> dbiTpl = NanNew<FunctionTemplate>(db::ctor); dbiTpl->SetClassName(NanNew(class_name)); dbiTpl->InstanceTemplate()->SetInternalFieldCount(1); // Add functions to the prototype NODE_SET_PROTOTYPE_METHOD(dbiTpl, "close", db::close); NODE_SET_PROTOTYPE_METHOD(dbiTpl, "get", db::get); NODE_SET_PROTOTYPE_METHOD(dbiTpl, "put", db::put); NODE_SET_PROTOTYPE_METHOD(dbiTpl, "del", db::del); NODE_SET_PROTOTYPE_METHOD(dbiTpl, "exists", db::exists); // TODO: wrap mdb_stat too // Set exports exports->Set(NanNew(class_name), dbiTpl->GetFunction()); }
void RasterBandPixels::Initialize(Local<Object> target) { Nan::HandleScope scope; Local<FunctionTemplate> lcons = Nan::New<FunctionTemplate>(RasterBandPixels::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(Nan::New("RasterBandPixels").ToLocalChecked()); Nan::SetPrototypeMethod(lcons, "toString", toString); Nan::SetPrototypeMethod(lcons, "get", get); Nan::SetPrototypeMethod(lcons, "set", set); Nan::SetPrototypeMethod(lcons, "read", read); Nan::SetPrototypeMethod(lcons, "write", write); Nan::SetPrototypeMethod(lcons, "readBlock", readBlock); Nan::SetPrototypeMethod(lcons, "writeBlock", writeBlock); target->Set(Nan::New("RasterBandPixels").ToLocalChecked(), lcons->GetFunction()); constructor.Reset(lcons); }
void Protobuf::Init(Handle<Object> exports) { // Prepare constructor template Local<FunctionTemplate> tpl = FunctionTemplate::New(New); tpl->SetClassName(String::NewSymbol("Protobuf")); tpl->InstanceTemplate()->SetInternalFieldCount(2); // Prototype tpl->PrototypeTemplate()->Set(String::NewSymbol("Serialize"), FunctionTemplate::New(Serialize)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("Parse"), FunctionTemplate::New(Parse)->GetFunction()); tpl->PrototypeTemplate()->Set(String::NewSymbol("MessageHandle"), FunctionTemplate::New(MessageHandle)->GetFunction()); Persistent<Function> constructor = Persistent<Function>::New(tpl->GetFunction()); exports->Set(String::NewSymbol("Protobuf"), constructor); KeySymbol = NODE_PSYMBOL("Key"); ValueSymbol = NODE_PSYMBOL("Value"); TypeTemplate = Persistent<FunctionTemplate>::New(FunctionTemplate::New()); TypeTemplate->InstanceTemplate()->SetInternalFieldCount(4); }
void ImageInitBinding(Handle<Object> target) { NanScope(); Local<FunctionTemplate> ctor = NanNew<FunctionTemplate>(newImage); NanAssignPersistent(constructor, ctor); ctor->InstanceTemplate()->SetInternalFieldCount(1); ctor->SetClassName(NanNew("Image")); Local<ObjectTemplate> proto = ctor->PrototypeTemplate(); proto->SetAccessor(NanNew("id"), ImageGetId, ImageSetId); proto->SetAccessor(NanNew("src"), ImageGetSrc, ImageSetSrc); proto->SetAccessor(NanNew("width"), ImageGetWidth, ImageSetWidth); proto->SetAccessor(NanNew("height"), ImageGetHeight, ImageSetHeight); NAN_SET_PROTOTYPE_METHOD(ctor, "load", ImageLoad); NAN_SET_PROTOTYPE_METHOD(ctor, "unload", ImageUnload); target->Set(NanNew("Image"), ctor->GetFunction()); }
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()); }
void DatasetLayers::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(DatasetLayers::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(NanNew("DatasetLayers")); NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString); NODE_SET_PROTOTYPE_METHOD(lcons, "count", count); NODE_SET_PROTOTYPE_METHOD(lcons, "create", create); NODE_SET_PROTOTYPE_METHOD(lcons, "copy", copy); NODE_SET_PROTOTYPE_METHOD(lcons, "get", get); NODE_SET_PROTOTYPE_METHOD(lcons, "remove", remove); ATTR_DONT_ENUM(lcons, "ds", dsGetter, READ_ONLY_SETTER); target->Set(NanNew("DatasetLayers"), lcons->GetFunction()); NanAssignPersistent(constructor, lcons); }
void Feature::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Feature::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(NanNew("Feature")); NODE_SET_PROTOTYPE_METHOD(lcons, "id", id); NODE_SET_PROTOTYPE_METHOD(lcons, "extent", extent); NODE_SET_PROTOTYPE_METHOD(lcons, "attributes", attributes); NODE_SET_PROTOTYPE_METHOD(lcons, "addGeometry", addGeometry); NODE_SET_PROTOTYPE_METHOD(lcons, "addAttributes", addAttributes); NODE_SET_PROTOTYPE_METHOD(lcons, "numGeometries", numGeometries); NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString); NODE_SET_PROTOTYPE_METHOD(lcons, "toJSON", toJSON); NODE_SET_PROTOTYPE_METHOD(lcons, "toWKB", toWKB); NODE_SET_PROTOTYPE_METHOD(lcons, "toWKT", toWKT); target->Set(NanNew("Feature"),lcons->GetFunction()); NanAssignPersistent(constructor, lcons); }
void Color::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Color::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(NanNew("Color")); // methods NODE_SET_PROTOTYPE_METHOD(lcons, "hex", hex); NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString); // properties ATTR(lcons, "r", get_prop, set_prop); ATTR(lcons, "g", get_prop, set_prop); ATTR(lcons, "b", get_prop, set_prop); ATTR(lcons, "a", get_prop, set_prop); target->Set(NanNew("Color"), lcons->GetFunction()); NanAssignPersistent(constructor, lcons); }