lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Sir Pogsalot once stated:
> I did originally do that, but then the receiving code I would pass this
> larger userdata object to would call lua_rawlen() and then the game was
> over :(  I need these 2 userdata to be bound through collection but
> entirely separate otherwise (I make this fun).

  I guess I don't understand the requirements then.  

  If you are using metatables to provide typechecking, then:

	struct myfoo *pmyfoo = luaL_checkudata(L,idx,TYPE_FOO);

and

	struct foo *pfoo = luaL_checkudata(L,idx,TYPE_FOO);

will work (as long as 'struct foo' is the first element of 'struct myfoo'). 
In the later case, the code doesn't know (nor care) that the memory for pfoo
is larger than normal.  Why would you call lua_rawlen() when you know what
you have?  (unless you aren't using metatables for typechecking and are
solely relying in the raw size)

  -spc