[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Need some help here .. Had agood start...!!
- From: Subhash_Patil <Subhash_Patil@...>
- Date: Sat, 1 Aug 2009 21:00:05 +0530
Dear Sir/Team,
Had a good startup.
Was able to call some c functions.
Now I am looking for loading and executing an external LUA (startup.lua) file.
Here if you see the "startup.lua" there are two lines of code. The first one gets executed but nothing for the second function call. But the same function works fine if called directly (not from external "startup.lua" file).
The next step is to pass the events from the C function to LUA.
TD_BOOLEAN GUI_DrawFillCircle(TD_UINT8 INucHandleIndex, TD_UINT32 INuiX, TD_UINT32 INuiY, TD_UINT32 INuiRadius)
{
**********Some code here****************
}
TD_BOOLEAN GUI_DrawFilledRect(TD_UINT8 INucHandleIndex, TD_UINT32 INuiX, TD_UINT32 INuiY, TD_UINT32 INuiWidth, TD_UINT32 INuiHeight)
{
**********Some code here****************
}
int DrawFill_Circle(lua_State*Lua_VM)
{
int i,j[5], n;
n = lua_gettop(Lua_VM);
printf("stack size:%d\n",n );
for (i = 1; i <= n; i++)
{
if ( ! lua_isnumber(Lua_VM, -1))
{
printf("from stack not an integer:%d\n",i );
}
else
{
j[(i-1)] = lua_tonumber(Lua_VM, -1);
lua_pop(Lua_VM, 1);
printf("from stack %d\n",j[(i-1)]);
}
if ( lua_isnumber(Lua_VM, n-1))
{
printf("from stack n-1 is an integer:%d\n",n-1 );
}
}//end for
GUI_DrawFillCircle (j[3], j[2] , j[1] , j[0]);
return 0;
}
int Draw_Rect(lua_State*Lua_VM)
{
int i,j[5], n;
n = lua_gettop(Lua_VM);
printf("stack size:%d\n",n );
for (i = 1; i <= n; i++)
{
if ( ! lua_isnumber(Lua_VM, -1))
{
printf("from stack not an integer:%d\n",i );
}
else
{
j[(i-1)] = lua_tonumber(Lua_VM, -1);
lua_pop(Lua_VM, 1);
printf("from stack %d\n",j[(i-1)]);
}
if ( lua_isnumber(Lua_VM, n-1))
{
printf("from stack n-1 is an integer:%d\n",n-1 );
}
}
GUI_DrawFilledRect(j[4] , j[3] , j[2] , j[1] , j[0] );
return 0;
}
int Lua_Main( void ){
int error;
lua_State *Lua_VM = lua_open(); /* opens Lua */
lua_Integer n;
luaL_openlibs(Lua_VM);
printf("luaL_openlibs\n");
lua_setglobal(Lua_VM, " DrawRect");
lua_setglobal(Lua_VM, " DrawFill_Circle");
n = lua_gettop(Lua_VM);
printf("stack size:%d\n",n );
lua_pushcfunction(Lua_VM, Draw_Rect);
lua_pushcfunction(Lua_VM, DrawFill_Circle);
n = lua_gettop(Lua_VM);
printf("stack size:%d\n",n );
#if LUA_CIRCLE
n = 0;
lua_pushinteger(Lua_VM, n);
n = 300;
lua_pushinteger(Lua_VM, n);
n = 100;
lua_pushinteger(Lua_VM, n);
n = 50;
lua_pushinteger(Lua_VM, n);
lua_call(Lua_VM, 4 , 1);
#elif LUA_RECT
n = 0;
lua_pushinteger(Lua_VM, n);
n = 100;
lua_pushinteger(Lua_VM, n);
n = 100;
lua_pushinteger(Lua_VM, n);
n = 300;
lua_pushinteger(Lua_VM, n);
n = 300;
lua_pushinteger(Lua_VM, n);
lua_call(Lua_VM, 5 , 1);
#else
luaL_dofile(Lua_VM, "./startup.lua");
#endif
/* luaL_loadbuffer(Lua_VM, buff, strlen(buff), "Rectangle");
printf("luaL_loadbuffer\n");
lua_pcall( Lua_VM, 5, 0,0);
printf("lua_call\n");
*/
lua_close(Lua_VM);
return 0;
}
/************startup.lua*************
io.write("Hello File load successful from LUA \n")
SCSL_DrawFill_Circle(0,300,100,50)
Best Regards,
Subhash
DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.