|
On Jul 11, 2008, at 9:08 PM, Abhinav Lele wrote: What does this snippet from lunar.h in http://lua-users.org/wiki/CppBindingWithLunar meanJust a macro for shorthand sugar.#define method(class, name) {#name, &class::name} The # symbol in a macro inserts quotation marks around the given value (i.e., it constructs a string). The ampersand (&), class name, double colon (::) and function name thing is the standard form of a (static) class method pointer in C++, which can be compatible with a C function pointer type. So, the macro results in a form compatible with a C-style lua module registration. Lunar<Account>::RegType Account::methods[] = { --> { "deposit", &Account::deposit }, --> { "withdraw", &Account::withdraw } , etc. I.e. it's just shorthand sugar. |