summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2008-10-15 18:11:27 -0700
committerPixel <pixel@nobis-crew.org>2008-10-15 18:11:27 -0700
commit465af69f28fddccdbcfea9a82aeadf3f106e6d12 (patch)
treee3c8f3f09d89b66c05f25399685bfc29eabbc0dc /lib
parentdf9e297708d838de8cf5f2effcd7eaa16c213dda (diff)
Adding the reset method to Lua Buffers, and fixing a couple of typos.
Diffstat (limited to 'lib')
-rw-r--r--lib/LuaHandle.cc26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc
index 1bd39d3..e336f54 100644
--- a/lib/LuaHandle.cc
+++ b/lib/LuaHandle.cc
@@ -64,6 +64,7 @@ class sLuaHandle : public Base {
static int bnewindex(lua_State * L);
static int bseek(lua_State * L);
static int btell(lua_State * L);
+ static int breset(lua_State * L);
static int exists(lua_State * L);
static int get_nb_handles(lua_State * L);
static int get_nb_input(lua_State * L);
@@ -692,6 +693,20 @@ int sLuaHandle::bseek(lua_State * __L) {
return 1;
}
+int sLuaHandle::breset(lua_State * __L) {
+ Lua * L = Lua::find(__L);
+ int n = L->gettop();
+ Buffer * h;
+
+ if (n != 1) {
+ L->error("Incorrect arguments to method `Buffer::reset'");
+ }
+
+ h = (Buffer *) LuaObject::getme(L);
+ h->reset();
+ return 0;
+}
+
int sLuaHandle::exists(lua_State * __L) {
Lua * L = Lua::find(__L);
int n = L->gettop();
@@ -733,6 +748,7 @@ void LuaBuffer::pushmembers(Lua * L) {
pushmeta(L, "__newindex", sLuaHandle::bnewindex);
pushit(L, "wtell", sLuaHandle::btell);
pushit(L, "wseek", sLuaHandle::bseek);
+ pushit(L, "reset", sLuaHandle::breset);
L->push("__handletype");
L->push("Buffer");
L->settable(-3, true);
@@ -741,11 +757,11 @@ void LuaBuffer::pushmembers(Lua * L) {
void LuaHandle::pushmembers(Lua * L) {
pushme(L, h, "Handle");
- pushit(L, "read", &sLuaHandle::read);
- pushit(L, "write", &sLuaHandle::write);
+ pushit(L, "read", sLuaHandle::read);
+ pushit(L, "write", sLuaHandle::write);
- pushit(L, "readstring", &sLuaHandle::readstring);
- pushit(L, "writestring", &sLuaHandle::writestring);
+ pushit(L, "readstring", sLuaHandle::readstring);
+ pushit(L, "writestring", sLuaHandle::writestring);
pushit(L, "readU8", sLuaHandle::readU8);
pushit(L, "readU16", sLuaHandle::readU16);
@@ -764,7 +780,7 @@ void LuaHandle::pushmembers(Lua * L) {
pushit(L, "isclosed", sLuaHandle::isclosed);
pushit(L, "isnonblock", sLuaHandle::isnonblock);
pushit(L, "canread", sLuaHandle::canread);
- pushit(L, "canwrite", sLuaHandle::canwatch);
+ pushit(L, "canwrite", sLuaHandle::canwrite);
pushit(L, "canseek", sLuaHandle::canseek);
pushit(L, "canwatch", sLuaHandle::canwatch);