Example #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;
	}
}
Example #2
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;
}
Example #3
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);
}
Example #4
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;
}
Example #5
0
unsigned int clua_togostruct(lua_State *L, int index)
{
	int *r = clua_checkgosomething(L, index, MT_GOINTERFACE);
	return (r != NULL) ? *r : -1;
}
Example #6
0
unsigned int clua_togofunction(lua_State* L, int index)
{
	int *r = clua_checkgosomething(L, index, MT_GOFUNCTION);
	return (r != NULL) ? *r : -1;
}