Ejemplo n.º 1
0
static int loader(lua_State *L)
{
	const luaL_Reg functionlist[] = {
        {"isConsole", isConsole},
        {"getStore", getStore},
		{NULL, NULL},
	};
    
    g_createClass(L, "StoreDetector", NULL, NULL, destruct, functionlist);
    
	// create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
    luaL_newweaktable(L, "v");
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	
	StoreDetector *sd = new StoreDetector(L);
	g_pushInstance(L, "StoreDetector", sd->object());
    
	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, sd);
	lua_pop(L, 1);
    
	lua_pushvalue(L, -1);
	lua_setglobal(L, "storedetector");
    
    return 1;
}
Ejemplo n.º 2
0
static int loader(lua_State *L)
{
	const luaL_Reg functionList[] = {
		{"loadBanner", loadBanner},
		{"removeBanner", removeBanner},
		{"showBanner", showBanner},
		{"hideBanner", hideBanner},
		{"getAlignment", getAlignment},
		{"setAlignment", setAlignment},
		{"getAutoRefresh", getAutoRefresh},
		{"loadInterstitial", loadInterstitial},
		{"showInterstitial", showInterstitial},
		{NULL, NULL}
	};

    g_createClass(L, "MoPub", "EventDispatcher", NULL, destruct, functionList);

    // create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
	luaL_newweaktable(L, "v");
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);

	lua_getglobal(L, "MoPub");
	lua_pushstring(L, "top");
	lua_setfield(L, -2, "ALIGN_TOP");
	lua_pushstring(L, "bottom");
	lua_setfield(L, -2, "ALIGN_BOTTOM");
	lua_pop(L, 1);

    lua_getglobal(L, "Event");
	lua_pushstring(L, AD_WILL_LOAD);
	lua_setfield(L, -2, "AD_WILL_LOAD");
	lua_pushstring(L, AD_LOADED);
	lua_setfield(L, -2, "AD_LOADED");
	lua_pushstring(L, AD_FAILED);
	lua_setfield(L, -2, "AD_FAILED");
	lua_pushstring(L, AD_CLOSED);
	lua_setfield(L, -2, "AD_CLOSED");
	lua_pushstring(L, INTERSTITIAL_LOADED);
	lua_setfield(L, -2, "INTERSTITIAL_LOADED");
	lua_pushstring(L, INTERSTITIAL_FAILED);
	lua_setfield(L, -2, "INTERSTITIAL_FAILED");
	lua_pushstring(L, INTERSTITIAL_CLOSED);
	lua_setfield(L, -2, "INTERSTITIAL_CLOSED");
	lua_pop(L, 1);

	MoPub *mopub = new MoPub(L);
	g_pushInstance(L, "MoPub", mopub->object());

	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, mopub);
	lua_pop(L, 1);

	lua_pushvalue(L, -1);
	lua_setglobal(L, "mopub");

    return 1;
}
Ejemplo n.º 3
0
static int loader(lua_State *L)
{
	const luaL_Reg functionList[] = {
		{"configure", configure},
		{"showBanner", showBanner},
		{"hideBanner", hideBanner},
		{"showInterstitial", showInterstitial},
		{NULL, NULL}
	};

    g_createClass(L, "Greystripe", "EventDispatcher", NULL, destruct, functionList);

    // create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
	luaL_newweaktable(L, "v");
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);

	lua_getglobal(L, "Greystripe");
	lua_pushstring(L, "top");
	lua_setfield(L, -2, "ALIGN_TOP");
	lua_pushstring(L, "bottom");
	lua_setfield(L, -2, "ALIGN_BOTTOM");
	lua_pop(L, 1);

    lua_getglobal(L, "Event");
	lua_pushstring(L, BANNER_LOADED);
	lua_setfield(L, -2, "BANNER_LOADED");
	lua_pushstring(L, BANNER_FAILED);
	lua_setfield(L, -2, "BANNER_FAILED");
	lua_pushstring(L, BANNER_CLOSED);
	lua_setfield(L, -2, "BANNER_CLOSED");
	lua_pushstring(L, BANNER_CLICKED);
	lua_setfield(L, -2, "BANNER_CLICKED");
	lua_pushstring(L, INTERSTITIAL_LOADED);
	lua_setfield(L, -2, "INTERSTITIAL_LOADED");
	lua_pushstring(L, INTERSTITIAL_FAILED);
	lua_setfield(L, -2, "INTERSTITIAL_FAILED");
	lua_pushstring(L, INTERSTITIAL_CLOSED);
	lua_setfield(L, -2, "INTERSTITIAL_CLOSED");
	lua_pushstring(L, INTERSTITIAL_CLICKED);
	lua_setfield(L, -2, "INTERSTITIAL_CLICKED");
	lua_pop(L, 1);

	Greystripe *greystripe = new Greystripe(L);
	g_pushInstance(L, "Greystripe", greystripe->object());

	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, greystripe);
	lua_pop(L, 1);

	lua_pushvalue(L, -1);
	lua_setglobal(L, "greystripe");

    return 1;
}
Ejemplo n.º 4
0
GeolocationBinder::GeolocationBinder(lua_State *L)
{
    Binder binder(L);

    static const luaL_Reg functionList[] = {
        {"isAvailable", isAvailable},
        {"isHeadingAvailable", isHeadingAvailable},
        {"setAccuracy", setAccuracy},
        {"getAccuracy", getAccuracy},
        {"setThreshold", setThreshold},
        {"getThreshold", getThreshold},
        {"start", start},
        {"stop", stop},
        {"startUpdatingLocation", startUpdatingLocation},
        {"stopUpdatingLocation", stopUpdatingLocation},
        {"startUpdatingHeading", startUpdatingHeading},
        {"stopUpdatingHeading", stopUpdatingHeading},
        {NULL, NULL},
    };

    binder.createClass("Geolocation", "EventDispatcher", create, destruct, functionList);

    lua_getglobal(L, "Event");
    lua_pushstring(L, LOCATION_UPDATE.type());
    lua_setfield(L, -2, "LOCATION_UPDATE");
    lua_pushstring(L, HEADING_UPDATE.type());
    lua_setfield(L, -2, "HEADING_UPDATE");
    lua_pop(L, 1);

    luaL_newweaktable(L);
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key);
}
static int loader(lua_State *L)
{
	const luaL_Reg functionlist[] = {
        {"purchaseItem", purchaseItem},
		{NULL, NULL},
	};

    g_createClass(L, "SamsungIAP", "EventDispatcher", NULL, destruct, functionlist);

	// create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
    luaL_newweaktable(L, "v");
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);

	lua_getglobal(L, "SamsungIAP");
	lua_pushstring(L, OK);
	lua_setfield(L, -2, "OK");
	lua_pushstring(L, ERROR);
	lua_setfield(L, -2, "ERROR");
	lua_pushstring(L, PURCHASED);
	lua_setfield(L, -2, "PURCHASED");
	lua_pushstring(L, CANCELED);
	lua_setfield(L, -2, "CANCELED");
	lua_pushstring(L, INAPP);
	lua_setfield(L, -2, "INAPP");
	lua_pushstring(L, SUBS);
	lua_setfield(L, -2, "SUBS");
	lua_pop(L, 1);

	lua_getglobal(L, "Event");
	lua_pushstring(L, PURCHASE_STATE_CHANGE);
	lua_setfield(L, -2, "PURCHASE_STATE_CHANGE");
	lua_pop(L, 1);

    SamsungIAP *samsungiap = new SamsungIAP(L);
	g_pushInstance(L, "SamsungIAP", samsungiap->object());

	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, samsungiap);
	lua_pop(L, 1);

	lua_pushvalue(L, -1);
	lua_setglobal(L, "samsungiap");

    return 1;
}
Ejemplo n.º 6
0
AudioBinder::AudioBinder(lua_State *L)
{
    Binder binder(L);

    const luaL_Reg Sound_functionList[] = {
        {"play", Sound_play},
        {"getLength", Sound_getLength},
        {NULL, NULL},
    };

    binder.createClass("Sound", NULL, Sound_create, Sound_destruct, Sound_functionList);

    const luaL_Reg SoundChannel_functionList[] = {
        {"stop", SoundChannel_stop},
        {"setPosition", SoundChannel_setPosition},
        {"getPosition", SoundChannel_getPosition},
        {"setVolume", SoundChannel_setVolume},
        {"getVolume", SoundChannel_getVolume},
        {"setPitch", SoundChannel_setPitch},
        {"getPitch", SoundChannel_getPitch},
        {"isPlaying", SoundChannel_isPlaying},
        {"setPaused", SoundChannel_setPaused},
        {"isPaused", SoundChannel_isPaused},
        {"setLooping", SoundChannel_setLooping},
        {"isLooping", SoundChannel_isLooping},
        {NULL, NULL},
    };

    binder.createClass("SoundChannel", "EventDispatcher", NULL, SoundChannel_destruct, SoundChannel_functionList);

    luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyStrong);
    if (lua_isnil(L, -1))
    {
        lua_newtable(L);
        luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyStrong);
    }
    lua_pop(L, 1);

    luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keySound);
    if (lua_isnil(L, -1))
    {
        lua_newtable(L);
        luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keySound);
    }
    lua_pop(L, 1);
}
Ejemplo n.º 7
0
static int init(lua_State* L)
{
	const char *iabp = luaL_checkstring(L, 1);
	IAB *iab = new IAB(L, iabp);
	g_pushInstance(L, "IAB", iab->object());
    
	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, iab);
	lua_pop(L, 1);
    
	lua_pushvalue(L, -1);
	return 1;
}
Ejemplo n.º 8
0
int AudioBinder::SoundChannel_stop(lua_State *L)
{
    Binder binder(L);

    GGSoundChannel *soundChannel = static_cast<GGSoundChannel*>(binder.getInstance("SoundChannel", 1));

    soundChannel->stop();

    luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyStrong);
    lua_pushnil(L);
    luaL_rawsetptr(L, -2, soundChannel);
    lua_pop(L, 1);

    return 0;
}
Ejemplo n.º 9
0
static int loader(lua_State *L)
{
	const luaL_Reg functionlist[] = {
        {"detectStores", detectStores},
        {"new", init},
        {"setUp", setup},
        {"setProducts", setProducts},
        {"setConsumables", setConsumables},
        {"isAvailable", check},
        {"requestProducts", request},
        {"purchase", purchase},
        {"restore", restore},
		{NULL, NULL},
	};
    
    g_createClass(L, "IAB", "EventDispatcher", NULL, destruct, functionlist);
    
	// create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
    luaL_newweaktable(L, "v");
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	
	lua_getglobal(L, "Event");
	lua_pushstring(L, AVAILABLE);
	lua_setfield(L, -2, "AVAILABLE");
	lua_pushstring(L, NOT_AVAILABLE);
	lua_setfield(L, -2, "NOT_AVAILABLE");
	lua_pushstring(L, PURCHASE_COMPLETE);
	lua_setfield(L, -2, "PURCHASE_COMPLETE");
	lua_pushstring(L, PURCHASE_ERROR);
	lua_setfield(L, -2, "PURCHASE_ERROR");
	lua_pushstring(L, PRODUCTS_COMPLETE);
	lua_setfield(L, -2, "PRODUCTS_COMPLETE");
	lua_pushstring(L, PRODUCTS_ERROR);
	lua_setfield(L, -2, "PRODUCTS_ERROR");
	lua_pushstring(L, RESTORE_COMPLETE);
	lua_setfield(L, -2, "RESTORE_COMPLETE");
	lua_pushstring(L, RESTORE_ERROR);
	lua_setfield(L, -2, "RESTORE_ERROR");
	lua_pop(L, 1);
    
    return 0;
}
Ejemplo n.º 10
0
int AudioBinder::Sound_play(lua_State *L)
{
    Binder binder(L);

    GGSound *sound = static_cast<GGSound*>(binder.getInstance("Sound", 1));

    unsigned int startTime = luaL_optnumber(L, 2, 0);

    bool looping;
    if (lua_type(L, 3) == LUA_TNUMBER)
    {
        // backward compatibility
        looping = lua_tonumber(L, 3) > 1;
    }
    else
    {
        looping = lua_toboolean(L, 3);
    }

    bool paused = lua_toboolean(L, 4);

    GGSoundChannel *soundChannel = new GGSoundChannel(L, sound, startTime, looping, paused);

    if (soundChannel->gid == 0)
    {
        soundChannel->unref();
        lua_pushnil(L);
    }
    else
    {
        binder.pushInstance("SoundChannel", soundChannel);

        luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyStrong);
        lua_pushvalue(L, -2);
        luaL_rawsetptr(L, -2, soundChannel);
        lua_pop(L, 1);
    }

    return 1;
}
Ejemplo n.º 11
0
int GeolocationBinder::create(lua_State* L)
{
    Binder binder(L);

    GGGeolocation *geolocation = new GGGeolocation(L);
    binder.pushInstance("Geolocation", geolocation);

    lua_getglobal(L, "Event");

    lua_getfield(L, -1, "new");
    lua_remove(L, -2);				// remove global "Event"

    lua_pushvalue(L, -1);	// duplicate Event.new
    lua_pushstring(L, LOCATION_UPDATE.type());
    lua_call(L, 1, 1); // call Event.new
    lua_setfield(L, -3, "__updateLocationEvent");

    lua_pushvalue(L, -1);	// duplicate Event.new
    lua_pushstring(L, HEADING_UPDATE.type());
    lua_call(L, 1, 1); // call Event.new
    lua_setfield(L, -3, "__updateHeadingEvent");

    lua_pushvalue(L, -1);	// duplicate Event.new
    lua_pushstring(L, ERROR.type());
    lua_call(L, 1, 1); // call Event.new
    lua_setfield(L, -3, "__errorEvent");

    lua_pop(L, 1);		// pop Event.new

    luaL_rawgetptr(L, LUA_REGISTRYINDEX, &key);
    lua_pushvalue(L, -2);
    luaL_rawsetptr(L, -2, geolocation);
    lua_pop(L, 1);

    return 1;
}
Ejemplo n.º 12
0
static int bindAll(lua_State* L)
{
	Application* application = static_cast<Application*>(lua_touserdata(L, 1));
	lua_pop(L, 1);

	StackChecker checker(L, "bindAll", 0);

	setEnvironTable(L);

	{
		lua_newtable(L);
		luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_touches);

		lua_newtable(L);
		luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_eventClosures);

		lua_newtable(L);
		luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_events);

		luaL_newweaktable(L);
		luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_b2);

		lua_newtable(L);
		luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_timers);
	}

    luaL_newmetatable(L, "Object");
    lua_setglobal(L, "Object");
	
	EventBinder eventBinder(L);
	EventDispatcherBinder eventDispatcherBinder(L);
	TimerBinder timerBinder(L);
	MatrixBinder matrixBinder(L);
	SpriteBinder spriteBinder(L);
	TextureBaseBinder textureBaseBinder(L);
	TextureBinder textureBinder(L);
	TexturePackBinder texturePackBinder(L);
	BitmapDataBinder bitmapDataBinder(L);
	BitmapBinder bitmapBinder(L);
	StageBinder stageBinder(L, application);
	FontBaseBinder fontBaseBinder(L);
	FontBinder fontBinder(L);
	TTFontBinder ttfontBinder(L);
	TextFieldBinder textFieldBinder(L);
    AccelerometerBinder accelerometerBinder(L);
	Box2DBinder2 box2DBinder2(L);
	DibBinder dibBinder(L);
	TileMapBinder tileMapBinder(L);
	ApplicationBinder applicationBinder(L);
	ShapeBinder shapeBinder(L);
	MovieClipBinder movieClipBinder(L);
    UrlLoaderBinder urlLoaderBinder(L);
	GeolocationBinder geolocationBinder(L);
	GyroscopeBinder gyroscopeBinder(L);
    AlertDialogBinder alertDialogBinder(L);
    TextInputDialogBinder textInputDialogBinder(L);
    MeshBinder meshBinder(L);
    AudioBinder audioBinder(L);
    RenderTargetBinder renderTargetBinder(L);

	PluginManager& pluginManager = PluginManager::instance();
	for (size_t i = 0; i < pluginManager.plugins.size(); ++i)
        pluginManager.plugins[i].main(L, 0);

	lua_getglobal(L, "Event");
	lua_getfield(L, -1, "new");
	lua_pushlightuserdata(L, NULL);
	lua_call(L, 1, 1);
	lua_remove(L, -2);
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_Event);

	lua_getglobal(L, "Event");
	lua_getfield(L, -1, "new");
	lua_pushlightuserdata(L, NULL);
	lua_call(L, 1, 1);
	lua_remove(L, -2);
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_EnterFrameEvent);

	lua_getglobal(L, "Event");
	lua_getfield(L, -1, "new");
	lua_pushlightuserdata(L, NULL);
	lua_call(L, 1, 1);
	lua_remove(L, -2);
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_MouseEvent);

	lua_getglobal(L, "Event");
	lua_getfield(L, -1, "new");
	lua_pushlightuserdata(L, NULL);
	lua_call(L, 1, 1);
	lua_remove(L, -2);
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_TouchEvent);


	lua_getglobal(L, "Event");
	lua_getfield(L, -1, "new");
	lua_pushlightuserdata(L, NULL);
	lua_call(L, 1, 1);
	lua_remove(L, -2);
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_TimerEvent);

	lua_getglobal(L, "Event");
	lua_getfield(L, -1, "new");
	lua_pushlightuserdata(L, NULL);
	lua_call(L, 1, 1);
	lua_remove(L, -2);
	luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_KeyboardEvent);

    lua_getglobal(L, "Event");
    lua_getfield(L, -1, "new");
    lua_pushlightuserdata(L, NULL);
    lua_call(L, 1, 1);
    lua_remove(L, -2);
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &key_CompleteEvent);

