void Image::Initialize(Handle<Object> target) {

    NanScope();

    Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Image::New);
    lcons->InstanceTemplate()->SetInternalFieldCount(1);
    lcons->SetClassName(NanNew("Image"));

    NODE_SET_PROTOTYPE_METHOD(lcons, "getPixel", getPixel);
    NODE_SET_PROTOTYPE_METHOD(lcons, "setPixel", setPixel);
    NODE_SET_PROTOTYPE_METHOD(lcons, "encodeSync", encodeSync);
    NODE_SET_PROTOTYPE_METHOD(lcons, "encode", encode);
    NODE_SET_PROTOTYPE_METHOD(lcons, "view", view);
    NODE_SET_PROTOTYPE_METHOD(lcons, "save", save);
    NODE_SET_PROTOTYPE_METHOD(lcons, "setGrayScaleToAlpha", setGrayScaleToAlpha);
    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, "composite", composite);
    NODE_SET_PROTOTYPE_METHOD(lcons, "premultiplySync", premultiplySync);
    NODE_SET_PROTOTYPE_METHOD(lcons, "premultiply", premultiply);
    NODE_SET_PROTOTYPE_METHOD(lcons, "demultiplySync", demultiplySync);
    NODE_SET_PROTOTYPE_METHOD(lcons, "demultiply", demultiply);
    NODE_SET_PROTOTYPE_METHOD(lcons, "clear", clear);
    NODE_SET_PROTOTYPE_METHOD(lcons, "clearSync", clear);
    NODE_SET_PROTOTYPE_METHOD(lcons, "compare", compare);

    ATTR(lcons, "background", get_prop, set_prop);

    // This *must* go after the ATTR setting
    NODE_SET_METHOD(lcons->GetFunction(),
                    "open",
                    Image::open);
    NODE_SET_METHOD(lcons->GetFunction(),
                    "fromBytes",
                    Image::fromBytes);
    NODE_SET_METHOD(lcons->GetFunction(),
                    "openSync",
                    Image::openSync);
    NODE_SET_METHOD(lcons->GetFunction(),
                    "fromBytesSync",
                    Image::fromBytesSync);
    target->Set(NanNew("Image"),lcons->GetFunction());
    NanAssignPersistent(constructor, lcons);
}
Exemple #2
0
Shell::Shell() {
	prompt = ">>>";
	HandleScope handle_scope;
	Handle<ObjectTemplate> global = ObjectTemplate::New();
	
	global->Set(String::New("print"), FunctionTemplate::New(Print));
	global->Set(String::New("read"), FunctionTemplate::New(Read));
	global->Set(String::New("load"), FunctionTemplate::New(Load));
	global->Set(String::New("include"), FunctionTemplate::New(Load));
	global->Set(String::New("quit"), FunctionTemplate::New(Quit));
	global->Set(String::New("version"), FunctionTemplate::New(Version));
	
	global->Set(String::New("XML"), FunctionTemplate::New(loadXML));
	global->Set(String::New("HTTPClient"), FunctionTemplate::New(loadHTTPClient));
	global->Set(String::New("SOAP"), FunctionTemplate::New(loadSoapLoader));
	global->Set(String::New("File"), FunctionTemplate::New(loadFile));
	
	globalTemplate = Persistent<ObjectTemplate>::New(global);	
	Handle<Context> context = Context::New(NULL, globalTemplate);
	globalContext = Persistent<Context>::New(context);
	// Enter the newly created execution environment.	
	
}
void Pngquant::Init(Handle<Object> exports) {
    HandleScope scope;

    Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
    Local<String> name = String::NewSymbol("Pngquant");

    constructor = Persistent<FunctionTemplate>::New(tpl);
    // ObjectWrap uses the first internal field to store the wrapped pointer.
    constructor->InstanceTemplate()->SetInternalFieldCount(1);
    constructor->SetClassName(name);

    // Add all prototype methods, getters and setters here.
    NODE_SET_PROTOTYPE_METHOD(constructor, "compress", Compress);

    // This has to be last, otherwise the properties won't show up on the
    // object in JavaScript.
    exports->Set(name, constructor->GetFunction());
}
    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, "hello", Hello);
    NODE_SET_PROTOTYPE_METHOD(s_ct, "index", IndexFiles);
    NODE_SET_PROTOTYPE_METHOD(s_ct, "search", SearchFiles);
    NODE_SET_PROTOTYPE_METHOD(s_ct, "indexText", IndexText);

    target->Set(String::NewSymbol("Lucene"),
                s_ct->GetFunction());
  }
