|
Hello,I'm working to a graphical framework in C dealing with Cairo graphics.I'm creating an object named SelDCSurface that deals with Cairo's surfaceSome methods are attached to it using luaL_setfuncs() or luaL_register().Now, I'm working on SelDCImageSurface which is basically an extension of SelDCSurface : it has to know all methods of SelDCSurface plus its own.1/ How to do that ?I guess I can use luaL_setfuncs() or luaL_register() more than once on the same object, to add additional methods, isn't it ?2/ my main concern is the function used if "self" object has the right typeI.E. for methodmySelDCSurface:GetSize()the C code is----------static struct SelDCSurface *checkSelDCSurface(lua_State *L, int where){
void *r = luaL_checkudata(L, where, "SelDCSurface");
luaL_argcheck(L, r != NULL, where, "'SelDCSurface' expected");
return (struct SelDCSurface *)r;
}static int GetSize(lua_State *L){
/* Return surface's size
* <- width, hight
*/
struct SelDCSurface *srf = checkSelDCSurface(L, 1);
lua_pushnumber(L, srf->w);
lua_pushnumber(L, srf->h);
return 2;
}
---The problem, is when called from a SelDCImageSurface object, GetSize() will still call checkSelDCSurface() which fails as facing a "SelDCImageSurface" and not a "SelDCSurface".Any smart way to avoid that ?ThanksLaurent