PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms 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
 1%module union_parameter
 2
 3%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype'
 4
 5%inline %{
 6
 7typedef unsigned char Uint8;
 8
 9typedef struct SDL_ActiveEvent {
10        Uint8 type;     /* SDL_ACTIVEEVENT */
11        Uint8 gain;     /* Whether given states were gained or lost (1/0) */
12        Uint8 state;    /* A mask of the focus states */
13} SDL_ActiveEvent;
14
15/* Keyboard event structure */
16typedef struct SDL_KeyboardEvent {
17        Uint8 type;     /* SDL_KEYDOWN or SDL_KEYUP */
18        int which;    /* The keyboard device index */
19        int state;    /* SDL_PRESSED or SDL_RELEASED */
20} SDL_KeyboardEvent;
21
22typedef union {
23        Uint8 type;
24        SDL_ActiveEvent active;
25        SDL_KeyboardEvent key;
26} SDL_Event;
27
28int SDL_PollEvent (SDL_Event *ev) {
29    static int toggle = 0;
30    if (toggle == 0) {
31        ev->type = 1;
32        ev->active.gain = 20;
33        ev->active.state = 30;
34    } else {
35        ev->type = 2;
36        ev->key.which = 2000;
37        ev->key.state = 3000;
38    }
39    toggle = 1 - toggle;
40    return 1;
41}
42
43%}