void Connection::Init(Handle<Object> target) {
  HandleScope scope;

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

  NODE_SET_PROTOTYPE_METHOD(constructorTemplate, "execute", Execute);
  NODE_SET_PROTOTYPE_METHOD(constructorTemplate, "executeSync", ExecuteSync);
  NODE_SET_PROTOTYPE_METHOD(constructorTemplate, "close", Close);
  NODE_SET_PROTOTYPE_METHOD(constructorTemplate, "isConnected", IsConnected);
  NODE_SET_PROTOTYPE_METHOD(constructorTemplate, "setAutoCommit", SetAutoCommit);
  NODE_SET_PROTOTYPE_METHOD(constructorTemplate, "commit", Commit);
  NODE_SET_PROTOTYPE_METHOD(constructorTemplate, "rollback", Rollback);

  target->Set(String::NewSymbol("Connection"), constructorTemplate->GetFunction());
}
Exemple #6
0
void InitLa(Handle<Object> Exports, const TStr& NsNm) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);

	Handle<Object> NsObj = Object::New(Isolate);

	TNodeJsLinAlg::Init(NsObj);
	TNodeJsVec<TFlt, TAuxFltV>::Init(NsObj);
	TNodeJsVec<TInt, TAuxIntV>::Init(NsObj);
	TNodeJsVec<TStr, TAuxStrV>::Init(NsObj);

	TNodeJsBoolV::Init(NsObj);
	TNodeJsFltVV::Init(NsObj);
	TNodeJsSpVec::Init(NsObj);
	TNodeJsSpMat::Init(NsObj);

	Exports->Set(String::NewFromUtf8(Isolate, NsNm.CStr()), NsObj);
}
 Handle<Value> ASGetRegisteredAnimations(const Arguments& args)
 {
    dtEntity::AnimationSystem* ss = UnwrapAnimationSystem(args.This());
    dtEntity::Component* acomp = ss->GetComponent(args[0]->Uint32Value());
    if(acomp == NULL) 
    {
       return ThrowError("Cannot get registered animations: component with this entity id not found!");
    }
    std::vector<std::string> names;
    static_cast<dtEntity::AnimationComponent*>(acomp)->GetRegisteredAnimations(names);
    HandleScope scope;
    Handle<Array> arr = Array::New(names.size());
    for(unsigned int i = 0; i < names.size(); ++i)
    {
       arr->Set(Int32::New(i), String::New(names[i].c_str()));
    }
    return scope.Close(arr);
 }
