summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js190
1 files changed, 101 insertions, 89 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 5872545..991e982 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -281,9 +281,13 @@ const lua_pushboolean = function(L, b) {
};
const lua_pushlightuserdata = function(L, p) {
- assert(typeof p === "object");
+ L.stack[L.top++] = new TValue(CT.LUA_TLIGHTUSERDATA_PTR, p);
- L.stack[L.top++] = new TValue(CT.LUA_TLIGHTUSERDATA, p);
+ assert(L.top <= L.ci.top, "stack overflow");
+};
+
+const lua_pushobject = function(L, p) {
+ L.stack[L.top++] = new TValue(CT.LUA_TLIGHTUSERDATA_OBJ, p);
assert(L.top <= L.ci.top, "stack overflow");
};
@@ -428,8 +432,8 @@ const lua_createtable = function(L, narray, nrec) {
assert(L.top <= L.ci.top, "stack overflow");
};
-const lua_newuserdata = function(L, u) {
- L.stack[L.top++] = new lobject.TValue(CT.LUA_TUSERDATA, u);
+const lua_newuserdata = function(L, size) {
+ L.stack[L.top++] = new lobject.TValue(CT.LUA_TUSERDATA, new ArrayBuffer(size));
assert(L.top <= L.ci.top, "stack overflow");
@@ -698,6 +702,11 @@ const lua_isstring = function(L, idx) {
return o.ttisstring() || o.ttisnumber();
};
+const lua_isuserdata = function(L, idx) {
+ let o = index2addr(L, idx);
+ return o.ttisfulluserdata(o) || o.ttislightuserdata();
+};
+
const lua_rawequal = function(L, index1, index2) {
let o1 = index2addr(L, index1);
let o2 = index2addr(L, index2);
@@ -863,88 +872,91 @@ const lua_getextraspace = function () {
return null;
};
-module.exports.index2addr = index2addr;
-module.exports.index2addr_ = index2addr_;
-module.exports.lua_absindex = lua_absindex;
-module.exports.lua_atpanic = lua_atpanic;
-module.exports.lua_call = lua_call;
-module.exports.lua_callk = lua_callk;
-module.exports.lua_checkstack = lua_checkstack;
-module.exports.lua_compare = lua_compare;
-module.exports.lua_compare_ = lua_compare_;
-module.exports.lua_concat = lua_concat;
-module.exports.lua_copy = lua_copy;
-module.exports.lua_createtable = lua_createtable;
-module.exports.lua_dump = lua_dump;
-module.exports.lua_error = lua_error;
-module.exports.lua_gc = lua_gc;
-module.exports.lua_getallocf = lua_getallocf;
-module.exports.lua_getextraspace = lua_getextraspace;
-module.exports.lua_getfield = lua_getfield;
-module.exports.lua_getglobal = lua_getglobal;
-module.exports.lua_geti = lua_geti;
-module.exports.lua_getmetatable = lua_getmetatable;
-module.exports.lua_gettable = lua_gettable;
-module.exports.lua_gettop = lua_gettop;
-module.exports.lua_insert = lua_insert;
-module.exports.lua_isinteger = lua_isinteger;
-module.exports.lua_isnil = lua_isnil;
-module.exports.lua_isnone = lua_isnone;
-module.exports.lua_isnoneornil = lua_isnoneornil;
-module.exports.lua_isnumber = lua_isnumber;
-module.exports.lua_isstring = lua_isstring;
-module.exports.lua_istable = lua_istable;
-module.exports.lua_len = lua_len;
-module.exports.lua_load = lua_load;
-module.exports.lua_newtable = lua_newtable;
-module.exports.lua_newuserdata = lua_newuserdata;
-module.exports.lua_next = lua_next;
-module.exports.lua_pcall = lua_pcall;
-module.exports.lua_pcallk = lua_pcallk;
-module.exports.lua_pop = lua_pop;
-module.exports.lua_pushboolean = lua_pushboolean;
-module.exports.lua_pushcclosure = lua_pushcclosure;
-module.exports.lua_pushcfunction = lua_pushcfunction;
-module.exports.lua_pushglobaltable = lua_pushglobaltable;
-module.exports.lua_pushinteger = lua_pushinteger;
-module.exports.lua_pushjsclosure = lua_pushjsclosure;
-module.exports.lua_pushjsfunction = lua_pushjsfunction;
-module.exports.lua_pushliteral = lua_pushliteral;
-module.exports.lua_pushlstring = lua_pushlstring;
-module.exports.lua_pushnil = lua_pushnil;
-module.exports.lua_pushnumber = lua_pushnumber;
-module.exports.lua_pushstring = lua_pushstring;
-module.exports.lua_pushthread = lua_pushthread;
-module.exports.lua_pushtvalue = lua_pushtvalue;
-module.exports.lua_pushvalue = lua_pushvalue;
-module.exports.lua_rawequal = lua_rawequal;
-module.exports.lua_rawget = lua_rawget;
-module.exports.lua_rawgeti = lua_rawgeti;
-module.exports.lua_rawlen = lua_rawlen;
-module.exports.lua_rawset = lua_rawset;
-module.exports.lua_remove = lua_remove;
-module.exports.lua_replace = lua_replace;
-module.exports.lua_rotate = lua_rotate;
-module.exports.lua_setfield = lua_setfield;
-module.exports.lua_setglobal = lua_setglobal;
-module.exports.lua_seti = lua_seti;
-module.exports.lua_setmetatable = lua_setmetatable;
-module.exports.lua_settable = lua_settable;
-module.exports.lua_settop = lua_settop;
-module.exports.lua_setupvalue = lua_setupvalue;
-module.exports.lua_status = lua_status;
-module.exports.lua_stringtonumber = lua_stringtonumber;
-module.exports.lua_toboolean = lua_toboolean;
-module.exports.lua_todataview = lua_todataview;
-module.exports.lua_tointeger = lua_tointeger;
-module.exports.lua_tointegerx = lua_tointegerx;
-module.exports.lua_tolstring = lua_tolstring;
-module.exports.lua_tonumber = lua_tonumber;
-module.exports.lua_topointer = lua_topointer;
-module.exports.lua_tostring = lua_tostring;
-module.exports.lua_tothread = lua_tothread;
-module.exports.lua_touserdata = lua_touserdata;
-module.exports.lua_type = lua_type;
-module.exports.lua_typename = lua_typename;
-module.exports.lua_version = lua_version;
-module.exports.lua_xmove = lua_xmove; \ No newline at end of file
+module.exports.index2addr = index2addr;
+module.exports.index2addr_ = index2addr_;
+module.exports.lua_absindex = lua_absindex;
+module.exports.lua_atpanic = lua_atpanic;
+module.exports.lua_call = lua_call;
+module.exports.lua_callk = lua_callk;
+module.exports.lua_checkstack = lua_checkstack;
+module.exports.lua_compare = lua_compare;
+module.exports.lua_compare_ = lua_compare_;
+module.exports.lua_concat = lua_concat;
+module.exports.lua_copy = lua_copy;
+module.exports.lua_createtable = lua_createtable;
+module.exports.lua_dump = lua_dump;
+module.exports.lua_error = lua_error;
+module.exports.lua_gc = lua_gc;
+module.exports.lua_getallocf = lua_getallocf;
+module.exports.lua_getextraspace = lua_getextraspace;
+module.exports.lua_getfield = lua_getfield;
+module.exports.lua_getglobal = lua_getglobal;
+module.exports.lua_geti = lua_geti;
+module.exports.lua_getmetatable = lua_getmetatable;
+module.exports.lua_gettable = lua_gettable;
+module.exports.lua_gettop = lua_gettop;
+module.exports.lua_insert = lua_insert;
+module.exports.lua_isinteger = lua_isinteger;
+module.exports.lua_isnil = lua_isnil;
+module.exports.lua_isnone = lua_isnone;
+module.exports.lua_isnoneornil = lua_isnoneornil;
+module.exports.lua_isnumber = lua_isnumber;
+module.exports.lua_isstring = lua_isstring;
+module.exports.lua_istable = lua_istable;
+module.exports.lua_isuserdata = lua_isuserdata;
+module.exports.lua_len = lua_len;
+module.exports.lua_load = lua_load;
+module.exports.lua_newtable = lua_newtable;
+module.exports.lua_newuserdata = lua_newuserdata;
+module.exports.lua_next = lua_next;
+module.exports.lua_pcall = lua_pcall;
+module.exports.lua_pcallk = lua_pcallk;
+module.exports.lua_pop = lua_pop;
+module.exports.lua_pushboolean = lua_pushboolean;
+module.exports.lua_pushcclosure = lua_pushcclosure;
+module.exports.lua_pushcfunction = lua_pushcfunction;
+module.exports.lua_pushglobaltable = lua_pushglobaltable;
+module.exports.lua_pushinteger = lua_pushinteger;
+module.exports.lua_pushjsclosure = lua_pushjsclosure;
+module.exports.lua_pushjsfunction = lua_pushjsfunction;
+module.exports.lua_pushlightuserdata = lua_pushlightuserdata;
+module.exports.lua_pushliteral = lua_pushliteral;
+module.exports.lua_pushlstring = lua_pushlstring;
+module.exports.lua_pushnil = lua_pushnil;
+module.exports.lua_pushnumber = lua_pushnumber;
+module.exports.lua_pushobject = lua_pushobject;
+module.exports.lua_pushstring = lua_pushstring;
+module.exports.lua_pushthread = lua_pushthread;
+module.exports.lua_pushtvalue = lua_pushtvalue;
+module.exports.lua_pushvalue = lua_pushvalue;
+module.exports.lua_rawequal = lua_rawequal;
+module.exports.lua_rawget = lua_rawget;
+module.exports.lua_rawgeti = lua_rawgeti;
+module.exports.lua_rawlen = lua_rawlen;
+module.exports.lua_rawset = lua_rawset;
+module.exports.lua_remove = lua_remove;
+module.exports.lua_replace = lua_replace;
+module.exports.lua_rotate = lua_rotate;
+module.exports.lua_setfield = lua_setfield;
+module.exports.lua_setglobal = lua_setglobal;
+module.exports.lua_seti = lua_seti;
+module.exports.lua_setmetatable = lua_setmetatable;
+module.exports.lua_settable = lua_settable;
+module.exports.lua_settop = lua_settop;
+module.exports.lua_setupvalue = lua_setupvalue;
+module.exports.lua_status = lua_status;
+module.exports.lua_stringtonumber = lua_stringtonumber;
+module.exports.lua_toboolean = lua_toboolean;
+module.exports.lua_todataview = lua_todataview;
+module.exports.lua_tointeger = lua_tointeger;
+module.exports.lua_tointegerx = lua_tointegerx;
+module.exports.lua_tolstring = lua_tolstring;
+module.exports.lua_tonumber = lua_tonumber;
+module.exports.lua_topointer = lua_topointer;
+module.exports.lua_tostring = lua_tostring;
+module.exports.lua_tothread = lua_tothread;
+module.exports.lua_touserdata = lua_touserdata;
+module.exports.lua_type = lua_type;
+module.exports.lua_typename = lua_typename;
+module.exports.lua_version = lua_version;
+module.exports.lua_xmove = lua_xmove; \ No newline at end of file