Independent name of a class

Posted by tobi on Stack Overflow See other posts from Stack Overflow or by tobi
Published on 2012-06-29T06:55:33Z Indexed on 2012/06/29 9:16 UTC
Read the original article Hit count: 288

Filed under:
|

We have class lua.

In lua class there is a method registerFunc() which is defined:

void lua::registerFun() {
    lua_register( luaState, "asd", luaApi::asd);
    lua_register( luaState, "zxc", luaApi::zxc);
}

lua_register is a built-in function from lua library: http://pgl.yoyo.org/luai/i/lua_register

it takes static methods from luaApi class as an 3rd argument.

Now some programmer wants to use the lua class, so he is forced to create his own class with definitions of the static methods, like:

class luaApi {
public:
    static int asd();
    static int zxc();
};

and now is the point. I don't want (as a programmer) to create class named exactly "luaApi", but e.g. myClassForLuaApi. But for now it's not possible because it is explicitly written in the code - in lua class:

lua_register( luaState, "asd", luaApi::asd); 

I would have to change it to:

lua_register( luaState, "asd", myClassForLuaApi::asd);

but I don't want to (let's assume that the programmer has no access there).

If it's still not understandable, I give up. :)

Thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about lua