#include "property.c.in"
#include "texturepack.c.in"
#include "sprite.c.in"
#include "compatibility.c.in"

	lua_newtable(L);

    lua_pushinteger(L, GINPUT_KEY_BACK);
	lua_setfield(L, -2, "BACK");
    lua_pushinteger(L, GINPUT_KEY_SEARCH);
	lua_setfield(L, -2, "SEARCH");
    lua_pushinteger(L, GINPUT_KEY_MENU);
	lua_setfield(L, -2, "MENU");
    lua_pushinteger(L, GINPUT_KEY_CENTER);
	lua_setfield(L, -2, "CENTER");
    lua_pushinteger(L, GINPUT_KEY_SELECT);
	lua_setfield(L, -2, "SELECT");
    lua_pushinteger(L, GINPUT_KEY_START);
	lua_setfield(L, -2, "START");
    lua_pushinteger(L, GINPUT_KEY_L1);
	lua_setfield(L, -2, "L1");
    lua_pushinteger(L, GINPUT_KEY_R1);
	lua_setfield(L, -2, "R1");

    lua_pushinteger(L, GINPUT_KEY_LEFT);
	lua_setfield(L, -2, "LEFT");
    lua_pushinteger(L, GINPUT_KEY_UP);
	lua_setfield(L, -2, "UP");
    lua_pushinteger(L, GINPUT_KEY_RIGHT);
	lua_setfield(L, -2, "RIGHT");
    lua_pushinteger(L, GINPUT_KEY_DOWN);
	lua_setfield(L, -2, "DOWN");

    lua_pushinteger(L, GINPUT_KEY_A);
    lua_setfield(L, -2, "A");
    lua_pushinteger(L, GINPUT_KEY_B);
    lua_setfield(L, -2, "B");
    lua_pushinteger(L, GINPUT_KEY_C);
    lua_setfield(L, -2, "C");
    lua_pushinteger(L, GINPUT_KEY_D);
    lua_setfield(L, -2, "D");
    lua_pushinteger(L, GINPUT_KEY_E);
    lua_setfield(L, -2, "E");
    lua_pushinteger(L, GINPUT_KEY_F);
    lua_setfield(L, -2, "F");
    lua_pushinteger(L, GINPUT_KEY_G);
    lua_setfield(L, -2, "G");
    lua_pushinteger(L, GINPUT_KEY_H);
    lua_setfield(L, -2, "H");
    lua_pushinteger(L, GINPUT_KEY_I);
    lua_setfield(L, -2, "I");
    lua_pushinteger(L, GINPUT_KEY_J);
    lua_setfield(L, -2, "J");
    lua_pushinteger(L, GINPUT_KEY_K);
    lua_setfield(L, -2, "K");
    lua_pushinteger(L, GINPUT_KEY_L);
    lua_setfield(L, -2, "L");
    lua_pushinteger(L, GINPUT_KEY_M);
    lua_setfield(L, -2, "M");
    lua_pushinteger(L, GINPUT_KEY_N);
    lua_setfield(L, -2, "N");
    lua_pushinteger(L, GINPUT_KEY_O);
    lua_setfield(L, -2, "O");
    lua_pushinteger(L, GINPUT_KEY_P);
    lua_setfield(L, -2, "P");
    lua_pushinteger(L, GINPUT_KEY_Q);
    lua_setfield(L, -2, "Q");
    lua_pushinteger(L, GINPUT_KEY_R);
    lua_setfield(L, -2, "R");
    lua_pushinteger(L, GINPUT_KEY_S);
    lua_setfield(L, -2, "S");
    lua_pushinteger(L, GINPUT_KEY_T);
    lua_setfield(L, -2, "T");
    lua_pushinteger(L, GINPUT_KEY_U);
    lua_setfield(L, -2, "U");
    lua_pushinteger(L, GINPUT_KEY_V);
    lua_setfield(L, -2, "V");
    lua_pushinteger(L, GINPUT_KEY_W);
    lua_setfield(L, -2, "W");
    lua_pushinteger(L, GINPUT_KEY_X);
    lua_setfield(L, -2, "X");
    lua_pushinteger(L, GINPUT_KEY_Y);
    lua_setfield(L, -2, "Y");
    lua_pushinteger(L, GINPUT_KEY_Z);
    lua_setfield(L, -2, "Z");

    lua_pushinteger(L, GINPUT_KEY_0);
    lua_setfield(L, -2, "NUM_0");
    lua_pushinteger(L, GINPUT_KEY_1);
    lua_setfield(L, -2, "NUM_1");
    lua_pushinteger(L, GINPUT_KEY_2);
    lua_setfield(L, -2, "NUM_2");
    lua_pushinteger(L, GINPUT_KEY_3);
    lua_setfield(L, -2, "NUM_3");
    lua_pushinteger(L, GINPUT_KEY_4);
    lua_setfield(L, -2, "NUM_4");
    lua_pushinteger(L, GINPUT_KEY_5);
    lua_setfield(L, -2, "NUM_5");
    lua_pushinteger(L, GINPUT_KEY_6);
    lua_setfield(L, -2, "NUM_6");
    lua_pushinteger(L, GINPUT_KEY_7);
    lua_setfield(L, -2, "NUM_7");
    lua_pushinteger(L, GINPUT_KEY_8);
    lua_setfield(L, -2, "NUM_8");
    lua_pushinteger(L, GINPUT_KEY_9);
    lua_setfield(L, -2, "NUM_9");

	lua_setglobal(L, "KeyCode");


	// correct clock function which is wrong in iphone
	lua_getglobal(L, "os");
	lua_pushcfunction(L, os_timer);
	lua_setfield(L, -2, "timer");
	lua_pop(L, 1);

	// register collectgarbagelater
