Exemple #1
0
/* called when lua code attempts to set a field of a published go object */
int interface_newindex_callback(lua_State *L)
{
	unsigned int *iid = clua_checkgosomething(L, 1, MT_GOINTERFACE);
	if (iid == NULL)
	{
		lua_pushnil(L);
		return 1;
	}

	char *field_name = (char *)lua_tostring(L, 2);
	if (field_name == NULL)
	{
		lua_pushnil(L);
		return 1;
	}

	GoInterface* gi = clua_getgostate(L);

	int r = golua_interface_newindex_callback(*gi, *iid, field_name);

	if (r < 0)
	{
		lua_error(L);
		return 0;
	}
	else
	{
		return r;
	}
}
Exemple #2
0
//wrapper for callgofunction
int callback_function(lua_State* L)
{
	unsigned int *fid = clua_checkgofunction(L,1);
	GoInterface* gi = clua_getgostate(L);
	//remove the go function from the stack (to present same behavior as lua_CFunctions)
	lua_remove(L,1);
	return golua_callgofunction(*gi,*fid);
}
Exemple #3
0
//wrapper for gchook
int gchook_wrapper(lua_State* L)
{
	//printf("Garbage collection wrapper\n");
	unsigned int* fid = clua_checkgosomething(L, -1, NULL);
	GoInterface* gi = clua_getgostate(L);
	if (fid != NULL)
		return golua_gchook(*gi,*fid);
	return 0;
}
Exemple #4
0
//wrapper for callgofunction
int callback_function(lua_State* L)
{
	int r;
	unsigned int *fid = clua_checkgosomething(L, 1, MT_GOFUNCTION);
	GoInterface* gi = clua_getgostate(L);
	//remove the go function from the stack (to present same behavior as lua_CFunctions)
	lua_remove(L,1);
	return golua_callgofunction(*gi, fid!=NULL ? *fid : -1);
}
Exemple #5
0
//wrapper for gchook
int gchook_wrapper(lua_State* L)
{
	//printf("Garbage collection wrapper\n");
	unsigned int* fid = clua_checkgosomething(L, -1, NULL);
	size_t gostateindex = clua_getgostate(L);
	if (fid != NULL)
		return golua_gchook(gostateindex,*fid);
	return 0;
}
Exemple #6
0
int callback_panicf(lua_State* L)
{
	lua_pushlightuserdata(L,(void*)&PanicFIDRegistryKey);
	lua_gettable(L,LUA_REGISTRYINDEX);
	unsigned int fid = lua_tointeger(L,-1);
	lua_pop(L,1);
	GoInterface* gi = clua_getgostate(L);
	return golua_callpanicfunction(*gi,fid);

}
Exemple #7
0
//wrapper for gchook
int gchook_wrapper(lua_State* L) 
{
	unsigned int* fid = clua_checkgofunction(L,-1); //TODO: this will error
	GoInterface* gi = clua_getgostate(L);
	if(fid != NULL)
		return golua_gchook(*gi,*fid);

	//TODO: try udata or whatever, after impl

	return 0;
}
Exemple #8
0
int panic_msghandler(lua_State *L)
{
	GoInterface* gi = clua_getgostate(L);
	go_panic_msghandler(*gi, (char *)lua_tolstring(L, -1, NULL));
}
Exemple #9
0
static int callback_c (lua_State* L)
{
	int fid = clua_togofunction(L,lua_upvalueindex(1));
	GoInterface *gi = clua_getgostate(L);
	return golua_callgofunction(*gi,fid);
}
Exemple #10
0
int panic_msghandler(lua_State *L)
{
	int gostateindex = clua_getgostate(L);
	go_panic_msghandler(gostateindex, (char *)lua_tolstring(L, -1, NULL));
	return 0;
}
Exemple #11
0
static int callback_c (lua_State* L)
{
	int fid = clua_togofunction(L,lua_upvalueindex(1));
	int gostateindex = clua_getgostate(L);
	return golua_callgofunction(gostateindex,fid);
}