Пример #1
0
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);
    }
}
Пример #2
0
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);
}
Пример #3
0
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());
}
Пример #4
0
void Proxy::bindProxy(Local<Object> exports, Local<Context> context)
{
    Isolate* isolate = context->GetIsolate();
    Local<String> javaClass = NEW_SYMBOL(isolate, "__javaClass__");
    javaClassSymbol.Reset(isolate, javaClass);
    constructorSymbol.Reset(isolate, NEW_SYMBOL(isolate, "constructor"));
    inheritSymbol.Reset(isolate, NEW_SYMBOL(isolate, "inherit"));
    propertiesSymbol.Reset(isolate, NEW_SYMBOL(isolate, "_properties"));
    lengthSymbol.Reset(isolate, NEW_SYMBOL(isolate, "length"));
    sourceUrlSymbol.Reset(isolate, NEW_SYMBOL(isolate, "sourceUrl"));

    Local<FunctionTemplate> proxyTemplate = FunctionTemplate::New(isolate);
    Local<String> proxySymbol = NEW_SYMBOL(isolate, "Proxy");
    proxyTemplate->InstanceTemplate()->SetInternalFieldCount(kInternalFieldCount);
    proxyTemplate->SetClassName(proxySymbol);
    proxyTemplate->Inherit(EventEmitter::constructorTemplate.Get(isolate));

    proxyTemplate->Set(javaClass, External::New(isolate, JNIUtil::krollProxyClass),
                       static_cast<PropertyAttribute>(DontDelete | DontEnum));

    SetProtoMethod(isolate, proxyTemplate, "_hasListenersForEventType", hasListenersForEventType);
    SetProtoMethod(isolate, proxyTemplate, "onPropertiesChanged", proxyOnPropertiesChanged);
    SetProtoMethod(isolate, proxyTemplate, "_onEventFired", onEventFired);

    baseProxyTemplate.Reset(isolate, proxyTemplate);

    exports->Set(proxySymbol, proxyTemplate->GetFunction(context).ToLocalChecked());
}
Пример #5
0
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);
  }
}
Пример #6
0
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());
}
Пример #7
0
void JNIV8ClassInfo::_registerJavaAccessor(JNIV8ObjectJavaAccessorHolder *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()));
    javaAccessorHolders.push_back(holder);

    Local<External> data = External::New(isolate, (void*)holder);

    AccessorNameSetterCallback finalSetter = 0;
    v8::PropertyAttribute settings = v8::PropertyAttribute::None;
    if(holder->javaSetterId) {
        finalSetter = v8JavaAccessorSetterCallback;
    } else {
        settings = v8::PropertyAttribute::ReadOnly;
    }

    if(holder->isStatic) {
        Local<Function> f = ft->GetFunction();
        f->SetAccessor(engine->getContext(), String::NewFromUtf8(isolate, holder->propertyName.c_str(), v8::NewStringType::kNormal).ToLocalChecked().As<Name>(),
                       v8JavaAccessorGetterCallback, finalSetter,
                       data, DEFAULT, settings);
    } else {
        Local<ObjectTemplate> instanceTpl = ft->InstanceTemplate();
        instanceTpl->SetAccessor(String::NewFromUtf8(isolate, holder->propertyName.c_str()),
                                 v8JavaAccessorGetterCallback, finalSetter,
                                 data, DEFAULT, settings);
    }
}
Пример #8
0
/*! 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()
Пример #9
0
// 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());
}
// 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);

}
// 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());
}
Пример #12
0
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());
}
Пример #13
0
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);
}
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());
}
Пример #15
0
	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());
	}
Пример #16
0
// 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());
}
 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 );
 }
Пример #18
0
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, "close", Close);

  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);

  Nan::SetAccessor(tpl->InstanceTemplate(),
    Nan::New<v8::String>("autoCloseLob").ToLocalChecked(),
    ILob::GetIsAutoCloseLob,
    ILob::SetIsAutoCloseLob);

  Nan::SetAccessor(tpl->InstanceTemplate(),
    Nan::New<v8::String>("valid").ToLocalChecked(),
    ILob::GetIsValid,
    ILob::SetIsValid);

  iLobTemplate_s.Reset(tpl);
  Nan::Set(target, Nan::New<v8::String>("ILob").ToLocalChecked(), tpl->GetFunction());
}
Пример #19
0
void
Png::Initialize(Handle<Object> target)
{
    HandleScope scope;

    Local<FunctionTemplate> t = FunctionTemplate::New(New);
    t->InstanceTemplate()->SetInternalFieldCount(1);
    NODE_SET_PROTOTYPE_METHOD(t, "encodeSync", PngEncodeSync);
    target->Set(String::NewSymbol("Png"), t->GetFunction());
}
Пример #20
0
/*
   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());
}
Пример #21
0
void
TxtRecordRef::Initialize(Handle<Object> target) {
    Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(New);
    constructor_template.Reset( t);
    t->InstanceTemplate()->SetInternalFieldCount(1);
    t->SetClassName(Nan::New("TXTRecordRef").ToLocalChecked());

    Nan::Set(target, Nan::New("TXTRecordRef").ToLocalChecked(),
             Nan::GetFunction(t).ToLocalChecked());
}
Пример #22
0
/**
 * The C++ class represents a JS constructor as follows:
 *
 * function OutParam(type, options) {
 *   this._type = type || 0;
 *   this._size = options.size;
 *   this._inOut.hasInParam = options.in;
 * }
 */
