PIP Lua Module
This commit is contained in:
12
lib/main/lua/piluaprogram.h
Normal file
12
lib/main/lua/piluaprogram.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef PILUAPROGRAM_H
|
||||
#define PILUAPROGRAM_H
|
||||
|
||||
#include "pip_lua.h"
|
||||
|
||||
class PILuaProgram
|
||||
{
|
||||
public:
|
||||
PILuaProgram();
|
||||
};
|
||||
|
||||
#endif // PILUAPROGRAM_H
|
||||
39
lib/main/lua/pip_lua.h
Normal file
39
lib/main/lua/pip_lua.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef PIP_LUA_H
|
||||
#define PIP_LUA_H
|
||||
|
||||
extern "C" {
|
||||
# include "lua.h"
|
||||
# include "lauxlib.h"
|
||||
# include "lualib.h"
|
||||
}
|
||||
#include <LuaBridge/LuaBridge.h>
|
||||
#include "pistring.h"
|
||||
|
||||
namespace luabridge {
|
||||
|
||||
template <>
|
||||
struct Stack <PIString> {
|
||||
static void push (lua_State* L, PIString const& str) {
|
||||
lua_pushstring(L, str.dataUTF8());
|
||||
}
|
||||
|
||||
static PIString get (lua_State* L, int index) {
|
||||
if (lua_type(L, index) == LUA_TSTRING) {
|
||||
const char* str = lua_tostring(L, index);
|
||||
return PIString::fromUTF8(str);
|
||||
}
|
||||
|
||||
lua_pushvalue(L, index);
|
||||
const char* str = lua_tostring(L, -1);
|
||||
PIString string = PIString::fromUTF8(str);
|
||||
lua_pop(L, 1);
|
||||
return string;
|
||||
}
|
||||
|
||||
static bool isInstance (lua_State* L, int index) {
|
||||
return lua_type(L, index) == LUA_TSTRING;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif // PIP_LUA_H
|
||||
Reference in New Issue
Block a user