예제 #1
0
void Bush::Init(v8::Handle<v8::Object> target)
{
	// Prepare constructor template
		v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(nodeNew);
		tpl->SetClassName(v8::String::NewSymbol("Bush"));
		tpl->InstanceTemplate()->SetInternalFieldCount(1);

		// Prototype functions
		tpl->PrototypeTemplate()->Set(v8::String::NewSymbol("collide"), v8::FunctionTemplate::New(nodeCollide)->GetFunction());

		v8::Persistent<v8::Function> constructor = v8::Persistent<v8::Function>::New(tpl->GetFunction());
		target->Set(v8::String::NewSymbol("Bush"), constructor);
}
예제 #2
0
파일: persistent.cpp 프로젝트: az7arul/nan
void Init (v8::Handle<v8::Object> target) {
  target->Set(
      NanNew<v8::String>("save1")
    , NanNew<v8::FunctionTemplate>(Save1)->GetFunction()
  );
  target->Set(
      NanNew<v8::String>("get1")
    , NanNew<v8::FunctionTemplate>(Get1)->GetFunction()
  );
  target->Set(
      NanNew<v8::String>("dispose1")
    , NanNew<v8::FunctionTemplate>(Dispose1)->GetFunction()
  );
  target->Set(
      NanNew<v8::String>("toPersistentAndBackAgain")
    , NanNew<v8::FunctionTemplate>(ToPersistentAndBackAgain)->GetFunction()
  );
  target->Set(
      NanNew<v8::String>("persistentToPersistent")
    , NanNew<v8::FunctionTemplate>(PersistentToPersistent)->GetFunction()
  );
}
  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());
  }
