aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-26 10:47:05 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-10-26 10:47:05 -0200
commitb892f0a8774f573d7ec9b02617428871b8d3a2b3 (patch)
tree4aab88443264d84d314ca663cf3c30b48c7e9107 /lapi.c
parentaadc35449ec2752c298a7a8fa6359a3a12c538ee (diff)
downloadlua-b892f0a8774f573d7ec9b02617428871b8d3a2b3.tar.gz
lua-b892f0a8774f573d7ec9b02617428871b8d3a2b3.tar.bz2
lua-b892f0a8774f573d7ec9b02617428871b8d3a2b3.zip
new API function `createuserdata'
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lapi.c b/lapi.c
index f0c64191..adcd0ef1 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 1.107 2000/10/20 16:39:03 roberto Exp roberto $ 2** $Id: lapi.c,v 1.108 2000/10/24 19:19:15 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -173,7 +173,7 @@ LUA_API const char *lua_tostring (lua_State *L, int index) {
173LUA_API size_t lua_strlen (lua_State *L, int index) { 173LUA_API size_t lua_strlen (lua_State *L, int index) {
174 StkId o = luaA_indexAcceptable(L, index); 174 StkId o = luaA_indexAcceptable(L, index);
175 if (o == NULL || tostring(L, o)) return 0; 175 if (o == NULL || tostring(L, o)) return 0;
176 else return tsvalue(o)->u.s.len; 176 else return tsvalue(o)->len;
177} 177}
178 178
179LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) { 179LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index) {
@@ -491,3 +491,12 @@ LUA_API void lua_concat (lua_State *L, int n) {
491 luaC_checkGC(L); 491 luaC_checkGC(L);
492} 492}
493 493
494
495LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
496 TString *ts = luaS_newudata(L, size, NULL);
497 tsvalue(L->top) = ts;
498 ttype(L->top) = LUA_TUSERDATA;
499 api_incr_top(L);
500 return ts->u.d.value;
501}
502