void OutParam::Init(Handle<Object> target) {
  NanScope();

  Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
  NanAssignPersistent(constructorTemplate, t);
  t->InstanceTemplate()->SetInternalFieldCount(1);
  t->SetClassName(NanNew<String>("OutParam"));
  target->Set(NanNew<String>("OutParam"),
      t->GetFunction());
}
Handle<Object> FixLoginResponse::wrapFixLoginResponse(FixLoginResponse* fixLoginResponse) {

	Local<FunctionTemplate> ctor = Nan::New<FunctionTemplate>();

	ctor->InstanceTemplate()->SetInternalFieldCount(1);
	ctor->SetClassName(Nan::New("FixLoginResponse").ToLocalChecked());

	Local<ObjectTemplate> proto = ctor->PrototypeTemplate();

	Nan::SetPrototypeMethod(ctor, "done", done);

	Handle<Object> obj = ctor->InstanceTemplate()->NewInstance();
	//obj->SetInternalField(0, Nan::New<External>(fixLoginResponse));

	fixLoginResponse->Wrap(obj);
	fixLoginResponse->Ref();

	return obj;
}
void ABPFilterParserWrap::Init(Local<Object> exports) {
  Isolate* isolate = exports->GetIsolate();

  // Prepare constructor template
  Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
  tpl->SetClassName(String::NewFromUtf8(isolate, "ABPFilterParser"));
  tpl->InstanceTemplate()->SetInternalFieldCount(1);

  // Prototype
  NODE_SET_PROTOTYPE_METHOD(tpl, "parse", ABPFilterParserWrap::Parse);
  NODE_SET_PROTOTYPE_METHOD(tpl, "matches", ABPFilterParserWrap::Matches);
  NODE_SET_PROTOTYPE_METHOD(tpl, "serialize", ABPFilterParserWrap::Serialize);
  NODE_SET_PROTOTYPE_METHOD(tpl, "deserialize",
    ABPFilterParserWrap::Deserialize);
  NODE_SET_PROTOTYPE_METHOD(tpl, "cleanup", ABPFilterParserWrap::Cleanup);

  Local<Object> filterOptions = Object::New(isolate);
  filterOptions->Set(String::NewFromUtf8(isolate, "noFilterOption"),
    Int32::New(isolate, 0));
  filterOptions->Set(String::NewFromUtf8(isolate, "script"),
    Int32::New(isolate, 01));
  filterOptions->Set(String::NewFromUtf8(isolate, "image"),
    Int32::New(isolate, 02));
  filterOptions->Set(String::NewFromUtf8(isolate, "stylesheet"),
    Int32::New(isolate, 04));
  filterOptions->Set(String::NewFromUtf8(isolate, "object"),
    Int32::New(isolate, 010));
  filterOptions->Set(String::NewFromUtf8(isolate, "xmlHttpRequest"),
    Int32::New(isolate, 020));
  filterOptions->Set(String::NewFromUtf8(isolate, "objectSubrequest"),
    Int32::New(isolate, 040));
  filterOptions->Set(String::NewFromUtf8(isolate, "subdocument"),
    Int32::New(isolate, 0100));
  filterOptions->Set(String::NewFromUtf8(isolate, "document"),
    Int32::New(isolate, 0200));
  filterOptions->Set(String::NewFromUtf8(isolate, "other"),
    Int32::New(isolate, 0400));
  filterOptions->Set(String::NewFromUtf8(isolate, "xbl"),
    Int32::New(isolate, 01000));
  filterOptions->Set(String::NewFromUtf8(isolate, "collapse"),
    Int32::New(isolate, 02000));
  filterOptions->Set(String::NewFromUtf8(isolate, "doNotTrack"),
    Int32::New(isolate, 04000));
  filterOptions->Set(String::NewFromUtf8(isolate, "elemHide"),
    Int32::New(isolate, 010000));
  filterOptions->Set(String::NewFromUtf8(isolate, "thirdParty"),
    Int32::New(isolate, 020000));
  filterOptions->Set(String::NewFromUtf8(isolate, "notThirdParty"),
    Int32::New(isolate, 040000));

  constructor.Reset(isolate, tpl->GetFunction());
  exports->Set(String::NewFromUtf8(isolate, "ABPFilterParser"),
               tpl->GetFunction());
  exports->Set(String::NewFromUtf8(isolate, "FilterOptions"), filterOptions);
}
Пример #25
0
	void Widget::Initialize(Handle<Object> target)
	{
		HandleScope scope;

		Local<String> name = String::NewSymbol("Widget");

		/* Create a new class */
		Handle<ObjectTemplate> ObjectTpl = ObjectTemplate::New();
		ObjectTpl->SetInternalFieldCount(1);
		Local<Object> ClassObject = ObjectTpl->NewInstance();
		target->Set(name, ClassObject);

		/* Initializing Widget Class  */
		Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
		tpl->InstanceTemplate()->SetInternalFieldCount(1);

		/* Widgets */
		Style::Initialize(ClassObject);
		Bin::Initialize(ClassObject);
		BoxLayout::Initialize(ClassObject);
		Stack::Initialize(ClassObject);
		Grid::Initialize(ClassObject);
		Table::Initialize(ClassObject);
		Adjustment::Initialize(ClassObject);
		Scrollable::Initialize(ClassObject);
		//Stylable::Initialize(ClassObject);
		Button::Initialize(ClassObject);
		Entry::Initialize(ClassObject);
		Frame::Initialize(ClassObject);
		Label::Initialize(ClassObject);
		Dialog::Initialize(ClassObject);
		ProgressBar::Initialize(ClassObject);
		Slider::Initialize(ClassObject);
		Toggle::Initialize(ClassObject);
		Spinner::Initialize(ClassObject);
		Image::Initialize(ClassObject);
		Viewport::Initialize(ClassObject);
		ScrollView::Initialize(ClassObject);
		KineticScrollView::Initialize(ClassObject);

		/* Constants */
		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "ORIENTATION_HORIZONTAL", JSDX_TOOLKIT_WIDGET_ORIENTATION_HORIZONTAL);
		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "ORIENTATION_VERTICAL", JSDX_TOOLKIT_WIDGET_ORIENTATION_VERTICAL);

		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "SCALE_MODE_NONE", MX_IMAGE_SCALE_NONE);
		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "SCALE_MODE_FIT", MX_IMAGE_SCALE_FIT);
		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "SCALE_MODE_CROP", MX_IMAGE_SCALE_CROP);

		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "KINETIC_SCROLL_VIEW_STATE_IDLE", MX_KINETIC_SCROLL_VIEW_STATE_IDLE);
		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "KINETIC_SCROLL_VIEW_STATE_PANNING", MX_KINETIC_SCROLL_VIEW_STATE_PANNING);
		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "KINETIC_SCROLL_VIEW_STATE_SCROLLING", MX_KINETIC_SCROLL_VIEW_STATE_SCROLLING);
		JSDX_TOOLKIT_DEFINE_CONSTANT(ClassObject, "KINETIC_SCROLL_VIEW_STATE_CLAMPING", MX_KINETIC_SCROLL_VIEW_STATE_CLAMPING);

		ClassObject->Set(name, tpl->GetFunction());
	}