예제 #4
0
/*static*/ void wxNode_wxButton::Init(v8::Handle<v8::Object> target) {
  v8::HandleScope scope;

  v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(wxNodeObject::NewFunc);
  s_ct = v8::Persistent<v8::FunctionTemplate>::New(t);
  s_ct->InstanceTemplate()->SetInternalFieldCount(2);
  s_ct->SetClassName(v8::String::NewSymbol("Button"));

  NODE_SET_PROTOTYPE_METHOD(s_ct, "init", _init);
  AddMethods(s_ct);

  target->Set(v8::String::NewSymbol("Button"), s_ct->GetFunction());
}
예제 #5
0
void
FixedJpegStack::Initialize(v8::Handle<v8::Object> target)
{
    HandleScope scope;

    Local<FunctionTemplate> t = FunctionTemplate::New(New);
    t->InstanceTemplate()->SetInternalFieldCount(1);
    NODE_SET_PROTOTYPE_METHOD(t, "encode", JpegEncodeAsync);
    NODE_SET_PROTOTYPE_METHOD(t, "encodeSync", JpegEncodeSync);
    NODE_SET_PROTOTYPE_METHOD(t, "push", Push);
    NODE_SET_PROTOTYPE_METHOD(t, "setQuality", SetQuality);
    target->Set(String::NewSymbol("FixedJpegStack"), t->GetFunction());
}
예제 #6
0
void MyObject::Init(v8::Handle<v8::Object> exports) {
    NanScope();

    // Prepare constructor template
    v8::Local<v8::FunctionTemplate> tpl = NanNew<v8::FunctionTemplate>(New);
    tpl->SetClassName(NanNew<v8::String>("MyObject"));
    tpl->InstanceTemplate()->SetInternalFieldCount(1);

    NODE_SET_PROTOTYPE_METHOD(tpl, "call_emit", CallEmit);

    NanAssignPersistent<v8::Function>(constructor, tpl->GetFunction());
    exports->Set(NanNew<v8::String>("MyObject"), tpl->GetFunction());
}
예제 #7
0
void NthPrime::Init(v8::Handle<v8::Object> target) {
  // Prepare constructor function template.
  v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(NthPrime::New);
  tpl->SetClassName(v8::String::NewSymbol("NthPrime"));
  tpl->InstanceTemplate()->SetInternalFieldCount(1);
  // Add class methods to constructor function prototype
  tpl->PrototypeTemplate()->Set(v8::String::NewSymbol("getNthPrime"),
        v8::FunctionTemplate::New(NthPrime::getNthPrime_JS)->GetFunction());

  // Add the constructor to the module exports.
  target->Set(v8::String::NewSymbol("NthPrime"),
      v8::Persistent<v8::Function>::New(tpl->GetFunction()));
}
예제 #8
0
void InitDevice(v8::Handle<v8::Object> exports)
{
    exports->Set(NanNew("getDeviceCount"), NanNew<FunctionTemplate>(GetDeviceCount)->GetFunction());
    exports->Set(NanNew("getDevice"), NanNew<FunctionTemplate>(GetDevice)->GetFunction());
    exports->Set(NanNew("setDevice"), NanNew<FunctionTemplate>(SetDevice)->GetFunction());
    exports->Set(NanNew("deviceInfo"), NanNew<FunctionTemplate>(DeviceInfo)->GetFunction());
    exports->Set(NanNew("isDoubleAvailable"), NanNew<FunctionTemplate>(IsDoubleAvailable)->GetFunction());
    exports->Set(NanNew("sync"), NanNew<FunctionTemplate>(Sync)->GetFunction());
    exports->Set(NanNew("wait"), NanNew<FunctionTemplate>(Sync)->GetFunction());
    exports->Set(NanNew("alloc"), NanNew<FunctionTemplate>(Alloc)->GetFunction());
    exports->Set(NanNew("pinned"), NanNew<FunctionTemplate>(Pinned)->GetFunction());
}
예제 #9
0
파일: odbc.cpp 프로젝트: impy88/node-odbc
void ODBC::Init(v8::Handle<Object> target) {
  DEBUG_PRINTF("ODBC::Init\n");
  HandleScope scope;

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

  // Constructor Template
  constructor_template = Persistent<FunctionTemplate>::New(t);
  constructor_template->SetClassName(String::NewSymbol("ODBC"));

  // Reserve space for one Handle<Value>
  Local<ObjectTemplate> instance_template = constructor_template->InstanceTemplate();
  instance_template->SetInternalFieldCount(1);
  
  // Constants
  NODE_DEFINE_CONSTANT(constructor_template, SQL_CLOSE);
  NODE_DEFINE_CONSTANT(constructor_template, SQL_DROP);
  NODE_DEFINE_CONSTANT(constructor_template, SQL_UNBIND);
  NODE_DEFINE_CONSTANT(constructor_template, SQL_RESET_PARAMS);
  NODE_DEFINE_CONSTANT(constructor_template, SQL_DESTROY); //SQL_DESTROY is non-standard
  NODE_DEFINE_CONSTANT(constructor_template, FETCH_ARRAY);
  NODE_DEFINE_CONSTANT(constructor_template, FETCH_OBJECT);
  
  // Prototype Methods
  NODE_SET_PROTOTYPE_METHOD(constructor_template, "createConnection", CreateConnection);
  NODE_SET_PROTOTYPE_METHOD(constructor_template, "createConnectionSync", CreateConnectionSync);

  // Attach the Database Constructor to the target object
  target->Set( v8::String::NewSymbol("ODBC"),
               constructor_template->GetFunction());
  
#if NODE_VERSION_AT_LEAST(0, 7, 9)
  // Initialize uv_async so that we can prevent node from exiting
  uv_async_init( uv_default_loop(),
                 &ODBC::g_async,
                 ODBC::WatcherCallback);
  
  // Not sure if the init automatically calls uv_ref() because there is weird
  // behavior going on. When ODBC::Init is called which initializes the 
  // uv_async_t g_async above, there seems to be a ref which will keep it alive
  // but we only want this available so that we can uv_ref() later on when
  // we have a connection.
  // so to work around this, I am possibly mistakenly calling uv_unref() once
  // so that there are no references on the loop.
  uv_unref((uv_handle_t *)&ODBC::g_async);
#endif
  
  // Initialize the cross platform mutex provided by libuv
  uv_mutex_init(&ODBC::g_odbcMutex);
}
예제 #10
0
bool bind_Debug_AudioSource(v8::Handle<v8::Object> parent)
{
    ScriptingManager* pManager = ScriptingManager::getSingletonPtr();

    v8::Handle<FunctionTemplate> component = pManager->getClassTemplate("Athena.Graphics.Debug.AudioSource");

    if (component.IsEmpty())
    {
        assert(!pManager->getClassTemplate("Athena.Graphics.Debug.DebugComponent").IsEmpty());

        // Declaration of the class
        component = FunctionTemplate::New(Debug_AudioSource_New);
        component->InstanceTemplate()->SetInternalFieldCount(1);
        component->Inherit(pManager->getClassTemplate("Athena.Graphics.Debug.DebugComponent"));

        pManager->declareClassTemplate("Athena.Graphics.Debug.AudioSource", component);

        parent->Set(String::New("AudioSource_TYPE"), String::New(Athena::Graphics::Debug::AudioSource::TYPE.c_str()));
    }

    // Add the class to the parent
    return parent->Set(String::New("AudioSource"), component->GetFunction());
}
예제 #11
0
void ODBC::Init(v8::Handle<Object> exports) {
  DEBUG_PRINTF("ODBC::Init\n");
  Nan::HandleScope scope;

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

  // Constructor Template
  constructor_template->SetClassName(Nan::New("ODBC").ToLocalChecked());

  // Reserve space for one Handle<Value>
  Local<ObjectTemplate> instance_template = constructor_template->InstanceTemplate();
  instance_template->SetInternalFieldCount(1);
  
  PropertyAttribute constant_attributes = static_cast<PropertyAttribute>(ReadOnly | DontDelete);
  constructor_template->Set(Nan::New<String>("SQL_CLOSE").ToLocalChecked(), Nan::New<Number>(SQL_CLOSE), constant_attributes);
  constructor_template->Set(Nan::New<String>("SQL_DROP").ToLocalChecked(), Nan::New<Number>(SQL_DROP), constant_attributes);
  constructor_template->Set(Nan::New<String>("SQL_UNBIND").ToLocalChecked(), Nan::New<Number>(SQL_UNBIND), constant_attributes);
  constructor_template->Set(Nan::New<String>("SQL_RESET_PARAMS").ToLocalChecked(), Nan::New<Number>(SQL_RESET_PARAMS), constant_attributes);
  constructor_template->Set(Nan::New<String>("SQL_DESTROY").ToLocalChecked(), Nan::New<Number>(SQL_DESTROY), constant_attributes);
  constructor_template->Set(Nan::New<String>("FETCH_ARRAY").ToLocalChecked(), Nan::New<Number>(FETCH_ARRAY), constant_attributes);
  NODE_ODBC_DEFINE_CONSTANT(constructor_template, FETCH_OBJECT);
  
  // Prototype Methods
  Nan::SetPrototypeMethod(constructor_template, "createConnection", CreateConnection);
  Nan::SetPrototypeMethod(constructor_template, "createConnectionSync", CreateConnectionSync);

  // Attach the Database Constructor to the target object
  constructor.Reset(constructor_template->GetFunction());
  exports->Set(Nan::New("ODBC").ToLocalChecked(),
               constructor_template->GetFunction());
  
#if NODE_VERSION_AT_LEAST(0, 7, 9)
  // Initialize uv_async so that we can prevent node from exiting
  //uv_async_init( uv_default_loop(),
  //               &ODBC::g_async,
  //               ODBC::WatcherCallback);
  
  // Not sure if the init automatically calls uv_ref() because there is weird
  // behavior going on. When ODBC::Init is called which initializes the 
  // uv_async_t g_async above, there seems to be a ref which will keep it alive
  // but we only want this available so that we can uv_ref() later on when
  // we have a connection.
  // so to work around this, I am possibly mistakenly calling uv_unref() once
  // so that there are no references on the loop.
  //uv_unref((uv_handle_t *)&ODBC::g_async);
#endif
  
  // Initialize the cross platform mutex provided by libuv
  uv_mutex_init(&ODBC::g_odbcMutex);
}
void XpcConnection::Init(v8::Handle<v8::Object> target) {
  v8::HandleScope scope;

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

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

  NODE_SET_PROTOTYPE_METHOD(s_ct, "setup", XpcConnection::Setup);
  NODE_SET_PROTOTYPE_METHOD(s_ct, "sendMessage", XpcConnection::SendMessage);

  target->Set(v8::String::NewSymbol("XpcConnection"), s_ct->GetFunction());
}
예제 #13
0
static v8::Handle<v8::FunctionTemplate> ConfigureV8TestExceptionTemplate(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, "TestException", v8::Local<v8::FunctionTemplate>(), V8TestException::internalFieldCount,
        V8TestExceptionAttributes, WTF_ARRAY_LENGTH(V8TestExceptionAttributes),
        0, 0, isolate, currentWorldType);
    UNUSED_PARAM(defaultSignature);

    // Custom toString template
    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    return desc;
}
예제 #14
0
void batchConfigureCallbacks(v8::Handle<v8::ObjectTemplate> proto, 
                             v8::Handle<v8::Signature> signature, 
                             v8::PropertyAttribute attributes,
                             const BatchedCallback* callbacks,
                             size_t callbackCount)
{
    for (size_t i = 0; i < callbackCount; ++i) {
        proto->Set(v8::String::New(callbacks[i].name),
                   v8::FunctionTemplate::New(callbacks[i].callback, 
                                             v8::Handle<v8::Value>(),
                                             signature),
                   attributes);
    }
}
예제 #15
0
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());
}
예제 #16
0
void JSInterleavedVideoFrame::PopulateInstance(v8::Handle<v8::Object> inst) {
	inst->Set(JSPROP_NAME("pitch"), v8::Int32::New(frame->GetPitch()), JSPROP_READONLY);
	inst->Set(JSPROP_NAME("rowSize"), v8::Int32::New(frame->GetRowSize()), JSPROP_READONLY);
	inst->Set(JSPROP_NAME("width"), v8::Int32::New(frame->GetRowSize() / vi.BytesFromPixels(1)), JSPROP_READONLY);
	inst->Set(JSPROP_NAME("height"), v8::Int32::New(frame->GetHeight()), JSPROP_READONLY);
	inst->Set(JSPROP_NAME("bitsPerPixel"), v8::Int32::New(vi.BitsPerPixel()), JSPROP_READONLY);
	inst->Set(JSPROP_NAME("bytesPerPixel"), v8::Int32::New(vi.BytesFromPixels(1)), JSPROP_READONLY);
	inst->SetInternalField(0, v8::External::New(this));
}
예제 #17
0
파일: object.hpp 프로젝트: tempbottle/v8pp
bool set_option(v8::Isolate* isolate, v8::Handle<v8::Object> options,
	char const* name, T const& value)
{
	char const* dot = strchr(name, '.');
	if (dot)
	{
		std::string const subname(name, dot);
		v8::HandleScope scope(isolate);
		v8::Local<v8::Object> suboptions;
		return get_option(isolate, options, subname.c_str(), suboptions)
			&& set_option(isolate, suboptions, dot + 1, value);
	}
	options->Set(v8pp::to_v8(isolate, name), to_v8(isolate, value));
	return true;
}
예제 #18
0
void BGJSModule::javaToJsField (v8::Isolate* isolate, const char* fieldName,
        const char fieldType, JNIEnv *env, jobject &jobj, v8::Handle<v8::Object> &jsObj) {
	jclass clazz = env->GetObjectClass(jobj);
	switch (fieldType) {
		case 's': {
			jfieldID fieldId = env->GetFieldID(clazz, fieldName, "Ljava/lang/String;");
			if (fieldId) {
				jstring javaString = (jstring)env->GetObjectField(jobj, fieldId);
				if (javaString) {
					const char *nativeString = env->GetStringUTFChars(javaString, 0);
					jsObj->Set(String::NewFromUtf8(isolate, fieldName), String::NewFromUtf8(isolate, nativeString));
					env->ReleaseStringUTFChars(javaString, nativeString);
				} else {
					LOGD("Couldn't retrieve java string for field %s", fieldName);
				}
			} else {
				LOGD("Couldn't find fieldId for string field %s", fieldName);
			}
			break;
		}
		case 'I': {
			jfieldID fieldId = env->GetFieldID(clazz, fieldName, "I");
			if (fieldId) {
				jint data = env->GetIntField(jobj, fieldId);
				if (env->ExceptionCheck()) {
					LOGD("Couldn't get int field for field %s", fieldName);
				}
				jsObj->Set(String::NewFromUtf8(isolate, fieldName), Integer::New(isolate, (int)data));
			} else {
				LOGD("Couldn't find fieldId for int field %s", fieldName);
			}

			break;
		}
	}
}
예제 #19
0
void  UnZip_Wrap::Init(v8::Handle<v8::Object> exports) {
  Isolate* isolate = Isolate::GetCurrent();

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

  // Prototype
  NODE_SET_PROTOTYPE_METHOD(tpl, "run", Run);

  //add other if exists..
  constructor.Reset(isolate, tpl->GetFunction());
  exports->Set(String::NewFromUtf8(isolate, "Unzipper"), tpl->GetFunction());
}
예제 #20
0
void ProcessWrap::Init(v8::Handle<v8::Object> exports)
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();

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

    // Prototypes
    NODE_SET_PROTOTYPE_METHOD(tpl, "Attach", Attach);

    constructor.Reset(isolate, tpl->GetFunction());
    exports->Set(v8::String::NewFromUtf8(isolate, "ProcessWrap"), tpl->GetFunction());
}
예제 #21
0
파일: settergetter.cpp 프로젝트: 4ver/nan
void SetterGetter::Init(v8::Handle<v8::Object> target) {
  v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(SetterGetter::New)
;
  NanAssignPersistent(v8::FunctionTemplate, settergetter_constructor, tpl);
  tpl->SetClassName(NanSymbol("SetterGetter"));
  tpl->InstanceTemplate()->SetInternalFieldCount(1);
  NODE_SET_PROTOTYPE_METHOD(tpl, "log", SetterGetter::Log);
  v8::Local<v8::ObjectTemplate> proto = tpl->PrototypeTemplate();
  proto->SetAccessor(NanSymbol("prop1"), SetterGetter::GetProp1);
  proto->SetAccessor(NanSymbol("prop2"), SetterGetter::GetProp2, SetterGetter::SetProp2);

  v8::Local<v8::Function> createnew =
    v8::FunctionTemplate::New(CreateNew)->GetFunction();
  target->Set(NanSymbol("create"), createnew);
}
예제 #22
0
 void OSMNodeWrap::Initialize(v8::Handle<v8::Object> target) {
     v8::HandleScope scope;
     constructor = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(OSMNodeWrap::New));
     constructor->Inherit(OSMObjectWrap::constructor);
     constructor->InstanceTemplate()->SetInternalFieldCount(1);
     constructor->SetClassName(v8::String::NewSymbol("Node"));
     node::SetPrototypeMethod(constructor, "wkb", wkb);
     node::SetPrototypeMethod(constructor, "wkt", wkt);
     auto attributes = static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);
     set_accessor(constructor, "location", get_coordinates, attributes);
     set_accessor(constructor, "coordinates", get_coordinates, attributes);
     set_accessor(constructor, "lon", get_lon, attributes);
     set_accessor(constructor, "lat", get_lat, attributes);
     target->Set(v8::String::NewSymbol("Node"), constructor->GetFunction());
 }
