gosu 0.15.1 → 1.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/COPYING +1 -1
  4. data/dependencies/SDL/include/SDL.h +138 -0
  5. data/dependencies/SDL/include/SDL_assert.h +293 -0
  6. data/dependencies/SDL/include/SDL_atomic.h +295 -0
  7. data/dependencies/SDL/include/SDL_audio.h +859 -0
  8. data/dependencies/SDL/include/SDL_bits.h +121 -0
  9. data/dependencies/SDL/include/SDL_blendmode.h +123 -0
  10. data/dependencies/SDL/include/SDL_clipboard.h +71 -0
  11. data/dependencies/SDL/include/SDL_config.h +55 -0
  12. data/dependencies/SDL/include/SDL_config_android.h +182 -0
  13. data/dependencies/SDL/include/SDL_config_iphoneos.h +207 -0
  14. data/dependencies/SDL/include/SDL_config_macosx.h +266 -0
  15. data/dependencies/SDL/include/SDL_config_minimal.h +85 -0
  16. data/dependencies/SDL/include/SDL_config_os2.h +188 -0
  17. data/dependencies/SDL/include/SDL_config_pandora.h +135 -0
  18. data/dependencies/SDL/include/SDL_config_psp.h +165 -0
  19. data/dependencies/SDL/include/SDL_config_windows.h +288 -0
  20. data/dependencies/SDL/include/SDL_config_winrt.h +243 -0
  21. data/dependencies/SDL/include/SDL_config_wiz.h +149 -0
  22. data/dependencies/SDL/include/SDL_copying.h +20 -0
  23. data/dependencies/SDL/include/SDL_cpuinfo.h +299 -0
  24. data/dependencies/SDL/include/SDL_egl.h +1676 -0
  25. data/dependencies/SDL/include/SDL_endian.h +263 -0
  26. data/dependencies/SDL/include/SDL_error.h +112 -0
  27. data/dependencies/SDL/include/SDL_events.h +827 -0
  28. data/dependencies/SDL/include/SDL_filesystem.h +136 -0
  29. data/dependencies/SDL/include/SDL_gamecontroller.h +541 -0
  30. data/dependencies/SDL/include/SDL_gesture.h +87 -0
  31. data/dependencies/SDL/include/SDL_haptic.h +1247 -0
  32. data/dependencies/SDL/include/SDL_hints.h +1578 -0
  33. data/dependencies/SDL/include/SDL_joystick.h +499 -0
  34. data/dependencies/SDL/include/SDL_keyboard.h +217 -0
  35. data/dependencies/SDL/include/SDL_keycode.h +351 -0
  36. data/dependencies/SDL/include/SDL_loadso.h +81 -0
  37. data/dependencies/SDL/include/SDL_locale.h +101 -0
  38. data/dependencies/SDL/include/SDL_log.h +211 -0
  39. data/dependencies/SDL/include/SDL_main.h +180 -0
  40. data/dependencies/SDL/include/SDL_messagebox.h +146 -0
  41. data/dependencies/SDL/include/SDL_metal.h +117 -0
  42. data/dependencies/SDL/include/SDL_misc.h +75 -0
  43. data/dependencies/SDL/include/SDL_mouse.h +302 -0
  44. data/dependencies/SDL/include/SDL_mutex.h +251 -0
  45. data/dependencies/SDL/include/SDL_name.h +33 -0
  46. data/dependencies/SDL/include/SDL_opengl.h +2183 -0
  47. data/dependencies/SDL/include/SDL_opengl_glext.h +11180 -0
  48. data/dependencies/SDL/include/SDL_opengles.h +39 -0
  49. data/dependencies/SDL/include/SDL_opengles2.h +52 -0
  50. data/dependencies/SDL/include/SDL_opengles2_gl2.h +621 -0
  51. data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +2050 -0
  52. data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +30 -0
  53. data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +282 -0
  54. data/dependencies/SDL/include/SDL_pixels.h +479 -0
  55. data/dependencies/SDL/include/SDL_platform.h +198 -0
  56. data/dependencies/SDL/include/SDL_power.h +75 -0
  57. data/dependencies/SDL/include/SDL_quit.h +58 -0
  58. data/dependencies/SDL/include/SDL_rect.h +174 -0
  59. data/dependencies/SDL/include/SDL_render.h +1158 -0
  60. data/dependencies/SDL/include/SDL_revision.h +2 -0
  61. data/dependencies/SDL/include/SDL_rwops.h +283 -0
  62. data/dependencies/SDL/include/SDL_scancode.h +413 -0
  63. data/dependencies/SDL/include/SDL_sensor.h +267 -0
  64. data/dependencies/SDL/include/SDL_shape.h +144 -0
  65. data/dependencies/SDL/include/SDL_stdinc.h +647 -0
  66. data/dependencies/SDL/include/SDL_surface.h +563 -0
  67. data/dependencies/SDL/include/SDL_system.h +325 -0
  68. data/dependencies/SDL/include/SDL_syswm.h +354 -0
  69. data/dependencies/SDL/include/SDL_test.h +69 -0
  70. data/dependencies/SDL/include/SDL_test_assert.h +105 -0
  71. data/dependencies/SDL/include/SDL_test_common.h +218 -0
  72. data/dependencies/SDL/include/SDL_test_compare.h +69 -0
  73. data/dependencies/SDL/include/SDL_test_crc32.h +124 -0
  74. data/dependencies/SDL/include/SDL_test_font.h +81 -0
  75. data/dependencies/SDL/include/SDL_test_fuzzer.h +384 -0
  76. data/dependencies/SDL/include/SDL_test_harness.h +134 -0
  77. data/dependencies/SDL/include/SDL_test_images.h +78 -0
  78. data/dependencies/SDL/include/SDL_test_log.h +67 -0
  79. data/dependencies/SDL/include/SDL_test_md5.h +129 -0
  80. data/dependencies/SDL/include/SDL_test_memory.h +63 -0
  81. data/dependencies/SDL/include/SDL_test_random.h +115 -0
  82. data/dependencies/SDL/include/SDL_thread.h +366 -0
  83. data/dependencies/SDL/include/SDL_timer.h +115 -0
  84. data/dependencies/SDL/include/SDL_touch.h +102 -0
  85. data/dependencies/SDL/include/SDL_types.h +29 -0
  86. data/dependencies/SDL/include/SDL_version.h +162 -0
  87. data/dependencies/SDL/include/SDL_video.h +1282 -0
  88. data/dependencies/SDL/include/SDL_vulkan.h +276 -0
  89. data/dependencies/SDL/include/begin_code.h +166 -0
  90. data/dependencies/SDL/include/close_code.h +40 -0
  91. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  92. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  93. data/dependencies/SDL_sound/SDL_sound.c +795 -0
  94. data/dependencies/SDL_sound/SDL_sound.h +725 -0
  95. data/dependencies/SDL_sound/SDL_sound_aiff.c +537 -0
  96. data/dependencies/SDL_sound/SDL_sound_au.c +352 -0
  97. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +747 -0
  98. data/dependencies/SDL_sound/SDL_sound_flac.c +182 -0
  99. data/dependencies/SDL_sound/SDL_sound_internal.h +304 -0
  100. data/dependencies/SDL_sound/SDL_sound_modplug.c +228 -0
  101. data/dependencies/SDL_sound/SDL_sound_mp3.c +184 -0
  102. data/dependencies/SDL_sound/SDL_sound_raw.c +164 -0
  103. data/dependencies/SDL_sound/SDL_sound_shn.c +1309 -0
  104. data/dependencies/SDL_sound/SDL_sound_voc.c +550 -0
  105. data/dependencies/SDL_sound/SDL_sound_vorbis.c +223 -0
  106. data/dependencies/SDL_sound/SDL_sound_wav.c +783 -0
  107. data/dependencies/SDL_sound/dr_flac.h +5906 -0
  108. data/dependencies/SDL_sound/dr_mp3.h +2832 -0
  109. data/dependencies/SDL_sound/libmodplug/fastmix.c +1748 -0
  110. data/dependencies/SDL_sound/libmodplug/libmodplug.h +1001 -0
  111. data/dependencies/SDL_sound/libmodplug/load_669.c +188 -0
  112. data/dependencies/SDL_sound/libmodplug/load_abc.c +4725 -0
  113. data/dependencies/SDL_sound/libmodplug/load_amf.c +403 -0
  114. data/dependencies/SDL_sound/libmodplug/load_ams.c +587 -0
  115. data/dependencies/SDL_sound/libmodplug/load_dbm.c +357 -0
  116. data/dependencies/SDL_sound/libmodplug/load_dmf.c +531 -0
  117. data/dependencies/SDL_sound/libmodplug/load_dsm.c +232 -0
  118. data/dependencies/SDL_sound/libmodplug/load_far.c +253 -0
  119. data/dependencies/SDL_sound/libmodplug/load_it.c +796 -0
  120. data/dependencies/SDL_sound/libmodplug/load_mdl.c +488 -0
  121. data/dependencies/SDL_sound/libmodplug/load_med.c +757 -0
  122. data/dependencies/SDL_sound/libmodplug/load_mid.c +1405 -0
  123. data/dependencies/SDL_sound/libmodplug/load_mod.c +269 -0
  124. data/dependencies/SDL_sound/libmodplug/load_mt2.c +546 -0
  125. data/dependencies/SDL_sound/libmodplug/load_mtm.c +142 -0
  126. data/dependencies/SDL_sound/libmodplug/load_okt.c +192 -0
  127. data/dependencies/SDL_sound/libmodplug/load_pat.c +1143 -0
  128. data/dependencies/SDL_sound/libmodplug/load_pat.h +25 -0
  129. data/dependencies/SDL_sound/libmodplug/load_psm.c +350 -0
  130. data/dependencies/SDL_sound/libmodplug/load_ptm.c +204 -0
  131. data/dependencies/SDL_sound/libmodplug/load_s3m.c +325 -0
  132. data/dependencies/SDL_sound/libmodplug/load_stm.c +180 -0
  133. data/dependencies/SDL_sound/libmodplug/load_ult.c +206 -0
  134. data/dependencies/SDL_sound/libmodplug/load_umx.c +51 -0
  135. data/dependencies/SDL_sound/libmodplug/load_xm.c +554 -0
  136. data/dependencies/SDL_sound/libmodplug/mmcmp.c +382 -0
  137. data/dependencies/SDL_sound/libmodplug/modplug.c +170 -0
  138. data/dependencies/SDL_sound/libmodplug/modplug.h +90 -0
  139. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +301 -0
  140. data/dependencies/SDL_sound/libmodplug/snd_flt.c +63 -0
  141. data/dependencies/SDL_sound/libmodplug/snd_fx.c +2350 -0
  142. data/dependencies/SDL_sound/libmodplug/sndfile.c +1169 -0
  143. data/dependencies/SDL_sound/libmodplug/sndmix.c +1034 -0
  144. data/dependencies/SDL_sound/libmodplug/tables.h +371 -0
  145. data/{src/stb_vorbis.c → dependencies/SDL_sound/stb_vorbis.h} +143 -78
  146. data/dependencies/al_soft/AL/al.h +655 -0
  147. data/dependencies/al_soft/AL/alc.h +270 -0
  148. data/dependencies/al_soft/AL/alext.h +585 -0
  149. data/dependencies/al_soft/AL/efx-creative.h +3 -0
  150. data/dependencies/al_soft/AL/efx-presets.h +402 -0
  151. data/dependencies/al_soft/AL/efx.h +762 -0
  152. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  153. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  154. data/{src → dependencies/stb}/stb_image.h +330 -127
  155. data/{src → dependencies/stb}/stb_image_write.h +156 -85
  156. data/{src → dependencies/stb}/stb_truetype.h +192 -69
  157. data/{src → dependencies/utf8proc}/utf8proc.c +0 -0
  158. data/{src → dependencies/utf8proc}/utf8proc.h +0 -0
  159. data/{src → dependencies/utf8proc}/utf8proc_data.h +0 -0
  160. data/ext/gosu/extconf.rb +53 -39
  161. data/{Gosu → include/Gosu}/Audio.hpp +6 -8
  162. data/include/Gosu/Bitmap.hpp +100 -0
  163. data/{Gosu → include/Gosu}/Buttons.hpp +104 -44
  164. data/{Gosu → include/Gosu}/Color.hpp +0 -0
  165. data/{Gosu → include/Gosu}/Directories.hpp +0 -0
  166. data/{Gosu → include/Gosu}/Font.hpp +1 -1
  167. data/{Gosu → include/Gosu}/Fwd.hpp +0 -5
  168. data/{Gosu → include/Gosu}/Gosu.hpp +0 -0
  169. data/{Gosu → include/Gosu}/Graphics.hpp +0 -0
  170. data/{Gosu → include/Gosu}/GraphicsBase.hpp +0 -0
  171. data/{Gosu → include/Gosu}/IO.hpp +0 -0
  172. data/{Gosu → include/Gosu}/Image.hpp +7 -6
  173. data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
  174. data/{Gosu → include/Gosu}/Input.hpp +39 -51
  175. data/{Gosu → include/Gosu}/Inspection.hpp +0 -0
  176. data/{Gosu → include/Gosu}/Math.hpp +0 -0
  177. data/{Gosu → include/Gosu}/Platform.hpp +0 -0
  178. data/{Gosu → include/Gosu}/Text.hpp +0 -0
  179. data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
  180. data/{Gosu → include/Gosu}/Timing.hpp +0 -0
  181. data/{Gosu → include/Gosu}/Utility.hpp +15 -4
  182. data/{Gosu → include/Gosu}/Version.hpp +3 -3
  183. data/{Gosu → include/Gosu}/Window.hpp +46 -34
  184. data/lib/OpenAL32.dll +0 -0
  185. data/lib/SDL2.dll +0 -0
  186. data/lib/gosu.rb +0 -3
  187. data/lib/gosu/patches.rb +0 -23
  188. data/lib/gosu/preview.rb +1 -3
  189. data/lib/gosu/swig_patches.rb +6 -8
  190. data/lib64/OpenAL32.dll +0 -0
  191. data/lib64/SDL2.dll +0 -0
  192. data/rdoc/gosu.rb +112 -23
  193. data/src/Audio.cpp +50 -224
  194. data/src/AudioFile.hpp +20 -37
  195. data/src/AudioFileAudioToolbox.cpp +237 -0
  196. data/src/AudioFileSDLSound.cpp +147 -0
  197. data/src/AudioImpl.cpp +3 -12
  198. data/src/AudioImpl.hpp +3 -1
  199. data/src/Bitmap.cpp +85 -83
  200. data/src/BitmapIO.cpp +52 -58
  201. data/src/Font.cpp +4 -1
  202. data/src/Graphics.cpp +7 -4
  203. data/src/Image.cpp +13 -16
  204. data/src/Input.cpp +412 -164
  205. data/src/LargeImageData.cpp +2 -1
  206. data/src/MarkupParser.cpp +2 -1
  207. data/src/Resolution.cpp +8 -8
  208. data/src/RubyGosu.cxx +1184 -352
  209. data/src/RubyGosu.h +3 -2
  210. data/src/TexChunk.cpp +1 -1
  211. data/src/Text.cpp +1 -0
  212. data/src/TextBuilder.cpp +3 -1
  213. data/src/Texture.cpp +1 -1
  214. data/src/TrueTypeFont.cpp +2 -1
  215. data/src/TrueTypeFontWin.cpp +3 -3
  216. data/src/Utility.cpp +11 -7
  217. data/src/Window.cpp +90 -62
  218. data/src/WindowUIKit.cpp +21 -9
  219. metadata +195 -46
  220. data/Gosu/AutoLink.hpp +0 -14
  221. data/Gosu/Bitmap.hpp +0 -113
  222. data/lib/gosu/zen.rb +0 -89
  223. data/src/AudioToolboxFile.hpp +0 -210
  224. data/src/MPEGFile.hpp +0 -90
  225. data/src/OggFile.hpp +0 -92
  226. data/src/SndFile.hpp +0 -174
  227. data/src/WinMain.cpp +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1449a3ca8ec9bbfe03a06c7b8602f8ba342689cfb063d164d81105063b078512