Пример #26
0
	void static setup(Handle<Object> exports) {
		Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(TestWrap::New);
		tpl->SetClassName(Nan::New("TestWrap").ToLocalChecked());
		tpl->InstanceTemplate()->SetInternalFieldCount(1);

		Nan::SetPrototypeMethod(tpl, "unwrap", TestWrap::unwrap);
		Nan::SetPrototypeMethod(tpl, "foo", TestWrap::foo);

		exports->Set(Nan::New("TestWrap").ToLocalChecked(), tpl->GetFunction());
		TestWrap::ctor.Reset(tpl->GetFunction());
	}
Пример #27
0
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);
}
Пример #28
0
  static void Init(v8::Local<v8::Object> exports) {
      Isolate* isolate = exports->GetIsolate();

      // Prepare constructor template
      Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, New);
      tpl->SetClassName(String::NewFromUtf8(isolate, "Polynomial"));
      tpl->InstanceTemplate()->SetInternalFieldCount(1);

      // Prototype
      NODE_SET_PROTOTYPE_METHOD(tpl, "at", At);
      NODE_SET_PROTOTYPE_METHOD(tpl, "roots", Roots);
     
      tpl->InstanceTemplate()->SetAccessor(String::NewFromUtf8(isolate, "a"), GetCoeff, SetCoeff);
      tpl->InstanceTemplate()->SetAccessor(String::NewFromUtf8(isolate, "b"), GetCoeff, SetCoeff);
      tpl->InstanceTemplate()->SetAccessor(String::NewFromUtf8(isolate, "c"), GetCoeff, SetCoeff);

      constructor.Reset(isolate, tpl->GetFunction());
      exports->Set(String::NewFromUtf8(isolate, "Polynomial"),
               tpl->GetFunction());
  }
Пример #29
0
void Gallium::Init()
{
    // Binding this tpl to the New C++ function.
    Local<FunctionTemplate> tpl = FunctionTemplate::New(New);

    tpl->SetClassName(String::NewSymbol("Gallium"));
    tpl->InstanceTemplate()->SetInternalFieldCount(1);

    // Binding the constructor to the New C++ function via template.
    constructor = Persistent<Function>::New(tpl->GetFunction());
}
Пример #30
0
void Fluorine::Init() {
    // Prepare constructor template
    Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
    tpl->SetClassName(String::NewSymbol("Fluorine"));
    tpl->InstanceTemplate()->SetInternalFieldCount(1);
    // Prototype
    tpl->PrototypeTemplate()->Set(String::NewSymbol("plusOne"),
                                  FunctionTemplate::New(PlusOne)->GetFunction());

    constructor = Persistent<Function>::New(tpl->GetFunction());
}