PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/union_parameter.i

#
Swig | 43 lines | 34 code | 8 blank | 1 comment | 0 complexity | 21c63a83b4b6783c6af6699af7861385 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module union_parameter
  2. %warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype'
  3. %inline %{
  4. typedef unsigned char Uint8;
  5. typedef struct SDL_ActiveEvent {
  6. Uint8 type; /* SDL_ACTIVEEVENT */
  7. Uint8 gain; /* Whether given states were gained or lost (1/0) */
  8. Uint8 state; /* A mask of the focus states */
  9. } SDL_ActiveEvent;
  10. /* Keyboard event structure */
  11. typedef struct SDL_KeyboardEvent {
  12. Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
  13. int which; /* The keyboard device index */
  14. int state; /* SDL_PRESSED or SDL_RELEASED */
  15. } SDL_KeyboardEvent;
  16. typedef union {
  17. Uint8 type;
  18. SDL_ActiveEvent active;
  19. SDL_KeyboardEvent key;
  20. } SDL_Event;
  21. int SDL_PollEvent (SDL_Event *ev) {
  22. static int toggle = 0;
  23. if (toggle == 0) {
  24. ev->type = 1;
  25. ev->active.gain = 20;
  26. ev->active.state = 30;
  27. } else {
  28. ev->type = 2;
  29. ev->key.which = 2000;
  30. ev->key.state = 3000;
  31. }
  32. toggle = 1 - toggle;
  33. return 1;
  34. }
  35. %}