Lua_icxx  1.02 (Aug 2011)
LuaBoundMethRef Class Reference

Represent a bound Lua method. More...

#include <LuaFuncRef.h>

Collaboration diagram for LuaBoundMethRef:

List of all members.

Public Member Functions

 LuaBoundMethRef ()
 Nil bound method.
 LuaBoundMethRef (const LuaObjRef &obj, const LuaFuncRef &fn)
 Create from a function fn and an object; function must expect object as first arg.
 LuaBoundMethRef (const LuaTempResult &res)
 create from LuaTempResult; res[1] is function, is object res[2]
bool isNil () const
 true if Lua object OR Lua function is nil
std::string typeName () const
 return a type name for this "new" Lua type
std::string getID () const
 returns an ID created from the Lua object ID and function ID
void resetRef (const LuaObjRef &obj, const LuaFuncRef &fn)
 Change what the reference is pointing to.
void resetRef (const LuaTempResult &result)
 Change what the reference is pointing to.
LuaBoundMethRefoperator= (const LuaTempResult &result)
 Change what the reference is pointing to.
 DECL_FN_CALLS (operator())
 Call the bound method. Automatically provides the Lua object as first arg to in the call.
 DECL_FN_CALLS (call)
 Call the bound method. Automatically provides the Lua object as first arg to in the call.

Detailed Description

Represent a bound Lua method.

Ie, a Lua function that is "in" a Lua object and takes the object as its first argument. It is the C++ way of providing Lua's syntactic sugar, "object:function(...)", the equivalent of "object.function(object, ...)".

Note that there is no Lua representation for bound methods (hence LuaBoundMethRef does not derive from LuaObjRef): a bound method is a callable object that consists of a Lua object plus a Lua function, and for which the call operator automatically provides the object as first argument when the function is called.

Definition at line 70 of file LuaFuncRef.h.