[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Polymorphic luaL_checkudata?
- From: Peter Odding <xolox@...>
- Date: Sun, 15 Apr 2007 13:23:21 +0200
Hi all! I'm (still) working on binding APR. Currently busy with pipes, which
seem to be backwards compatible with files but not the other way around:
* pipes have a timeout which needs two methods (timeout_get/timeout_set)
* I need to make sure I'm dealing with a pipe (instead of a file) when using
them as stdin/stdout/stderr for processes
Right now my io_file module uses luaL_checkudata(L, i, "apr-file") to validate
arguments. Of course when I give pipes their own metatable my io_file module
will start rejecting pipes, which is not my intention.
One solution is a function in the vein of luaL_checkudata that checks a userdata
argument for one *of a given set* of metatable names, like luaL_checkudata_m(L,
i, "apr-file", "apr-pipe"). Have any of you needed this functionality before?
Have you used a different approach?
I don't mind copying and extending the source for luaL_checkudata() to handle
one or more metatable names but if I'm not the only one needing this
functionality, it might make a good candidate for inclusion in the auxiliary
library of either Lua 5.1.3 or Lua 6.
- Peter Odding