]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add Lua binding, patch by pancake and Phil Housley, fixes bug 540820
authorJürg Billeter <j@bitron.ch>
Sat, 17 Jan 2009 21:22:32 +0000 (21:22 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Sat, 17 Jan 2009 21:22:32 +0000 (21:22 +0000)
2009-01-17  Jürg Billeter  <j@bitron.ch>

* vapi/Makefile.am:
* vapi/lua.vapi:

Add Lua binding, patch by pancake and Phil Housley,
fixes bug 540820

svn path=/trunk/; revision=2378

ChangeLog
vapi/Makefile.am
vapi/lua.vapi [new file with mode: 0644]

index 82c8c89338840f6062ef6d95e46123deafe51acc..21b9cf81dd179cfe35917eb5ce12cb179c19cf10 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-01-17  Jürg Billeter  <j@bitron.ch>
+
+       * vapi/Makefile.am:
+       * vapi/lua.vapi:
+
+       Add Lua binding, patch by pancake and Phil Housley,
+       fixes bug 540820
+
 2009-01-17  Jürg Billeter  <j@bitron.ch>
 
        * vapi/gsl.vapi:
index e1a5651d4ba7d41007f0123a7502d3c8b521df84..4ff6036cad33f2067676ad5cf951e65776ee0577 100644 (file)
@@ -107,6 +107,7 @@ dist_vapi_DATA = \
        libwnck-1.0.vapi \
        libxml-2.0.vapi \
        loudmouth-1.0.vapi \
+       lua.vapi \
        mysql.vapi \
        pango.deps \
        pango.vapi \
diff --git a/vapi/lua.vapi b/vapi/lua.vapi
new file mode 100644 (file)
index 0000000..3cd0379
--- /dev/null
@@ -0,0 +1,131 @@
+/* lua.vapi
+ *
+ * Copyright (C) 2008 pancake
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     pancake <youterm.com>
+ */
+
+[CCode (lower_case_cprefix = "lua_", cheader_filename = "lua.h")]
+namespace Lua {
+       [CCode (cname="lua_CFunction")]
+       public static delegate int Callback(LuaVM vm);
+
+       [CCode (free_function = "lua_close", cname = "lua_State", cprefix = "lua_")]
+       [Compact]
+       public class LuaVM {
+               /* creation methods */
+               [CCode (cname="(lua_State*)lua_open")]
+               public static LuaVM open();
+               [CCode (cname="lua_newthread")]
+               public LuaVM new_thread();
+               public void close();
+               public int gc(int what, int data);
+               public int getgccount();
+               [CCode (cname="luaL_openlibs")]
+               public void openlibs();
+
+               /* stack manipulation */
+               public int gettop();
+               public void settop(int idx);
+               public void pushvalue(int idx);
+               public void remove(int idx);
+               public void insert(int idx);
+               public void replace(int idx);
+               public int checkstack(int sz);
+               public static void xmove(LuaVM from, LuaVM to, int n);
+
+               /* code loading */
+               [CCode (cname = "luaL_loadbuffer")]
+               public int load_buffer(string cmd, int len);
+
+               /* access functions */
+               public int isnumber(int idx);
+               public int isstring(int idx);
+               public int iscfunction(int idx);
+               public int isuserdata(int idx);
+               public int type(int idx);
+               public weak string typename(int tp);
+
+               public int equal(int idx1, int idx2);
+               public int rawequal(int idx1, int idx2);
+               public int lessthan(int idx1, int idx2);
+
+               // TODO: tonumber, tointeger
+               public double tonumber(int idx);
+               public int tointeger(int idx);
+               public LuaVM tothread(int idx);
+               public void* topointer(int idx);
+               public Callback tocfunction(int idx);
+               public int toboolean(int idx1);
+
+               //[CCode (cname = "lua_register")]
+               public void register(string name, Callback fun);
+               public void pushcfunction(Callback fun);
+
+               /* push functions */
+               public void pushnil();
+               public void pushnumber();
+               public void pushlstring(string s, int len);
+               public void pushstring(string s);
+               //public void pushvfstring(weak string s);
+               public void pushboolean(int b);
+               public void pushlightuserdata(void* p);
+               public void pushthread(LuaVM vm);
+
+               /* get functions */
+               public void gettable(int idx);
+               public void getfield(int idx, string k);
+               public void rawget(int idx);
+               public void rawgeti(int idx, int n);
+               public void createtable(int narr, int nrec);
+               public void* newuserdata(int sz);
+               public int getmetatable(int objindex);
+               public void getfenv(int idx);
+
+               /* set functions */
+               public void settable(int idx);
+               public void setfield(int idx, string k);
+               public void rawset(int idx);
+               public void rawseti(int idx, int n);
+               public int setmetatable(int objindex);
+               public void setfenv(int idx);
+
+               /* call functions */
+               public void call(int nargs=0, int nresults=0);
+               public int pcall(int nargs=0, int nresults=0, int errfunc=0);
+               public int cpcall(Callback fun, void* ud);
+//TODO         public int load(lua_Reader reader, pointer ud, weak string chunkname);
+
+               /* some useful macros */
+               public int pop(int idx);
+               public void newtable();
+               public int strlen(int n);
+               public bool isnil(int n);
+               public bool isboolean(int n);
+               public bool isthread(int n);
+               public bool isnone(int n);
+               public bool isnoneornil(int n);
+               public void pushliteral(string s);
+               public weak string tostring(int idx);
+
+               /* coroutine functions */
+               public int yield(int nresults);
+               public int resume(int narg);
+               public int status();
+       }
+}