From d577d991b97ae2b5ee1af23641bcffc3f83af5b2 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 4 Nov 2009 11:56:41 -0800 Subject: Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux. --- iup/srclua5/iuplua_api.c | 874 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 874 insertions(+) create mode 100755 iup/srclua5/iuplua_api.c (limited to 'iup/srclua5/iuplua_api.c') diff --git a/iup/srclua5/iuplua_api.c b/iup/srclua5/iuplua_api.c new file mode 100755 index 0000000..8673442 --- /dev/null +++ b/iup/srclua5/iuplua_api.c @@ -0,0 +1,874 @@ +/** \file +* \brief IUP binding for Lua 5. +* +* See Copyright Notice in "iup.h" +*/ + +#include +#include +#include + +#include "iup.h" +#include "iupkey.h" + +#include +#include + +#include "iuplua.h" +#include "il.h" + +#include "iup_attrib.h" +#include "iup_globalattrib.h" +#include "iup_object.h" +#include "iup_str.h" + + +static int SaveImageAsText(lua_State *L) +{ + Ihandle *ih = iuplua_checkihandle(L, 1); + const char *file_name = luaL_checkstring(L, 2); + const char *format = luaL_checkstring(L, 3); + const char *name = luaL_optstring(L, 4, NULL); + lua_pushboolean(L, IupSaveImageAsText(ih, file_name, format, name)); + return 1; +} + +static int Reparent(lua_State *L) +{ + lua_pushnumber(L, IupReparent(iuplua_checkihandle(L,1), + iuplua_checkihandle(L,2))); + return 1; +} + +static int Insert(lua_State *L) +{ + iuplua_pushihandle(L, IupInsert(iuplua_checkihandle(L,1), + iuplua_checkihandleornil(L,2), + iuplua_checkihandle(L,3))); + return 1; +} + +static int Append(lua_State *L) +{ + iuplua_pushihandle(L, IupAppend(iuplua_checkihandle(L,1), + iuplua_checkihandle(L,2))); + return 1; +} + +static int Destroy(lua_State *L) +{ + Ihandle* ih = iuplua_checkihandle(L,1); + iuplua_removeihandle(L, ih); + IupDestroy(ih); + return 0; +} + +static int Detach(lua_State *L) +{ + IupDetach(iuplua_checkihandle(L,1)); + return 0; +} + +static int Flush(lua_State *L) +{ + (void)L; /* not used */ + IupFlush(); + return 0; +} + +static int Version(lua_State *L) +{ + lua_pushstring(L, IupVersion()); + return 1; +} + +static int GetAttributeData (lua_State *L) +{ + Ihandle *ih = iuplua_checkihandle(L,1); + const char *name = luaL_checkstring(L,2); + const char *value = IupGetAttribute(ih, name); + if (!value) + lua_pushnil(L); + else + lua_pushlightuserdata(L, (void*)value); + return 1; +} + +static int GetAttribute (lua_State *L) +{ + Ihandle *ih = iuplua_checkihandle(L,1); + const char *name = luaL_checkstring(L,2); + const char *value = IupGetAttribute(ih, name); + if (!value || iupAttribIsInternal(name)) + lua_pushnil(L); + else + { + if (iupAttribIsPointer(ih, name)) + { + if (iupObjectCheck((Ihandle*)value)) + iuplua_pushihandle(L, (Ihandle*)value); + else + lua_pushlightuserdata(L, (void*)value); + } + else + lua_pushstring(L,value); + } + return 1; +} + +static int GetAttributes(lua_State *L) +{ + Ihandle *ih = iuplua_checkihandle(L,1); + const char *value = IupGetAttributes(ih); + lua_pushstring(L,value); + return 1; +} + +static int GetAllDialogs(lua_State *L) +{ + int i, max_n = luaL_checkint(L,1); + char **names = (char **) malloc (max_n * sizeof(char *)); + int n = IupGetAllDialogs(names, max_n); + lua_newtable(L); + for (i=0; i