summaryrefslogtreecommitdiff
path: root/src/lapi.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-20 16:15:36 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-20 16:15:36 +0100
commit5f5ba74ace8a956ae48a9f0b182a157052c2546e (patch)
tree93381379f3711fd5ad67015d686dbfd518c0eef5 /src/lapi.js
parent645437b8e0846635f886520bb679a79ec1849c09 (diff)
downloadfengari-5f5ba74ace8a956ae48a9f0b182a157052c2546e.tar.gz
fengari-5f5ba74ace8a956ae48a9f0b182a157052c2546e.tar.bz2
fengari-5f5ba74ace8a956ae48a9f0b182a157052c2546e.zip
string.gsub
Diffstat (limited to 'src/lapi.js')
-rw-r--r--src/lapi.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lapi.js b/src/lapi.js
index a884a97..6840ef9 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -428,6 +428,14 @@ 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);
+
+ assert(L.top <= L.ci.top, "stack overflow");
+
+ return L.stack[L.top - 1].value;
+};
+
const aux_upvalue = function(fi, n) {
switch(fi.ttype()) {
case CT.LUAT_TCCL: { /* C closure */
@@ -578,6 +586,16 @@ const lua_tonumber = function(L, idx) {
return lvm.tonumber(index2addr(L, idx));
};
+const lua_touserdata = function(L, idx) {
+ let o = index2addr(L, idx);
+ switch (o.ttnov()) {
+ case CT.LUA_TUSERDATA:
+ case CT.LUA_TLIGHTUSERDATA:
+ return o.value;
+ default: return null;
+ }
+};
+
const lua_tothread = function(L, idx) {
let o = index2addr(L, idx);
return o.ttisthread() ? o.value : null;
@@ -879,6 +897,7 @@ 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;
@@ -924,6 +943,7 @@ 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;