diff options
Diffstat (limited to 'lib/LuaHandle.cc')
-rw-r--r-- | lib/LuaHandle.cc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index fb0a228..15c3ee3 100644 --- a/lib/LuaHandle.cc +++ b/lib/LuaHandle.cc @@ -38,6 +38,8 @@ class sLuaHandle : public Base { static int setz(lua_State * L);
static int bindex(lua_State * L);
static int bnewindex(lua_State * L);
+ static int bseek(lua_State * L);
+ static int btell(lua_State * L);
private:
static int read(lua_State * L, int);
static int write(lua_State * L, int);
@@ -505,6 +507,46 @@ int sLuaHandle::bnewindex(lua_State * _L) { return 0;
}
+int sLuaHandle::btell(lua_State * _L) {
+ Lua * L = Lua::find(_L);
+ int n = L->gettop();
+ Buffer * h;
+
+ if (n != 1) {
+ L->error("Incorrect arguments to method `Buffer::wtell'");
+ }
+
+ h = (Buffer *) LuaObject::getme(L);
+ L->push((lua_Number) h->wtell());
+ return 1;
+}
+
+int sLuaHandle::bseek(lua_State * _L) {
+ Lua * L = Lua::find(_L);
+ int n = L->gettop();
+ off_t off;
+ int wheel;
+ Buffer * h;
+
+ if ((n < 2) || (n > 3) || !L->isnumber(2) || ((n == 3) && !L->isnumber(3))) {
+ L->error("Incorrect arguments to method `Buffer::wseek'");
+ }
+
+ h = (Buffer *) LuaObject::getme(L);
+
+ off = L->tonumber(2);
+
+ if (n == 3) {
+ wheel = L->tonumber(3);
+ } else {
+ wheel = SEEK_SET;
+ }
+
+ L->push((lua_Number) h->wseek(off, wheel));
+
+ return 1;
+}
+
void LuaInput::pushmembers(Lua * L) {
LuaHandle::pushmembers(L);
}
@@ -525,6 +567,8 @@ void LuaBuffer::pushmembers(Lua * L) { L->push(sLuaHandle::bnewindex);
L->settable();
L->setmetatable(1);
+ pushit(L, "wtell", sLuaHandle::btell);
+ pushit(L, "wseek", sLuaHandle::bseek);
}
void LuaHandle::pushmembers(Lua * L) {
|