static void get_fields(Local<Object> fields, mapnik::datasource_ptr ds) { NanScope(); mapnik::layer_descriptor ld = ds->get_descriptor(); // field names and types std::vector<mapnik::attribute_descriptor> const& desc = ld.get_descriptors(); std::vector<mapnik::attribute_descriptor>::const_iterator itr = desc.begin(); std::vector<mapnik::attribute_descriptor>::const_iterator end = desc.end(); while (itr != end) { unsigned field_type = itr->get_type(); std::string type(""); if (field_type == mapnik::Integer) type = "Number"; else if (field_type == mapnik::Float) type = "Number"; else if (field_type == mapnik::Double) type = "Number"; else if (field_type == mapnik::String) type = "String"; else if (field_type == mapnik::Boolean) type = "Boolean"; else if (field_type == mapnik::Geometry) type = "Geometry"; else if (field_type == mapnik::Object) type = "Object"; else type = "Unknown"; fields->Set(NanNew(itr->get_name().c_str()), NanNew(type.c_str())); fields->Set(NanNew(itr->get_name().c_str()), NanNew(type.c_str())); ++itr; } }
Handle<Value> SpatialReference::New(OGRSpatialReference *raw, bool owned) { NanEscapableScope(); if (!raw) { return NanEscapeScope(NanNull()); } if (cache.has(raw)) { return NanEscapeScope(NanNew(cache.get(raw))); } //make a copy of spatialreference owned by a layer, feature, etc // + no need to track when a layer is destroyed // + no need to throw errors when a method trys to modify an owned read-only srs // - is slower OGRSpatialReference* cloned_srs = raw->Clone(); SpatialReference *wrapped = new SpatialReference(cloned_srs); wrapped->owned_ = true; Handle<Value> ext = NanNew<External>(wrapped); Handle<Object> obj = NanNew(SpatialReference::constructor)->GetFunction()->NewInstance(1, &ext); cache.add(cloned_srs, raw, obj); return NanEscapeScope(obj); }
/* DESCRIPTION Callback function of Get Connection method PARAMETERS: UV queue work block NOTES: Connection handle is formed and handed over to JS. */ void Oracledb::Async_AfterGetConnection (uv_work_t *req) { NanScope(); connectionBaton *connBaton = (connectionBaton*)req->data; v8::TryCatch tc; Handle<Value> argv[2]; if( !(connBaton->error).empty() ) { argv[0] = v8::Exception::Error(NanNew<v8::String>( (connBaton->error).c_str() )); argv[1] = NanNull(); } else { argv[0] = NanUndefined(); Local<FunctionTemplate> lft = NanNew(Connection::connectionTemplate_s); Handle<Object> connection = lft->GetFunction()-> NewInstance(); (ObjectWrap::Unwrap<Connection> (connection))-> setConnection( connBaton->dpiconn, connBaton->oracledb ); argv[1] = connection; } Local<Function> callback = NanNew(connBaton->cb); delete connBaton; NanMakeCallback( NanGetCurrentContext()->Global(), callback, 2, argv ); if(tc.HasCaught()) node::FatalException(tc); }
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; }
void HttpClient::callOnDone() { NanScope(); Handle<Value> argv[2]; argv[0] = NanNew("err"); argv[1] = NanNew("info"); this->_onDone->Call(2, argv); }
// 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); }
/** * Generator for [UTFGrid](https://www.mapbox.com/guides/an-open-platform) * representations of data. * * @name mapnik.Grid * @class * @param {number} width * @param {number} height * @param {Object} [options={}] optional argument, which can have a 'key' property * @property {string} key */ void Grid::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Grid::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(NanNew("Grid")); // methods NODE_SET_PROTOTYPE_METHOD(lcons, "encodeSync", encodeSync); NODE_SET_PROTOTYPE_METHOD(lcons, "encode", encode); NODE_SET_PROTOTYPE_METHOD(lcons, "addField", addField); NODE_SET_PROTOTYPE_METHOD(lcons, "fields", fields); NODE_SET_PROTOTYPE_METHOD(lcons, "view", view); NODE_SET_PROTOTYPE_METHOD(lcons, "width", width); NODE_SET_PROTOTYPE_METHOD(lcons, "height", height); NODE_SET_PROTOTYPE_METHOD(lcons, "painted", painted); NODE_SET_PROTOTYPE_METHOD(lcons, "clear", clear); NODE_SET_PROTOTYPE_METHOD(lcons, "clearSync", clearSync); // properties ATTR(lcons, "key", get_key, set_key); target->Set(NanNew("Grid"), lcons->GetFunction()); NODE_MAPNIK_DEFINE_64_BIT_CONSTANT(lcons->GetFunction(), "base_mask", mapnik::grid::base_mask); NanAssignPersistent(constructor, lcons); }
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()); }
Handle<Value> TypedArray::New(GDALDataType type, unsigned int length) { NanEscapableScope(); Handle<Value> val; Handle<Function> constructor; Local<Object> global = NanGetCurrentContext()->Global(); const char *name; switch(type) { case GDT_Byte: name = "Uint8Array"; break; case GDT_Int16: name = "Int16Array"; break; case GDT_UInt16: name = "Uint16Array"; break; case GDT_Int32: name = "Int32Array"; break; case GDT_UInt32: name = "Uint32Array"; break; case GDT_Float32: name = "Float32Array"; break; case GDT_Float64: name = "Float64Array"; break; default: NanThrowError("Unsupported array type"); return NanEscapeScope(NanUndefined()); } // make ArrayBuffer val = global->Get(NanNew("ArrayBuffer")); if(val.IsEmpty() || !val->IsFunction()) { NanThrowError("Error getting ArrayBuffer constructor"); return NanEscapeScope(NanUndefined()); } constructor = val.As<Function>(); Local<Value> size = NanNew<Integer>(length * GDALGetDataTypeSize(type) / 8); Local<Value> array_buffer = constructor->NewInstance(1, &size); if(array_buffer.IsEmpty() || !array_buffer->IsObject()) { NanThrowError("Error allocating ArrayBuffer"); return NanEscapeScope(NanUndefined()); } // make TypedArray val = global->Get(NanNew(name)); if(val.IsEmpty() || !val->IsFunction()) { NanThrowError("Error getting typed array constructor"); return NanEscapeScope(NanUndefined()); } constructor = val.As<Function>(); Local<Object> array = constructor->NewInstance(1, &array_buffer); if(array.IsEmpty() || !array->IsObject()) { NanThrowError("Error creating TypedArray"); return NanEscapeScope(NanUndefined()); } return NanEscapeScope(array); }
static inline NAN_METHOD(register_fonts) { NanScope(); try { if (args.Length() == 0 || !args[0]->IsString()) { NanThrowTypeError("first argument must be a path to a directory of fonts"); NanReturnUndefined(); } bool found = false; std::vector<std::string> const names_before = mapnik::freetype_engine::face_names(); // option hash if (args.Length() == 2){ if (!args[1]->IsObject()) { NanThrowTypeError("second argument is optional, but if provided must be an object, eg. { recurse:Boolean }"); NanReturnUndefined(); } Local<Object> options = args[1].As<Object>(); if (options->Has(NanNew("recurse"))) { Local<Value> recurse_opt = options->Get(NanNew("recurse")); if (!recurse_opt->IsBoolean()) { NanThrowTypeError("'recurse' must be a Boolean"); NanReturnUndefined(); } bool recurse = recurse_opt->BooleanValue(); std::string path = TOSTR(args[0]); found = mapnik::freetype_engine::register_fonts(path,recurse); } } else { std::string path = TOSTR(args[0]); found = mapnik::freetype_engine::register_fonts(path); } std::vector<std::string> const& names_after = mapnik::freetype_engine::face_names(); if (names_after.size() == names_before.size()) found = false; NanReturnValue(NanNew(found)); } catch (std::exception const& ex) { NanThrowError(ex.what()); NanReturnUndefined(); } }
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 ); }
Local<Object> EventStream::Event::v8Object() { NanEscapableScope(); Local<Object> eventPayload(NanNew<Object>()); eventPayload->Set(NanNew("key"), v8Value(entryEventPtr->getKey())); eventPayload->Set(NanNew("oldValue"), v8Value(entryEventPtr->getOldValue())); eventPayload->Set(NanNew("newValue"), v8Value(entryEventPtr->getNewValue())); return NanEscapeScope(eventPayload); }
void ServiceRef::Initialize(Handle<Object> target) { Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New); NanAssignPersistent(constructor_template, t); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(NanNew("DNSServiceRef")); t->InstanceTemplate()->SetAccessor(NanNew("fd"), fd_getter); t->InstanceTemplate()->SetAccessor( NanNew("initialized"), initialized_getter); target->Set(NanNew("DNSServiceRef"), t->GetFunction()); }
void SpatialReference::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(SpatialReference::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(NanNew("SpatialReference")); NODE_SET_METHOD(lcons, "fromUserInput", fromUserInput); NODE_SET_METHOD(lcons, "fromWKT", fromWKT); NODE_SET_METHOD(lcons, "fromProj4", fromProj4); NODE_SET_METHOD(lcons, "fromEPSG", fromEPSG); NODE_SET_METHOD(lcons, "fromEPSGA", fromEPSGA); NODE_SET_METHOD(lcons, "fromESRI", fromESRI); NODE_SET_METHOD(lcons, "fromWMSAUTO", fromWMSAUTO); NODE_SET_METHOD(lcons, "fromXML", fromXML); NODE_SET_METHOD(lcons, "fromURN", fromURN); NODE_SET_METHOD(lcons, "fromCRSURL", fromCRSURL); NODE_SET_METHOD(lcons, "fromURL", fromURL); NODE_SET_METHOD(lcons, "fromMICoordSys", fromMICoordSys); NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString); NODE_SET_PROTOTYPE_METHOD(lcons, "toWKT", exportToWKT); NODE_SET_PROTOTYPE_METHOD(lcons, "toPrettyWKT", exportToPrettyWKT); NODE_SET_PROTOTYPE_METHOD(lcons, "toProj4", exportToProj4); NODE_SET_PROTOTYPE_METHOD(lcons, "toXML", exportToXML); NODE_SET_PROTOTYPE_METHOD(lcons, "clone", clone); NODE_SET_PROTOTYPE_METHOD(lcons, "cloneGeogCS", cloneGeogCS); NODE_SET_PROTOTYPE_METHOD(lcons, "setWellKnownGeogCS", setWellKnownGeogCS); NODE_SET_PROTOTYPE_METHOD(lcons, "morphToESRI", morphToESRI); NODE_SET_PROTOTYPE_METHOD(lcons, "morphFromESRI", morphFromESRI); NODE_SET_PROTOTYPE_METHOD(lcons, "EPSGTreatsAsLatLong", EPSGTreatsAsLatLong); NODE_SET_PROTOTYPE_METHOD(lcons, "EPSGTreatsAsNorthingEasting", EPSGTreatsAsNorthingEasting); NODE_SET_PROTOTYPE_METHOD(lcons, "getLinearUnits", getLinearUnits); NODE_SET_PROTOTYPE_METHOD(lcons, "getAngularUnits", getAngularUnits); NODE_SET_PROTOTYPE_METHOD(lcons, "isGeocentric", isGeocentric); NODE_SET_PROTOTYPE_METHOD(lcons, "isProjected", isProjected); NODE_SET_PROTOTYPE_METHOD(lcons, "isLocal", isLocal); NODE_SET_PROTOTYPE_METHOD(lcons, "isVectical", isVertical); NODE_SET_PROTOTYPE_METHOD(lcons, "isCompound", isCompound); NODE_SET_PROTOTYPE_METHOD(lcons, "isSameGeogCS", isSameGeogCS); NODE_SET_PROTOTYPE_METHOD(lcons, "isSameVertCS", isSameVertCS); NODE_SET_PROTOTYPE_METHOD(lcons, "isSame", isSame); NODE_SET_PROTOTYPE_METHOD(lcons, "getAuthorityName", getAuthorityName); NODE_SET_PROTOTYPE_METHOD(lcons, "getAuthorityCode", getAuthorityCode); NODE_SET_PROTOTYPE_METHOD(lcons, "getAttrValue", getAttrValue); NODE_SET_PROTOTYPE_METHOD(lcons, "autoIdentifyEPSG", autoIdentifyEPSG); NODE_SET_PROTOTYPE_METHOD(lcons, "validate", validate); target->Set(NanNew("SpatialReference"), lcons->GetFunction()); NanAssignPersistent(constructor, lcons); }
static void Init(v8::Handle<v8::Object> exports) { NanScope(); v8::Local<v8::FunctionTemplate> tpl = NanNew<v8::FunctionTemplate>(New); tpl->SetClassName(NanNew("MyObject")); tpl->InstanceTemplate()->SetInternalFieldCount(1); NODE_SET_PROTOTYPE_METHOD(tpl, "getHandle", GetHandle); NanAssignPersistent(constructor, tpl->GetFunction()); exports->Set(NanNew("MyObject"), tpl->GetFunction()); }
Handle<Value> DatasetBands::New(Handle<Value> ds_obj) { NanEscapableScope(); DatasetBands *wrapped = new DatasetBands(); v8::Handle<v8::Value> ext = NanNew<External>(wrapped); v8::Handle<v8::Object> obj = NanNew(DatasetBands::constructor)->GetFunction()->NewInstance(1, &ext); obj->SetHiddenValue(NanNew("parent_"), ds_obj); return NanEscapeScope(obj); }
Handle<Value> FeatureDefnFields::New(Handle<Value> feature_defn) { NanEscapableScope(); FeatureDefnFields *wrapped = new FeatureDefnFields(); v8::Handle<v8::Value> ext = NanNew<External>(wrapped); v8::Handle<v8::Object> obj = NanNew(FeatureDefnFields::constructor)->GetFunction()->NewInstance(1, &ext); obj->SetHiddenValue(NanNew("parent_"), feature_defn); return NanEscapeScope(obj); }
void GetStats(Handle<Object> result, Sass_Context* ctx) { char** included_files = sass_context_get_included_files(ctx); Handle<Array> arr = NanNew<Array>(); if (included_files) { for (int i = 0; included_files[i] != nullptr; ++i) { arr->Set(i, NanNew<String>(included_files[i])); } } (*result)->Get(NanNew("stats"))->ToObject()->Set(NanNew("includedFiles"), arr); }
static inline NAN_METHOD(available_font_files) { NanScope(); std::map<std::string,std::pair<int,std::string> > const& mapping = mapnik::freetype_engine::get_mapping(); Local<Object> obj = NanNew<Object>(); std::map<std::string,std::pair<int,std::string> >::const_iterator itr; for (itr = mapping.begin();itr!=mapping.end();++itr) { obj->Set(NanNew(itr->first.c_str()), NanNew(itr->second.second.c_str())); } NanReturnValue(obj); }
void NodeFileSource::Init(v8::Handle<v8::Object> target) { NanScope(); v8::Local<v8::FunctionTemplate> t = NanNew<v8::FunctionTemplate>(New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(NanNew("FileSource")); NanAssignPersistent(constructorTemplate, t); target->Set(NanNew("FileSource"), t->GetFunction()); }
v8::Handle<v8::Object> NodeRequest::Create(NodeFileSource* source, const mbgl::Resource& resource) { NanEscapableScope(); v8::Local<v8::Value> argv[] = { NanNew<v8::External>(const_cast<NodeFileSource*>(source)), NanNew<v8::External>(const_cast<mbgl::Resource*>(&resource)) }; auto instance = NanNew<v8::FunctionTemplate>(constructorTemplate)->GetFunction()->NewInstance(2, argv); instance->ForceSet(NanNew("url"), NanNew(resource.url), v8::ReadOnly); instance->ForceSet(NanNew("kind"), NanNew<v8::Integer>(int(resource.kind)), v8::ReadOnly); return NanEscapeScope(instance); }
Handle<Value> LayerFeatures::New(Handle<Value> layer_obj) { NanEscapableScope(); LayerFeatures *wrapped = new LayerFeatures(); v8::Handle<v8::Value> ext = NanNew<External>(wrapped); v8::Handle<v8::Object> obj = NanNew(LayerFeatures::constructor)->GetFunction()->NewInstance(1, &ext); obj->SetHiddenValue(NanNew("parent_"), layer_obj); return NanEscapeScope(obj); }
void HttpClient::callOnProgress(int total, int finished) { NanScope(); Handle<Value> argv[2]; Handle<Object> obj = NanNew<Object>(); obj->Set(NanNew("total"), NanNew<Number>(total)); obj->Set(NanNew("finished"), NanNew<Number>(finished)); argv[0] = NanNew("success"); argv[1] = obj; this->_onProgress->Call(2, argv); }
static void Init(v8::Handle<v8::Object> exports) { NanScope(); v8::Local<v8::FunctionTemplate> tpl = NanNew<v8::FunctionTemplate>(New); NanAssignPersistent(base_type::function_template, tpl); tpl->SetClassName(NanNew(ClassName)); tpl->InstanceTemplate()->SetInternalFieldCount(1); EIGENJS_OBJECT_INITIALIZE(PartialPivLU, tpl) exports->Set(NanNew(ClassName), tpl->GetFunction()); NanAssignPersistent(base_type::constructor, tpl->GetFunction()); }
uint8_t *ConversionUtility::getNativePointerToUint8(v8::Local<v8::Object>js, char *name) { v8::Local<v8::Array> jsarray = v8::Local<v8::Array>::Cast(js->Get(NanNew(name))); uint8_t *string = (uint8_t *)malloc(sizeof(uint8_t) * jsarray->Length()); for (uint32_t i = 0; i < jsarray->Length(); ++i) { string[i] = (uint8_t)jsarray->Get(NanNew(i))->Uint32Value(); } return string; }
void NodeRequest::Init(v8::Handle<v8::Object> target) { NanScope(); v8::Local<v8::FunctionTemplate> t = NanNew<v8::FunctionTemplate>(New); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(NanNew("Request")); NODE_SET_PROTOTYPE_METHOD(t, "respond", Respond); NanAssignPersistent(constructorTemplate, t); target->Set(NanNew("Request"), t->GetFunction()); }
void get_stats(sass_context_wrapper* ctx_w, Sass_Context* ctx) { NanScope(); char** included_files = sass_context_get_included_files(ctx); Handle<Array> arr = NanNew<Array>(); if (included_files) { for (int i = 0; included_files[i] != nullptr; ++i) { arr->Set(i, NanNew<String>(included_files[i])); } } NanNew(ctx_w->result)->Get(NanNew("stats"))->ToObject()->Set(NanNew("includedFiles"), arr); }
int GetResult(sass_context_wrapper* ctx_w, Sass_Context* ctx) { NanScope(); int status = sass_context_get_error_status(ctx); if (status == 0) { NanNew(ctx_w->result)->Set(NanNew("css"), NanNew<String>(sass_context_get_output_string(ctx))); GetStats(ctx_w, ctx); GetSourceMap(ctx_w, ctx); } return status; }
void Init(v8::Handle<v8::Object> target) { target->Set( NanNew("newNumber") , NanNew<v8::FunctionTemplate>(NewNumber)->GetFunction() ); target->Set( NanNew("newNegativeInteger") , NanNew<v8::FunctionTemplate>(NewNegativeInteger)->GetFunction() ); target->Set( NanNew("newPositiveInteger") , NanNew<v8::FunctionTemplate>(NewPositiveInteger)->GetFunction() ); target->Set( NanNew("newUtf8String") , NanNew<v8::FunctionTemplate>(NewUtf8String)->GetFunction() ); target->Set( NanNew("newLatin1String") , NanNew<v8::FunctionTemplate>(NewLatin1String)->GetFunction() ); target->Set( NanNew("newUcs2String") , NanNew<v8::FunctionTemplate>(NewUcs2String)->GetFunction() ); target->Set( NanNew("newExternalStringResource") , NanNew<v8::FunctionTemplate>(NewExternalStringResource)->GetFunction() ); target->Set( NanNew("newExternalAsciiStringResource") , NanNew<v8::FunctionTemplate>(NewExternalAsciiStringResource) ->GetFunction() ); }
void ProjTransform::Initialize(Handle<Object> target) { NanScope(); Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(ProjTransform::New); lcons->InstanceTemplate()->SetInternalFieldCount(1); lcons->SetClassName(NanNew("ProjTransform")); NODE_SET_PROTOTYPE_METHOD(lcons, "forward", forward); NODE_SET_PROTOTYPE_METHOD(lcons, "backward", backward); target->Set(NanNew("ProjTransform"), lcons->GetFunction()); NanAssignPersistent(constructor, lcons); }