summaryrefslogtreecommitdiff
path: root/src/LuaHandle.cc
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-07 22:57:40 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2013-08-07 22:57:40 +0200
commit97fcb80cb047a1e72ec39dc14a5d790461fa84b9 (patch)
treeccc46f63f388f199932bbdd4c05a69630643f0ec /src/LuaHandle.cc
parent8e84d4a3df8ae03104d61af27713a0924d9c228f (diff)
Adding readU8()
Diffstat (limited to 'src/LuaHandle.cc')
-rw-r--r--src/LuaHandle.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/LuaHandle.cc b/src/LuaHandle.cc
index 6fb8d44..355b992 100644
--- a/src/LuaHandle.cc
+++ b/src/LuaHandle.cc
@@ -8,10 +8,12 @@ typedef IOHandle IOInput;
enum IOHandle_methods_t {
IOHANDLE_CLOSE,
+ IOHANDLE_READU8,
};
struct Balau::lua_functypes_t IOHandle_methods[] = {
{ IOHANDLE_CLOSE, "close", 0, 0, { } },
+ { IOHANDLE_READU8, "readU8", 0, 0, { } },
{ -1, 0, 0, 0, 0 },
};
@@ -27,6 +29,12 @@ int sLua_IOHandle::IOHandle_proceed(Balau::Lua & L, int n, IOHandle * obj, int c
case IOHANDLE_CLOSE:
return L.yield(Balau::Future<int>([h]() mutable { h->close(); return 0; }));
break;
+ case IOHANDLE_READU8:
+ {
+ Balau::Future<uint8_t> c = h->readU8();
+ return L.yield(Balau::Future<int>([L, c]() mutable { L.push((lua_Number) c.get()); return 1; }));
+ }
+ break;
}
return r;
@@ -42,6 +50,7 @@ void Balau::LuaHandleFactory::pushObjectAndMembers(Lua & L) {
pushObj(L, m_obj, "Handle");
PUSH_METHOD(IOHandle, IOHANDLE_CLOSE);
+ PUSH_METHOD(IOHandle, IOHANDLE_READU8);
}