new API function to create tables

This commit is contained in:
Roberto Ierusalimschy 1994-11-13 14:17:04 -02:00
parent 5e60b961de
commit e1d91fd0e1
2 changed files with 16 additions and 3 deletions

5
lua.h
View File

@ -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 */

View File

@ -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.