Example #1
0
// initialize a JS wrapper around this object
void NodeFSEvents::Initialize(Handle<Object> target)
{
    HandleScope scope;
    emit_sym = NODE_PSYMBOL("emit");
    change_sym = NODE_PSYMBOL("fsevent");
    Local<FunctionTemplate> t = FunctionTemplate::New(NodeFSEvents::New);
    constructor_template = Persistent<FunctionTemplate>::New(t);
    constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
    constructor_template->SetClassName(String::NewSymbol("FSEvents"));
    Local<Function> constructor = constructor_template->GetFunction();

    constructor->Set(String::New("kFSEventStreamEventFlagNone"), Integer::New(0x00000000));
    constructor->Set(String::New("kFSEventStreamEventFlagMustScanSubDirs"), Integer::New(0x00000001));
    constructor->Set(String::New("kFSEventStreamEventFlagUserDropped"), Integer::New(0x00000002));
    constructor->Set(String::New("kFSEventStreamEventFlagKernelDropped"), Integer::New(0x00000004));
    constructor->Set(String::New("kFSEventStreamEventFlagEventIdsWrapped"), Integer::New(0x00000008));
    constructor->Set(String::New("kFSEventStreamEventFlagHistoryDone"), Integer::New(0x00000010));
    constructor->Set(String::New("kFSEventStreamEventFlagRootChanged"), Integer::New(0x00000020));
    constructor->Set(String::New("kFSEventStreamEventFlagMount"), Integer::New(0x00000040));
    constructor->Set(String::New("kFSEventStreamEventFlagUnmount"), Integer::New(0x00000080));
    constructor->Set(String::New("kFSEventStreamEventFlagItemCreated"), Integer::New(0x00000100));
    constructor->Set(String::New("kFSEventStreamEventFlagItemRemoved"), Integer::New(0x00000200));
    constructor->Set(String::New("kFSEventStreamEventFlagItemInodeMetaMod"), Integer::New(0x00000400));
    constructor->Set(String::New("kFSEventStreamEventFlagItemRenamed"), Integer::New(0x00000800));
    constructor->Set(String::New("kFSEventStreamEventFlagItemModified"), Integer::New(0x00001000));
    constructor->Set(String::New("kFSEventStreamEventFlagItemFinderInfoMod"), Integer::New(0x00002000));
    constructor->Set(String::New("kFSEventStreamEventFlagItemChangeOwner"), Integer::New(0x00004000));
    constructor->Set(String::New("kFSEventStreamEventFlagItemXattrMod"), Integer::New(0x00008000));
    constructor->Set(String::New("kFSEventStreamEventFlagItemIsFile"), Integer::New(0x00010000));
    constructor->Set(String::New("kFSEventStreamEventFlagItemIsDir"), Integer::New(0x00020000));
    constructor->Set(String::New("kFSEventStreamEventFlagItemIsSymlink"), Integer::New(0x00040000));

    target->Set(String::NewSymbol("FSEvents"), constructor);
}
Example #2
0
void Query::Initialize(Handle<Object> target) {
    HandleScope scope;
    constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Query::New));
    constructor->InstanceTemplate()->SetInternalFieldCount(1);
    constructor->SetClassName(String::NewSymbol("Query"));
    target->Set(String::NewSymbol("Query"),constructor->GetFunction());
}
Example #3
0
void Engine::Initialize(Handle<Object> target) {
    HandleScope scope;
    constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Engine::New));
    constructor->InstanceTemplate()->SetInternalFieldCount(1);
    constructor->SetClassName(String::NewSymbol("Engine"));
    NODE_SET_PROTOTYPE_METHOD(constructor, "run", run);
    NODE_SET_PROTOTYPE_METHOD(constructor, "runSync", run);
    target->Set(String::NewSymbol("Engine"),constructor->GetFunction());
}
Example #4
0
Handle<Value> ShaderBindings_WrapShader(Shader* toWrap) {
    static Persistent<FunctionTemplate> s_templ = Persistent<FunctionTemplate>::New(fl_shad_GetTemplate());
    HandleScope handle_scope;
    Locker locker;
    Local<Object> texture_inst = s_templ->InstanceTemplate()->NewInstance();
    texture_inst->SetInternalField(0, External::New(toWrap));
    Persistent<Object> ref = Persistent<Object>::New(texture_inst->ToObject());
    toWrap->SetWrappedObject(ref);
    return handle_scope.Close(texture_inst);
}
  static void Init(Handle<Object> target)
  {
    s_ct = Persistent<FunctionTemplate>::New(FunctionTemplate::New(New));
    s_ct->InstanceTemplate()->SetInternalFieldCount(1);
    s_ct->SetClassName(String::NewSymbol("HelloWorld"));

    NODE_SET_PROTOTYPE_METHOD(s_ct, "hi", Hello);

    target->Set(String::NewSymbol("HelloWorld"),
                s_ct->GetFunction());
  }
        static void Init(Handle<Object> target)
        {
            s_ct = Persistent<FunctionTemplate>::New(FunctionTemplate::New(New));
            s_ct->InstanceTemplate()->SetInternalFieldCount(1);
            s_ct->SetClassName(String::NewSymbol("Scws"));

            // bind methods
            NODE_SET_PROTOTYPE_METHOD(s_ct, "segment", segment);


            // expose class as Scws
            target->Set(String::NewSymbol("Scws"), s_ct->GetFunction());
        }
