mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
luainstance: the name is "Lua", not "LUA"
Origin commit data
------------------
Branch: ni/coolstream
Commit: 4d7e07f81f
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2013-03-18 (Mon, 18 Mar 2013)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
committed by
Michael Liebmann
parent
88c69c92bd
commit
cef20d5284
@@ -36,9 +36,9 @@
|
|||||||
#define lua_unboxpointer(L, i) \
|
#define lua_unboxpointer(L, i) \
|
||||||
(*(void **)(lua_touserdata(L, i)))
|
(*(void **)(lua_touserdata(L, i)))
|
||||||
|
|
||||||
const char CLUAInstance::className[] = "neutrino";
|
const char CLuaInstance::className[] = "neutrino";
|
||||||
|
|
||||||
CLUAInstance::CLUAInstance()
|
CLuaInstance::CLuaInstance()
|
||||||
{
|
{
|
||||||
/* Create the intepreter object. */
|
/* Create the intepreter object. */
|
||||||
lua = luaL_newstate();
|
lua = luaL_newstate();
|
||||||
@@ -47,7 +47,7 @@ CLUAInstance::CLUAInstance()
|
|||||||
registerFunctions();
|
registerFunctions();
|
||||||
}
|
}
|
||||||
|
|
||||||
CLUAInstance::~CLUAInstance()
|
CLuaInstance::~CLuaInstance()
|
||||||
{
|
{
|
||||||
if (lua != NULL)
|
if (lua != NULL)
|
||||||
{
|
{
|
||||||
@@ -67,13 +67,13 @@ CLUAInstance::~CLUAInstance()
|
|||||||
lua_setglobal(lua, #NAME);
|
lua_setglobal(lua, #NAME);
|
||||||
|
|
||||||
/* Run the given script. */
|
/* Run the given script. */
|
||||||
void CLUAInstance::runScript(const char *fileName)
|
void CLuaInstance::runScript(const char *fileName)
|
||||||
{
|
{
|
||||||
// luaL_dofile(lua, fileName);
|
// luaL_dofile(lua, fileName);
|
||||||
/* run the script */
|
/* run the script */
|
||||||
int status = luaL_loadfile(lua, fileName);
|
int status = luaL_loadfile(lua, fileName);
|
||||||
if (status) {
|
if (status) {
|
||||||
fprintf(stderr, "[CLUAInstance::%s] Can't load file: %s\n", __func__, lua_tostring(lua, -1));
|
fprintf(stderr, "[CLuaInstance::%s] Can't load file: %s\n", __func__, lua_tostring(lua, -1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,19 +121,19 @@ void CLUAInstance::runScript(const char *fileName)
|
|||||||
|
|
||||||
status = lua_pcall(lua, 0, LUA_MULTRET, 0);
|
status = lua_pcall(lua, 0, LUA_MULTRET, 0);
|
||||||
if (status)
|
if (status)
|
||||||
fprintf(stderr, "[CLUAInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1));
|
fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, lua_tostring(lua, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
const luaL_Reg CLUAInstance::methods[] =
|
const luaL_Reg CLuaInstance::methods[] =
|
||||||
{
|
{
|
||||||
{ "PaintBox", CLUAInstance::PaintBox },
|
{ "PaintBox", CLuaInstance::PaintBox },
|
||||||
{ "RenderString", CLUAInstance::RenderString },
|
{ "RenderString", CLuaInstance::RenderString },
|
||||||
{ "PaintIcon", CLUAInstance::PaintIcon },
|
{ "PaintIcon", CLuaInstance::PaintIcon },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* load basic functions and register our own C callbacks */
|
/* load basic functions and register our own C callbacks */
|
||||||
void CLUAInstance::registerFunctions()
|
void CLuaInstance::registerFunctions()
|
||||||
{
|
{
|
||||||
luaL_openlibs(lua);
|
luaL_openlibs(lua);
|
||||||
luaopen_table(lua);
|
luaopen_table(lua);
|
||||||
@@ -165,16 +165,16 @@ void CLUAInstance::registerFunctions()
|
|||||||
lua_register(lua, className, NewWindow);
|
lua_register(lua, className, NewWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFBWindow *CLUAInstance::CheckWindow(lua_State *L, int narg)
|
CFBWindow *CLuaInstance::CheckWindow(lua_State *L, int narg)
|
||||||
{
|
{
|
||||||
luaL_checktype(L, narg, LUA_TUSERDATA);
|
luaL_checktype(L, narg, LUA_TUSERDATA);
|
||||||
void *ud = luaL_checkudata(L, narg, className);
|
void *ud = luaL_checkudata(L, narg, className);
|
||||||
if (!ud)
|
if (!ud)
|
||||||
fprintf(stderr, "[CLUAInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className);
|
fprintf(stderr, "[CLuaInstance::%s] wrong type %p, %d, %s\n", __func__, L, narg, className);
|
||||||
return *(CFBWindow **)ud; // unbox pointer
|
return *(CFBWindow **)ud; // unbox pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLUAInstance::NewWindow(lua_State *L)
|
int CLuaInstance::NewWindow(lua_State *L)
|
||||||
{
|
{
|
||||||
int count = lua_gettop(L);
|
int count = lua_gettop(L);
|
||||||
int x = g_settings.screen_StartX;
|
int x = g_settings.screen_StartX;
|
||||||
@@ -196,9 +196,9 @@ int CLUAInstance::NewWindow(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLUAInstance::PaintBox(lua_State *L)
|
int CLuaInstance::PaintBox(lua_State *L)
|
||||||
{
|
{
|
||||||
DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L));
|
DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
|
|
||||||
@@ -225,9 +225,9 @@ int CLUAInstance::PaintBox(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLUAInstance::PaintIcon(lua_State *L)
|
int CLuaInstance::PaintIcon(lua_State *L)
|
||||||
{
|
{
|
||||||
DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L));
|
DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
int x, y, h;
|
int x, y, h;
|
||||||
unsigned int o;
|
unsigned int o;
|
||||||
const char *fname;
|
const char *fname;
|
||||||
@@ -244,13 +244,13 @@ int CLUAInstance::PaintIcon(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLUAInstance::RenderString(lua_State *L)
|
int CLuaInstance::RenderString(lua_State *L)
|
||||||
{
|
{
|
||||||
int x, y, w, boxh, utf8, f;
|
int x, y, w, boxh, utf8, f;
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
const char *text;
|
const char *text;
|
||||||
int numargs = lua_gettop(L);
|
int numargs = lua_gettop(L);
|
||||||
DBG("CLUAInstance::%s %d\n", __func__, numargs);
|
DBG("CLuaInstance::%s %d\n", __func__, numargs);
|
||||||
c = COL_MENUCONTENT;
|
c = COL_MENUCONTENT;
|
||||||
boxh = 0;
|
boxh = 0;
|
||||||
utf8 = 1;
|
utf8 = 1;
|
||||||
@@ -278,9 +278,9 @@ int CLUAInstance::RenderString(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLUAInstance::GCWindow(lua_State *L)
|
int CLuaInstance::GCWindow(lua_State *L)
|
||||||
{
|
{
|
||||||
DBG("CLUAInstance::%s %d\n", __func__, lua_gettop(L));
|
DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L));
|
||||||
CFBWindow *w = (CFBWindow *)lua_unboxpointer(L, 1);
|
CFBWindow *w = (CFBWindow *)lua_unboxpointer(L, 1);
|
||||||
delete w;
|
delete w;
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -28,14 +28,14 @@ extern "C" {
|
|||||||
#include <driver/fb_window.h>
|
#include <driver/fb_window.h>
|
||||||
|
|
||||||
/* inspired by Steve Kemp http://www.steve.org.uk/ */
|
/* inspired by Steve Kemp http://www.steve.org.uk/ */
|
||||||
class CLUAInstance
|
class CLuaInstance
|
||||||
{
|
{
|
||||||
static const char className[];
|
static const char className[];
|
||||||
static const luaL_Reg methods[];
|
static const luaL_Reg methods[];
|
||||||
static CFBWindow *CheckWindow(lua_State *L, int narg);
|
static CFBWindow *CheckWindow(lua_State *L, int narg);
|
||||||
public:
|
public:
|
||||||
CLUAInstance();
|
CLuaInstance();
|
||||||
~CLUAInstance();
|
~CLuaInstance();
|
||||||
void runScript(const char *fileName);
|
void runScript(const char *fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -354,7 +354,7 @@ void CPlugins::startLuaPlugin(int number)
|
|||||||
script, plugin_list[number].cfgfile.c_str());
|
script, plugin_list[number].cfgfile.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CLUAInstance *lua = new CLUAInstance();
|
CLuaInstance *lua = new CLuaInstance();
|
||||||
lua->runScript(script);
|
lua->runScript(script);
|
||||||
delete lua;
|
delete lua;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user