4
- data.tar.gz: 940808da15d888b9f8e383d03620630a8c0bbd08284fe53a314a9bbc675bcc6b
3
+ metadata.gz: 54c79a5d22ee53e69f48bcd2c1ffb20bf35672ee30d6f08890a9c3037a39fe24
4
+ data.tar.gz: 6a5e06a31f1a7ad257be143a37a1163b324e7124cb56a97154c9eba9fb0686d8
5
5
  SHA512:
6
- metadata.gz: 6791b229fc790e46372057ee5e45c339b808ad9ad3866d2c223bc3cd1c3ec51626254e4567a7a8a0b0d3b0ceef12964ab3c297701a09f03075db871113f7637a
7
- data.tar.gz: 2329dbb588b9ab44c60dab9cd7c0eb86e0a6139445a9b4441670f0bfdaf460314f5a129b5e2a23cfbeb32ee6899989aca09bcb57978ad833dfb3d6d6e1f1d7cf
6
+ metadata.gz: 7db1b37245a24e569bbc623ec025a3e2d13fd61c7a011272e30cca9d4cf6970a2326ec159ee839236fc246ed177702c3de6942e46ba9297c50e51078f61cb564
7
+ data.tar.gz: 0a75ca1ddf6de40050638cc33e8c41acdd68808b1c3942aaecff2219aaf44e8148398bdd27991d5f5d4e1757b8fec651f59c7b9bba82b140dffdcda7df5ab632
@@ -0,0 +1 @@
1
+ rdoc/gosu.rb - README.md COPYING
data/COPYING CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2001-2019 Julian Raschke, Jan Lücker and all contributors.
1
+ Copyright (C) 2001-2020 Julian Raschke, Jan Lücker and all contributors.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a
4
4
  copy of this software and associated documentation files (the "Software"),
