sdl2-bindings 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +145 -134
- data/LICENSE.txt +0 -0
- data/README.md +108 -86
- data/lib/sdl2.rb +131 -131
- data/lib/sdl2_audio.rb +265 -261
- data/lib/sdl2_blendmode.rb +72 -72
- data/lib/sdl2_clipboard.rb +56 -56
- data/lib/sdl2_cpuinfo.rb +137 -129
- data/lib/sdl2_error.rb +71 -71
- data/lib/sdl2_events.rb +575 -564
- data/lib/sdl2_filesystem.rb +52 -52
- data/lib/sdl2_framerate.rb +74 -74
- data/lib/sdl2_gamecontroller.rb +345 -329
- data/lib/sdl2_gesture.rb +61 -61
- data/lib/sdl2_gfxPrimitives.rb +283 -283
- data/lib/sdl2_guid.rb +58 -0
- data/lib/sdl2_haptic.rb +301 -301
- data/lib/sdl2_hidapi.rb +139 -139
- data/lib/sdl2_hints.rb +240 -221
- data/lib/sdl2_image.rb +296 -296
- data/lib/sdl2_imageFilter.rb +164 -164
- data/lib/sdl2_joystick.rb +332 -294
- data/lib/sdl2_keyboard.rb +129 -125
- data/lib/sdl2_keycode.rb +311 -307
- data/lib/sdl2_log.rb +131 -131
- data/lib/sdl2_main.rb +74 -74
- data/lib/sdl2_messagebox.rb +102 -102
- data/lib/sdl2_misc.rb +48 -48
- data/lib/sdl2_mixer.rb +464 -464
- data/lib/sdl2_mouse.rb +136 -136
- data/lib/sdl2_pixels.rb +240 -240
- data/lib/sdl2_platform.rb +48 -48
- data/lib/sdl2_power.rb +54 -54
- data/lib/sdl2_rect.rb +145 -145
- data/lib/sdl2_render.rb +408 -408
- data/lib/sdl2_rotozoom.rb +76 -76
- data/lib/sdl2_rwops.rb +242 -242
- data/lib/sdl2_scancode.rb +293 -289
- data/lib/sdl2_sensor.rb +115 -115
- data/lib/sdl2_shape.rb +83 -83
- data/lib/sdl2_sound.rb +154 -154
- data/lib/sdl2_stdinc.rb +572 -548
- data/lib/sdl2_surface.rb +229 -229
- data/lib/sdl2_syswm.rb +160 -160
- data/lib/sdl2_timer.rb +74 -74
- data/lib/sdl2_touch.rb +86 -86
- data/lib/sdl2_ttf.rb +414 -414
- data/lib/sdl2_version.rb +67 -67
- data/lib/sdl2_video.rb +549 -540
- data/lib/sdl2_vulkan.rb +72 -72
- metadata +4 -3
data/lib/sdl2_rotozoom.rb
CHANGED
@@ -1,76 +1,76 @@
|
|
1
|
-
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
-
#
|
3
|
-
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
-
#
|
5
|
-
# [NOTICE] This is an automatically generated file.
|
6
|
-
|
7
|
-
require 'ffi'
|
8
|
-
|
9
|
-
module SDL
|
10
|
-
extend FFI::Library
|
11
|
-
# Define/Macro
|
12
|
-
|
13
|
-
|
14
|
-
# Enum
|
15
|
-
|
16
|
-
|
17
|
-
# Typedef
|
18
|
-
|
19
|
-
|
20
|
-
# Struct
|
21
|
-
|
22
|
-
|
23
|
-
# Function
|
24
|
-
|
25
|
-
def self.setup_gfx_rotozoom_symbols(output_error = false)
|
26
|
-
symbols = [
|
27
|
-
:rotozoomSurface,
|
28
|
-
:rotozoomSurfaceXY,
|
29
|
-
:rotozoomSurfaceSize,
|
30
|
-
:rotozoomSurfaceSizeXY,
|
31
|
-
:zoomSurface,
|
32
|
-
:zoomSurfaceSize,
|
33
|
-
:shrinkSurface,
|
34
|
-
:rotateSurface90Degrees,
|
35
|
-
]
|
36
|
-
apis = {
|
37
|
-
:rotozoomSurface => :rotozoomSurface,
|
38
|
-
:rotozoomSurfaceXY => :rotozoomSurfaceXY,
|
39
|
-
:rotozoomSurfaceSize => :rotozoomSurfaceSize,
|
40
|
-
:rotozoomSurfaceSizeXY => :rotozoomSurfaceSizeXY,
|
41
|
-
:zoomSurface => :zoomSurface,
|
42
|
-
:zoomSurfaceSize => :zoomSurfaceSize,
|
43
|
-
:shrinkSurface => :shrinkSurface,
|
44
|
-
:rotateSurface90Degrees => :rotateSurface90Degrees,
|
45
|
-
}
|
46
|
-
args = {
|
47
|
-
:rotozoomSurface => [:pointer, :double, :double, :int],
|
48
|
-
:rotozoomSurfaceXY => [:pointer, :double, :double, :double, :int],
|
49
|
-
:rotozoomSurfaceSize => [:int, :int, :double, :double, :pointer, :pointer],
|
50
|
-
:rotozoomSurfaceSizeXY => [:int, :int, :double, :double, :double, :pointer, :pointer],
|
51
|
-
:zoomSurface => [:pointer, :double, :double, :int],
|
52
|
-
:zoomSurfaceSize => [:int, :int, :double, :double, :pointer, :pointer],
|
53
|
-
:shrinkSurface => [:pointer, :int, :int],
|
54
|
-
:rotateSurface90Degrees => [:pointer, :int],
|
55
|
-
}
|
56
|
-
retvals = {
|
57
|
-
:rotozoomSurface => :pointer,
|
58
|
-
:rotozoomSurfaceXY => :pointer,
|
59
|
-
:rotozoomSurfaceSize => :void,
|
60
|
-
:rotozoomSurfaceSizeXY => :void,
|
61
|
-
:zoomSurface => :pointer,
|
62
|
-
:zoomSurfaceSize => :void,
|
63
|
-
:shrinkSurface => :pointer,
|
64
|
-
:rotateSurface90Degrees => :pointer,
|
65
|
-
}
|
66
|
-
symbols.each do |sym|
|
67
|
-
begin
|
68
|
-
attach_function apis[sym], sym, args[sym], retvals[sym]
|
69
|
-
rescue FFI::NotFoundError => error
|
70
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
1
|
+
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] This is an automatically generated file.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module SDL
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
|
14
|
+
# Enum
|
15
|
+
|
16
|
+
|
17
|
+
# Typedef
|
18
|
+
|
19
|
+
|
20
|
+
# Struct
|
21
|
+
|
22
|
+
|
23
|
+
# Function
|
24
|
+
|
25
|
+
def self.setup_gfx_rotozoom_symbols(output_error = false)
|
26
|
+
symbols = [
|
27
|
+
:rotozoomSurface,
|
28
|
+
:rotozoomSurfaceXY,
|
29
|
+
:rotozoomSurfaceSize,
|
30
|
+
:rotozoomSurfaceSizeXY,
|
31
|
+
:zoomSurface,
|
32
|
+
:zoomSurfaceSize,
|
33
|
+
:shrinkSurface,
|
34
|
+
:rotateSurface90Degrees,
|
35
|
+
]
|
36
|
+
apis = {
|
37
|
+
:rotozoomSurface => :rotozoomSurface,
|
38
|
+
:rotozoomSurfaceXY => :rotozoomSurfaceXY,
|
39
|
+
:rotozoomSurfaceSize => :rotozoomSurfaceSize,
|
40
|
+
:rotozoomSurfaceSizeXY => :rotozoomSurfaceSizeXY,
|
41
|
+
:zoomSurface => :zoomSurface,
|
42
|
+
:zoomSurfaceSize => :zoomSurfaceSize,
|
43
|
+
:shrinkSurface => :shrinkSurface,
|
44
|
+
:rotateSurface90Degrees => :rotateSurface90Degrees,
|
45
|
+
}
|
46
|
+
args = {
|
47
|
+
:rotozoomSurface => [:pointer, :double, :double, :int],
|
48
|
+
:rotozoomSurfaceXY => [:pointer, :double, :double, :double, :int],
|
49
|
+
:rotozoomSurfaceSize => [:int, :int, :double, :double, :pointer, :pointer],
|
50
|
+
:rotozoomSurfaceSizeXY => [:int, :int, :double, :double, :double, :pointer, :pointer],
|
51
|
+
:zoomSurface => [:pointer, :double, :double, :int],
|
52
|
+
:zoomSurfaceSize => [:int, :int, :double, :double, :pointer, :pointer],
|
53
|
+
:shrinkSurface => [:pointer, :int, :int],
|
54
|
+
:rotateSurface90Degrees => [:pointer, :int],
|
55
|
+
}
|
56
|
+
retvals = {
|
57
|
+
:rotozoomSurface => :pointer,
|
58
|
+
:rotozoomSurfaceXY => :pointer,
|
59
|
+
:rotozoomSurfaceSize => :void,
|
60
|
+
:rotozoomSurfaceSizeXY => :void,
|
61
|
+
:zoomSurface => :pointer,
|
62
|
+
:zoomSurfaceSize => :void,
|
63
|
+
:shrinkSurface => :pointer,
|
64
|
+
:rotateSurface90Degrees => :pointer,
|
65
|
+
}
|
66
|
+
symbols.each do |sym|
|
67
|
+
begin
|
68
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
69
|
+
rescue FFI::NotFoundError => error
|
70
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
data/lib/sdl2_rwops.rb
CHANGED
@@ -1,242 +1,242 @@
|
|
1
|
-
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
-
#
|
3
|
-
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
-
#
|
5
|
-
# [NOTICE] This is an automatically generated file.
|
6
|
-
|
7
|
-
require 'ffi'
|
8
|
-
|
9
|
-
module SDL
|
10
|
-
extend FFI::Library
|
11
|
-
# Define/Macro
|
12
|
-
|
13
|
-
RWOPS_UNKNOWN = 0
|
14
|
-
RWOPS_WINFILE = 1
|
15
|
-
RWOPS_STDFILE = 2
|
16
|
-
RWOPS_JNIFILE = 3
|
17
|
-
RWOPS_MEMORY = 4
|
18
|
-
RWOPS_MEMORY_RO = 5
|
19
|
-
|
20
|
-
# Enum
|
21
|
-
|
22
|
-
|
23
|
-
# Typedef
|
24
|
-
|
25
|
-
|
26
|
-
RW_SEEK_SET = 0
|
27
|
-
RW_SEEK_CUR = 1
|
28
|
-
RW_SEEK_END = 2
|
29
|
-
|
30
|
-
class RWops_mem < FFI::Struct
|
31
|
-
layout(
|
32
|
-
:base, :pointer,
|
33
|
-
:here, :pointer,
|
34
|
-
:stop, :pointer,
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
class RWops_unknown < FFI::Struct
|
39
|
-
layout(
|
40
|
-
:data1, :pointer,
|
41
|
-
:data2, :pointer,
|
42
|
-
)
|
43
|
-
end
|
44
|
-
class RWops_windowsio_buffer < FFI::Struct
|
45
|
-
layout(
|
46
|
-
:data, :pointer,
|
47
|
-
:size, :size_t,
|
48
|
-
:left, :size_t,
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
class RWops_windowsio < FFI::Struct
|
53
|
-
layout(
|
54
|
-
:append, :int,
|
55
|
-
:h, :pointer,
|
56
|
-
:buffer, RWops_windowsio_buffer,
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
class Default_RWops_hidden < FFI::Union
|
61
|
-
layout(
|
62
|
-
:mem, RWops_mem,
|
63
|
-
:unknown, RWops_unknown,
|
64
|
-
)
|
65
|
-
end
|
66
|
-
|
67
|
-
class Win32_RWops_hidden < FFI::Union
|
68
|
-
layout(
|
69
|
-
:mem, RWops_mem,
|
70
|
-
:unknown, RWops_unknown,
|
71
|
-
:windowsio, RWops_windowsio,
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
class Default_RWops < FFI::Struct
|
76
|
-
layout(
|
77
|
-
:size, :pointer,
|
78
|
-
:seek, :pointer,
|
79
|
-
:read, :pointer,
|
80
|
-
:write, :pointer,
|
81
|
-
:close, :pointer,
|
82
|
-
:type, :uint,
|
83
|
-
:hidden, Default_RWops_hidden,
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
class Win32_RWops < FFI::Struct
|
88
|
-
layout(
|
89
|
-
:size, :pointer,
|
90
|
-
:seek, :pointer,
|
91
|
-
:read, :pointer,
|
92
|
-
:write, :pointer,
|
93
|
-
:close, :pointer,
|
94
|
-
:type, :uint,
|
95
|
-
:hidden, Win32_RWops_hidden
|
96
|
-
)
|
97
|
-
end
|
98
|
-
|
99
|
-
if RUBY_PLATFORM =~ /mswin|msys|mingw|cygwin/
|
100
|
-
RWops = Win32_RWops
|
101
|
-
else
|
102
|
-
RWops = Default_RWops
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
# Struct
|
107
|
-
|
108
|
-
|
109
|
-
# Function
|
110
|
-
|
111
|
-
def self.setup_rwops_symbols(output_error = false)
|
112
|
-
symbols = [
|
113
|
-
:SDL_RWFromFile,
|
114
|
-
:SDL_RWFromFP,
|
115
|
-
:SDL_RWFromMem,
|
116
|
-
:SDL_RWFromConstMem,
|
117
|
-
:SDL_AllocRW,
|
118
|
-
:SDL_FreeRW,
|
119
|
-
:SDL_RWsize,
|
120
|
-
:SDL_RWseek,
|
121
|
-
:SDL_RWtell,
|
122
|
-
:SDL_RWread,
|
123
|
-
:SDL_RWwrite,
|
124
|
-
:SDL_RWclose,
|
125
|
-
:SDL_LoadFile_RW,
|
126
|
-
:SDL_LoadFile,
|
127
|
-
:SDL_ReadU8,
|
128
|
-
:SDL_ReadLE16,
|
129
|
-
:SDL_ReadBE16,
|
130
|
-
:SDL_ReadLE32,
|
131
|
-
:SDL_ReadBE32,
|
132
|
-
:SDL_ReadLE64,
|
133
|
-
:SDL_ReadBE64,
|
134
|
-
:SDL_WriteU8,
|
135
|
-
:SDL_WriteLE16,
|
136
|
-
:SDL_WriteBE16,
|
137
|
-
:SDL_WriteLE32,
|
138
|
-
:SDL_WriteBE32,
|
139
|
-
:SDL_WriteLE64,
|
140
|
-
:SDL_WriteBE64,
|
141
|
-
]
|
142
|
-
apis = {
|
143
|
-
:SDL_RWFromFile => :RWFromFile,
|
144
|
-
:SDL_RWFromFP => :RWFromFP,
|
145
|
-
:SDL_RWFromMem => :RWFromMem,
|
146
|
-
:SDL_RWFromConstMem => :RWFromConstMem,
|
147
|
-
:SDL_AllocRW => :AllocRW,
|
148
|
-
:SDL_FreeRW => :FreeRW,
|
149
|
-
:SDL_RWsize => :RWsize,
|
150
|
-
:SDL_RWseek => :RWseek,
|
151
|
-
:SDL_RWtell => :RWtell,
|
152
|
-
:SDL_RWread => :RWread,
|
153
|
-
:SDL_RWwrite => :RWwrite,
|
154
|
-
:SDL_RWclose => :RWclose,
|
155
|
-
:SDL_LoadFile_RW => :LoadFile_RW,
|
156
|
-
:SDL_LoadFile => :LoadFile,
|
157
|
-
:SDL_ReadU8 => :ReadU8,
|
158
|
-
:SDL_ReadLE16 => :ReadLE16,
|
159
|
-
:SDL_ReadBE16 => :ReadBE16,
|
160
|
-
:SDL_ReadLE32 => :ReadLE32,
|
161
|
-
:SDL_ReadBE32 => :ReadBE32,
|
162
|
-
:SDL_ReadLE64 => :ReadLE64,
|
163
|
-
:SDL_ReadBE64 => :ReadBE64,
|
164
|
-
:SDL_WriteU8 => :WriteU8,
|
165
|
-
:SDL_WriteLE16 => :WriteLE16,
|
166
|
-
:SDL_WriteBE16 => :WriteBE16,
|
167
|
-
:SDL_WriteLE32 => :WriteLE32,
|
168
|
-
:SDL_WriteBE32 => :WriteBE32,
|
169
|
-
:SDL_WriteLE64 => :WriteLE64,
|
170
|
-
:SDL_WriteBE64 => :WriteBE64,
|
171
|
-
}
|
172
|
-
args = {
|
173
|
-
:SDL_RWFromFile => [:pointer, :pointer],
|
174
|
-
:SDL_RWFromFP => [:pointer, :int],
|
175
|
-
:SDL_RWFromMem => [:pointer, :int],
|
176
|
-
:SDL_RWFromConstMem => [:pointer, :int],
|
177
|
-
:SDL_AllocRW => [],
|
178
|
-
:SDL_FreeRW => [:pointer],
|
179
|
-
:SDL_RWsize => [:pointer],
|
180
|
-
:SDL_RWseek => [:pointer, :long_long, :int],
|
181
|
-
:SDL_RWtell => [:pointer],
|
182
|
-
:SDL_RWread => [:pointer, :pointer, :ulong, :ulong],
|
183
|
-
:SDL_RWwrite => [:pointer, :pointer, :ulong, :ulong],
|
184
|
-
:SDL_RWclose => [:pointer],
|
185
|
-
:SDL_LoadFile_RW => [:pointer, :pointer, :int],
|
186
|
-
:SDL_LoadFile => [:pointer, :pointer],
|
187
|
-
:SDL_ReadU8 => [:pointer],
|
188
|
-
:SDL_ReadLE16 => [:pointer],
|
189
|
-
:SDL_ReadBE16 => [:pointer],
|
190
|
-
:SDL_ReadLE32 => [:pointer],
|
191
|
-
:SDL_ReadBE32 => [:pointer],
|
192
|
-
:SDL_ReadLE64 => [:pointer],
|
193
|
-
:SDL_ReadBE64 => [:pointer],
|
194
|
-
:SDL_WriteU8 => [:pointer, :uchar],
|
195
|
-
:SDL_WriteLE16 => [:pointer, :ushort],
|
196
|
-
:SDL_WriteBE16 => [:pointer, :ushort],
|
197
|
-
:SDL_WriteLE32 => [:pointer, :uint],
|
198
|
-
:SDL_WriteBE32 => [:pointer, :uint],
|
199
|
-
:SDL_WriteLE64 => [:pointer, :ulong_long],
|
200
|
-
:SDL_WriteBE64 => [:pointer, :ulong_long],
|
201
|
-
}
|
202
|
-
retvals = {
|
203
|
-
:SDL_RWFromFile => :pointer,
|
204
|
-
:SDL_RWFromFP => :pointer,
|
205
|
-
:SDL_RWFromMem => :pointer,
|
206
|
-
:SDL_RWFromConstMem => :pointer,
|
207
|
-
:SDL_AllocRW => :pointer,
|
208
|
-
:SDL_FreeRW => :void,
|
209
|
-
:SDL_RWsize => :long_long,
|
210
|
-
:SDL_RWseek => :long_long,
|
211
|
-
:SDL_RWtell => :long_long,
|
212
|
-
:SDL_RWread => :size_t,
|
213
|
-
:SDL_RWwrite => :size_t,
|
214
|
-
:SDL_RWclose => :int,
|
215
|
-
:SDL_LoadFile_RW => :pointer,
|
216
|
-
:SDL_LoadFile => :pointer,
|
217
|
-
:SDL_ReadU8 => :uchar,
|
218
|
-
:SDL_ReadLE16 => :ushort,
|
219
|
-
:SDL_ReadBE16 => :ushort,
|
220
|
-
:SDL_ReadLE32 => :uint,
|
221
|
-
:SDL_ReadBE32 => :uint,
|
222
|
-
:SDL_ReadLE64 => :ulong_long,
|
223
|
-
:SDL_ReadBE64 => :ulong_long,
|
224
|
-
:SDL_WriteU8 => :size_t,
|
225
|
-
:SDL_WriteLE16 => :size_t,
|
226
|
-
:SDL_WriteBE16 => :size_t,
|
227
|
-
:SDL_WriteLE32 => :size_t,
|
228
|
-
:SDL_WriteBE32 => :size_t,
|
229
|
-
:SDL_WriteLE64 => :size_t,
|
230
|
-
:SDL_WriteBE64 => :size_t,
|
231
|
-
}
|
232
|
-
symbols.each do |sym|
|
233
|
-
begin
|
234
|
-
attach_function apis[sym], sym, args[sym], retvals[sym]
|
235
|
-
rescue FFI::NotFoundError => error
|
236
|
-
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
end
|
242
|
-
|
1
|
+
# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/sdl2-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] This is an automatically generated file.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module SDL
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
RWOPS_UNKNOWN = 0
|
14
|
+
RWOPS_WINFILE = 1
|
15
|
+
RWOPS_STDFILE = 2
|
16
|
+
RWOPS_JNIFILE = 3
|
17
|
+
RWOPS_MEMORY = 4
|
18
|
+
RWOPS_MEMORY_RO = 5
|
19
|
+
|
20
|
+
# Enum
|
21
|
+
|
22
|
+
|
23
|
+
# Typedef
|
24
|
+
|
25
|
+
|
26
|
+
RW_SEEK_SET = 0
|
27
|
+
RW_SEEK_CUR = 1
|
28
|
+
RW_SEEK_END = 2
|
29
|
+
|
30
|
+
class RWops_mem < FFI::Struct
|
31
|
+
layout(
|
32
|
+
:base, :pointer,
|
33
|
+
:here, :pointer,
|
34
|
+
:stop, :pointer,
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
class RWops_unknown < FFI::Struct
|
39
|
+
layout(
|
40
|
+
:data1, :pointer,
|
41
|
+
:data2, :pointer,
|
42
|
+
)
|
43
|
+
end
|
44
|
+
class RWops_windowsio_buffer < FFI::Struct
|
45
|
+
layout(
|
46
|
+
:data, :pointer,
|
47
|
+
:size, :size_t,
|
48
|
+
:left, :size_t,
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
class RWops_windowsio < FFI::Struct
|
53
|
+
layout(
|
54
|
+
:append, :int,
|
55
|
+
:h, :pointer,
|
56
|
+
:buffer, RWops_windowsio_buffer,
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
class Default_RWops_hidden < FFI::Union
|
61
|
+
layout(
|
62
|
+
:mem, RWops_mem,
|
63
|
+
:unknown, RWops_unknown,
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
class Win32_RWops_hidden < FFI::Union
|
68
|
+
layout(
|
69
|
+
:mem, RWops_mem,
|
70
|
+
:unknown, RWops_unknown,
|
71
|
+
:windowsio, RWops_windowsio,
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
class Default_RWops < FFI::Struct
|
76
|
+
layout(
|
77
|
+
:size, :pointer,
|
78
|
+
:seek, :pointer,
|
79
|
+
:read, :pointer,
|
80
|
+
:write, :pointer,
|
81
|
+
:close, :pointer,
|
82
|
+
:type, :uint,
|
83
|
+
:hidden, Default_RWops_hidden,
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
class Win32_RWops < FFI::Struct
|
88
|
+
layout(
|
89
|
+
:size, :pointer,
|
90
|
+
:seek, :pointer,
|
91
|
+
:read, :pointer,
|
92
|
+
:write, :pointer,
|
93
|
+
:close, :pointer,
|
94
|
+
:type, :uint,
|
95
|
+
:hidden, Win32_RWops_hidden
|
96
|
+
)
|
97
|
+
end
|
98
|
+
|
99
|
+
if RUBY_PLATFORM =~ /mswin|msys|mingw|cygwin/
|
100
|
+
RWops = Win32_RWops
|
101
|
+
else
|
102
|
+
RWops = Default_RWops
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
# Struct
|
107
|
+
|
108
|
+
|
109
|
+
# Function
|
110
|
+
|
111
|
+
def self.setup_rwops_symbols(output_error = false)
|
112
|
+
symbols = [
|
113
|
+
:SDL_RWFromFile,
|
114
|
+
:SDL_RWFromFP,
|
115
|
+
:SDL_RWFromMem,
|
116
|
+
:SDL_RWFromConstMem,
|
117
|
+
:SDL_AllocRW,
|
118
|
+
:SDL_FreeRW,
|
119
|
+
:SDL_RWsize,
|
120
|
+
:SDL_RWseek,
|
121
|
+
:SDL_RWtell,
|
122
|
+
:SDL_RWread,
|
123
|
+
:SDL_RWwrite,
|
124
|
+
:SDL_RWclose,
|
125
|
+
:SDL_LoadFile_RW,
|
126
|
+
:SDL_LoadFile,
|
127
|
+
:SDL_ReadU8,
|
128
|
+
:SDL_ReadLE16,
|
129
|
+
:SDL_ReadBE16,
|
130
|
+
:SDL_ReadLE32,
|
131
|
+
:SDL_ReadBE32,
|
132
|
+
:SDL_ReadLE64,
|
133
|
+
:SDL_ReadBE64,
|
134
|
+
:SDL_WriteU8,
|
135
|
+
:SDL_WriteLE16,
|
136
|
+
:SDL_WriteBE16,
|
137
|
+
:SDL_WriteLE32,
|
138
|
+
:SDL_WriteBE32,
|
139
|
+
:SDL_WriteLE64,
|
140
|
+
:SDL_WriteBE64,
|
141
|
+
]
|
142
|
+
apis = {
|
143
|
+
:SDL_RWFromFile => :RWFromFile,
|
144
|
+
:SDL_RWFromFP => :RWFromFP,
|
145
|
+
:SDL_RWFromMem => :RWFromMem,
|
146
|
+
:SDL_RWFromConstMem => :RWFromConstMem,
|
147
|
+
:SDL_AllocRW => :AllocRW,
|
148
|
+
:SDL_FreeRW => :FreeRW,
|
149
|
+
:SDL_RWsize => :RWsize,
|
150
|
+
:SDL_RWseek => :RWseek,
|
151
|
+
:SDL_RWtell => :RWtell,
|
152
|
+
:SDL_RWread => :RWread,
|
153
|
+
:SDL_RWwrite => :RWwrite,
|
154
|
+
:SDL_RWclose => :RWclose,
|
155
|
+
:SDL_LoadFile_RW => :LoadFile_RW,
|
156
|
+
:SDL_LoadFile => :LoadFile,
|
157
|
+
:SDL_ReadU8 => :ReadU8,
|
158
|
+
:SDL_ReadLE16 => :ReadLE16,
|
159
|
+
:SDL_ReadBE16 => :ReadBE16,
|
160
|
+
:SDL_ReadLE32 => :ReadLE32,
|
161
|
+
:SDL_ReadBE32 => :ReadBE32,
|
162
|
+
:SDL_ReadLE64 => :ReadLE64,
|
163
|
+
:SDL_ReadBE64 => :ReadBE64,
|
164
|
+
:SDL_WriteU8 => :WriteU8,
|
165
|
+
:SDL_WriteLE16 => :WriteLE16,
|
166
|
+
:SDL_WriteBE16 => :WriteBE16,
|
167
|
+
:SDL_WriteLE32 => :WriteLE32,
|
168
|
+
:SDL_WriteBE32 => :WriteBE32,
|
169
|
+
:SDL_WriteLE64 => :WriteLE64,
|
170
|
+
:SDL_WriteBE64 => :WriteBE64,
|
171
|
+
}
|
172
|
+
args = {
|
173
|
+
:SDL_RWFromFile => [:pointer, :pointer],
|
174
|
+
:SDL_RWFromFP => [:pointer, :int],
|
175
|
+
:SDL_RWFromMem => [:pointer, :int],
|
176
|
+
:SDL_RWFromConstMem => [:pointer, :int],
|
177
|
+
:SDL_AllocRW => [],
|
178
|
+
:SDL_FreeRW => [:pointer],
|
179
|
+
:SDL_RWsize => [:pointer],
|
180
|
+
:SDL_RWseek => [:pointer, :long_long, :int],
|
181
|
+
:SDL_RWtell => [:pointer],
|
182
|
+
:SDL_RWread => [:pointer, :pointer, :ulong, :ulong],
|
183
|
+
:SDL_RWwrite => [:pointer, :pointer, :ulong, :ulong],
|
184
|
+
:SDL_RWclose => [:pointer],
|
185
|
+
:SDL_LoadFile_RW => [:pointer, :pointer, :int],
|
186
|
+
:SDL_LoadFile => [:pointer, :pointer],
|
187
|
+
:SDL_ReadU8 => [:pointer],
|
188
|
+
:SDL_ReadLE16 => [:pointer],
|
189
|
+
:SDL_ReadBE16 => [:pointer],
|
190
|
+
:SDL_ReadLE32 => [:pointer],
|
191
|
+
:SDL_ReadBE32 => [:pointer],
|
192
|
+
:SDL_ReadLE64 => [:pointer],
|
193
|
+
:SDL_ReadBE64 => [:pointer],
|
194
|
+
:SDL_WriteU8 => [:pointer, :uchar],
|
195
|
+
:SDL_WriteLE16 => [:pointer, :ushort],
|
196
|
+
:SDL_WriteBE16 => [:pointer, :ushort],
|
197
|
+
:SDL_WriteLE32 => [:pointer, :uint],
|
198
|
+
:SDL_WriteBE32 => [:pointer, :uint],
|
199
|
+
:SDL_WriteLE64 => [:pointer, :ulong_long],
|
200
|
+
:SDL_WriteBE64 => [:pointer, :ulong_long],
|
201
|
+
}
|
202
|
+
retvals = {
|
203
|
+
:SDL_RWFromFile => :pointer,
|
204
|
+
:SDL_RWFromFP => :pointer,
|
205
|
+
:SDL_RWFromMem => :pointer,
|
206
|
+
:SDL_RWFromConstMem => :pointer,
|
207
|
+
:SDL_AllocRW => :pointer,
|
208
|
+
:SDL_FreeRW => :void,
|
209
|
+
:SDL_RWsize => :long_long,
|
210
|
+
:SDL_RWseek => :long_long,
|
211
|
+
:SDL_RWtell => :long_long,
|
212
|
+
:SDL_RWread => :size_t,
|
213
|
+
:SDL_RWwrite => :size_t,
|
214
|
+
:SDL_RWclose => :int,
|
215
|
+
:SDL_LoadFile_RW => :pointer,
|
216
|
+
:SDL_LoadFile => :pointer,
|
217
|
+
:SDL_ReadU8 => :uchar,
|
218
|
+
:SDL_ReadLE16 => :ushort,
|
219
|
+
:SDL_ReadBE16 => :ushort,
|
220
|
+
:SDL_ReadLE32 => :uint,
|
221
|
+
:SDL_ReadBE32 => :uint,
|
222
|
+
:SDL_ReadLE64 => :ulong_long,
|
223
|
+
:SDL_ReadBE64 => :ulong_long,
|
224
|
+
:SDL_WriteU8 => :size_t,
|
225
|
+
:SDL_WriteLE16 => :size_t,
|
226
|
+
:SDL_WriteBE16 => :size_t,
|
227
|
+
:SDL_WriteLE32 => :size_t,
|
228
|
+
:SDL_WriteBE32 => :size_t,
|
229
|
+
:SDL_WriteLE64 => :size_t,
|
230
|
+
:SDL_WriteBE64 => :size_t,
|
231
|
+
}
|
232
|
+
symbols.each do |sym|
|
233
|
+
begin
|
234
|
+
attach_function apis[sym], sym, args[sym], retvals[sym]
|
235
|
+
rescue FFI::NotFoundError => error
|
236
|
+
$stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|