예제 #23
0
        static void Init(v8::Handle<v8::Object> exports) {
            v8::Isolate* isolate = Isolate::GetCurrent();

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

            // Prototype
            NODE_SET_PROTOTYPE_METHOD(tpl, "isAvailable", isAvailable);
            NODE_SET_PROTOTYPE_METHOD(tpl, "getNFilters", getNFilters);
            NODE_SET_PROTOTYPE_METHOD(tpl, "getFilter", getFilter);

            Constructor.Reset(v8::Isolate::GetCurrent(), tpl);
            exports->Set(v8::String::NewFromUtf8(isolate, "Filters"), tpl->GetFunction());
        }
static void installV8SVGTestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
    functionTemplate->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "SVGTestInterface", v8::Local<v8::FunctionTemplate>(), V8SVGTestInterface::internalFieldCount,
        V8SVGTestInterfaceAttributes, WTF_ARRAY_LENGTH(V8SVGTestInterfaceAttributes),
        0, 0,
        0, 0,
        isolate);
    v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();

    // Custom toString template
    functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
}
예제 #25
0
static void configureV8TestInterfaceEventTargetTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
{
    functionTemplate->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEventTarget", V8EventTarget::domTemplate(isolate), V8TestInterfaceEventTarget::internalFieldCount,
        0, 0,
        0, 0,
        0, 0,
        isolate);
    v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();

    // Custom toString template
    functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
}
예제 #26
0
void XpcConnection::Init(v8::Handle<v8::Object> target) {
  NanScope();

  v8::Local<v8::FunctionTemplate> t = NanNew<v8::FunctionTemplate>(XpcConnection::New);

  NanAssignPersistent(s_ct, t);

  NanNew(s_ct)->SetClassName(NanNew("XpcConnection"));

  NanNew(s_ct)->InstanceTemplate()->SetInternalFieldCount(1);

  NODE_SET_PROTOTYPE_METHOD(NanNew(s_ct), "setup", XpcConnection::Setup);
  NODE_SET_PROTOTYPE_METHOD(NanNew(s_ct), "sendMessage", XpcConnection::SendMessage);

  target->Set(NanNew("XpcConnection"), NanNew(s_ct)->GetFunction());
}
예제 #27
0
void NODE_EXTERN Contacts::Init(v8::Handle<v8::Object> target) {
    AppLog("Entered Contacts::Init");

    v8::Local<v8::FunctionTemplate> funcTemplate = v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(Contacts::New));

    funcTemplate->SetClassName(v8::String::NewSymbol("Contacts"));
    funcTemplate->Set(v8::String::NewSymbol("list"), v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(list))->GetFunction());
    funcTemplate->Set(v8::String::NewSymbol("addCategory"), v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(addCategory))->GetFunction());
    funcTemplate->Set(v8::String::NewSymbol("removeCategory"), v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(removeCategory))->GetFunction());
    funcTemplate->Set(v8::String::NewSymbol("renameCategory"), v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(renameCategory))->GetFunction());
    funcTemplate->Set(v8::String::NewSymbol("isExistCategory"), v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(isExistCategory))->GetFunction());
    funcTemplate->Set(v8::String::NewSymbol("add"), v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(add))->GetFunction());
    funcTemplate->Set(v8::String::NewSymbol("remove"), v8::Local<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(remove))->GetFunction());

    target->Set(v8::String::NewSymbol("Contacts"), funcTemplate->GetFunction());
}
static v8::Handle<v8::FunctionTemplate> ConfigureV8TestEventConstructorTemplate(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
{
    desc->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestEventConstructor", v8::Local<v8::FunctionTemplate>(), V8TestEventConstructor::internalFieldCount,
        V8TestEventConstructorAttrs, WTF_ARRAY_LENGTH(V8TestEventConstructorAttrs),
        0, 0, isolate, currentWorldType);
    UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
    desc->SetCallHandler(V8TestEventConstructor::constructorCallback);
    desc->SetLength(1);

    // Custom toString template
    desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
    return desc;
}
static void configureV8TestInterfacePython3Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
{
    functionTemplate->ReadOnlyPrototype();

    v8::Local<v8::Signature> defaultSignature;
    defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfacePython3", v8::Local<v8::FunctionTemplate>(), V8TestInterfacePython3::internalFieldCount,
        0, 0,
        0, 0,
        0, 0,
        isolate, currentWorldType);
    v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
    v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();

    // Custom toString template
    functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
}
예제 #30
0
void Init(v8::Handle<v8::Object> exports)
{
    Symbols::Init();
    InitDevice(exports);
    ArrayWrapper::Init(exports);
    InitCreateArray(exports);
    InitMoveAndReorderArray(exports);
    InitArrayHelperFunctions(exports);
    InitMathFunctions(exports);
    InitVectorAlgorithms(exports);
    InitStatistics(exports);
    InitComputerVision(exports);

    // Helpers:
    exports->Set(NanNew("_doEvents"), NanNew<FunctionTemplate>(_DoEvents)->GetFunction());
}