summaryrefslogtreecommitdiff
path: root/lib/LuaHandle.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/LuaHandle.cc')
-rw-r--r--lib/LuaHandle.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc
index 22c5036..34d0412 100644
--- a/lib/LuaHandle.cc
+++ b/lib/LuaHandle.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: LuaHandle.cc,v 1.26 2008-05-13 06:59:10 pixel Exp $ */
+/* $Id: LuaHandle.cc,v 1.27 2008-08-11 16:23:52 pixel Exp $ */
#include "LuaHandle.h"
@@ -36,11 +36,15 @@ class sLuaHandle : public Base {
static int readU8(lua_State * L);
static int readU16(lua_State * L);
static int readU32(lua_State * L);
+ static int readFloat(lua_State * L);
+ static int readDouble(lua_State * L);
static int write(lua_State * L);
static int writestring(lua_State * L);
static int writeU8(lua_State * L);
static int writeU16(lua_State * L);
static int writeU32(lua_State * L);
+ static int writeFloat(lua_State * L);
+ static int writeDouble(lua_State * L);
static int copyfrom(lua_State * L);
static int copyto(lua_State * L);
static int isclosed(lua_State * L);
@@ -76,7 +80,7 @@ class sLuaHandle : public Base {
static int getcaps(lua_State * L, int);
static int action(lua_State * L, int);
enum {
- U8, U16, U32
+ U8, U16, U32, R_FLOAT, R_DOUBLE,
};
enum {
from, to
@@ -215,6 +219,14 @@ int sLuaHandle::readU32(lua_State * L) {
return read(L, U32);
}
+int sLuaHandle::readFloat(lua_State * L) {
+ return read(L, R_FLOAT);
+}
+
+int sLuaHandle::readDouble(lua_State * L) {
+ return read(L, R_DOUBLE);
+}
+
int sLuaHandle::write(lua_State * __L) {
Lua * L = Lua::find(__L);
int n = L->gettop(), i;
@@ -281,6 +293,14 @@ int sLuaHandle::writeU32(lua_State * L) {
return write(L, U32);
}
+int sLuaHandle::writeFloat(lua_State * L) {
+ return write(L, R_FLOAT);
+}
+
+int sLuaHandle::writeDouble(lua_State * L) {
+ return write(L, R_DOUBLE);
+}
+
int sLuaHandle::read(lua_State * __L, int t) {
Lua * L = Lua::find(__L);
int n = L->gettop();
@@ -297,6 +317,8 @@ int sLuaHandle::read(lua_State * __L, int t) {
case U8: r = h->readU8(); break;
case U16: r = h->readU16(); break;
case U32: r = h->readU32(); break;
+ case R_FLOAT: r = h->readFloat(); break;
+ case R_DOUBLE: r = h->readDouble(); break;
}
L->push(r);
@@ -321,6 +343,8 @@ int sLuaHandle::write(lua_State * __L, int t) {
case U8: h->writeU8(r); break;
case U16: h->writeU16(r); break;
case U32: h->writeU32(r); break;
+ case R_FLOAT: h->writeFloat(r); break;
+ case R_DOUBLE: h->writeDouble(r); break;
}
return 0;
@@ -728,9 +752,13 @@ void LuaHandle::pushmembers(Lua * L) {
pushit(L, "readU8", sLuaHandle::readU8);
pushit(L, "readU16", sLuaHandle::readU16);
pushit(L, "readU32", sLuaHandle::readU32);
+ pushit(L, "readFloat", sLuaHandle::readFloat);
+ pushit(L, "readDouble", sLuaHandle::readDouble);
pushit(L, "writeU8", sLuaHandle::writeU8);
pushit(L, "writeU16", sLuaHandle::writeU16);
pushit(L, "writeU32", sLuaHandle::writeU32);
+ pushit(L, "writeFloat", sLuaHandle::writeFloat);
+ pushit(L, "writeDouble", sLuaHandle::writeDouble);
pushit(L, "copyfrom", sLuaHandle::copyfrom);
pushit(L, "copyto", sLuaHandle::copyto);