void Geometry::Initialize(Handle<Object> target) {

    HandleScope scope;

    constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Geometry::New));
    constructor->InstanceTemplate()->SetInternalFieldCount(1);
    constructor->SetClassName(String::NewSymbol("Geometry"));

    NODE_SET_PROTOTYPE_METHOD(constructor, "extent", extent);
    NODE_SET_PROTOTYPE_METHOD(constructor, "type", type);
    NODE_MAPNIK_DEFINE_CONSTANT(constructor->GetFunction(),
                                "Point",MAPNIK_POINT)
    NODE_MAPNIK_DEFINE_CONSTANT(constructor->GetFunction(),
                                "LineString",MAPNIK_LINESTRING)
    NODE_MAPNIK_DEFINE_CONSTANT(constructor->GetFunction(),
                                "Polygon",MAPNIK_POLYGON)
    target->Set(String::NewSymbol("Geometry"),constructor->GetFunction());
}
    // var notify = require("../build/default/RCSwitchNode.node"); will bind our constructor function to rcswitch.RCSwitch
    // so that we can call "new rcswitch.RCSwitch();"
    static void Init(Handle<Object> target) {
      v8::HandleScope scope;

      v8::Local<FunctionTemplate> local_function_template = v8::FunctionTemplate::New(New);
      RCSwitchNode::persistent_function_template = v8::Persistent<FunctionTemplate>::New(local_function_template);
      RCSwitchNode::persistent_function_template->InstanceTemplate()->SetInternalFieldCount(1); // 1 since this is a constructor function
      RCSwitchNode::persistent_function_template->SetClassName(v8::String::NewSymbol("RCSwitch"));
      
      RCSwitchNode::persistent_function_template->InstanceTemplate()->SetAccessor(String::New("protocol"), GetProtocol, SetProtocol);
      
      NODE_SET_PROTOTYPE_METHOD(RCSwitchNode::persistent_function_template, "send", Send);
      NODE_SET_PROTOTYPE_METHOD(RCSwitchNode::persistent_function_template, "enableTransmit", EnableTransmit);
      NODE_SET_PROTOTYPE_METHOD(RCSwitchNode::persistent_function_template, "disableTransmit", DisableTransmit);
      NODE_SET_PROTOTYPE_METHOD(RCSwitchNode::persistent_function_template, "switchOn", SwitchOn);
      NODE_SET_PROTOTYPE_METHOD(RCSwitchNode::persistent_function_template, "switchOff", SwitchOff);
      
      target->Set(String::NewSymbol("RCSwitch"), RCSwitchNode::persistent_function_template->GetFunction());
    }
void ImageView::Initialize(Handle<Object> target) {

    HandleScope scope;

    constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(ImageView::New));
    constructor->InstanceTemplate()->SetInternalFieldCount(1);
    constructor->SetClassName(String::NewSymbol("ImageView"));

    NODE_SET_PROTOTYPE_METHOD(constructor, "encodeSync", encodeSync);
    NODE_SET_PROTOTYPE_METHOD(constructor, "encode", encode);
    NODE_SET_PROTOTYPE_METHOD(constructor, "save", save);
    NODE_SET_PROTOTYPE_METHOD(constructor, "width", width);
    NODE_SET_PROTOTYPE_METHOD(constructor, "height", height);
    NODE_SET_PROTOTYPE_METHOD(constructor, "isSolid", isSolid);
    NODE_SET_PROTOTYPE_METHOD(constructor, "getPixel", getPixel);

    target->Set(String::NewSymbol("ImageView"),constructor->GetFunction());
}
Exemple #11
0
void Polygon::Initialize(Handle<Object> target)
{
	NanScope();

	Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Polygon::New);
	lcons->Inherit(NanNew(Geometry::constructor));
	lcons->InstanceTemplate()->SetInternalFieldCount(1);
	lcons->SetClassName(NanNew("Polygon"));

	NODE_SET_PROTOTYPE_METHOD(lcons, "toString", toString);
	NODE_SET_PROTOTYPE_METHOD(lcons, "getArea", getArea);

	ATTR(lcons, "rings", ringsGetter, READ_ONLY_SETTER);

	target->Set(NanNew("Polygon"), lcons->GetFunction());

	NanAssignPersistent(constructor, lcons);
}
Exemple #12
0
void v8Music::initialize(Handle<ObjectTemplate> target) {
	HandleScope scope;

	constructor_template = Persistent<FunctionTemplate>::New(
		FunctionTemplate::New(v8Music::New)
	);
	constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
	constructor_template->SetClassName(String::NewSymbol("Music"));

	V8_SET_PROTOTYPE_METHOD(constructor_template, "%fadeIn", v8Music::FadeIn);
	V8_SET_PROTOTYPE_METHOD(constructor_template, "%fadeOut", v8Music::FadeOut);
	V8_SET_PROTOTYPE_METHOD(constructor_template, "%play", v8Music::Play);
	V8_SET_PROTOTYPE_METHOD(constructor_template, "%stop", v8Music::Stop);

	V8_SET_METHOD(constructor_template, "%load", v8Music::Load);

	target->Set(String::NewSymbol("Music"), constructor_template);
}
Exemple #13
0
  void GlobalVariable::Init(Handle<Object> target) {
    Nan::HandleScope scope;

    Local<v8::FunctionTemplate> ctor = Nan::New<v8::FunctionTemplate>(New);
    constructor.Reset(ctor);

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

    Nan::SetPrototypeMethod (ctor, "dump", GlobalVariable::Dump);
    Nan::SetPrototypeMethod (ctor, "setInitializer", GlobalVariable::SetInitializer);
    Nan::SetPrototypeMethod (ctor, "setAlignment", GlobalVariable::SetAlignment);
    Nan::SetPrototypeMethod (ctor, "toString", GlobalVariable::ToString);

    Local<v8::Function> ctor_func = ctor->GetFunction();
    constructor_func.Reset(ctor_func);
    target->Set(Nan::New("GlobalVariable").ToLocalChecked(), ctor_func);
  }
