summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-05-14 00:19:40 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-05-14 00:19:40 +0200
commit61ec261c36d33eb6f80f11db469bcdb39ca25050 (patch)
tree1ef13adf5012280b4521617d602f312d7978016a /src
parent4cc641ef7394d4aa07889d633068350eb26f893a (diff)
downloadfengari-61ec261c36d33eb6f80f11db469bcdb39ca25050.tar.gz
fengari-61ec261c36d33eb6f80f11db469bcdb39ca25050.tar.bz2
fengari-61ec261c36d33eb6f80f11db469bcdb39ca25050.zip
lua_arith, lua_islightuserdata, lua_register, lua_setallocf, lua_tocfunction
Diffstat (limited to 'src')
-rw-r--r--src/lapi.js33
-rw-r--r--src/lua.js12
2 files changed, 37 insertions, 8 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 4d2f288..8897fb2 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -569,6 +569,11 @@ const lua_newtable = function(L) {
lua_createtable(L, 0, 0);
};
+const lua_register = function(L, n, f) {
+ lua_pushcfunction(L, f);
+ lua_setglobal(L, n);
+};
+
const lua_getmetatable = function(L, objindex) {
let obj = index2addr(L, objindex);
let mt;
@@ -683,6 +688,12 @@ const lua_rawlen = function(L, idx) {
}
};
+const lua_tocfunction = function(L, idx) {
+ let o = index2addr(L, idx);
+ if (o.ttislcf() || o.ttisCclosure()) return o.value;
+ else return null; /* not a C function */
+};
+
const lua_tointeger = function(L, idx) {
return lvm.tointeger(index2addr(L, idx));
};
@@ -851,6 +862,10 @@ const lua_isfunction = function(L, idx) {
return lua_type(L, idx) === CT.LUA_TFUNCTION;
};
+const lua_islightuserdata = function(L, idx) {
+ return lua_type(L, idx) === CT.LUA_TLIGHTUSERDATA;
+};
+
const lua_rawequal = function(L, index1, index2) {
let o1 = index2addr(L, index1);
let o2 = index2addr(L, index2);
@@ -1070,12 +1085,18 @@ const lua_upvaluejoin = function(L, fidx1, n1, fidx2, n2) {
const lua_gc = function () {};
const lua_getallocf = function () {
- console.warn("lua_getallocf is not available and will always return null");
- return null;
+ console.warn("lua_getallocf is not available");
+ return 0;
+};
+
+const lua_setallocf = function () {
+ console.warn("lua_setallocf is not available");
+ return 0;
};
+
const lua_getextraspace = function () {
- console.warn("lua_getextraspace is not available and will always return null");
- return null;
+ console.warn("lua_getextraspace is not available");
+ return 0;
};
module.exports.index2addr = index2addr;
@@ -1108,6 +1129,7 @@ module.exports.lua_isboolean = lua_isboolean;
module.exports.lua_iscfunction = lua_iscfunction;
module.exports.lua_isfunction = lua_isfunction;
module.exports.lua_isinteger = lua_isinteger;
+module.exports.lua_islightuserdata = lua_islightuserdata;
module.exports.lua_isnil = lua_isnil;
module.exports.lua_isnone = lua_isnone;
module.exports.lua_isnoneornil = lua_isnoneornil;
@@ -1150,9 +1172,11 @@ module.exports.lua_rawlen = lua_rawlen;
module.exports.lua_rawset = lua_rawset;
module.exports.lua_rawseti = lua_rawseti;
module.exports.lua_rawsetp = lua_rawsetp;
+module.exports.lua_register = lua_register;
module.exports.lua_remove = lua_remove;
module.exports.lua_replace = lua_replace;
module.exports.lua_rotate = lua_rotate;
+module.exports.lua_setallocf = lua_setallocf;
module.exports.lua_setfield = lua_setfield;
module.exports.lua_setglobal = lua_setglobal;
module.exports.lua_seti = lua_seti;
@@ -1164,6 +1188,7 @@ module.exports.lua_setuservalue = lua_setuservalue;
module.exports.lua_status = lua_status;
module.exports.lua_stringtonumber = lua_stringtonumber;
module.exports.lua_toboolean = lua_toboolean;
+module.exports.lua_tocfunction = lua_tocfunction;
module.exports.lua_todataview = lua_todataview;
module.exports.lua_tointeger = lua_tointeger;
module.exports.lua_tointegerx = lua_tointegerx;
diff --git a/src/lua.js b/src/lua.js
index 2e86336..135dadb 100644
--- a/src/lua.js
+++ b/src/lua.js
@@ -93,6 +93,7 @@ module.exports.LUA_SHRDIR = defs.LUA_SHRDIR;
module.exports.LUA_VDIR = defs.LUA_VDIR;
module.exports.LUA_DIRSEP = defs.LUA_DIRSEP;
module.exports.lua_absindex = lapi.lua_absindex;
+module.exports.lua_arith = lapi.lua_arith;
module.exports.lua_atpanic = lapi.lua_atpanic;
module.exports.lua_call = lapi.lua_call;
module.exports.lua_callk = lapi.lua_callk;
@@ -126,6 +127,7 @@ module.exports.lua_isboolean = lapi.lua_isboolean;
module.exports.lua_iscfunction = lapi.lua_iscfunction;
module.exports.lua_isfunction = lapi.lua_isfunction;
module.exports.lua_isinteger = lapi.lua_isinteger;
+module.exports.lua_islightuserdata = lapi.lua_islightuserdata;
module.exports.lua_isnil = lapi.lua_isnil;
module.exports.lua_isnone = lapi.lua_isnone;
module.exports.lua_isnoneornil = lapi.lua_isnoneornil;
@@ -149,6 +151,7 @@ module.exports.lua_pop = lapi.lua_pop;
module.exports.lua_pushboolean = lapi.lua_pushboolean;
module.exports.lua_pushcclosure = lapi.lua_pushcclosure;
module.exports.lua_pushcfunction = lapi.lua_pushcfunction;
+module.exports.lua_pushfstring = lapi.lua_pushfstring;
module.exports.lua_pushglobaltable = lapi.lua_pushglobaltable;
module.exports.lua_pushinteger = lapi.lua_pushinteger;
module.exports.lua_pushjsclosure = lapi.lua_pushjsclosure;
@@ -159,23 +162,23 @@ module.exports.lua_pushlstring = lapi.lua_pushlstring;
module.exports.lua_pushnil = lapi.lua_pushnil;
module.exports.lua_pushnumber = lapi.lua_pushnumber;
module.exports.lua_pushstring = lapi.lua_pushstring;
-module.exports.lua_pushfstring = lapi.lua_pushfstring;
-module.exports.lua_pushvfstring = lapi.lua_pushvfstring;
module.exports.lua_pushthread = lapi.lua_pushthread;
module.exports.lua_pushvalue = lapi.lua_pushvalue;
+module.exports.lua_pushvfstring = lapi.lua_pushvfstring;
module.exports.lua_rawequal = lapi.lua_rawequal;
module.exports.lua_rawget = lapi.lua_rawget;
module.exports.lua_rawgeti = lapi.lua_rawgeti;
module.exports.lua_rawgetp = lapi.lua_rawgetp;
module.exports.lua_rawlen = lapi.lua_rawlen;
-module.exports.lua_rawseti = lapi.lua_rawseti;
module.exports.lua_rawset = lapi.lua_rawset;
+module.exports.lua_rawseti = lapi.lua_rawseti;
module.exports.lua_rawsetp = lapi.lua_rawsetp;
+module.exports.lua_register = lapi.lua_register;
module.exports.lua_remove = lapi.lua_remove;
module.exports.lua_replace = lapi.lua_replace;
-module.exports.lua_arith = lapi.lua_arith;
module.exports.lua_resume = ldo.lua_resume;
module.exports.lua_rotate = lapi.lua_rotate;
+module.exports.lua_setallof = ldo.lua_setallof;
module.exports.lua_setfield = lapi.lua_setfield;
module.exports.lua_setglobal = lapi.lua_setglobal;
module.exports.lua_sethook = ldebug.lua_sethook;
@@ -209,3 +212,4 @@ module.exports.lua_version = lapi.lua_version;
module.exports.lua_xmove = lapi.lua_xmove;
module.exports.lua_yield = ldo.lua_yield;
module.exports.lua_yieldk = ldo.lua_yieldk;
+module.exports.lua_tocfunctoin = ldo.lua_tocfunctoin;