annotate R/scratch/structs.R @ 54:918dab7a6606

- added callback support (comes with some bigger refactoring) - allow CPython's Py{CObject,Capsule} to be used as 'p'ointers
author Tassilo Philipp
date Tue, 02 Feb 2021 20:42:02 +0100
parents 0cfcc391201f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 # struct tests:
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 # test embedded structures and inline assignments
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 parseStructInfos("
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 SDL_Rect{ssSS}x y w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 Test{II<SDL_Rect>II}a b rect c d;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 ")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 x <- new.struct("Test")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 print(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13 r <- new.struct("SDL_Rect")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 r$x <- 1
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15 r$y <- 2
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 r$w <- 3
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 r$h <- 4
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 x$rect <- r
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 #
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 parseStructInfos("
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23 SDL_ActiveEvent{CCC}type gain state ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24 SDL_keysym{CiiS}scancode sym mod unicode ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25 SDL_KeyboardEvent{CCC<SDL_keysym>}type which state keysym ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26 SDL_MouseMotionEvent{CCCSSss}type which state x y xrel yrel ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27 SDL_MouseButtonEvent{CCCCSS}type which button state x y ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 ")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30 g
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 new <- function()
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 x <- list()
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35 class(x) <- "test"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36 return(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
37 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
38
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
39 "$<-.test" <- function(x, index, value)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
40 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
41 cat("$<-\n")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
42 cat("nargs:", nargs(), "\n" )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
43 x[index] <- value
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
44 return(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
45 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
46
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
47 "$.test" <- function(x, index)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
48 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
49 cat("$\n")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
50 x[index]
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
51 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
52
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
53 x <- new()
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
54 x$a <- 23
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
55
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
56 x$a$b <- 23
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
57
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
58
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
59
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
60
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
61 str(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
62
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
63 x$rect
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
64
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
65 registerStructInfos("
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
66 SDL_Rect{ssSS}x y w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
67 SDL_Surface{I*<SDL_PixelFormat>iiS*vi*<private_hwdata><SDL_Rect>II*<SDL_BlitMap>Ii}flags format w h pitch pixels offset hwdata clip_rect unused1 locked map format_version refcount ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
68 ")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
69
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
70
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
71 x <- new.struct("SDL_Rect")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
72 x$x <- 10
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
73 x$y <- 10
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
74 x$w <- 100
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
75 x$h <- 100
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
76 str(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
77
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
78 # ----------------------------------------------------------------------------
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
79 # tests
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
80
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
81
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
82 registerStructInfos("SDL_SysWMmsg{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
83 SDL_SysWMEvent{C*<SDL_SysWMmsg>}type msg ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
84 ")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
85
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
86 registerStructInfos(sdlStructs)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
87 parseStructInfos("SDL_UserEvent{Ci*v*v}type code data1 data2 ;SDL_QuitEvent{C}type ;")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
88 sigs <- "SDL_UserEvent{Ci*v*v}type code data1 data2 ;SDL_QuitEvent{C}type ;"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
89
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
90 for (i in seq(along=sigs))
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
91 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
92 if ( length(sigs[[i]]) < 2 ) next
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
93 name <- sigs[[i]][[1]]
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
94 # eat white spaces
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
95 name <- gsub("[ \n\t]*","",name)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
96 tail <- unlist( strsplit(sigs[[i]][[2]], "\\}") )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
97 sig <- tail[[1]]
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
98 fields <- unlist( strsplit( tail[[2]], "[ \n\t]+" ) )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
99 infos[[name]] <- list(sig, fields)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
100 infos[[name]] <- makeStructInfo(sig, fields)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
101 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
102 return(infos)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
103 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
104
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
105
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
106
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
107
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
108 registerStructInfos("SDL_version{CCC}major minor patch ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
109 _SDL_TimerID{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
110 SDL_SysWMmsg{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
111 SDL_SysWMEvent{C*<SDL_SysWMmsg>}type msg ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
112 SDL_UserEvent{Ci*v*v}type code data1 data2 ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
113 SDL_QuitEvent{C}type ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
114 SDL_ExposeEvent{C}type ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
115 SDL_ResizeEvent{Cii}type w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
116 SDL_JoyButtonEvent{CCCC}type which button state ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
117 SDL_JoyHatEvent{CCCC}type which hat value ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
118 SDL_JoyBallEvent{CCCss}type which ball xrel yrel ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
119 SDL_JoyAxisEvent{CCCs}type which axis value ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
120 SDL_MouseButtonEvent{CCCCSS}type which button state x y ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
121 SDL_MouseMotionEvent{CCCSSss}type which state x y xrel yrel ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
122 SDL_keysym{CiiS}scancode sym mod unicode ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
123 SDL_KeyboardEvent{CCC<SDL_keysym>}type which state keysym ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
124 SDL_ActiveEvent{CCC}type gain state ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
125 SDL_Rect{ssSS}x y w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
126 SDL_Surface{I*<SDL_PixelFormat>iiS*vi*<private_hwdata><SDL_Rect>II*<SDL_BlitMap>Ii}flags format w h pitch pixels offset hwdata clip_rect unused1 locked map format_version refcount ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
127 ")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
128
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
129
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
130
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
131 sigs <- "SDL_ActiveEvent{CCC}type gain state ;SDL_AudioCVT{iSSd*Ciiidi}needed src_format dst_format rate_incr buf len len_cvt len_mult len_ratio filters filter_index ;"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
132 sigs <- "SDL_AudioCVT{iSSd*Ciiidi}needed src_format dst_format rate_incr buf len len_cvt len_mult len_ratio filters filter_index ;"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
133 parseStructInfos(sigs)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
134 dsadsigs <- sdlStructs
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
135 sdlStructs <- "
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
136 SDL_version{CCC}major minor patch ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
137 _SDL_TimerID{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
138 SDL_SysWMmsg{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
139 SDL_SysWMEvent{C*<SDL_SysWMmsg>}type msg ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
140 SDL_UserEvent{Ci*v*v}type code data1 data2 ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
141 SDL_QuitEvent{C}type ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
142 SDL_ExposeEvent{C}type ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
143 SDL_ResizeEvent{Cii}type w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
144 SDL_JoyButtonEvent{CCCC}type which button state ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
145 SDL_JoyHatEvent{CCCC}type which hat value ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
146 SDL_JoyBallEvent{CCCss}type which ball xrel yrel ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
147 SDL_JoyAxisEvent{CCCs}type which axis value ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
148 SDL_MouseButtonEvent{CCCCSS}type which button state x y ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
149 SDL_MouseMotionEvent{CCCSSss}type which state x y xrel yrel ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
150 SDL_keysym{CiiS}scancode sym mod unicode ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
151 SDL_KeyboardEvent{CCC<SDL_keysym>}type which state keysym ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
152 SDL_ActiveEvent{CCC}type gain state ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
153 _SDL_Joystick{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
154 SDL_Rect{ssSS}x y w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
155 WMcursor{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
156 SDL_Cursor{<SDL_Rect>ss*C*C*<WMcursor>}area hot_x hot_y data mask save wm_cursor ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
157 SDL_Overlay{Iiii*S**<private_yuvhwfuncs>*<private_yuvhwdata>II}format w h planes pitches pixels hwfuncs hwdata hw_overlay UnusedBits ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
158 private_yuvhwdata{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
159 private_yuvhwfuncs{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
160 SDL_VideoInfo{IIIIIIIIIIIII*<SDL_PixelFormat>ii}hw_available wm_available UnusedBits1 UnusedBits2 blit_hw blit_hw_CC blit_hw_A blit_sw blit_sw_CC blit_sw_A blit_fill UnusedBits3 video_mem vfmt current_w current_h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
161 SDL_BlitMap{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
162 private_hwdata{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
163 SDL_Color{CCCC}r g b unused ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
164 SDL_Palette{i*<SDL_Color>}ncolors colors ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
165 SDL_PixelFormat{*<SDL_Palette>CCCCCCCCCCIIIIIC}palette BitsPerPixel BytesPerPixel Rloss Gloss Bloss Aloss Rshift Gshift Bshift Ashift Rmask Gmask Bmask Amask colorkey alpha ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
166 SDL_CD{iiiii}id status numtracks cur_track cur_frame track ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
167 SDL_CDtrack{CCSII}id type unused length offset ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
168 SDL_AudioCVT{iSSd*Ciiidi}needed src_format dst_format rate_incr buf len len_cvt len_mult len_ratio filters filter_index ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
169 SDL_AudioSpec{iSCCSSI*p*v}freq format channels silence samples padding size callback userdata ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
170 "
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
171
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
172
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
173
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
174 old <- "SDL_version{CCC}major minor patch ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
175 _SDL_TimerID{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
176 SDL_SysWMEvent{C*<SDL_SysWMmsg>}type msg ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
177 SDL_SysWMmsg{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
178 SDL_UserEvent{Ci*v*v}type code data1 data2 ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
179 SDL_QuitEvent{C}type ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
180 SDL_ExposeEvent{C}type ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
181 SDL_ResizeEvent{Cii}type w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
182 SDL_JoyButtonEvent{CCCC}type which button state ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
183 SDL_JoyHatEvent{CCCC}type which hat value ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
184 SDL_JoyBallEvent{CCCss}type which ball xrel yrel ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
185 SDL_JoyAxisEvent{CCCs}type which axis value ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
186 SDL_MouseButtonEvent{CCCCSS}type which button state x y ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
187 SDL_MouseMotionEvent{CCCSSss}type which state x y xrel yrel ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
188 SDL_KeyboardEvent{CCC<SDL_keysym>}type which state keysym ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
189 SDL_ActiveEvent{CCC}type gain state ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
190 _SDL_Joystick{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
191 SDL_Cursor{<SDL_Rect>ss*C*C*<WMcursor>}area hot_x hot_y data mask save wm_cursor ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
192 WMcursor{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
193 SDL_Overlay{Iiii*S**<private_yuvhwfuncs>*<private_yuvhwdata>II}format w h planes pitches pixels hwfuncs hwdata hw_overlay UnusedBits ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
194 private_yuvhwdata{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
195 private_yuvhwfuncs{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
196 SDL_VideoInfo{IIIIIIIIIIIII*<SDL_PixelFormat>ii}hw_available wm_available UnusedBits1 UnusedBits2 blit_hw blit_hw_CC blit_hw_A blit_sw blit_sw_CC blit_sw_A blit_fill UnusedBits3 video_mem vfmt current_w current_h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
197 SDL_Surface{I*<SDL_PixelFormat>iiS*vi*<private_hwdata><SDL_Rect>II*<SDL_BlitMap>Ii}flags format w h pitch pixels offset hwdata clip_rect unused1 locked map format_version refcount ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
198 SDL_BlitMap{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
199 private_hwdata{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
200 SDL_PixelFormat{*<SDL_Palette>CCCCCCCCCCIIIIIC}palette BitsPerPixel BytesPerPixel Rloss Gloss Bloss Aloss Rshift Gshift Bshift Ashift Rmask Gmask Bmask Amask colorkey alpha ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
201 SDL_Palette{i*<SDL_Color>}ncolors colors ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
202 SDL_Color{CCCC}r g b unused ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
203 SDL_Rect{ssSS}x y w h ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
204 SDL_keysym{CiiS}scancode sym mod unicode ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
205 SDL_CD{iiiii}id status numtracks cur_track cur_frame track ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
206 SDL_CDtrack{CCSII}id type unused length offset ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
207 SDL_AudioCVT{iSSd*Ciiidi}needed src_format dst_format rate_incr buf len len_cvt len_mult len_ratio filters filter_index ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
208 SDL_AudioSpec{iSCCSSI*p*v}freq format channels silence samples padding size callback userdata ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
209 SDL_RWops{*p*p*p*pI<$_7>}seek read write close type hidden ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
210 SDL_Thread{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
211 SDL_cond{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
212 SDL_semaphore{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
213 SDL_mutex{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
214 _SDL_iconv_t{};
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
215 lldiv_t{ll}quot rem ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
216 ldiv_t{jj}quot rem ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
217 div_t{ii}quot rem ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
218 _iobuf{*ci*ciiii*c}_ptr _cnt _base _flag _file _charbuf _bufsiz _tmpfname ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
219 $_8{i*v<$_9>}append h buffer ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
220 $_10{i*<_iobuf>}autoclose fp ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
221 $_11{*C*C*C}base here stop ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
222 $_12{*v}data1 ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
223 $_9{*vii}data size left ;
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
224 "
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
225
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
226
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
227 .types <- list()
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
228
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
229 setStruct <- function(name, ...)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
230 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
231 x <- list(...)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
232 class(x) <- c("struct","type")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
233 .types[[name]] <<- x
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
234 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
235
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
236 setUnion <- function(name, ...)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
237 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
238 x <- list(...)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
239 class(x) <- c("union","type")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
240 .types[[name]] <<- x
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
241 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
242
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
243 getType <- function(name)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
244 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
245 .types[[name]]
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
246 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
247
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
248
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
249 setStruct("SDL_keysym", scancode="C", sym="i", mod="i", unicode="S" )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
250 setStruct("SDL_KeyboardEvent", type="C", which="C", state="C", keysym="{SDL_keysym}")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
251
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
252 parseTypeSignature("SDL_Event|C<SDL_ActiveEvent><SDL_KeyboardEvent><SDL_MouseMotionEvent><SDL_MouseButtonEvent><SDL_JoyAxisEvent><SDL_JoyBallEvent><SDL_JoyHatEvent><SDL_JoyButtonEvent><SDL_ResizeEvent><SDL_ExposeEvent><SDL_QuitEvent><SDL_UserEvent><SDL_SysWMEvent>|type active key motion button jaxis jball jhat jbutton resize expose quit user syswm ;")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
253
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
254 setUnion("SDL_Event",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
255 type="uchar",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
256 action="SDL_ActiveEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
257 key="SDL_KeyboardEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
258 motion="SDL_MouseMotionEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
259 button="SDL_MouseButtonEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
260 jaxis="SDL_JoyAxisEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
261 jball="SDL_JoyBallEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
262 jbutton="SDL_JoyButtonEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
263 resize="SDL_ResizeEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
264 expose="SDL_ExposeEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
265 quit="SDL_QuitEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
266 user="SDL_UserEvent",
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
267 syswm="SDL_SysWMEvent")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
268
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
269 .sizeof <- c(
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
270 B=.Machine$sizeof.long,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
271 c=1L,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
272 C=1L,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
273 s=2L,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
274 S=2L,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
275 i=.Machine$sizeof.long,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
276 I=.Machine$sizeof.long,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
277 j=.Machine$sizeof.long,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
278 J=.Machine$sizeof.long,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
279 l=.Machine$sizeof.longlong,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
280 L=.Machine$sizeof.longlong,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
281 f=4L,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
282 d=8L,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
283 "*"=.Machine$sizeof.pointer,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
284 p=.Machine$sizeof.pointer,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
285 x=.Machine$sizeof.pointer,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
286 Z=.Machine$sizeof.pointer,
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
287 v=0L
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
288 )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
289
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
290 align <- function(start, type)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
291 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
292 start %% sizeof(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
293 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
294
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
295 sizeof <- function(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
296 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
297 first <- substr(x,1,1)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
298 if (first == "<") {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
299 if ( substr(x, nchar(x), nchar(x) ) != ">" ) stop("invalid signature")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
300 typeName <- substr(x,2,nchar(x)-2)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
301 sizeof(getType(typeName))
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
302 } else {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
303 .sizeof[[substr(x, 1,1)]]
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
304 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
305 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
306
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
307 sizeof.struct <- function(x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
308 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
309 total <- 0L
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
310 for(i in x)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
311 {
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
312 size <- sizeof(i)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
313 total <- total + total %% size + size
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
314 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
315 return(total)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
316 }
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
317
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
318
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
319 sizeof(struct("iii"))
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
320 sizeof(union("iii"))
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
321