RE: toLua and luaSDL bug in SDL_Event management (it's a union typedef)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: RE: toLua and luaSDL bug in SDL_Event management (it's a union typedef)
- From: Ariel Manzur <listas@...>
- Date: 2004年3月20日 03:45:08 -0300
At 10:24 AM 3/19/2004, you wrote:
The problem IS that SDL_Event was binded as a struct ! And in the real code
(SDL is a C library) the management of the SDL_Event type was made with
implicit assertions about its "union nature". Now that it is binded as a
struct, the fields which would have been are not updated anymore !
Yes they are.. the only reason why the union is binded as a struct is so
that you can access the fields of the union from lua.. if you look a the
code generated by tolua, you'll see that when you call 'e.type' the code is
accessing 'e->type'.. tolua doesn't know/care whether those fields are in
the same memory address or not.. The example you mention should look like
this on lua:
if e.type == SDL_KEYDOWN or e.type == SDL_KEYUP then
manage_key(e.key)
end
the actual problem will be that, because of a known bug, tolua++ (and
tolua5) will assume that 'e.key' inherits from 'e', and will change to type
of 'e' to 'e.key' after you access e.key.. That may limit the direct use of
unions that contain usertype fields..
Ariel.
http://Anime.com.ar
snm