Exemple #14
0
void Point::Initialize(Handle<Object> target)
{
	HandleScope scope;

	constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(Point::New));
	constructor->Inherit(Geometry::constructor);
	constructor->InstanceTemplate()->SetInternalFieldCount(1);
	constructor->SetClassName(String::NewSymbol("Point"));

	NODE_SET_PROTOTYPE_METHOD(constructor, "toString", toString);

	// properties
	ATTR(constructor, "x", xGetter, xSetter);
	ATTR(constructor, "y", yGetter, ySetter);
	ATTR(constructor, "z", zGetter, zSetter);

	target->Set(String::NewSymbol("Point"), constructor->GetFunction());
}
Exemple #15
0
void HashTable::init(Handle<Object> exports) {
  Local<FunctionTemplate> constructor = FunctionTemplate::New(Constructor);
  constructor->SetClassName(String::NewSymbol("HashTable"));
  constructor->InstanceTemplate()->SetInternalFieldCount(1);

  auto prototype = constructor->PrototypeTemplate();
  prototype->Set("put", FunctionTemplate::New(Put)->GetFunction());
  prototype->Set("get", FunctionTemplate::New(Get)->GetFunction());
  prototype->Set("keys", FunctionTemplate::New(Keys)->GetFunction());
  prototype->Set("remove", FunctionTemplate::New(Remove)->GetFunction());
  prototype->Set("clear", FunctionTemplate::New(Clear)->GetFunction());
  prototype->Set("size", FunctionTemplate::New(Size)->GetFunction());
  prototype->Set("rehash", FunctionTemplate::New(Rehash)->GetFunction());
  prototype->Set("reserve", FunctionTemplate::New(Reserve)->GetFunction());
  prototype->Set("max_load_factor", FunctionTemplate::New(MaxLoadFactor)->GetFunction());

  exports->Set(String::NewSymbol("HashTable"), Persistent<Function>::New(constructor->GetFunction()));
}
void Datasource::Initialize(Handle<Object> target) {

    NanScope();

    Local<FunctionTemplate> lcons = NanNew<FunctionTemplate>(Datasource::New);
    lcons->InstanceTemplate()->SetInternalFieldCount(1);
    lcons->SetClassName(NanNew("Datasource"));

    // methods
    NODE_SET_PROTOTYPE_METHOD(lcons, "parameters", parameters);
    NODE_SET_PROTOTYPE_METHOD(lcons, "describe", describe);
    NODE_SET_PROTOTYPE_METHOD(lcons, "features", features);
    NODE_SET_PROTOTYPE_METHOD(lcons, "featureset", featureset);
    NODE_SET_PROTOTYPE_METHOD(lcons, "extent", extent);

    target->Set(NanNew("Datasource"), lcons->GetFunction());
    NanAssignPersistent(constructor, lcons);
}
Exemple #17
0
void Statement::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("Statement"));
	NODE_SET_PROTOTYPE_METHOD(s_ct,"moveFirst",MoveFirst);
	NODE_SET_PROTOTYPE_METHOD(s_ct,"moveNext",MoveNext);
	NODE_SET_PROTOTYPE_METHOD(s_ct,"getFieldCount",GetFieldCount);
	NODE_SET_PROTOTYPE_METHOD(s_ct,"getRecordCount",GetRecordCount);
	NODE_SET_PROTOTYPE_METHOD(s_ct,"getFieldValueByIndex",GetFieldValueByIndex);
	NODE_SET_PROTOTYPE_METHOD(s_ct,"getFieldValueByName",GetFieldValueByName);
	NODE_SET_PROTOTYPE_METHOD(s_ct,"getFieldName",GetFieldName);
	target->Set(String::NewSymbol("Statement"),s_ct->GetFunction());


}
void IndexBound_initOnLoad(Handle<Object> target) {
    Persistent<Object> ibObj = Persistent<Object>(Object::New());
    Persistent<String> ibKey = Persistent<String>(String::NewSymbol("IndexBound"));
    target->Set(ibKey, ibObj);

    DEFINE_JS_FUNCTION(ibObj, "create", newIndexBound);

    Persistent<Object> BoundHelper = Persistent<Object>(Object::New());
    ibObj->Set(Persistent<String>(String::NewSymbol("helper")), BoundHelper);

    DEFINE_JS_INT(BoundHelper, "low_key", BOUND_LOW_KEY);
    DEFINE_JS_INT(BoundHelper, "low_key_count", BOUND_LOW_KEY_COUNT);
    DEFINE_JS_INT(BoundHelper, "low_inclusive", BOUND_LOW_INCLUSIVE);
    DEFINE_JS_INT(BoundHelper, "high_key", BOUND_HIGH_KEY);
    DEFINE_JS_INT(BoundHelper, "high_key_count", BOUND_HIGH_KEY_COUNT);
    DEFINE_JS_INT(BoundHelper, "high_inclusive", BOUND_HIGH_INCLUSIVE);
    DEFINE_JS_INT(BoundHelper, "range_no", BOUND_RANGE_NO);
}
void Nodehun::SpellDictionary::Init(Handle<Object> target) {
  HandleScope scope;
  
  Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
  Local<String> name = String::NewSymbol("Dictionary");
  
  constructor = Persistent<FunctionTemplate>::New(tpl);
  constructor->InstanceTemplate()->SetInternalFieldCount(5);
  constructor->SetClassName(name);
  
  NODE_SET_PROTOTYPE_METHOD(constructor, "spellSuggest", spellSuggest);
  NODE_SET_PROTOTYPE_METHOD(constructor, "spellSuggestions", spellSuggestions);
  NODE_SET_PROTOTYPE_METHOD(constructor,"addDictionary", addDictionary);
  NODE_SET_PROTOTYPE_METHOD(constructor,"addWord", addWord);
  NODE_SET_PROTOTYPE_METHOD(constructor,"removeWord", removeWord);
  
  target->Set(name, constructor->GetFunction());
}
Exemple #20
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());
}
Exemple #21
0
/**
 * @details This is called from the module initialisation function
 * when the module is first loaded by Node. It should only be called
 * once per process.
 *
 * @param target The object representing the module.
 */
void Map::Init(Handle<Object> target) {
  HandleScope scope;

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

  map_template = Persistent<FunctionTemplate>::New(template_);
  map_template->InstanceTemplate()->SetInternalFieldCount(1);
  map_template->SetClassName(String::NewSymbol("Map"));

  data_symbol = NODE_PSYMBOL("data");
  headers_symbol = NODE_PSYMBOL("headers");

  NODE_SET_PROTOTYPE_METHOD(map_template, "mapserv", MapservAsync);
  NODE_SET_METHOD(map_template, "FromFile", FromFileAsync);
  NODE_SET_METHOD(map_template, "FromString", FromStringAsync);

  target->Set(String::NewSymbol("Map"), map_template->GetFunction());
}
Exemple #22
0
void IndexBound_initOnLoad(Handle<Object> target) {
  Local<Object> ibObj = Object::New(Isolate::GetCurrent());
  Local<String> ibKey = NEW_SYMBOL("IndexBound");
  target->Set(ibKey, ibObj);

  DEFINE_JS_FUNCTION(ibObj, "create", newIndexBound);

  Local<Object> BoundHelper = Object::New(Isolate::GetCurrent());
  ibObj->Set(NEW_SYMBOL("helper"), BoundHelper);

  DEFINE_JS_INT(BoundHelper, "low_key", BOUND_LOW_KEY);
  DEFINE_JS_INT(BoundHelper, "low_key_count", BOUND_LOW_KEY_COUNT);
  DEFINE_JS_INT(BoundHelper, "low_inclusive", BOUND_LOW_INCLUSIVE);
  DEFINE_JS_INT(BoundHelper, "high_key", BOUND_HIGH_KEY);
  DEFINE_JS_INT(BoundHelper, "high_key_count", BOUND_HIGH_KEY_COUNT);
  DEFINE_JS_INT(BoundHelper, "high_inclusive", BOUND_HIGH_INCLUSIVE);
  DEFINE_JS_INT(BoundHelper, "range_no", BOUND_RANGE_NO);
}
void LineStringPoints::Initialize(Handle<Object> target)
{
	HandleScope scope;

	constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(LineStringPoints::New));
	constructor->InstanceTemplate()->SetInternalFieldCount(1);
	constructor->SetClassName(String::NewSymbol("LineStringPoints"));

	NODE_SET_PROTOTYPE_METHOD(constructor, "toString", toString);
	NODE_SET_PROTOTYPE_METHOD(constructor, "count", count);
	NODE_SET_PROTOTYPE_METHOD(constructor, "get", get);
	NODE_SET_PROTOTYPE_METHOD(constructor, "set", set);
	NODE_SET_PROTOTYPE_METHOD(constructor, "add", add);
	NODE_SET_PROTOTYPE_METHOD(constructor, "reverse", reverse);
	NODE_SET_PROTOTYPE_METHOD(constructor, "resize", resize);

	target->Set(String::NewSymbol("LineStringPoints"), constructor->GetFunction());
}
Exemple #24
0
void Nodehun::SpellDictionary::Init(Handle<Object> exports, Handle<Object> module) {
  HandleScope scope;
  
  Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
  
  constructor = Persistent<FunctionTemplate>::New(tpl);
  constructor->InstanceTemplate()->SetInternalFieldCount(6);
  constructor->SetClassName(String::NewSymbol("NodehunDictionary"));
  
  NODE_SET_PROTOTYPE_METHOD(constructor, "spellSuggest", spellSuggest);
  NODE_SET_PROTOTYPE_METHOD(constructor, "spellSuggestions", spellSuggestions);
  NODE_SET_PROTOTYPE_METHOD(constructor,"addDictionary", addDictionary);
  NODE_SET_PROTOTYPE_METHOD(constructor,"addWord", addWord);
  NODE_SET_PROTOTYPE_METHOD(constructor,"removeWord", removeWord);
  NODE_SET_PROTOTYPE_METHOD(constructor,"stem", stem);
  
  module->Set(String::NewSymbol("exports"), constructor->GetFunction());
}
Exemple #25
0
void ConnectionPool::Init(Handle<Object> target) {
  Nan::HandleScope scope;

  Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(ConnectionPool::New);
  ConnectionPool::s_ct.Reset( t);

  t->InstanceTemplate()->SetInternalFieldCount(1);
  t->SetClassName(Nan::New<String>("ConnectionPool").ToLocalChecked());

  Nan::SetPrototypeMethod(t, "getConnectionSync", ConnectionPool::GetConnectionSync);
  Nan::SetPrototypeMethod(t, "getConnection", ConnectionPool::GetConnection);
  Nan::SetPrototypeMethod(t, "execute", ConnectionPool::Execute);
  Nan::SetPrototypeMethod(t, "close", ConnectionPool::Close);
  Nan::SetPrototypeMethod(t, "closeSync", ConnectionPool::CloseSync);
  Nan::SetPrototypeMethod(t, "getInfo", ConnectionPool::GetInfo);

  target->Set(Nan::New<String>("ConnectionPool").ToLocalChecked(), t->GetFunction());
}
void MSMap::Initialize(Handle<Object> target) {
  HandleScope scope;

  constructor = Persistent<FunctionTemplate>::New(FunctionTemplate::New(MSMap::New));
  constructor->InstanceTemplate()->SetInternalFieldCount(1);
  constructor->SetClassName(String::NewSymbol("Map"));

  NODE_SET_PROTOTYPE_METHOD(constructor, "clone", Clone);
  NODE_SET_PROTOTYPE_METHOD(constructor, "selectOutputFormat", SelectOutputFormat);
  NODE_SET_PROTOTYPE_METHOD(constructor, "setExtent", SetExtent);
  NODE_SET_PROTOTYPE_METHOD(constructor, "drawMap", DrawMap);
  NODE_SET_PROTOTYPE_METHOD(constructor, "recompute", Recompute);
  NODE_SET_PROTOTYPE_METHOD(constructor, "insertLayer", InsertLayer);
  NODE_SET_PROTOTYPE_METHOD(constructor, "setSymbolSet", SetSymbolSet);
  NODE_SET_PROTOTYPE_METHOD(constructor, "save", Save);
  NODE_SET_PROTOTYPE_METHOD(constructor, "getLabelCache", GetLabelCache);
  // NODE_SET_PROTOTYPE_METHOD(constructor, "copy", Copy);

  /* Read-Write Properties */
  RW_PROPERTY(constructor, "name", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "status", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "width", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "height", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "maxsize", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "units", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "resolution", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "defresolution", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "shapepath", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "mappath", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "imagetype", PropertyGetter, PropertySetter);
  RW_PROPERTY(constructor, "projection", PropertyGetter, PropertySetter);

  /* Read-Only Properties */
  RO_PROPERTY(constructor, "cellsize", PropertyGetter);
  RO_PROPERTY(constructor, "scaledenom", PropertyGetter);
  RO_PROPERTY(constructor, "mimetype", PropertyGetter);
  RO_PROPERTY(constructor, "outputformat", PropertyGetter);
  RO_PROPERTY(constructor, "metadata", PropertyGetter);

  RO_PROPERTY(constructor, "extent", PropertyGetter);
  RO_PROPERTY(constructor, "layers", PropertyGetter);

  target->Set(String::NewSymbol("Map"), constructor->GetFunction());
}
Exemple #27
0
	void Viewport::Initialize(Handle<Object> target)
	{
		HandleScope scope;

		/* Template */
		Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
		Local<String> name = String::NewSymbol("Viewport");

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

		/* Methods */
		Widget::PrototypeMethodsInit(constructor);
		Bin::PrototypeMethodsInit(constructor);

		target->Set(name, constructor->GetFunction());
	}