@@ -0,0 +1,138 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ /**
23
+ * \file SDL.h
24
+ *
25
+ * Main include header for the SDL library
26
+ */
27
+
28
+
29
+ #ifndef SDL_h_
30
+ #define SDL_h_
31
+
32
+ #include "SDL_main.h"
33
+ #include "SDL_stdinc.h"
34
+ #include "SDL_assert.h"
35
+ #include "SDL_atomic.h"
36
+ #include "SDL_audio.h"
37
+ #include "SDL_clipboard.h"
38
+ #include "SDL_cpuinfo.h"
39
+ #include "SDL_endian.h"
40
+ #include "SDL_error.h"
41
+ #include "SDL_events.h"
42
+ #include "SDL_filesystem.h"
43
+ #include "SDL_gamecontroller.h"
44
+ #include "SDL_haptic.h"
45
+ #include "SDL_hints.h"
46
+ #include "SDL_joystick.h"
47
+ #include "SDL_loadso.h"
48
+ #include "SDL_log.h"
49
+ #include "SDL_messagebox.h"
50
+ #include "SDL_metal.h"
51
+ #include "SDL_mutex.h"
52
+ #include "SDL_power.h"
53
+ #include "SDL_render.h"
54
+ #include "SDL_rwops.h"
55
+ #include "SDL_sensor.h"
56
+ #include "SDL_shape.h"
57
+ #include "SDL_system.h"
58
+ #include "SDL_thread.h"
59
+ #include "SDL_timer.h"
60
+ #include "SDL_version.h"
61
+ #include "SDL_video.h"
62
+ #include "SDL_locale.h"
63
+ #include "SDL_misc.h"
64
+
65
+ #include "begin_code.h"
66
+ /* Set up for C function definitions, even when using C++ */
67
+ #ifdef __cplusplus
68
+ extern "C" {
69
+ #endif
70
+
71
+ /* As of version 0.5, SDL is loaded dynamically into the application */
72
+
73
+ /**
74
+ * \name SDL_INIT_*
75
+ *
76
+ * These are the flags which may be passed to SDL_Init(). You should
77
+ * specify the subsystems which you will be using in your application.
78
+ */
79
+ /* @{ */
80
+ #define SDL_INIT_TIMER 0x00000001u
81
+ #define SDL_INIT_AUDIO 0x00000010u
82
+ #define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */
83
+ #define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */
84
+ #define SDL_INIT_HAPTIC 0x00001000u
85
+ #define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
86
+ #define SDL_INIT_EVENTS 0x00004000u
87
+ #define SDL_INIT_SENSOR 0x00008000u
88
+ #define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */
89
+ #define SDL_INIT_EVERYTHING ( \
90
+ SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
91
+ SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \
92
+ )
93
+ /* @} */
94
+
95
+ /**
96
+ * This function initializes the subsystems specified by \c flags
97
+ */
98
+ extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
99
+
100
+ /**
101
+ * This function initializes specific SDL subsystems
102
+ *
103
+ * Subsystem initialization is ref-counted, you must call
104
+ * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly
105
+ * shutdown a subsystem manually (or call SDL_Quit() to force shutdown).
106
+ * If a subsystem is already loaded then this call will
107
+ * increase the ref-count and return.
108
+ */
109
+ extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
110
+
111
+ /**
112
+ * This function cleans up specific SDL subsystems
113
+ */
114
+ extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
115
+
116
+ /**
117
+ * This function returns a mask of the specified subsystems which have
118
+ * previously been initialized.
119
+ *
120
+ * If \c flags is 0, it returns a mask of all initialized subsystems.
121
+ */
122
+ extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
123
+
124
+ /**
125
+ * This function cleans up all initialized subsystems. You should
126
+ * call it upon all exit conditions.
127
+ */
128
+ extern DECLSPEC void SDLCALL SDL_Quit(void);
129
+
130
+ /* Ends C function definitions when using C++ */
131
+ #ifdef __cplusplus
132
+ }
133
+ #endif
134
+ #include "close_code.h"
135
+
136
+ #endif /* SDL_h_ */
137
+
138
+ /* vi: set ts=4 sw=4 expandtab: */
@@ -0,0 +1,293 @@
1
+ /*
2
+ Simple DirectMedia Layer
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
+
5
+ This software is provided 'as-is', without any express or implied
6
+ warranty. In no event will the authors be held liable for any damages
7
+ arising from the use of this software.
8
+
9
+ Permission is granted to anyone to use this software for any purpose,
10
+ including commercial applications, and to alter it and redistribute it
11
+ freely, subject to the following restrictions:
12
+
13
+ 1. The origin of this software must not be misrepresented; you must not
14
+ claim that you wrote the original software. If you use this software
15
+ in a product, an acknowledgment in the product documentation would be
16
+ appreciated but is not required.
17
+ 2. Altered source versions must be plainly marked as such, and must not be
18
+ misrepresented as being the original software.
19
+ 3. This notice may not be removed or altered from any source distribution.
20
+ */
21
+
22
+ #ifndef SDL_assert_h_
23
+ #define SDL_assert_h_
24
+
25
+ #include "SDL_config.h"
26
+
27
+ #include "begin_code.h"
28
+ /* Set up for C function definitions, even when using C++ */
29
+ #ifdef __cplusplus
30
+ extern "C" {
31
+ #endif
32
+
33
+ #ifndef SDL_ASSERT_LEVEL
34
+ #ifdef SDL_DEFAULT_ASSERT_LEVEL
35
+ #define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL
36
+ #elif defined(_DEBUG) || defined(DEBUG) || \
37
+ (defined(__GNUC__) && !defined(__OPTIMIZE__))
38
+ #define SDL_ASSERT_LEVEL 2
39
+ #else
40
+ #define SDL_ASSERT_LEVEL 1
41
+ #endif
42
+ #endif /* SDL_ASSERT_LEVEL */
43
+
44
+ /*
45
+ These are macros and not first class functions so that the debugger breaks
46
+ on the assertion line and not in some random guts of SDL, and so each
47
+ assert can have unique static variables associated with it.
48
+ */
49
+
50
+ #if defined(_MSC_VER)
51
+ /* Don't include intrin.h here because it contains C++ code */
52
+ extern void __cdecl __debugbreak(void);
53
+ #define SDL_TriggerBreakpoint() __debugbreak()
54
+ #elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) )
55
+ #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
56
+ #elif ( defined(__APPLE__) && defined(__arm64__) ) /* this might work on other ARM targets, but this is a known quantity... */
57
+ #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
58
+ #elif defined(__386__) && defined(__WATCOMC__)
59
+ #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
60
+ #elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
61
+ #include <signal.h>
62
+ #define SDL_TriggerBreakpoint() raise(SIGTRAP)
63
+ #else
64
+ /* How do we trigger breakpoints on this platform? */
65
+ #define SDL_TriggerBreakpoint()
66
+ #endif
67
+
68
+ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
69
+ # define SDL_FUNCTION __func__
70
+ #elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__))
71
+ # define SDL_FUNCTION __FUNCTION__
72
+ #else
73
+ # define SDL_FUNCTION "???"
74
+ #endif
75
+ #define SDL_FILE __FILE__
76
+ #define SDL_LINE __LINE__
77
+
78
+ /*
79
+ sizeof (x) makes the compiler still parse the expression even without
80
+ assertions enabled, so the code is always checked at compile time, but
81
+ doesn't actually generate code for it, so there are no side effects or
82
+ expensive checks at run time, just the constant size of what x WOULD be,
83
+ which presumably gets optimized out as unused.
84
+ This also solves the problem of...
85
+
86
+ int somevalue = blah();
87
+ SDL_assert(somevalue == 1);
88
+
89
+ ...which would cause compiles to complain that somevalue is unused if we
90
+ disable assertions.
91
+ */
92
+
93
+ /* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking
94
+ this condition isn't constant. And looks like an owl's face! */
95
+ #ifdef _MSC_VER /* stupid /W4 warnings. */
96
+ #define SDL_NULL_WHILE_LOOP_CONDITION (0,0)
97
+ #else
98
+ #define SDL_NULL_WHILE_LOOP_CONDITION (0)
99
+ #endif
100
+
101
+ #define SDL_disabled_assert(condition) \
102
+ do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
103
+
104
+ typedef enum
105
+ {
106
+ SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */
107
+ SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */
108
+ SDL_ASSERTION_ABORT, /**< Terminate the program. */
109
+ SDL_ASSERTION_IGNORE, /**< Ignore the assert. */
110
+ SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */
111
+ } SDL_AssertState;
112
+
113
+ typedef struct SDL_AssertData
114
+ {
115
+ int always_ignore;
116
+ unsigned int trigger_count;
117
+ const char *condition;
118
+ const char *filename;
119
+ int linenum;
120
+ const char *function;
121
+ const struct SDL_AssertData *next;
122
+ } SDL_AssertData;
123
+
124
+ #if (SDL_ASSERT_LEVEL > 0)
125
+
126
+ /* Never call this directly. Use the SDL_assert* macros. */
127
+ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
128
+ const char *,
129
+ const char *, int)
130
+ #if defined(__clang__)
131
+ #if __has_feature(attribute_analyzer_noreturn)
132
+ /* this tells Clang's static analysis that we're a custom assert function,
133
+ and that the analyzer should assume the condition was always true past this
134
+ SDL_assert test. */
135
+ __attribute__((analyzer_noreturn))
136
+ #endif
137
+ #endif
138
+ ;
139
+
140
+ /* the do {} while(0) avoids dangling else problems:
141
+ if (x) SDL_assert(y); else blah();
142
+ ... without the do/while, the "else" could attach to this macro's "if".
143
+ We try to handle just the minimum we need here in a macro...the loop,
144
+ the static vars, and break points. The heavy lifting is handled in
145
+ SDL_ReportAssertion(), in SDL_assert.c.
146
+ */
147
+ #define SDL_enabled_assert(condition) \
148
+ do { \
149
+ while ( !(condition) ) { \
150
+ static struct SDL_AssertData sdl_assert_data = { \
151
+ 0, 0, #condition, 0, 0, 0, 0 \
152
+ }; \
153
+ const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
154
+ if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
155
+ continue; /* go again. */ \
156
+ } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
157
+ SDL_TriggerBreakpoint(); \
158
+ } \
159
+ break; /* not retrying. */ \
160
+ } \
161
+ } while (SDL_NULL_WHILE_LOOP_CONDITION)
162
+
163
+ #endif /* enabled assertions support code */
164
+
165
+ /* Enable various levels of assertions. */
166
+ #if SDL_ASSERT_LEVEL == 0 /* assertions disabled */
167
+ # define SDL_assert(condition) SDL_disabled_assert(condition)
168
+ # define SDL_assert_release(condition) SDL_disabled_assert(condition)
169
+ # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
170
+ #elif SDL_ASSERT_LEVEL == 1 /* release settings. */
171
+ # define SDL_assert(condition) SDL_disabled_assert(condition)
172
+ # define SDL_assert_release(condition) SDL_enabled_assert(condition)
173
+ # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
174
+ #elif SDL_ASSERT_LEVEL == 2 /* normal settings. */
175
+ # define SDL_assert(condition) SDL_enabled_assert(condition)
176
+ # define SDL_assert_release(condition) SDL_enabled_assert(condition)
177
+ # define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
178
+ #elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */
179
+ # define SDL_assert(condition) SDL_enabled_assert(condition)
180
+ # define SDL_assert_release(condition) SDL_enabled_assert(condition)
181
+ # define SDL_assert_paranoid(condition) SDL_enabled_assert(condition)
182
+ #else
183
+ # error Unknown assertion level.
184
+ #endif
185
+
186
+ /* this assertion is never disabled at any level. */
187
+ #define SDL_assert_always(condition) SDL_enabled_assert(condition)
188
+
189
+
190
+ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
191
+ const SDL_AssertData* data, void* userdata);
192
+
193
+ /**
194
+ * \brief Set an application-defined assertion handler.
195
+ *
196
+ * This allows an app to show its own assertion UI and/or force the
197
+ * response to an assertion failure. If the app doesn't provide this, SDL
198
+ * will try to do the right thing, popping up a system-specific GUI dialog,
199
+ * and probably minimizing any fullscreen windows.
200
+ *
201
+ * This callback may fire from any thread, but it runs wrapped in a mutex, so
202
+ * it will only fire from one thread at a time.
203
+ *
204
+ * Setting the callback to NULL restores SDL's original internal handler.
205
+ *
206
+ * This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
207
+ *
208
+ * Return SDL_AssertState value of how to handle the assertion failure.
209
+ *
210
+ * \param handler Callback function, called when an assertion fails.
211
+ * \param userdata A pointer passed to the callback as-is.
212
+ */
213
+ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler(
214
+ SDL_AssertionHandler handler,
215
+ void *userdata);
216
+
217
+ /**
218
+ * \brief Get the default assertion handler.
219
+ *
220
+ * This returns the function pointer that is called by default when an
221
+ * assertion is triggered. This is an internal function provided by SDL,
222
+ * that is used for assertions when SDL_SetAssertionHandler() hasn't been
223
+ * used to provide a different function.
224
+ *
225
+ * \return The default SDL_AssertionHandler that is called when an assert triggers.
226
+ */
227
+ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void);
228
+
229
+ /**
230
+ * \brief Get the current assertion handler.
231
+ *
232
+ * This returns the function pointer that is called when an assertion is
233
+ * triggered. This is either the value last passed to
234
+ * SDL_SetAssertionHandler(), or if no application-specified function is
235
+ * set, is equivalent to calling SDL_GetDefaultAssertionHandler().
236
+ *
237
+ * \param puserdata Pointer to a void*, which will store the "userdata"
238
+ * pointer that was passed to SDL_SetAssertionHandler().
239
+ * This value will always be NULL for the default handler.
240
+ * If you don't care about this data, it is safe to pass
241
+ * a NULL pointer to this function to ignore it.
242
+ * \return The SDL_AssertionHandler that is called when an assert triggers.
243
+ */
244
+ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata);
245
+
246
+ /**
247
+ * \brief Get a list of all assertion failures.
248
+ *
249
+ * Get all assertions triggered since last call to SDL_ResetAssertionReport(),
250
+ * or the start of the program.
251
+ *
252
+ * The proper way to examine this data looks something like this:
253
+ *
254
+ * <code>
255
+ * const SDL_AssertData *item = SDL_GetAssertionReport();
256
+ * while (item) {
257
+ * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n",
258
+ * item->condition, item->function, item->filename,
259
+ * item->linenum, item->trigger_count,
260
+ * item->always_ignore ? "yes" : "no");
261
+ * item = item->next;
262
+ * }
263
+ * </code>
264
+ *
265
+ * \return List of all assertions.
266
+ * \sa SDL_ResetAssertionReport
267
+ */
268
+ extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void);
269
+
270
+ /**
271
+ * \brief Reset the list of all assertion failures.
272
+ *
273
+ * Reset list of all assertions triggered.
274
+ *
275
+ * \sa SDL_GetAssertionReport
276
+ */
277
+ extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void);
278
+
279
+
280
+ /* these had wrong naming conventions until 2.0.4. Please update your app! */
281
+ #define SDL_assert_state SDL_AssertState
282
+ #define SDL_assert_data SDL_AssertData
283
+
284
+
285
+ /* Ends C function definitions when using C++ */
286
+ #ifdef __cplusplus
287
+ }
288
+ #endif
289
+ #include "close_code.h"
290
+
291
+ #endif /* SDL_assert_h_ */
292
+
293
+ /* vi: set ts=4 sw=4 expandtab: */