Handle<ObjectTemplate> getPlayerTemplate(){
    Handle<ObjectTemplate> player = ObjectTemplate::New();
    player->SetAccessor(String::New("x"), PlayerXGetter, PlayerXSetter);
    player->SetAccessor(String::New("y"), PlayerYGetter, PlayerYSetter);
    player->SetAccessor(String::New("direction"), PlayerDirectionGetter, PlayerDirectionSetter);
    player->SetAccessor(String::New("speed"), PlayerSpeedGetter, PlayerSpeedSetter);
    player->Set(String::New("move"), FunctionTemplate::New(PlayerMove));

    return( player );
}
void AddFontStateAcessors(Handle<ObjectTemplate> &templ)
{
	HandleScope scope;
	
	templ->SetAccessor(String::New("face"), Get_FontState_face, Set_FontState_face);
	templ->SetAccessor(String::New("size"), Get_FontState_size, Set_FontState_size);
	templ->SetAccessor(String::New("italic"), Get_FontState_italic, Set_FontState_italic);
	templ->SetAccessor(String::New("bold"), Get_FontState_bold, Set_FontState_bold);
	templ->SetAccessor(String::New("underline"), Get_FontState_underline, Set_FontState_underline);
	templ->SetAccessor(String::New("strikeOut"), Get_FontState_strikeOut, Set_FontState_strikeOut);
	templ->SetAccessor(String::New("color"), Get_FontState_color, Set_FontState_color);
}
Handle<ObjectTemplate> getSystemTemplate(){
    Handle<ObjectTemplate> system = ObjectTemplate::New();
    system->Set(String::New("log"), FunctionTemplate::New(LogCallback));
    system->Set(String::New("moveBox"), FunctionTemplate::New(MoveBox));
    system->Set(String::New("positionBox"), FunctionTemplate::New(SetBoxLocation));
    system->Set(String::New("setBoxColor"), FunctionTemplate::New(SetBoxColor));
    system->SetAccessor(String::New("boxPosition"), BoxPositionGetter, NULL);
    system->SetAccessor(String::New("screenSize"), ScreenSizeGetter, NULL);
    system->Set(String::New("sleep"), FunctionTemplate::New(SleepCallback));
    system->Set(String::New("usleep"), FunctionTemplate::New(uSleepCallback));
    
    return( system );
}
Exemplo n.º 4
0
void
test_obj_propexn() {
  HandleScope handle_scope;
  Persistent<Context> context = Context::New();

  Context::Scope context_scope(context);

  Handle<Object> obj = Object::New();
  obj->SetAccessor(String::New("myprop"), ReadExn, WriteExn);
  Local<Object> global = context->Global();
  global->Set(String::New("testobj"), obj);

  Handle<String> source = String::New("var n = 0;"
                                      "try { testobj.myprop; } catch (e) { n += e; };"
                                      "try { testobj.myprop = (n+9); } catch (e) { n += e; }; n");

  // Compile the source code.
  Handle<Script> script = Script::Compile(source);

  TryCatch trycatch;
  // Run the script to get the result.
  Handle<Value> result = script->Run();

  do_check_false(result.IsEmpty());
  do_check_true(result->IsInt32());
  do_check_false(trycatch.HasCaught());
  JSInt32 i = result->Int32Value();
  do_check_eq(13, i);
  context.Dispose();
}
Exemplo n.º 5
0
void
test_obj_defprop() {
  HandleScope handle_scope;
  Persistent<Context> context = Context::New();

  Context::Scope context_scope(context);

  Handle<Object> obj = Object::New();
  Handle<Value> data = Integer::New(2);
  obj->SetAccessor(String::New("myprop"), ReadTestVal, WriteTestVal, data);
  Local<Object> global = context->Global();
  global->Set(String::New("testobj"), obj);

  Handle<String> source = String::New("var n = testobj.myprop; testobj.myprop = (n+9); testobj.myprop");

  // Compile the source code.
  Handle<Script> script = Script::Compile(source);

  // Run the script to get the result.
  Handle<Value> result = script->Run();

  do_check_true(!result.IsEmpty());
  do_check_true(result->IsInt32());
  JSInt32 i = result->Int32Value();
  do_check_eq(12, i);
  context.Dispose();
}
Exemplo n.º 6
0
// Defines a Point() JS Object
void PointConstructor( const FunctionCallbackInfo<v8::Value>& args )
{
    //Locker lock;
    HandleScope scope;
	Handle<ObjectTemplate> t = v8::ObjectTemplate::New();

	//The JavaScript point object only has 1 C++ object
	t->SetInternalFieldCount(1);

	// Create x and y members with starting values of 0
	//t->Set(String::New("x"), Number::New(0));
	t->SetAccessor(String::New("x"), 
		(AccessorGetterCallback)GetPointX,
		(AccessorSetterCallback)SetPointX);

	//t->Set(String::New("y"), Number::New(0));
	t->SetAccessor(String::New("y"),
		(AccessorGetterCallback)GetPointY,
		(AccessorSetterCallback)SetPointY);

	// Create a mul(number) function that scales the point
	t->Set(String::New("mul"), FunctionTemplate::New(MulCallback));

	// for use in the if statement
	Point *p = NULL;
	Local<Object> obj;
	
	// If Point(x, y) ctor was passed in values assign them
	if(!args[0].IsEmpty() && args[0]->IsNumber() &&
		!args[1].IsEmpty() && args[1]->IsNumber()) {
			//t->Set(String::New("x"), args[0]);
			//t->Set(String::New("y"), args[1]);
			p = new Point(args[0]->Int32Value(), args[1]->Int32Value());
			obj = t->NewInstance();
			obj->SetInternalField(0, External::New(p));			
	} else {
		/**
		 * Wrap a point object
		 */
		p = new Point(0, 0);
		obj = t->NewInstance();
		obj->SetInternalField(0, External::New(p));
	}

	// Return this newly created object
	args.GetReturnValue().Set(obj);
}
Exemplo n.º 7
0
void
_gum_v8_stalker_init (GumV8Stalker * self,
                      GumV8Core * core,
                      Handle<ObjectTemplate> scope)
{
  Isolate * isolate = core->isolate;

  self->core = core;
  self->stalker = NULL;
  self->sink = NULL;
  self->queue_capacity = 16384;
  self->queue_drain_interval = 250;
  self->pending_follow_level = 0;

  Local<External> data (External::New (isolate, self));

  Handle<ObjectTemplate> stalker = ObjectTemplate::New (isolate);
  stalker->SetAccessor (String::NewFromUtf8 (isolate, "trustThreshold"),
      gum_v8_stalker_on_get_trust_threshold,
      gum_v8_stalker_on_set_trust_threshold,
      data);
  stalker->SetAccessor (String::NewFromUtf8 (isolate, "queueCapacity"),
      gum_v8_stalker_on_get_queue_capacity,
      gum_v8_stalker_on_set_queue_capacity,
      data);
  stalker->SetAccessor (String::NewFromUtf8 (isolate, "queueDrainInterval"),
      gum_v8_stalker_on_get_queue_drain_interval,
      gum_v8_stalker_on_set_queue_drain_interval,
      data);
  stalker->Set (String::NewFromUtf8 (isolate, "garbageCollect"),
      FunctionTemplate::New (isolate, gum_v8_stalker_on_garbage_collect,
      data));
  stalker->Set (String::NewFromUtf8 (isolate, "follow"),
      FunctionTemplate::New (isolate, gum_v8_stalker_on_follow,
      data));
  stalker->Set (String::NewFromUtf8 (isolate, "unfollow"),
      FunctionTemplate::New (isolate, gum_v8_stalker_on_unfollow,
      data));
  stalker->Set (String::NewFromUtf8 (isolate, "addCallProbe"),
      FunctionTemplate::New (isolate, gum_v8_stalker_on_add_call_probe,
      data));
  stalker->Set (String::NewFromUtf8 (isolate, "removeCallProbe"),
      FunctionTemplate::New (isolate, gum_v8_stalker_on_remove_call_probe,
      data));
  scope->Set (String::NewFromUtf8 (isolate, "Stalker"), stalker);
}
void MetadataNode::InjectPrototype(Handle<Object>& target, Handle<Object>& implementationObject)
{
	auto isolate = Isolate::GetCurrent();

	implementationObject->SetAccessor(ConvertToV8String("super"), SuperAccessorGetterCallback, nullptr, implementationObject);
	implementationObject->SetPrototype(target->GetPrototype());
	target->SetPrototype(implementationObject);
}
Exemplo n.º 9
0
Handle<ObjectTemplate> js_haptics_get_template() {
	Handle<ObjectTemplate> haptics = ObjectTemplate::New();
	
	haptics->Set(STRING_CACHE_cancel, FunctionTemplate::New(js_haptics_cancel));
	haptics->Set(STRING_CACHE_vibrate, FunctionTemplate::New(js_haptics_vibrate));
	haptics->SetAccessor(STRING_CACHE_hasVibrator, js_haptics_has_vibrator);
	
	return haptics;
}
void AddDialogStateAcessors(Handle<ObjectTemplate> &templ)
{
    HandleScope scope;

    templ->SetAccessor(String::New("width"), Get_DialogState_width, Set_DialogState_width);
    templ->SetAccessor(String::New("height"), Get_DialogState_height, Set_DialogState_height);
    templ->SetAccessor(String::New("x"), Get_DialogState_x, NULL, Handle<Value>(), DEFAULT, ReadOnly);
    templ->SetAccessor(String::New("y"), Get_DialogState_y, NULL, Handle<Value>(), DEFAULT, ReadOnly);
    templ->SetAccessor(String::New("left"), Get_DialogState_left, NULL, Handle<Value>(), DEFAULT, ReadOnly);
    templ->SetAccessor(String::New("top"), Get_DialogState_top, NULL, Handle<Value>(), DEFAULT, ReadOnly);
    templ->SetAccessor(String::New("right"), Get_DialogState_right, NULL, Handle<Value>(), DEFAULT, ReadOnly);
    templ->SetAccessor(String::New("bottom"), Get_DialogState_bottom, NULL, Handle<Value>(), DEFAULT, ReadOnly);
    templ->SetAccessor(String::New("borders"), Get_DialogState_borders, Set_DialogState_borders);
}
Exemplo n.º 11
0
Handle<ObjectTemplate> vectorTemplate::makeVectorObjectTemplate(vector<double>* instVect, PropertyAttribute attributes){
	HandleScope scope;
	Handle<External> data = External::New(reinterpret_cast<void *>(instVect));
	
	Handle<ObjectTemplate> vectOjbTempInst = ObjectTemplate::New();
	vectOjbTempInst->Set("add", FunctionTemplate::New(addVectors));
	vectOjbTempInst->Set("sub", FunctionTemplate::New(subVectors));
	vectOjbTempInst->Set("subtract", FunctionTemplate::New(subVectors));
	vectOjbTempInst->Set("dist", FunctionTemplate::New(distanceVectors));
	vectOjbTempInst->Set("mag", FunctionTemplate::New(magVectors));
	vectOjbTempInst->SetAccessor(String::New("x"), getVectorX, setVectorX, data, DEFAULT, attributes);
	vectOjbTempInst->SetAccessor(String::New("y"), getVectorY, setVectorY, data, DEFAULT, attributes);
	
	return scope.Close(vectOjbTempInst);
}
Exemplo n.º 12
0
//Used to make a new vector object
Handle<Object> vectorTemplate::makeVectorObject(vector<double>* instVect){
	HandleScope scope;
	
	//This is the prototype for the object
	Handle<Object> objProto = vectorObjTemp->NewInstance();
	//This is the vector data that will be associated with this object
	Handle<External> data = External::New(reinterpret_cast<void *>(instVect));
	
	Handle<ObjectTemplate> vectOjbTempInst = ObjectTemplate::New();
	
	//Set up the setters
	vectOjbTempInst->SetAccessor(String::New("x"), getVectorX, setVectorX, data);
	vectOjbTempInst->SetAccessor(String::New("y"), getVectorY, setVectorY, data);
	
	Handle<Object> obj = vectOjbTempInst->NewInstance();
	obj->SetPrototype(objProto);
	
	return scope.Close(obj);
}
Handle<Function> MetadataNode::SetMembersFromRuntimeMetadata(Isolate *isolate, Handle<FunctionTemplate>& ctorFuncTemplate, Handle<ObjectTemplate>& prototypeTemplate, MetadataTreeNode *treeNode)
{
	SET_PROFILER_FRAME();

	assert(treeNode->metadata != nullptr);

	string line;
	const string& metadata = *treeNode->metadata;
	stringstream s(metadata);

	string kind;
	string name;
	string signature;
	int paramCount;

	getline(s, line); // type line
	getline(s, line); // base class line

	string lastMethodName;
	MethodCallbackData *callbackData = nullptr;

	while (getline(s, line))
	{
		stringstream tmp(line);
		tmp >> kind >> name >> signature >> paramCount;

		char chKind = kind[0];

		assert((chKind == 'M') || (chKind == 'F'));

		MetadataEntry entry;
		entry.name = name;
		entry.sig = signature;
		entry.paramCount = paramCount;
		entry.isStatic = false;

		if (chKind == 'M')
		{
			if (entry.name != lastMethodName)
			{
				callbackData = new MethodCallbackData(this);
				auto funcData = External::New(isolate, callbackData);
				auto funcTemplate = FunctionTemplate::New(isolate, MethodCallback, funcData);
				auto funcName = ConvertToV8String(entry.name);
				prototypeTemplate->Set(funcName, funcTemplate->GetFunction());
				lastMethodName = entry.name;
			}
			callbackData->candidates.push_back(entry);
		}
		else if (chKind == 'F')
		{
			auto fieldName = ConvertToV8String(entry.name);
			auto fieldData = External::New(isolate, new FieldCallbackData(entry));
			auto access = entry.isFinal ? AccessControl::ALL_CAN_READ : AccessControl::DEFAULT;
			prototypeTemplate->SetAccessor(fieldName, FieldAccessorGetterCallback, FieldAccessorSetterCallback, fieldData, access, PropertyAttribute::DontDelete);
		}
	}

	auto ctorFunction = ctorFuncTemplate->GetFunction();

	return ctorFunction;
}
Exemplo n.º 14
0
Handle<ObjectTemplate> js_native_get_template(const char* uri, const char* native_hash) {
    Handle<ObjectTemplate> NATIVE = ObjectTemplate::New();

    // functions
    NATIVE->Set(String::New("_call"), FunctionTemplate::New(js_native_call));
    NATIVE->Set(STRING_CACHE_getFileSync, FunctionTemplate::New(native_fetch));
    NATIVE->Set(STRING_CACHE_eval, FunctionTemplate::New(native_eval));
    NATIVE->Set(STRING_CACHE_startGame, FunctionTemplate::New(native_start_game));
    NATIVE->Set(STRING_CACHE_doneLoading, FunctionTemplate::New(native_done_loading));
    NATIVE->Set(STRING_CACHE_applyUpdate, FunctionTemplate::New(native_apply_update));
    NATIVE->Set(STRING_CACHE_Socket, FunctionTemplate::New(js_socket_ctor));
    NATIVE->Set(STRING_CACHE_sendActivityToBack, FunctionTemplate::New(js_native_send_activity_to_back));
    NATIVE->Set(STRING_CACHE_stayAwake, FunctionTemplate::New(js_native_stay_awake));
    NATIVE->Set(STRING_CACHE_uploadDeviceInfo, FunctionTemplate::New(js_native_upload_device_info));
    NATIVE->Set(STRING_CACHE_getCurrentTimeMicroseconds, FunctionTemplate::New(js_native_get_microseconds));
    NATIVE->Set(STRING_CACHE_reload, FunctionTemplate::New(js_native_reload));
    NATIVE->Set(STRING_CACHE_isSimulator, FunctionTemplate::New(js_is_simulator));

    // templates
    NATIVE->Set(STRING_CACHE_console, js_console_get_template());
    NATIVE->Set(STRING_CACHE_gl, js_gl_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_localStorage, js_local_storage_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_sound, js_sound_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_overlay, js_overlay_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_device, js_device_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_textbox, js_textbox_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_dialogs, js_dialog_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_haptics, js_haptics_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_camera, js_camera_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_gallery, js_gallery_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_timestep, js_timestep_get_template());
    NATIVE->Set(STRING_CACHE_xhr, js_xhr_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_plugins,js_plugins_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_gc, js_gc_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_build, js_build_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_locale, js_locale_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_profiler, js_profiler_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_input, js_input_get_template()->NewInstance());
    NATIVE->Set(STRING_CACHE_statusBar, js_status_bar_get_template()->NewInstance());
    NATIVE->Set(String::New("imageCache"), js_image_cache_get_template()->NewInstance());

    // market
    Handle<Object> market = Object::New();
    const char *marketUrl = get_market_url();
    market->Set(STRING_CACHE_url, String::New(marketUrl), ReadOnly);
    free((void*)marketUrl);
    NATIVE->Set(STRING_CACHE_market, market);

    // Values
    NATIVE->SetAccessor(STRING_CACHE_deviceUUID, js_device_global_id);
    NATIVE->SetAccessor(STRING_CACHE_installReferrer, js_install_referrer);
    NATIVE->SetAccessor(STRING_CACHE_usedHeap, js_used_heap);
    NATIVE->Set(STRING_CACHE_simulateID, String::New(config_get_simulate_id()));
    NATIVE->Set(STRING_CACHE_screen, Object::New());
    NATIVE->Set(STRING_CACHE_uri, String::New(uri));
    NATIVE->Set(STRING_CACHE_tcpHost, String::New(config_get_tcp_host()));
    NATIVE->Set(STRING_CACHE_tcpPort, Number::New(config_get_tcp_port()));
    const char *versionCode = get_version_code(); // versionCode
    NATIVE->Set(STRING_CACHE_versionCode, String::New(versionCode), ReadOnly);
    free((void*)versionCode);
    NATIVE->Set(STRING_CACHE_nativeHash, String::New(native_hash));
    NATIVE->SetAccessor(STRING_CACHE_location, jsGetLocation, jsSetLocation);

    return NATIVE;
}
void CanvasContextV8Bindings::loadScript(const std::string& _filename, OgreCanvas::CanvasContext* _canvasContext, OgreCanvas::CanvasLogger* _console)
{
	CanvasContextV8Bindings::context2D = _canvasContext;
	
	HandleScope handle_scope;
	
	//Console :
		
		//template
		Handle<FunctionTemplate> consoleTemplate = FunctionTemplate::New();
		consoleTemplate->SetClassName(v8::String::New("Console"));
		CanvasContextV8Bindings::consoleTemplate = Persistent<FunctionTemplate>::New(consoleTemplate);

		//prototype
		Handle<ObjectTemplate> consolePrototype = consoleTemplate->PrototypeTemplate();

		//attaching method
		consolePrototype->Set("log", FunctionTemplate::New(log));

		//creating instance
		Handle<ObjectTemplate> consoleInstance = consoleTemplate->InstanceTemplate();
		consoleInstance->SetInternalFieldCount(1);

	//Image :
		
		//template
		Handle<FunctionTemplate> imageTemplate = FunctionTemplate::New();
		imageTemplate->SetClassName(v8::String::New("Image"));
		CanvasContextV8Bindings::imageTemplate = Persistent<FunctionTemplate>::New(imageTemplate);

		//prototype
		Handle<ObjectTemplate> imagePrototype = imageTemplate->PrototypeTemplate();

		//creating instance
		Handle<ObjectTemplate> imageInstance = imageTemplate->InstanceTemplate();
		imageInstance->SetInternalFieldCount(1);

	//Canvas gradient :
		
		//template
		Handle<FunctionTemplate> canvasGradientTemplate = FunctionTemplate::New();
		canvasGradientTemplate->SetClassName(v8::String::New("CanvasGradient"));
		CanvasContextV8Bindings::canvasGradientTemplate = Persistent<FunctionTemplate>::New(canvasGradientTemplate);

		//prototype
		Handle<ObjectTemplate> canvasGradientPrototype = canvasGradientTemplate->PrototypeTemplate();

		//creating instance
		Handle<ObjectTemplate> canvasGradientInstance = canvasGradientTemplate->InstanceTemplate();
		canvasGradientInstance->SetInternalFieldCount(1);

		//attaching method
		canvasGradientPrototype->Set("addColorStop", FunctionTemplate::New(addColorStop));

	//Canvas Pattern :

		//template
		Handle<FunctionTemplate> canvasPatternTemplate = FunctionTemplate::New();
		canvasPatternTemplate->SetClassName(v8::String::New("CanvasPattern"));
		CanvasContextV8Bindings::canvasPatternTemplate = Persistent<FunctionTemplate>::New(canvasPatternTemplate);

		//prototype
		Handle<ObjectTemplate> canvasPatternPrototype = canvasPatternTemplate->PrototypeTemplate();
		
		//creating instance
		Handle<ObjectTemplate> canvasPatternInstance = canvasPatternTemplate->InstanceTemplate();
		canvasPatternInstance->SetInternalFieldCount(1);

	//Canvas context :

		//template
		Handle<FunctionTemplate> canvasContextTemplate = FunctionTemplate::New();
		canvasContextTemplate->SetClassName(v8::String::New("CanvasContext"));
	
		//prototype
		Handle<ObjectTemplate> canvasContextPrototype = canvasContextTemplate->PrototypeTemplate();

		//attaching method

			//2D Context
			canvasContextPrototype->Set("save",        FunctionTemplate::New(save));
			canvasContextPrototype->Set("restore",     FunctionTemplate::New(restore));

			//Transformation
			canvasContextPrototype->Set("scale",        FunctionTemplate::New(scale));
			canvasContextPrototype->Set("rotate",       FunctionTemplate::New(rotate));
			canvasContextPrototype->Set("translate",    FunctionTemplate::New(translate));
			canvasContextPrototype->Set("transform",    FunctionTemplate::New(transform));
			canvasContextPrototype->Set("setTransform", FunctionTemplate::New(setTransform));
			
			//Image drawing
			canvasContextPrototype->Set("drawImage",    FunctionTemplate::New(drawImage));		

			//Colors, styles and shadows
			canvasContextPrototype->Set("createLinearGradient", FunctionTemplate::New(createLinearGradient));
			canvasContextPrototype->Set("createRadialGradient", FunctionTemplate::New(createRadialGradient));
			canvasContextPrototype->Set("createPattern",        FunctionTemplate::New(createPattern));

			//Paths
			canvasContextPrototype->Set("beginPath",        FunctionTemplate::New(beginPath));
			canvasContextPrototype->Set("closePath",        FunctionTemplate::New(closePath));		
			canvasContextPrototype->Set("fill",             FunctionTemplate::New(fill));
			canvasContextPrototype->Set("stroke",           FunctionTemplate::New(stroke));
			canvasContextPrototype->Set("clip",             FunctionTemplate::New(clip));

			canvasContextPrototype->Set("moveTo",           FunctionTemplate::New(moveTo));
			canvasContextPrototype->Set("lineTo",           FunctionTemplate::New(lineTo));
			canvasContextPrototype->Set("quadraticCurveTo", FunctionTemplate::New(quadraticCurveTo));
			canvasContextPrototype->Set("bezierCurveTo",    FunctionTemplate::New(bezierCurveTo));
			canvasContextPrototype->Set("arcTo",            FunctionTemplate::New(arcTo));
			canvasContextPrototype->Set("arc",              FunctionTemplate::New(arc));
			canvasContextPrototype->Set("rect",             FunctionTemplate::New(rect));
			canvasContextPrototype->Set("isPointInPath",    FunctionTemplate::New(isPointInPath));

			//Text
			canvasContextPrototype->Set("fillText",    FunctionTemplate::New(fillText));
			canvasContextPrototype->Set("strokeText",  FunctionTemplate::New(strokeText));
			canvasContextPrototype->Set("measureText", FunctionTemplate::New(measureText));

			//Rectangles
			canvasContextPrototype->Set("clearRect",   FunctionTemplate::New(clearRect));
			canvasContextPrototype->Set("fillRect",    FunctionTemplate::New(fillRect));
			canvasContextPrototype->Set("strokeRect",  FunctionTemplate::New(strokeRect));

			//New
			canvasContextPrototype->Set("saveToPNG",   FunctionTemplate::New(saveToPNG));		
			canvasContextPrototype->Set("clear",       FunctionTemplate::New(clear));

		//creating instance
		Handle<ObjectTemplate> canvasContextInstance = canvasContextTemplate->InstanceTemplate();
		canvasContextInstance->SetInternalFieldCount(1);

		//attaching properties

			//Compositing
			canvasContextInstance->SetAccessor(v8::String::New("globalAlpha"), getterGlobalAlpha, setterGlobalAlpha);
			canvasContextInstance->SetAccessor(v8::String::New("globalCompositeOperation"), getterGlobalCompositeOperation, setterGlobalCompositeOperation);
			
			//Line styles
			canvasContextInstance->SetAccessor(v8::String::New("lineWidth"),   getterLineWidth,  setterLineWidth);
			canvasContextInstance->SetAccessor(v8::String::New("lineCap"),     getterLineCap,    setterLineCap);
			canvasContextInstance->SetAccessor(v8::String::New("lineJoin"),    getterLineJoin,   setterLineJoin);
			canvasContextInstance->SetAccessor(v8::String::New("miterLimit"),  getterMiterLimit, setterMiterLimit);
			canvasContextInstance->SetAccessor(v8::String::New("lineDash"),    getterLineDash,   setterLineDash);
			
			//Colors, styles and shadows
			canvasContextInstance->SetAccessor(v8::String::New("fillStyle"),     getterFillStyle,     setterFillStyle);
			canvasContextInstance->SetAccessor(v8::String::New("strokeStyle"),   getterStrokeStyle,   setterStrokeStyle);
			canvasContextInstance->SetAccessor(v8::String::New("shadowOffsetX"), getterShadowOffsetX, setterShadowOffsetX);
			canvasContextInstance->SetAccessor(v8::String::New("shadowOffsetY"), getterShadowOffsetY, setterShadowOffsetY);
			canvasContextInstance->SetAccessor(v8::String::New("shadowBlur"),    getterShadowBlur,    setterShadowBlur);
			canvasContextInstance->SetAccessor(v8::String::New("shadowColor"),   getterShadowColor,   setterShadowColor);

			//Text
			canvasContextInstance->SetAccessor(v8::String::New("font"),         getterFont,         setterFont);
			canvasContextInstance->SetAccessor(v8::String::New("textAlign"),    getterTextAlign,    setterTextAlign);
			canvasContextInstance->SetAccessor(v8::String::New("textBaseline"), getterTextBaseline, setterTextBaseline);
			
			//New
			canvasContextInstance->SetAccessor(v8::String::New("antialiasing"), getterAntiAliasing, setterAntiAliasing);

	//Image
	Handle<ObjectTemplate> global = ObjectTemplate::New();
	global->Set(String::New("loadImage"), FunctionTemplate::New(loadImage));

	Persistent<Context> context = Context::New(NULL, global);
	CanvasContextV8Bindings::contextV8 = context;

	Context::Scope context_scope(context);

		//building link between js 'ctx' variable and c++ _canvasContext variable
		Handle<Function> canvasContextConstructor = canvasContextTemplate->GetFunction();
		Local<Object> obj = canvasContextConstructor->NewInstance();
		obj->SetInternalField(0, External::New(_canvasContext));
		context->Global()->Set(v8::String::New("ctx"), obj);

		//building link between js 'console' variable and c++ _console variable
		Handle<Function> consoleConstructor = consoleTemplate->GetFunction();
		Local<Object> obj2 = consoleConstructor->NewInstance();
		obj2->SetInternalField(0, External::New(_console));
		context->Global()->Set(v8::String::New("console"), obj2);

	Handle<v8::String> source = v8::String::New(readScript(_filename).c_str());
	Handle<Script> script = Script::Compile(source);
	Handle<Value> result = script->Run();
	/*
	CanvasContextV8Bindings::canvasGradientTemplate.Dispose();
	CanvasContextV8Bindings::canvasPatternTemplate.Dispose();
	CanvasContextV8Bindings::imageTemplate.Dispose();
	*/
}
void MetadataNode::ExtendCallMethodHandler(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	if (info.IsConstructCall())
	{
		string exMsg("Cannot call 'extend' as constructor");
		ExceptionUtil::GetInstance()->ThrowExceptionToJs(exMsg);
		return;
	}

	SET_PROFILER_FRAME();

	Handle<Object> implementationObject;
	Handle<String> extendName;
	string extendLocation;
	auto validArgs = ValidateExtendArguments(info, extendLocation, extendName, implementationObject);

	if (!validArgs)
		return;

	auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());

	DEBUG_WRITE("ExtendsCallMethodHandler: called with %s", ConvertToString(extendName).c_str());

	string extendNameAndLocation = extendLocation + ConvertToString(extendName);
	auto fullClassName = TNS_PREFIX + CreateFullClassName(node->m_name, extendNameAndLocation);


	//
	JEnv env;
	//resolve class (pre-generated or generated runtime from dex generator)
	jclass generatedClass = s_resolveClass(fullClassName, implementationObject); //resolve class returns GlobalRef
	std::string generatedFullClassName = s_objectManager->GetClassName(generatedClass);
	//

	auto fullExtendedName = generatedFullClassName;
	DEBUG_WRITE("ExtendsCallMethodHandler: extend full name %s", fullClassName.c_str());

	auto isolate = info.GetIsolate();
	auto cachedData = GetCachedExtendedClassData(isolate, fullExtendedName);
	if (cachedData.extendedCtorFunction != nullptr)
	{
		auto cachedExtendedCtorFunc = Local<Function>::New(isolate, *cachedData.extendedCtorFunction);
		info.GetReturnValue().Set(cachedExtendedCtorFunc);
		return;
	}

	auto implementationObjectPropertyName = V8StringConstants::GetClassImplementationObject();
	//reuse validation - checks that implementationObject is not reused for different classes
	auto implementationObjectProperty = implementationObject->GetHiddenValue(implementationObjectPropertyName).As<String>();
	if (implementationObjectProperty.IsEmpty())
	{
		//mark the implementationObject as such and set a pointer to it's class node inside it for reuse validation later
		implementationObject->SetHiddenValue(implementationObjectPropertyName, String::NewFromUtf8(isolate, fullExtendedName.c_str()));

		//append resolved class to implementation object
		implementationObject->SetHiddenValue(ConvertToV8String(fullExtendedName), External::New(Isolate::GetCurrent(), generatedClass));
	}
	else
	{
		string usedClassName = ConvertToString(implementationObjectProperty);
		stringstream s;
		s << "This object is used to extend another class '" << usedClassName << "'";
		ExceptionUtil::GetInstance()->ThrowExceptionToJs(s.str());
		return;
	}

	auto baseClassCtorFunc = node->GetConstructorFunction(isolate);
	auto extendData = External::New(isolate, new ExtendedClassData(node, extendNameAndLocation, implementationObject, fullExtendedName));
	auto extendFuncTemplate = FunctionTemplate::New(isolate, ExtendedClassConstructorCallback, extendData);
	auto extendFunc = extendFuncTemplate->GetFunction();
	auto prototypeName = ConvertToV8String("prototype");
	implementationObject->SetPrototype(baseClassCtorFunc->Get(prototypeName));
	implementationObject->SetAccessor(ConvertToV8String("super"), SuperAccessorGetterCallback, nullptr, implementationObject);
	extendFunc->Set(prototypeName, implementationObject);
	extendFunc->SetPrototype(baseClassCtorFunc);
	SetClassAccessor(extendFunc);
	SetTypeMetadata(isolate, extendFunc, new TypeMetadata(fullExtendedName));
	info.GetReturnValue().Set(extendFunc);

	s_name2NodeCache.insert(make_pair(fullExtendedName, node));

	ExtendedClassCacheData cacheData(extendFunc, fullExtendedName, node);
	s_extendedCtorFuncCache.insert(make_pair(fullExtendedName, cacheData));
}
Handle<Function> MetadataNode::SetMembersFromStaticMetadata(Isolate *isolate, Handle<FunctionTemplate>& ctorFuncTemplate, Handle<ObjectTemplate>& prototypeTemplate, MetadataTreeNode *treeNode)
{
	SET_PROFILER_FRAME();

	Handle<Function> ctorFunction;

	uint8_t *curPtr = s_metadataReader.GetValueData() + treeNode->offsetValue + 1;

	auto nodeType = s_metadataReader.GetNodeType(treeNode);

	auto curType = s_metadataReader.ReadTypeName(treeNode);

	curPtr += sizeof(uint16_t /* baseClassId */);

	if (s_metadataReader.IsNodeTypeInterface(nodeType))
	{
		curPtr += sizeof(uint8_t) + sizeof(uint32_t);
	}

	//get candidates from instance methods metadata
	auto instanceMethodCout = *reinterpret_cast<uint16_t*>(curPtr);
	curPtr += sizeof(uint16_t);
	string lastMethodName;
	MethodCallbackData *callbackData = nullptr;
	for (auto i = 0; i < instanceMethodCout; i++)
	{
		auto entry = s_metadataReader.ReadInstanceMethodEntry(&curPtr);
		if (entry.name != lastMethodName)
		{
			callbackData = new MethodCallbackData(this);
			auto funcData = External::New(isolate, callbackData);
			auto funcTemplate = FunctionTemplate::New(isolate, MethodCallback, funcData);
			auto funcName = ConvertToV8String(entry.name);
			prototypeTemplate->Set(funcName, funcTemplate->GetFunction());
			lastMethodName = entry.name;
		}
		callbackData->candidates.push_back(entry);
	}

	//get candidates from instance fields metadata
	auto instanceFieldCout = *reinterpret_cast<uint16_t*>(curPtr);
	curPtr += sizeof(uint16_t);
	for (auto i = 0; i < instanceFieldCout; i++)
	{
		auto entry = s_metadataReader.ReadInstanceFieldEntry(&curPtr);

		auto fieldName = ConvertToV8String(entry.name);
		auto fieldInfo = new FieldCallbackData(entry);
		fieldInfo->declaringType = curType;
		auto fieldData = External::New(isolate, fieldInfo);
		prototypeTemplate->SetAccessor(fieldName, FieldAccessorGetterCallback, FieldAccessorSetterCallback, fieldData, AccessControl::DEFAULT, PropertyAttribute::DontDelete);
	}

	ctorFunction = ctorFuncTemplate->GetFunction();

	//get candidates from static methods metadata
	callbackData = nullptr;
	lastMethodName.clear();
	auto staticMethodCout = *reinterpret_cast<uint16_t*>(curPtr);
	curPtr += sizeof(uint16_t);
	for (auto i = 0; i < staticMethodCout; i++)
	{
		auto entry = s_metadataReader.ReadStaticMethodEntry(&curPtr);
		if (entry.name != lastMethodName)
		{
			callbackData = new MethodCallbackData(this);
			auto funcData = External::New(isolate, callbackData);
			auto funcTemplate = FunctionTemplate::New(isolate, MethodCallback, funcData);
			auto funcName = ConvertToV8String(entry.name);
			ctorFunction->Set(funcName, funcTemplate->GetFunction());
			lastMethodName = entry.name;
		}
		callbackData->candidates.push_back(entry);
	}

	auto extendFuncName = V8StringConstants::GetExtend();
	auto extendFuncTemplate = FunctionTemplate::New(isolate, ExtendCallMethodHandler, External::New(isolate, this));
	ctorFunction->Set(extendFuncName, extendFuncTemplate->GetFunction());

	//get candidates from static fields metadata
	auto staticFieldCout = *reinterpret_cast<uint16_t*>(curPtr);
	curPtr += sizeof(uint16_t);
	for (auto i = 0; i < staticFieldCout; i++)
	{
		auto entry = s_metadataReader.ReadStaticFieldEntry(&curPtr);

		auto fieldName = ConvertToV8String(entry.name);
		auto fieldData = External::New(isolate, new FieldCallbackData(entry));
		ctorFunction->SetAccessor(fieldName, FieldAccessorGetterCallback, FieldAccessorSetterCallback, fieldData, AccessControl::DEFAULT, PropertyAttribute::DontDelete);
	}

	SetClassAccessor(ctorFunction);

	return ctorFunction;
}
void MetadataNode::SetClassAccessor(Handle<Function>& ctorFunction)
{
	auto classFieldName = ConvertToV8String("class");
	ctorFunction->SetAccessor(classFieldName, ClassAccessorGetterCallback, nullptr, Handle<Value>(), AccessControl::ALL_CAN_READ, PropertyAttribute::DontDelete);
}
Exemplo n.º 19
0
Arquivo: bind.cpp Projeto: Qard/jsgame
Handle<ObjectTemplate> AlFactory::createAl(int* pargc, char** argv) {
	HandleScope handle_scope;
	Handle<ObjectTemplate> Al = ObjectTemplate::New();

	Al->SetInternalFieldCount(1);

	Al->SetAccessor(String::NewSymbol("INVALID"), GetAL_INVALID);
	Al->SetAccessor(String::NewSymbol("ILLEGAL_ENUM"), GetAL_ILLEGAL_ENUM);
	Al->SetAccessor(String::NewSymbol("ILLEGAL_COMMAND"), GetAL_ILLEGAL_COMMAND);
	Al->SetAccessor(String::NewSymbol("NONE"), GetAL_NONE);
	Al->SetAccessor(String::NewSymbol("FALSE"), GetAL_FALSE);
	Al->SetAccessor(String::NewSymbol("TRUE"), GetAL_TRUE);
	Al->SetAccessor(String::NewSymbol("SOURCE_RELATIVE"), GetAL_SOURCE_RELATIVE);
	Al->SetAccessor(String::NewSymbol("CONE_INNER_ANGLE"), GetAL_CONE_INNER_ANGLE);
	Al->SetAccessor(String::NewSymbol("CONE_OUTER_ANGLE"), GetAL_CONE_OUTER_ANGLE);
	Al->SetAccessor(String::NewSymbol("PITCH"), GetAL_PITCH);
	Al->SetAccessor(String::NewSymbol("POSITION"), GetAL_POSITION);
	Al->SetAccessor(String::NewSymbol("DIRECTION"), GetAL_DIRECTION);
	Al->SetAccessor(String::NewSymbol("VELOCITY"), GetAL_VELOCITY);
	Al->SetAccessor(String::NewSymbol("LOOPING"), GetAL_LOOPING);
	Al->SetAccessor(String::NewSymbol("BUFFER"), GetAL_BUFFER);
	Al->SetAccessor(String::NewSymbol("GAIN"), GetAL_GAIN);
	Al->SetAccessor(String::NewSymbol("MIN_GAIN"), GetAL_MIN_GAIN);
	Al->SetAccessor(String::NewSymbol("MAX_GAIN"), GetAL_MAX_GAIN);
	Al->SetAccessor(String::NewSymbol("ORIENTATION"), GetAL_ORIENTATION);
	Al->SetAccessor(String::NewSymbol("SOURCE_STATE"), GetAL_SOURCE_STATE);
	Al->SetAccessor(String::NewSymbol("INITIAL"), GetAL_INITIAL);
	Al->SetAccessor(String::NewSymbol("PLAYING"), GetAL_PLAYING);
	Al->SetAccessor(String::NewSymbol("PAUSED"), GetAL_PAUSED);
	Al->SetAccessor(String::NewSymbol("STOPPED"), GetAL_STOPPED);
	Al->SetAccessor(String::NewSymbol("BUFFERS_QUEUED"), GetAL_BUFFERS_QUEUED);
	Al->SetAccessor(String::NewSymbol("BUFFERS_PROCESSED"), GetAL_BUFFERS_PROCESSED);
	Al->SetAccessor(String::NewSymbol("SEC_OFFSET"), GetAL_SEC_OFFSET);
	Al->SetAccessor(String::NewSymbol("SAMPLE_OFFSET"), GetAL_SAMPLE_OFFSET);
	Al->SetAccessor(String::NewSymbol("BYTE_OFFSET"), GetAL_BYTE_OFFSET);
	Al->SetAccessor(String::NewSymbol("SOURCE_TYPE"), GetAL_SOURCE_TYPE);
	Al->SetAccessor(String::NewSymbol("STATIC"), GetAL_STATIC);
	Al->SetAccessor(String::NewSymbol("STREAMING"), GetAL_STREAMING);
	Al->SetAccessor(String::NewSymbol("UNDETERMINED"), GetAL_UNDETERMINED);
	Al->SetAccessor(String::NewSymbol("FORMAT_MONO8"), GetAL_FORMAT_MONO8);
	Al->SetAccessor(String::NewSymbol("FORMAT_MONO16"), GetAL_FORMAT_MONO16);
	Al->SetAccessor(String::NewSymbol("FORMAT_STEREO8"), GetAL_FORMAT_STEREO8);
	Al->SetAccessor(String::NewSymbol("FORMAT_STEREO16"), GetAL_FORMAT_STEREO16);
	Al->SetAccessor(String::NewSymbol("REFERENCE_DISTANCE"), GetAL_REFERENCE_DISTANCE);
	Al->SetAccessor(String::NewSymbol("ROLLOFF_FACTOR"), GetAL_ROLLOFF_FACTOR);
	Al->SetAccessor(String::NewSymbol("CONE_OUTER_GAIN"), GetAL_CONE_OUTER_GAIN);
	Al->SetAccessor(String::NewSymbol("MAX_DISTANCE"), GetAL_MAX_DISTANCE);
	Al->SetAccessor(String::NewSymbol("FREQUENCY"), GetAL_FREQUENCY);
	Al->SetAccessor(String::NewSymbol("BITS"), GetAL_BITS);
	Al->SetAccessor(String::NewSymbol("CHANNELS"), GetAL_CHANNELS);
	Al->SetAccessor(String::NewSymbol("SIZE"), GetAL_SIZE);
	Al->SetAccessor(String::NewSymbol("UNUSED"), GetAL_UNUSED);
	Al->SetAccessor(String::NewSymbol("PENDING"), GetAL_PENDING);
	Al->SetAccessor(String::NewSymbol("PROCESSED"), GetAL_PROCESSED);
	Al->SetAccessor(String::NewSymbol("NO_ERROR"), GetAL_NO_ERROR);
	Al->SetAccessor(String::NewSymbol("INVALID_NAME"), GetAL_INVALID_NAME);
	Al->SetAccessor(String::NewSymbol("INVALID_ENUM"), GetAL_INVALID_ENUM);
	Al->SetAccessor(String::NewSymbol("INVALID_VALUE"), GetAL_INVALID_VALUE);
	Al->SetAccessor(String::NewSymbol("INVALID_OPERATION"), GetAL_INVALID_OPERATION);
	Al->SetAccessor(String::NewSymbol("OUT_OF_MEMORY"), GetAL_OUT_OF_MEMORY);
	Al->SetAccessor(String::NewSymbol("VENDOR"), GetAL_VENDOR);
	Al->SetAccessor(String::NewSymbol("VERSION"), GetAL_VERSION);
	Al->SetAccessor(String::NewSymbol("RENDERER"), GetAL_RENDERER);
	Al->SetAccessor(String::NewSymbol("EXTENSIONS"), GetAL_EXTENSIONS);
	Al->SetAccessor(String::NewSymbol("DOPPLER_FACTOR"), GetAL_DOPPLER_FACTOR);
	Al->SetAccessor(String::NewSymbol("DOPPLER_VELOCITY"), GetAL_DOPPLER_VELOCITY);
	Al->SetAccessor(String::NewSymbol("SPEED_OF_SOUND"), GetAL_SPEED_OF_SOUND);
	Al->SetAccessor(String::NewSymbol("DISTANCE_MODEL"), GetAL_DISTANCE_MODEL);
	Al->SetAccessor(String::NewSymbol("INVERSE_DISTANCE"), GetAL_INVERSE_DISTANCE);
	Al->SetAccessor(String::NewSymbol("INVERSE_DISTANCE_CLAMPED"), GetAL_INVERSE_DISTANCE_CLAMPED);
	Al->SetAccessor(String::NewSymbol("LINEAR_DISTANCE"), GetAL_LINEAR_DISTANCE);
	Al->SetAccessor(String::NewSymbol("LINEAR_DISTANCE_CLAMPED"), GetAL_LINEAR_DISTANCE_CLAMPED);
	Al->SetAccessor(String::NewSymbol("EXPONENT_DISTANCE"), GetAL_EXPONENT_DISTANCE);
	Al->SetAccessor(String::NewSymbol("EXPONENT_DISTANCE_CLAMPED"), GetAL_EXPONENT_DISTANCE_CLAMPED);

	Al->Set(String::NewSymbol("enable"), FunctionTemplate::New(ALEnableCallback));
	Al->Set(String::NewSymbol("disable"), FunctionTemplate::New(ALDisableCallback));
	Al->Set(String::NewSymbol("isEnabled"), FunctionTemplate::New(ALIsEnabledCallback));
	Al->Set(String::NewSymbol("getBoolean"), FunctionTemplate::New(ALGetBooleanCallback));
	Al->Set(String::NewSymbol("getInteger"), FunctionTemplate::New(ALGetIntegerCallback));
	Al->Set(String::NewSymbol("getFloat"), FunctionTemplate::New(ALGetFloatCallback));
	Al->Set(String::NewSymbol("getDouble"), FunctionTemplate::New(ALGetDoubleCallback));
	Al->Set(String::NewSymbol("getError"), FunctionTemplate::New(ALGetErrorCallback));
	Al->Set(String::NewSymbol("isSource"), FunctionTemplate::New(ALIsSourceCallback));
	Al->Set(String::NewSymbol("sourcePlay"), FunctionTemplate::New(ALSourcePlayCallback));
	Al->Set(String::NewSymbol("sourceStop"), FunctionTemplate::New(ALSourceStopCallback));
	Al->Set(String::NewSymbol("sourceRewind"), FunctionTemplate::New(ALSourceRewindCallback));
	Al->Set(String::NewSymbol("sourcePause"), FunctionTemplate::New(ALSourcePauseCallback));
	Al->Set(String::NewSymbol("isBuffer"), FunctionTemplate::New(ALIsBufferCallback));
	Al->Set(String::NewSymbol("dopplerFactor"), FunctionTemplate::New(ALDopplerFactorCallback));
	Al->Set(String::NewSymbol("dopplerVelocity"), FunctionTemplate::New(ALDopplerVelocityCallback));
	Al->Set(String::NewSymbol("speedOfSound"), FunctionTemplate::New(ALSpeedOfSoundCallback));
	Al->Set(String::NewSymbol("distanceModel"), FunctionTemplate::New(ALDistanceModelCallback));

	// Again, return the result through the current handle scope.
	return handle_scope.Close(Al);
}	
Exemplo n.º 20
0
Arquivo: bind.cpp Projeto: Qard/jsgame
Handle<ObjectTemplate> AlutFactory::createAlut(int* pargc, char** argv) {
	HandleScope handle_scope;
	Handle<ObjectTemplate> Alut = ObjectTemplate::New();

	Alut->SetInternalFieldCount(1);

	Alut->SetAccessor(String::NewSymbol("API"), GetALUT_API);
	Alut->SetAccessor(String::NewSymbol("APIENTRY"), GetALUT_APIENTRY);
	Alut->SetAccessor(String::NewSymbol("ATTRIBUTE_DEPRECATED"), GetALUT_ATTRIBUTE_DEPRECATED);
	Alut->SetAccessor(String::NewSymbol("API_MAJOR_VERSION"), GetALUT_API_MAJOR_VERSION);
	Alut->SetAccessor(String::NewSymbol("API_MINOR_VERSION"), GetALUT_API_MINOR_VERSION);
	Alut->SetAccessor(String::NewSymbol("ERROR_NO_ERROR"), GetALUT_ERROR_NO_ERROR);
	Alut->SetAccessor(String::NewSymbol("ERROR_OUT_OF_MEMORY"), GetALUT_ERROR_OUT_OF_MEMORY);
	Alut->SetAccessor(String::NewSymbol("ERROR_INVALID_ENUM"), GetALUT_ERROR_INVALID_ENUM);
	Alut->SetAccessor(String::NewSymbol("ERROR_INVALID_VALUE"), GetALUT_ERROR_INVALID_VALUE);
	Alut->SetAccessor(String::NewSymbol("ERROR_INVALID_OPERATION"), GetALUT_ERROR_INVALID_OPERATION);
	Alut->SetAccessor(String::NewSymbol("ERROR_NO_CURRENT_CONTEXT"), GetALUT_ERROR_NO_CURRENT_CONTEXT);
	Alut->SetAccessor(String::NewSymbol("ERROR_AL_ERROR_ON_ENTRY"), GetALUT_ERROR_AL_ERROR_ON_ENTRY);
	Alut->SetAccessor(String::NewSymbol("ERROR_ALC_ERROR_ON_ENTRY"), GetALUT_ERROR_ALC_ERROR_ON_ENTRY);
	Alut->SetAccessor(String::NewSymbol("ERROR_OPEN_DEVICE"), GetALUT_ERROR_OPEN_DEVICE);
	Alut->SetAccessor(String::NewSymbol("ERROR_CLOSE_DEVICE"), GetALUT_ERROR_CLOSE_DEVICE);
	Alut->SetAccessor(String::NewSymbol("ERROR_CREATE_CONTEXT"), GetALUT_ERROR_CREATE_CONTEXT);
	Alut->SetAccessor(String::NewSymbol("ERROR_MAKE_CONTEXT_CURRENT"), GetALUT_ERROR_MAKE_CONTEXT_CURRENT);
	Alut->SetAccessor(String::NewSymbol("ERROR_DESTROY_CONTEXT"), GetALUT_ERROR_DESTROY_CONTEXT);
	Alut->SetAccessor(String::NewSymbol("ERROR_GEN_BUFFERS"), GetALUT_ERROR_GEN_BUFFERS);
	Alut->SetAccessor(String::NewSymbol("ERROR_BUFFER_DATA"), GetALUT_ERROR_BUFFER_DATA);
	Alut->SetAccessor(String::NewSymbol("ERROR_IO_ERROR"), GetALUT_ERROR_IO_ERROR);
	Alut->SetAccessor(String::NewSymbol("ERROR_UNSUPPORTED_FILE_TYPE"), GetALUT_ERROR_UNSUPPORTED_FILE_TYPE);
	Alut->SetAccessor(String::NewSymbol("ERROR_UNSUPPORTED_FILE_SUBTYPE"), GetALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE);
	Alut->SetAccessor(String::NewSymbol("ERROR_CORRUPT_OR_TRUNCATED_DATA"), GetALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA);
	Alut->SetAccessor(String::NewSymbol("WAVEFORM_SINE"), GetALUT_WAVEFORM_SINE);
	Alut->SetAccessor(String::NewSymbol("WAVEFORM_SQUARE"), GetALUT_WAVEFORM_SQUARE);
	Alut->SetAccessor(String::NewSymbol("WAVEFORM_SAWTOOTH"), GetALUT_WAVEFORM_SAWTOOTH);
	Alut->SetAccessor(String::NewSymbol("WAVEFORM_WHITENOISE"), GetALUT_WAVEFORM_WHITENOISE);
	Alut->SetAccessor(String::NewSymbol("WAVEFORM_IMPULSE"), GetALUT_WAVEFORM_IMPULSE);
	Alut->SetAccessor(String::NewSymbol("LOADER_BUFFER"), GetALUT_LOADER_BUFFER);
	Alut->SetAccessor(String::NewSymbol("LOADER_MEMORY"), GetALUT_LOADER_MEMORY);

	Alut->Set(String::NewSymbol("init"), FunctionTemplate::New(ALUTInitCallback));
	Alut->Set(String::NewSymbol("initWithoutContext"), FunctionTemplate::New(ALUTInitWithoutContextCallback));
	Alut->Set(String::NewSymbol("exit"), FunctionTemplate::New(ALUTExitCallback));
	Alut->Set(String::NewSymbol("getError"), FunctionTemplate::New(ALUTGetErrorCallback));
	Alut->Set(String::NewSymbol("getErrorString"), FunctionTemplate::New(ALUTGetErrorStringCallback));
	Alut->Set(String::NewSymbol("createBufferFromFile"), FunctionTemplate::New(ALUTCreateBufferFromFileCallback));
	Alut->Set(String::NewSymbol("createBufferFromFileImage"), FunctionTemplate::New(ALUTCreateBufferFromFileImageCallback));
	Alut->Set(String::NewSymbol("createBufferHelloWorld"), FunctionTemplate::New(ALUTCreateBufferHelloWorldCallback));
	Alut->Set(String::NewSymbol("createBufferWaveform"), FunctionTemplate::New(ALUTCreateBufferWaveformCallback));
	Alut->Set(String::NewSymbol("loadMemoryFromFile"), FunctionTemplate::New(ALUTLoadMemoryFromFileCallback));
	Alut->Set(String::NewSymbol("loadMemoryFromFileImage"), FunctionTemplate::New(ALUTLoadMemoryFromFileImageCallback));
	Alut->Set(String::NewSymbol("loadMemoryHelloWorld"), FunctionTemplate::New(ALUTLoadMemoryHelloWorldCallback));
	Alut->Set(String::NewSymbol("loadMemoryWaveform"), FunctionTemplate::New(ALUTLoadMemoryWaveformCallback));
	Alut->Set(String::NewSymbol("getMIMETypes"), FunctionTemplate::New(ALUTGetMIMETypesCallback));
	Alut->Set(String::NewSymbol("getMajorVersion"), FunctionTemplate::New(ALUTGetMajorVersionCallback));
	Alut->Set(String::NewSymbol("getMinorVersion"), FunctionTemplate::New(ALUTGetMinorVersionCallback));
	Alut->Set(String::NewSymbol("sleep"), FunctionTemplate::New(ALUTSleepCallback));
	Alut->Set(String::NewSymbol("loadWAVFile"), FunctionTemplate::New(ALUTLoadWAVFileCallback));
	Alut->Set(String::NewSymbol("loadWAVMemory"), FunctionTemplate::New(ALUTLoadWAVMemoryCallback));
	Alut->Set(String::NewSymbol("loadWAVFile"), FunctionTemplate::New(ALUTLoadWAVFileCallback));
	Alut->Set(String::NewSymbol("loadWAVMemory"), FunctionTemplate::New(ALUTLoadWAVMemoryCallback));
	Alut->Set(String::NewSymbol("unloadWAV"), FunctionTemplate::New(ALUTUnloadWAVCallback));

	// Again, return the result through the current handle scope.
	return handle_scope.Close(Alut);
}