summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscuri <scuri>2010-06-10 20:17:50 +0000
committerscuri <scuri>2010-06-10 20:17:50 +0000
commit2fb345fc972465ade03cc1d527ad3c8db3438ac5 (patch)
tree3fd9b1f7e2b12fd79c2000c0f305e8ef7763364a /src
parentc5f7b4e29afdd70a0f05d8785619585a45916b27 (diff)
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/cdluacairo5.mak38
-rw-r--r--src/config.mak11
-rw-r--r--src/lua5/cdluacairo5.c108
-rw-r--r--src/lua5/cdluacairo5.def4
-rw-r--r--src/lua5/cdluapdf5.c4
5 files changed, 163 insertions, 2 deletions
diff --git a/src/cdluacairo5.mak b/src/cdluacairo5.mak
new file mode 100644
index 0000000..691046c
--- /dev/null
+++ b/src/cdluacairo5.mak
@@ -0,0 +1,38 @@
+PROJNAME = cd
+LIBNAME = cdluacairo
+
+OPT = YES
+
+DEFINES = CD_NO_OLD_INTERFACE
+SRCDIR = lua5
+SRC = cdluacairo5.c
+DEF_FILE = cdluacairo5.def
+
+ifneq ($(findstring Win, $(TEC_SYSNAME)), )
+ # In Win32 will work only for the Win32 base driver,
+ # it will NOT work for the GDK base driver.
+ LIBS = cdcairo
+else
+ ifdef GTK_DEFAULT
+ # In Linux will work only for the GDK base driver,
+ # it will NOT work for the X11 base driver.
+ # The main cd library already includes the Cairo driver.
+ LIBS =
+ else
+ # In Other Unices will work only for the X11 base driver,
+ # it will NOT work for the GDK base driver.
+ LIBS = cdcairo
+ endif
+endif
+
+ifdef USE_LUA52
+ LIBNAME := $(LIBNAME)52
+else
+ USE_LUA51 = Yes
+ LIBNAME := $(LIBNAME)51
+endif
+
+NO_LUALINK = Yes
+USE_CD = YES
+USE_CDLUA = YES
+CD = ..
diff --git a/src/config.mak b/src/config.mak
index ec852fb..d9af743 100644
--- a/src/config.mak
+++ b/src/config.mak
@@ -41,7 +41,7 @@ SRC = $(SRCCOMM) $(SRCSVG) $(SRCINTCGM) $(SRCDRV) $(SRCSIM)
ifneq ($(findstring Win, $(TEC_SYSNAME)), )
ifdef USE_GDK
SRC += $(SRCGDK) $(SRCNULL) $(SRCCAIRO)
- LIBNAME := cdgdk
+ LIBNAME := $(LIBNAME)gdk
USE_GTK = Yes
LIBS += cairo
else
@@ -51,10 +51,17 @@ ifneq ($(findstring Win, $(TEC_SYSNAME)), )
else
ifdef USE_GDK
SRC += $(SRCGDK) $(SRCCAIRO)
- LIBNAME := cdgdk
USE_GTK = Yes
LIBS += cairo
+ ifndef GTK_DEFAULT
+ # Build GDK version in IRIX,SunOS,AIX,Win32
+ LIBNAME := $(LIBNAME)gdk
+ endif
else
+ ifdef GTK_DEFAULT
+ # Build X11 version in Linux,Darwin,FreeBSD
+ LIBNAME := $(LIBNAME)x11
+ endif
SRC += $(SRCX11)
USE_X11 = Yes
endif
diff --git a/src/lua5/cdluacairo5.c b/src/lua5/cdluacairo5.c
new file mode 100644
index 0000000..0e99b3c
--- /dev/null
+++ b/src/lua5/cdluacairo5.c
@@ -0,0 +1,108 @@
+/** \file
+ * \brief Cairo Lua 5 Binding
+ *
+ * See Copyright Notice in cd.h
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "cd.h"
+#include "cdcairo.h"
+
+#include <lua.h>
+#include <lauxlib.h>
+
+#include "cdlua.h"
+#include "cdlua5_private.h"
+
+
+static void *cdimagergb_checkdata(lua_State* L, int param)
+{
+ return (void *)luaL_checkstring(L, param);
+}
+
+static cdluaContext cdluaimagergbctx =
+{
+ 0,
+ "CAIRO_IMAGERGB",
+ cdContextCairoImageRGB,
+ cdimagergb_checkdata,
+ NULL,
+ 0
+};
+
+static void *cdps_checkdata( lua_State *L, int param)
+{
+ return (void *)luaL_checkstring(L, param);
+}
+
+static cdluaContext cdluapsctx =
+{
+ 0,
+ "CAIRO_PS",
+ cdContextCairoPS,
+ cdps_checkdata,
+ NULL,
+ 0
+};
+
+static void *cdsvg_checkdata( lua_State *L, int param)
+{
+ return (void *)luaL_checkstring(L, param);
+}
+
+static cdluaContext cdluasvgctx =
+{
+ 0,
+ "CAIRO_SVG",
+ cdContextCairoSVG,
+ cdsvg_checkdata,
+ NULL,
+ 0
+};
+
+static void *cdpdf_checkdata(lua_State *L, int param)
+{
+ return (void *)luaL_checkstring(L, param);
+}
+
+static cdluaContext cdluapdfctx =
+{
+ 0,
+ "CAIRO_PDF",
+ cdContextCairoPDF,
+ cdpdf_checkdata,
+ NULL,
+ 0
+};
+
+static int cdlua5_initcairo(lua_State *L)
+{
+ (void)L;
+ cdInitContextPlus();
+ return 0;
+}
+
+static const struct luaL_reg cdlib[] = {
+ {"InitContextPlus", cdlua5_initcairo},
+ {NULL, NULL},
+};
+
+
+static int cdluacairo_open (lua_State *L)
+{
+ cdluaLuaState* cdL = cdlua_getstate(L);
+ cdInitContextPlus();
+ luaL_register(L, "cd", cdlib); /* leave "cd" table at the top of the stack */
+ cdlua_addcontext(L, cdL, &cdluapdfctx);
+ cdlua_addcontext(L, cdL, &cdluapsctx);
+ cdlua_addcontext(L, cdL, &cdluasvgctx);
+ cdlua_addcontext(L, cdL, &cdluaimagergbctx);
+ return 1;
+}
+
+int luaopen_cdluacairo(lua_State* L)
+{
+ return cdluacairo_open(L);
+}
diff --git a/src/lua5/cdluacairo5.def b/src/lua5/cdluacairo5.def
new file mode 100644
index 0000000..aa12034
--- /dev/null
+++ b/src/lua5/cdluacairo5.def
@@ -0,0 +1,4 @@
+EXPORTS
+ luaopen_cdluacairo
+
+ \ No newline at end of file
diff --git a/src/lua5/cdluapdf5.c b/src/lua5/cdluapdf5.c
index 40877ad..7fd2ece 100644
--- a/src/lua5/cdluapdf5.c
+++ b/src/lua5/cdluapdf5.c
@@ -37,7 +37,11 @@ int cdluapdf_open (lua_State *L)
{
cdluaLuaState* cdL = cdlua_getstate(L);
lua_pushliteral(L, "cd");
+#if LUA_VERSION_NUM > 501
+ lua_pushglobaltable(L);
+#else
lua_gettable(L, LUA_GLOBALSINDEX); /* leave "cd" table at the top of the stack */
+#endif
cdlua_addcontext(L, cdL, &cdluapdfctx);
return 1;
}