//	lua_pushcfunction(L, ::collectgarbagelater);
//	lua_setglobal(L, "collectgarbagelater");

	registerModules(L);

	return 0;
}
Ejemplo n.º 13
0
static int loader(lua_State *L)
{
	const luaL_Reg functionlist[] = {
        {"isAvailable", isAvailable},
        {"login", login},
        {"logout", logout},
        {"showLeaderboard", showLeaderboard},
        {"reportScore", reportScore},
        {"showAchievements", showAchievements},
        {"reportAchievement", reportAchievement},
        {"loadAchievements", loadAchievements},
        {"loadScores", loadScores},
        {"loadPlayerScores", loadPlayerScores},
        {"getCurrentPlayer", getCurrentPlayer},
        {"getCurrentPlayerId", getCurrentPlayerId},
		{"loadState", loadState},
        {"updateState", updateState},
        {"resolveState", resolveState},
        {"deleteState", deleteState},
		{NULL, NULL},
	};
    
    g_createClass(L, "GooglePlay", "EventDispatcher", NULL, destruct, functionlist);
    
	// create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
    luaL_newweaktable(L, "v");
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);
    
	lua_getglobal(L, "Event");
	lua_pushstring(L, LOGIN_ERROR);
	lua_setfield(L, -2, "LOGIN_ERROR");
	lua_pushstring(L, LOGIN_COMPLETE);
	lua_setfield(L, -2, "LOGIN_COMPLETE");
	lua_pushstring(L, LOAD_SCORES_COMPLETE);
	lua_setfield(L, -2, "LOAD_SCORES_COMPLETE");
	lua_pushstring(L, REPORT_SCORE_COMPLETE);
	lua_setfield(L, -2, "REPORT_SCORE_COMPLETE");
	lua_pushstring(L, LOAD_ACHIEVEMENTS_COMPLETE);
	lua_setfield(L, -2, "LOAD_ACHIEVEMENTS_COMPLETE");
	lua_pushstring(L, REPORT_ACHIEVEMENT_COMPLETE);
	lua_setfield(L, -2, "REPORT_ACHIEVEMENT_COMPLETE");
	lua_pushstring(L, STATE_LOADED);
	lua_setfield(L, -2, "STATE_LOADED");
	lua_pushstring(L, STATE_ERROR);
	lua_setfield(L, -2, "STATE_ERROR");
	lua_pushstring(L, STATE_CONFLICT);
	lua_setfield(L, -2, "STATE_CONFLICT");
	lua_pushstring(L, STATE_DELETED);
	lua_setfield(L, -2, "STATE_DELETED");
	lua_pop(L, 1);
	
	lua_getglobal(L, "GooglePlay");
	lua_pushstring(L, TODAY);
	lua_setfield(L, -2, "TODAY");
	lua_pushstring(L, WEEK);
	lua_setfield(L, -2, "WEEK");
	lua_pushstring(L, ALL_TIME);
	lua_setfield(L, -2, "ALL_TIME");
	lua_pushstring(L, FRIENDS);
	lua_setfield(L, -2, "FRIENDS");
	lua_pushstring(L, ALL_PLAYERS);
	lua_setfield(L, -2, "ALL_PLAYERS");
	lua_pushnumber(L, UNLOCKED);
	lua_setfield(L, -2, "UNLOCKED");
	lua_pushnumber(L, REVEALED);
	lua_setfield(L, -2, "REVEALED");
	lua_pushnumber(L, HIDDEN);
	lua_setfield(L, -2, "HIDDEN");
	lua_pop(L, 1);

    GooglePlay *gms = new GooglePlay(L);
	g_pushInstance(L, "GooglePlay", gms->object());
    
	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, gms);
	lua_pop(L, 1);
    
	lua_pushvalue(L, -1);
	lua_setglobal(L, "googleplay");
    
    return 1;
}
Ejemplo n.º 14
0
static int loader(lua_State *L)
{
	const luaL_Reg functionlist[] = {
		{"isAnyAvailable", isAnyAvailable},
		{"getPlayerCount", getPlayerCount},
		{"getControllerName", getControllerName},
		{"getPlayers", getPlayers},
		{"vibrate", vibrate},
		{"setDeadZone", lSetDeadZone},
		{NULL, NULL},
	};
    
    g_createClass(L, "Controller", "EventDispatcher", NULL, destruct, functionlist);
    
	// create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
    luaL_newweaktable(L, "v");
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);
    
	lua_getglobal(L, "Event");
	lua_pushstring(L, RIGHT_JOYSTICK);
	lua_setfield(L, -2, "RIGHT_JOYSTICK");
	lua_pushstring(L, LEFT_JOYSTICK);
	lua_setfield(L, -2, "LEFT_JOYSTICK");
	lua_pushstring(L, RIGHT_TRIGGER);
	lua_setfield(L, -2, "RIGHT_TRIGGER");
	lua_pushstring(L, LEFT_TRIGGER);
	lua_setfield(L, -2, "LEFT_TRIGGER");
    lua_pushstring(L, AXIS_JOYSTICK);
    lua_setfield(L, -2, "AXIS_JOYSTICK");
	lua_pushstring(L, CONNECTED);
	lua_setfield(L, -2, "CONNECTED");
	lua_pushstring(L, DISCONNECTED);
	lua_setfield(L, -2, "DISCONNECTED");
	lua_pop(L, 1);
	
	lua_getglobal(L, "KeyCode");
	lua_pushnumber(L, DPAD_DOWN);
	lua_setfield(L, -2, "DPAD_DOWN");
	lua_pushnumber(L, DPAD_LEFT);
	lua_setfield(L, -2, "DPAD_LEFT");
	lua_pushnumber(L, DPAD_RIGHT);
	lua_setfield(L, -2, "DPAD_RIGHT");
	lua_pushnumber(L, DPAD_UP);
	lua_setfield(L, -2, "DPAD_UP");
	lua_pushnumber(L, BUTTON_L1);
	lua_setfield(L, -2, "BUTTON_L1");
	lua_pushnumber(L, BUTTON_L2);
	lua_setfield(L, -2, "BUTTON_L2");
	lua_pushnumber(L, BUTTON_L3);
	lua_setfield(L, -2, "BUTTON_L3");
	lua_pushnumber(L, BUTTON_R1);
	lua_setfield(L, -2, "BUTTON_R1");
	lua_pushnumber(L, BUTTON_R2);
	lua_setfield(L, -2, "BUTTON_R2");
	lua_pushnumber(L, BUTTON_R3);
	lua_setfield(L, -2, "BUTTON_R3");
	lua_pushnumber(L, BUTTON_MENU);
	lua_setfield(L, -2, "BUTTON_MENU");
	lua_pushnumber(L, BUTTON_BACK);
	lua_setfield(L, -2, "BUTTON_BACK");
	lua_pushnumber(L, BUTTON_A);
	lua_setfield(L, -2, "BUTTON_A");
	lua_pushnumber(L, BUTTON_X);
	lua_setfield(L, -2, "BUTTON_X");
	lua_pushnumber(L, BUTTON_Y);
	lua_setfield(L, -2, "BUTTON_Y");
	lua_pushnumber(L, BUTTON_B);
	lua_setfield(L, -2, "BUTTON_B");
	lua_pop(L, 1);

    Controller *c = new Controller(L);
	g_pushInstance(L, "Controller", c->object());
    
	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, c);
	lua_pop(L, 1);
    
	lua_pushvalue(L, -1);
	lua_setglobal(L, "controller");
    
    return 1;
}
Ejemplo n.º 15
0
static int loader(lua_State *L)
{
	const luaL_Reg functionlist[] = {
        {"login", login},
        {"logout", logout},
        {"getAccessToken", getAccessToken},
        {"getExpirationDate", getExpirationDate},
        {"dialog", dialog},
        {"get", request},
        {"post", post},
        {"delete", deleteRequest},
		{"getProfile", getProfile},
		{"getFriends", getFriends},
		{"getAlbums", getAlbums},
		{"getAppRequests", getAppRequests},
		{"getScores", getScores},
		{"postScore", postScore},
		{"postPhoto", postPhoto},
		{"postToFeed", postToFeed},
		{"inviteFriends", inviteFriends},
		{"share", share},
		{"upload", upload},
		{NULL, NULL},
	};
    
    g_createClass(L, "Facebook", "EventDispatcher", NULL, destruct, functionlist);
    
	// create a weak table in LUA_REGISTRYINDEX that can be accessed with the address of keyWeak
    luaL_newweaktable(L, "v");
    luaL_rawsetptr(L, LUA_REGISTRYINDEX, &keyWeak);
    
	lua_getglobal(L, "Event");
	lua_pushstring(L, LOGIN_COMPLETE);
	lua_setfield(L, -2, "LOGIN_COMPLETE");
	lua_pushstring(L, LOGIN_ERROR);
	lua_setfield(L, -2, "LOGIN_ERROR");
    lua_pushstring(L, LOGOUT_COMPLETE);
	lua_setfield(L, -2, "LOGOUT_COMPLETE");
	lua_pushstring(L, LOGOUT_ERROR);
	lua_setfield(L, -2, "LOGOUT_ERROR");
    lua_pushstring(L, OPEN_URL);
	lua_setfield(L, -2, "OPEN_URL");
    lua_pushstring(L, DIALOG_COMPLETE);
	lua_setfield(L, -2, "DIALOG_COMPLETE");
    lua_pushstring(L, DIALOG_ERROR);
	lua_setfield(L, -2, "DIALOG_ERROR");
    lua_pushstring(L, REQUEST_COMPLETE);
	lua_setfield(L, -2, "REQUEST_COMPLETE");
    lua_pushstring(L, REQUEST_ERROR);
	lua_setfield(L, -2, "REQUEST_ERROR");
	lua_pop(L, 1);
	
    GFacebook *facebook = new GFacebook;
	g_pushInstance(L, "Facebook", facebook->object());
    
	luaL_rawgetptr(L, LUA_REGISTRYINDEX, &keyWeak);
	lua_pushvalue(L, -2);
	luaL_rawsetptr(L, -2, facebook);
	lua_pop(L, 1);
    
	lua_pushvalue(L, -1);
	lua_setglobal(L, "facebook");
    
    return 1;
}