Exemple #28
0
	void LoadBase(){
		HandleScope store;

		Handle<Object> obj = GetGlobal();
		SET_OBJ_FUNC_RO(obj,alert,alert);
		SET_OBJ_FUNC_RO(obj,getPageCode,getPageCode);
		SET_OBJ_FUNC_RO(obj,require,require);
		SET_OBJ_FUNC_RO(obj,run,loadJsCode);
		SET_OBJ_FUNC_RO(obj,load,loadJsFile);
		SET_OBJ_FUNC_RO(obj,format,format);
		//SET_OBJ_FUNC_RO(obj,log,debug);
		SET_OBJ_FUNC_RO(obj,startMsgLoop,startMsgLoop);
		SET_OBJ_FUNC_RO(obj,exitMsgLoop,exitMsgLoop);
		SET_OBJ_FUNC_RO(obj,setConfig,setConfig);

		JsApp::Load(obj,L"App");

		obj->Set(String::New("Global"),obj,ReadOnly);
	}
Exemple #29
0
/*
   DESCRIPTION
     Init function of the Pool class.
     Initiates and maps the functions and properties of Pool class.
*/
void Pool::Init(Handle<Object> target)
{
  NanScope();

  Local<FunctionTemplate> temp = NanNew<FunctionTemplate>(New);
  temp->InstanceTemplate()->SetInternalFieldCount(1);
  temp->SetClassName(NanNew<v8::String>("Pool"));

  NODE_SET_PROTOTYPE_METHOD(temp, "terminate", Terminate);
  NODE_SET_PROTOTYPE_METHOD(temp, "getConnection", GetConnection);

  temp->InstanceTemplate()->SetAccessor(
                                        NanNew<v8::String>("poolMax"),
                                        Pool::GetPoolMax,
                                        Pool::SetPoolMax );
  temp->InstanceTemplate()->SetAccessor(
                                        NanNew<v8::String>("poolMin"),
                                        Pool::GetPoolMin,
                                        Pool::SetPoolMin );
  temp->InstanceTemplate()->SetAccessor(
                                        NanNew<v8::String>("poolIncrement"),
                                        Pool::GetPoolIncrement,
                                        Pool::SetPoolIncrement );
  temp->InstanceTemplate()->SetAccessor(
                                        NanNew<v8::String>("poolTimeout"),
                                        Pool::GetPoolTimeout,
                                        Pool::SetPoolTimeout );
  temp->InstanceTemplate()->SetAccessor(
                                        NanNew<v8::String>("connectionsOpen"),
                                        Pool::GetConnectionsOpen,
                                        Pool::SetConnectionsOpen );
  temp->InstanceTemplate()->SetAccessor(
                                        NanNew<v8::String>("connectionsInUse"),
                                        Pool::GetConnectionsInUse,
                                        Pool::SetConnectionsInUse );
  temp->InstanceTemplate()->SetAccessor(
                                        NanNew<v8::String>("stmtCacheSize"),
                                        Pool::GetStmtCacheSize,
                                        Pool::SetStmtCacheSize );

  NanAssignPersistent( poolTemplate_s, temp );
  target->Set(NanNew<v8::String>("Pool"),temp->GetFunction());
}
Exemple #30
0
void Text::Initialize(Handle<Object> target)
{
    HandleScope scope;

    Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
    tpl->InstanceTemplate()->SetInternalFieldCount(1);
    Local<String> name = String::NewSymbol("Text");

    /* Methods */
    Actor::PrototypeMethodsInit(tpl);
    NODE_SET_PROTOTYPE_METHOD(tpl, "setColor", Text::SetColor);
    NODE_SET_PROTOTYPE_METHOD(tpl, "getColor", Text::GetColor);
    NODE_SET_PROTOTYPE_METHOD(tpl, "setText", Text::SetText);
    NODE_SET_PROTOTYPE_METHOD(tpl, "getText", Text::GetText);
    NODE_SET_PROTOTYPE_METHOD(tpl, "setFontName", Text::SetFontName);
    NODE_SET_PROTOTYPE_METHOD(tpl, "getFontName", Text::GetFontName);

    target->Set(name, tpl->GetFunction());
}