summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Buffer.cc6
-rw-r--r--lib/LuaHandle.cc16
-rwxr-xr-xlib/genloadlib.sh1
3 files changed, 23 insertions, 0 deletions
diff --git a/lib/Buffer.cc b/lib/Buffer.cc
index 2d615b5..9b8aa8d 100644
--- a/lib/Buffer.cc
+++ b/lib/Buffer.cc
@@ -104,6 +104,8 @@ bool Buffer::CanWrite() const {
}
String Buffer::GetName() const {
+ if (fake_name.strlen() != 0)
+ return fake_name;
if (seekable)
return "Buffer";
else
@@ -240,3 +242,7 @@ void Buffer::reset() {
realsiz = bufsiz = ptr = wptr = 0;
got_eof = false;
}
+
+void Buffer::SetFakeName(const String & _fake_name) {
+ fake_name = _fake_name;
+}
diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc
index ba66afc..4b6fd6e 100644
--- a/lib/LuaHandle.cc
+++ b/lib/LuaHandle.cc
@@ -78,6 +78,7 @@ class sLuaHandle : public Base {
static int bseek(lua_State * L);
static int btell(lua_State * L);
static int breset(lua_State * L);
+ static int setfakename(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);
@@ -1090,6 +1091,20 @@ int sLuaHandle::breset(lua_State * __L) {
return 0;
}
+int sLuaHandle::setfakename(lua_State * __L) {
+ Lua * L = Lua::find(__L);
+ int n = L->gettop();
+ Buffer * h;
+
+ if ((n != 2) || !L->isstring(2)) {
+ L->error("Incorrect arguments to method `Buffer::setfakename'");
+ }
+
+ h = L->recast<Buffer>();
+ h->setfakename(L->tostring(2));
+ return 0;
+}
+
int sLuaHandle::exists(lua_State * __L) {
Lua * L = Lua::find(__L);
int n = L->gettop();
@@ -1132,6 +1147,7 @@ void LuaBuffer::pushmembers(Lua * L) {
pushit(L, "wtell", sLuaHandle::btell);
pushit(L, "wseek", sLuaHandle::bseek);
pushit(L, "reset", sLuaHandle::breset);
+ pushit(L, "setfakename", sLuaHandle::setfakename);
L->push("__handletype");
L->push("Buffer");
L->settable(-3, true);
diff --git a/lib/genloadlib.sh b/lib/genloadlib.sh
index c7231b1..c9b2c19 100755
--- a/lib/genloadlib.sh
+++ b/lib/genloadlib.sh
@@ -14,6 +14,7 @@ echo 'void LoadLuaLibs(Lua * L) {'
ls *.lua | while read f ; do
b=${f%%.*}
echo " Buffer ${b}_buff;"
+ echo " ${b}_buff.SetFakeName(\"@$b.lua\");"
echo " ${b}_buff.write($b, size_$b);"
echo " L->load(&${b}_buff);"
echo