Example #7
0
    static void Init(Handle<Object> target) {
        HandleScope scope;

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

        s_ct = Persistent<FunctionTemplate>::New(t);
        s_ct->InstanceTemplate()->SetInternalFieldCount(1);
        s_ct->SetClassName(String::NewSymbol("Lucene"));

        NODE_SET_PROTOTYPE_METHOD(s_ct, "addDocument", AddDocumentAsync);
        NODE_SET_PROTOTYPE_METHOD(s_ct, "search", SearchAsync);

        target->Set(String::NewSymbol("Lucene"), s_ct->GetFunction());
    }
Example #8
0
void NodeRTree::Initialize(Handle<Object> target) {
    HandleScope scope;

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

    s_ct = Persistent<FunctionTemplate>::New(t);
    s_ct->InstanceTemplate()->SetInternalFieldCount(1);
    s_ct->SetClassName(String::NewSymbol("RTree"));

    NODE_SET_PROTOTYPE_METHOD(s_ct, "insertData", InsertData);

    target->Set(String::NewSymbol("RTree"), s_ct->GetFunction());

}
Example #9
0
	static void Init(Handle<Object> target){
		HandleScope scope;

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

		s_ct = Persistent<FunctionTemplate>::New(t);
		s_ct->InstanceTemplate()->SetInternalFieldCount(1);
		s_ct->SetClassName(String::NewSymbol("Connection"));

		NODE_SET_PROTOTYPE_METHOD(s_ct, "Connect", Connect);
		NODE_SET_PROTOTYPE_METHOD(s_ct, "Subscribe", Subscribe);
		NODE_SET_PROTOTYPE_METHOD(s_ct, "Publish", Publish);

		target->Set(String::NewSymbol("Connection"), s_ct->GetFunction());
	}
Example #10
0
File: fft.cpp Project: EQ4/node-dsp
void NodeFFT::Initialize (Handle<Object> target) {
	HandleScope scope;

	Local<FunctionTemplate> t = FunctionTemplate::New(New);
	fft_constructor_template = Persistent<FunctionTemplate>::New(t);
	fft_constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
	fft_constructor_template->SetClassName(String::NewSymbol("FFT"));

	NODE_SET_PROTOTYPE_METHOD(fft_constructor_template, "forward", Forward);
	NODE_SET_PROTOTYPE_METHOD(fft_constructor_template, "forwardCplx", ForwardCplx);
	NODE_SET_PROTOTYPE_METHOD(fft_constructor_template, "inverse", Forward);
	NODE_SET_PROTOTYPE_METHOD(fft_constructor_template, "inverseCplx", InverseCplx);

	target->Set(String::NewSymbol("FFT"), fft_constructor_template->GetFunction());
}
Example #11
0
    static void Init(Handle<Object> target) {
        PRINTF("Entering Init\n");
        PRINTF("EV_DEFAULT_ = %s\n", TEST_EV_DEFAULT_NAME);
        HandleScope scope;
        
        Local<FunctionTemplate> t = FunctionTemplate::New(New);
        ct = Persistent<FunctionTemplate>::New(t);
        ct->InstanceTemplate()->SetInternalFieldCount(1);
        ct->SetClassName(String::NewSymbol("Pollpri"));
        target->Set(String::NewSymbol("Pollpri"), ct->GetFunction());
        
        target->Set(String::NewSymbol("delay"), 
            FunctionTemplate::New(delay)->GetFunction());

        PRINTF("Leaving Init\n");
    }
Example #12
0
	void QuickWindowWrap::Initialize(Handle<Object> target)
	{
		HandleScope scope;

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

		/* Constructor template */
		Persistent<FunctionTemplate> tpl = Persistent<FunctionTemplate>::New(FunctionTemplate::New(QuickWindowWrap::New));
		tpl->InstanceTemplate()->SetInternalFieldCount(1);  
		tpl->SetClassName(name);

		/* Prototype */
		NODE_SET_PROTOTYPE_METHOD(tpl, "show", QuickWindowWrap::show);
		NODE_SET_PROTOTYPE_METHOD(tpl, "toObject", QuickWindowWrap::toObject);

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

		target->Set(name, constructor);
	}
Example #13
0
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);
}
Example #14
0
    static void NODE_EXTERN Init(Handle<Object> target)
    {
        HandleScope scope;

        // set the constructor function
        Local<FunctionTemplate> t = FunctionTemplate::New(New);

        // set the node.js/v8 class name
        s_ct = Persistent<FunctionTemplate>::New(t);
        s_ct->InstanceTemplate()->SetInternalFieldCount(1);
        s_ct->SetClassName(String::NewSymbol("SharpObject"));

        // registers a class member functions 
        NODE_SET_PROTOTYPE_METHOD(s_ct, "async", Async);
        NODE_SET_PROTOTYPE_METHOD(s_ct, "async2", Async2);
        NODE_SET_PROTOTYPE_METHOD(s_ct, "getSharpValue", GetSharpValue);

        target->Set(String::NewSymbol("SharpObject"),
            s_ct->GetFunction());
    }
Example #15
0
    static void NODE_EXTERN Init(Handle<Object> target)
    {
        HandleScope scope;

        // set the constructor function
        Local<FunctionTemplate> t = FunctionTemplate::New(New);

        // set the node.js/v8 class name
        s_ct = Persistent<FunctionTemplate>::New(t);
        s_ct->InstanceTemplate()->SetInternalFieldCount(1);
        s_ct->SetClassName(String::NewSymbol("tsqlftw"));

        // registers a class member functions 
        NODE_SET_PROTOTYPE_METHOD(s_ct, "connect", connect);
		NODE_SET_PROTOTYPE_METHOD(s_ct, "query", query);
		NODE_SET_PROTOTYPE_METHOD(s_ct, "close", close);

        target->Set(String::NewSymbol("tsqlftw"),
            s_ct->GetFunction());
    }