From 6527126b549870eb1767dfc74e41d8e8eb7b62b5 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 27 Apr 2017 14:36:54 +1000 Subject: src/lobject: Add setters to TValue class --- src/lobject.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/lobject.js') diff --git a/src/lobject.js b/src/lobject.js index 00f5ac6..d7751b3 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -117,6 +117,41 @@ class TValue { return this.ttisnil() || (this.ttisboolean() && this.value === false); } + setfltvalue(x) { + this.type = CT.LUA_TNUMFLT; + this.value = x; + } + + setivalue(x) { + this.type = CT.LUA_TNUMINT; + this.value = x; + } + + setnilvalue() { + this.type = CT.LUA_TNIL; + this.value = void 0; + } + + setfvalue(x) { + this.type = CT.LUA_TLCF; + this.value = x; + } + + setpvalue(x) { + this.type = CT.LUA_TLIGHTUSERDATA; + this.value = x; + } + + setbvalue(x) { + this.type = CT.LUA_TBOOLEAN; + this.value = x; + } + + setfrom(tv) { /* in lua C source setobj2t is often used for this */ + this.type = tv.type; + this.value = tv.value; + } + jsstring(from, to) { return defs.to_jsstring(this.value, from, to); } -- cgit v1.2.3-54-g00ecf