Commit c537b8e0 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia
Browse files

[OPENBUS-2184] Adaptação do código para ser compatível também com Lua 5.2

- Remoção da dependência da biblioteca 'LuaInspector'.
- Ajustes para compilar em Lua 5.1 com o a biblioteca Compat-5.2.

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/core/branches/02_00_00@149423 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 84990331
......@@ -13,7 +13,6 @@
#include "luatuple.h"
#include "luacoroutine.h"
#include "luacothread.h"
#include "luainspector.h"
#include "luaidl.h"
#include "oil.h"
#include "luascs.h"
......@@ -33,8 +32,8 @@
#define LPW_LIBNAME "lpw"
#if (LUA_VERSION_NUM < 502)
#define luaL_newlib(L,f) luaL_register(L,"lpw",f)
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
#include "compat-5.2.h"
#endif
const char const* OPENBUS_MAIN = "openbus.core.admin.main";
......@@ -154,7 +153,6 @@ void luapreload_extralibraries(lua_State *L)
luapreload_luatuple(L);
luapreload_luacoroutine(L);
luapreload_luacothread(L);
luapreload_luainspector(L);
luapreload_luaidl(L);
luapreload_oil(L);
luapreload_luascs(L);
......
......@@ -71,6 +71,12 @@ LDIR+= \
$(SCS_LUA_HOME)/lib/$(TEC_UNAME) \
$(OPENBUS_LUA_HOME)/lib/$(TEC_UNAME)
ifdef USE_LUA51
INCLUDES+= $(LUACOMPAT52_HOME)/c-api $(LUACOMPAT52_HOME)/obj/$(TEC_UNAME)
LDIR+= $(LUACOMPAT52_HOME)/lib/$(TEC_UNAME)
LIBS+= luacompat52 luabit32 luacompat52c
endif
ifeq "$(TEC_SYSNAME)" "Linux"
LFLAGS = -Wl,-E
endif
......
......@@ -77,6 +77,12 @@ LDIR+= \
$(SCS_LUA_HOME)/lib/$(TEC_UNAME) \
$(OPENBUS_LUA_HOME)/lib/$(TEC_UNAME)
ifdef USE_LUA51
INCLUDES+= $(LUACOMPAT52_HOME)/c-api $(LUACOMPAT52_HOME)/obj/$(TEC_UNAME)
LDIR+= $(LUACOMPAT52_HOME)/lib/$(TEC_UNAME)
LIBS+= luacompat52 luabit32 luacompat52c
endif
ifeq "$(TEC_SYSNAME)" "Linux"
LFLAGS = -Wl,-E
endif
......
......@@ -16,7 +16,6 @@
#include "luatuple.h"
#include "luacoroutine.h"
#include "luacothread.h"
#include "luainspector.h"
#include "luaidl.h"
#include "oil.h"
#include "luascs.h"
......@@ -51,7 +50,6 @@ void luapreload_extralibraries(lua_State *L)
luapreload_luatuple(L);
luapreload_luacoroutine(L);
luapreload_luacothread(L);
luapreload_luainspector(L);
luapreload_luaidl(L);
luapreload_oil(L);
luapreload_luascs(L);
......
......@@ -16,6 +16,14 @@
#include "extralibraries.h"
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
#include "compat-5.2.h"
#include "luacompat52.h"
#endif
#if !defined(LUA_OK)
#define LUA_OK 0
#endif
#if !defined(LUA_PROMPT)
#define LUA_PROMPT "> "
......@@ -45,6 +53,9 @@ static lua_State *globalL = NULL;
static const char *progpath = NULL;
static const char *callerchunk =
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
" require 'compat52'"
#endif
" local _G = require '_G'"
" local error = _G.error"
" local tostring = _G.tostring"
......@@ -88,8 +99,9 @@ static void laction (int i) {
static void l_message (const char *pname, const char *msg) {
if (pname) luai_writestringerror("%s: ", pname);
luai_writestringerror("%s\n", msg);
if (pname) fprintf(stderr, "%s: ", pname);
fprintf(stderr, "%s\n", msg);
fflush(stderr);
}
......@@ -164,7 +176,6 @@ static int dostring (lua_State *L, const char *s, const char *name) {
static int pmain (lua_State *L) {
int argc = (int)lua_tointeger(L, 1);
char **argv = (char **)lua_touserdata(L, 2);
int status = 0;
/* open standard libraries */
......@@ -187,6 +198,9 @@ static int pmain (lua_State *L) {
/* preload libraries and global variables */
lua_pushstring(L, OPENBUS_MAIN); lua_setglobal(L, "OPENBUS_MAIN");
lua_pushstring(L, OPENBUS_PROGNAME); lua_setglobal(L, "OPENBUS_PROGNAME");
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501
luapreload_luacompat52(L);
#endif
luapreload_extralibraries(L);
/* ??? */
......@@ -196,7 +210,7 @@ static int pmain (lua_State *L) {
if (status == LUA_OK) {
lua_getglobal(L, "require");
lua_pushstring(L, OPENBUS_MAIN);
status = lua_pcall(L, 1, 1, 0);
status = docall(L, 1, 1);
if (status == LUA_OK) {
int narg = getargs(L, argv); /* collect arguments */
status = docall(L, narg+1, 1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment