Example #1
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 #2
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 #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());
}
  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 #6
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 #7
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 #8
0
Handle<Value> V8Util::newInstanceFromConstructorTemplate(Persistent<FunctionTemplate>& t, const Arguments& args)
{
	HandleScope scope;
	const int argc = args.Length();
	Local<Value>* argv = new Local<Value> [argc];

	for (int i = 0; i < argc; ++i) {
		argv[i] = args[i];
	}

	Local<Object> instance = t->GetFunction()->NewInstance(argc, argv);
	delete[] argv;
	return scope.Close(instance);
}
Example #9
0
Type* Protobuf::GetType(const Descriptor* descriptor) {
	TypeMap::iterator it = mTypeMap.find(descriptor);
	if (it != mTypeMap.end())
		return it->second;
	Type* result = mTypeMap[descriptor] = 
		new Type(this,
		factory.GetPrototype(descriptor)->New(),
		TypeTemplate->GetFunction()->NewInstance(),
		handles.size());
	handles.push_back(result);

    Handle<Array> types = handle_->GetInternalField(1).As<Array>();
    types->Set(types->Length(), result->handle_);
	return result;
}
Example #10
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 #11
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 #12
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 #13
0
JsEngine* JsEngine::New(int32_t max_young_space = -1, int32_t max_old_space = -1)
{
	JsEngine* engine = new JsEngine();
    if (engine != NULL) 
	{            
		engine->isolate_ = Isolate::New();
		engine->isolate_->Enter();
		
		if (max_young_space > 0 && max_old_space > 0) {
			v8::ResourceConstraints constraints;
			constraints.set_max_young_space_size(max_young_space * Mega);
			constraints.set_max_old_space_size(max_old_space * Mega);
		
			v8::SetResourceConstraints(&constraints);
		}

		engine->isolate_->Exit();

		Locker locker(engine->isolate_);
		Isolate::Scope isolate_scope(engine->isolate_);
		HandleScope scope;      

		// Setup the template we'll use for all managed object references.
        Handle<FunctionTemplate> fo = FunctionTemplate::New(NULL);
		Handle<ObjectTemplate> obj_template = fo->InstanceTemplate();
    	obj_template->SetInternalFieldCount(1);
        obj_template->SetNamedPropertyHandler(
			managed_prop_get, 
			managed_prop_set, 
			NULL, 
			managed_prop_delete, 
			managed_prop_enumerate);
        obj_template->SetCallAsFunctionHandler(managed_call);
        engine->managed_template_ = new Persistent<FunctionTemplate>(Persistent<FunctionTemplate>::New(fo));

		Persistent<FunctionTemplate> fp = Persistent<FunctionTemplate>::New(FunctionTemplate::New(managed_valueof));
		engine->valueof_function_template_ = new Persistent<FunctionTemplate>(fp);
		
		engine->global_context_ = new Persistent<Context>(Context::New());
		(*engine->global_context_)->Enter();

		fo->PrototypeTemplate()->Set(String::New("valueOf"), fp->GetFunction());

		(*engine->global_context_)->Exit();
	}
	return engine;
}
Example #14
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 #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("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 #16
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());
    }