commit e1d91fd0e185e295fa15dd508580d3c8d4636960
parent 5e60b961deb0d70935c6b1ec6e92eb7b9f9be75b
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Sun, 13 Nov 1994 14:16:45 -0200
new API function to create tables
Diffstat:
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/lua.h b/lua.h
@@ -2,7 +2,7 @@
** LUA - Linguagem para Usuarios de Aplicacao
** Grupo de Tecnologia em Computacao Grafica
** TeCGraf - PUC-Rio
-** $Id: lua.h,v 3.5 1994/11/08 19:56:39 roberto Exp roberto $
+** $Id: lua.h,v 3.6 1994/11/09 18:10:11 roberto Exp roberto $
*/
@@ -38,7 +38,7 @@ int lua_callfunction (lua_Object function);
int lua_call (char *funcname);
lua_Object lua_getparam (int number);
-#define lua_getresult lua_getparam
+#define lua_getresult(_) lua_getparam(_)
float lua_getnumber (lua_Object object);
char *lua_getstring (lua_Object object);
@@ -65,6 +65,7 @@ int lua_lock (lua_Object object);
lua_Object lua_getlocked (int ref);
void lua_unlock (int ref);
+lua_Object lua_createTable (int initSize);
/* for lua 1.1 */
diff --git a/opcode.c b/opcode.c
@@ -3,7 +3,7 @@
** TecCGraf - PUC-Rio
*/
-char *rcs_opcode="$Id: opcode.c,v 3.9 1994/11/10 17:36:54 roberto Exp roberto $";
+char *rcs_opcode="$Id: opcode.c,v 3.10 1994/11/11 14:00:08 roberto Exp roberto $";
#include <stdio.h>
#include <stdlib.h>
@@ -459,6 +459,18 @@ int lua_storesubscript (void)
return(do_protectedrun(&func, 0));
}
+/*
+** API: creates a new table
+*/
+lua_Object lua_createTable (int initSize)
+{
+ adjustC(0);
+ top++;
+ tag(top-1) = LUA_T_ARRAY;
+ avalue(top-1) = lua_createarray(initSize);
+ CBase++; /* incorporate object in the stack */
+ return Ref(top-1);
+}
/*
** Get a parameter, returning the object handle or 0 on error.