sfml3-rb 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +43 -17
  4. data/README.md +97 -29
  5. data/ext/audio/audio_enums.c +58 -20
  6. data/ext/audio/listener.c +89 -6
  7. data/ext/audio/music.c +206 -5
  8. data/ext/audio/sound.c +175 -5
  9. data/ext/audio/sound_buffer.c +189 -47
  10. data/ext/audio/sound_buffer_recorder.c +83 -16
  11. data/ext/audio/sound_recorder.c +172 -52
  12. data/ext/audio/sound_source_cone.c +108 -29
  13. data/ext/audio/sound_stream.c +178 -5
  14. data/ext/core/exceptions.c +10 -8
  15. data/ext/core/unicode.c +12 -2
  16. data/ext/ext.c +4 -0
  17. data/ext/graphics/blend_mode.c +203 -53
  18. data/ext/graphics/circle.c +271 -4
  19. data/ext/graphics/color.c +240 -90
  20. data/ext/graphics/drawable.c +15 -4
  21. data/ext/graphics/font.c +138 -25
  22. data/ext/graphics/glyph.c +31 -8
  23. data/ext/graphics/image.c +180 -37
  24. data/ext/graphics/polygon.c +293 -26
  25. data/ext/graphics/rect.c +211 -54
  26. data/ext/graphics/rectangle.c +279 -26
  27. data/ext/graphics/render_state.c +116 -2
  28. data/ext/graphics/render_texture.c +163 -2
  29. data/ext/graphics/shader.c +283 -17
  30. data/ext/graphics/shape.c +252 -26
  31. data/ext/graphics/sprite.c +216 -25
  32. data/ext/graphics/stencil_mode.c +148 -39
  33. data/ext/graphics/target.c +67 -22
  34. data/ext/graphics/target.h +15 -15
  35. data/ext/graphics/text.c +306 -6
  36. data/ext/graphics/texture.c +257 -3
  37. data/ext/graphics/transform.c +178 -5
  38. data/ext/graphics/transformable.c +126 -2
  39. data/ext/graphics/vertex.c +79 -2
  40. data/ext/graphics/vertex_array.c +128 -16
  41. data/ext/graphics/vertex_buffer.c +124 -2
  42. data/ext/graphics/view.c +130 -2
  43. data/ext/network/ftp.c +249 -10
  44. data/ext/network/http.c +156 -38
  45. data/ext/network/ip_address.c +107 -26
  46. data/ext/network/network_enums.c +248 -141
  47. data/ext/network/packet.c +273 -39
  48. data/ext/network/socket_selector.c +91 -19
  49. data/ext/network/tcp_listener.c +75 -16
  50. data/ext/network/tcp_socket.c +128 -25
  51. data/ext/network/udp_socket.c +122 -26
  52. data/ext/ports.rb +7 -0
  53. data/ext/system/buffer.c +41 -12
  54. data/ext/system/clock.c +68 -9
  55. data/ext/system/input_stream.c +94 -42
  56. data/ext/system/sleep.c +10 -2
  57. data/ext/system/time.c +172 -34
  58. data/ext/system/vec2.c +156 -35
  59. data/ext/system/vec3.c +166 -35
  60. data/ext/window/clipboard.c +47 -17
  61. data/ext/window/context.c +59 -9
  62. data/ext/window/context_settings.c +116 -38
  63. data/ext/window/cursor.c +39 -9
  64. data/ext/window/event.c +163 -42
  65. data/ext/window/joystick.c +69 -3
  66. data/ext/window/keyboard.c +168 -116
  67. data/ext/window/mouse.c +36 -2
  68. data/ext/window/sensor.c +28 -2
  69. data/ext/window/touch.c +20 -2
  70. data/ext/window/video_mode.c +90 -19
  71. data/ext/window/vulkan.c +34 -6
  72. data/ext/window/window.c +340 -16
  73. data/lib/sfml/version.rb +1 -1
  74. data/sig/audio/audio_enums.rbs +30 -0
  75. data/sig/audio/listener.rbs +16 -0
  76. data/sig/audio/music.rbs +56 -0
  77. data/sig/audio/sound.rbs +51 -0
  78. data/sig/audio/sound_buffer.rbs +17 -0
  79. data/sig/audio/sound_buffer_recorder.rbs +14 -0
  80. data/sig/audio/sound_recorder.rbs +17 -0
  81. data/sig/audio/sound_source_cone.rbs +14 -0
  82. data/sig/audio/sound_stream.rbs +51 -0
  83. data/sig/graphics/blend_mode.rbs +29 -0
  84. data/sig/graphics/circle.rbs +44 -0
  85. data/sig/graphics/color.rbs +39 -0
  86. data/sig/graphics/drawable.rbs +5 -0
  87. data/sig/graphics/font.rbs +20 -0
  88. data/sig/graphics/glyph.rbs +7 -0
  89. data/sig/graphics/image.rbs +22 -0
  90. data/sig/graphics/polygon.rbs +42 -0
  91. data/sig/graphics/rect.rbs +33 -0
  92. data/sig/graphics/rectangle.rbs +42 -0
  93. data/sig/graphics/render_state.rbs +21 -0
  94. data/sig/graphics/render_texture.rbs +37 -0
  95. data/sig/graphics/shader.rbs +39 -0
  96. data/sig/graphics/shape.rbs +38 -0
  97. data/sig/graphics/sprite.rbs +34 -0
  98. data/sig/graphics/stencil_mode.rbs +18 -0
  99. data/sig/graphics/target.rbs +10 -0
  100. data/sig/graphics/text.rbs +48 -0
  101. data/sig/graphics/texture.rbs +34 -0
  102. data/sig/graphics/transform.rbs +37 -0
  103. data/sig/graphics/transformable.rbs +25 -0
  104. data/sig/graphics/vertex.rbs +17 -0
  105. data/sig/graphics/vertex_array.rbs +17 -0
  106. data/sig/graphics/vertex_buffer.rbs +22 -0
  107. data/sig/graphics/view.rbs +24 -0
  108. data/sig/network/ftp.rbs +46 -0
  109. data/sig/network/http.rbs +27 -0
  110. data/sig/network/ip_address.rbs +22 -0
  111. data/sig/network/network_enums.rbs +95 -0
  112. data/sig/network/packet.rbs +40 -0
  113. data/sig/network/socket_selector.rbs +14 -0
  114. data/sig/network/tcp_listener.rbs +13 -0
  115. data/sig/network/tcp_socket.rbs +18 -0
  116. data/sig/network/udp_socket.rbs +17 -0
  117. data/sig/system/buffer.rbs +11 -0
  118. data/sig/system/clock.rbs +13 -0
  119. data/sig/system/input_stream.rbs +7 -0
  120. data/sig/system/sleep.rbs +3 -0
  121. data/sig/system/time.rbs +28 -0
  122. data/sig/system/vec2.rbs +26 -0
  123. data/sig/system/vec3.rbs +27 -0
  124. data/sig/window/clipboard.rbs +8 -0
  125. data/sig/window/context.rbs +11 -0
  126. data/sig/window/context_settings.rbs +20 -0
  127. data/sig/window/cursor.rbs +6 -0
  128. data/sig/window/event.rbs +20 -0
  129. data/sig/window/joystick.rbs +15 -0
  130. data/sig/window/keyboard.rbs +10 -0
  131. data/sig/window/mouse.rbs +9 -0
  132. data/sig/window/sensor.rbs +8 -0
  133. data/sig/window/touch.rbs +6 -0
  134. data/sig/window/video_mode.rbs +16 -0
  135. data/sig/window/vulkan.rbs +7 -0
  136. data/sig/window/window.rbs +57 -0
  137. metadata +66 -2
@@ -3,42 +3,41 @@
3
3
  #include <ruby.h>
4
4
  #include <string.h>
5
5
 
6
- static const char *socket_status_names[] = {"done", "not_ready", "partial", "disconnected", "error"};
7
- static const char *http_method_names[] = {"get", "post", "head", "put", "delete"};
8
- static const char *ftp_transfer_mode_names[] = {"binary", "ascii", "ebcdic"};
6
+ static const char* socket_status_names[] = {"done", "not_ready", "partial", "disconnected",
7
+ "error"};
8
+ static const char* http_method_names[] = {"get", "post", "head", "put", "delete"};
9
+ static const char* ftp_transfer_mode_names[] = {"binary", "ascii", "ebcdic"};
9
10
 
10
11
  typedef struct {
11
12
  int value;
12
- const char *name;
13
+ const char* name;
13
14
  } EnumName;
14
15
 
15
16
  /* The HTTP and FTP status enums are sparse and mostly meaningful by number,
16
17
  so they are stored as value/name pairs and looked up linearly. */
17
- static const EnumName http_status_names[] = {
18
- {sfHttpOk, "ok"},
19
- {sfHttpCreated, "created"},
20
- {sfHttpAccepted, "accepted"},
21
- {sfHttpNoContent, "no_content"},
22
- {sfHttpResetContent, "reset_content"},
23
- {sfHttpPartialContent, "partial_content"},
24
- {sfHttpMultipleChoices, "multiple_choices"},
25
- {sfHttpMovedPermanently, "moved_permanently"},
26
- {sfHttpMovedTemporarily, "moved_temporarily"},
27
- {sfHttpNotModified, "not_modified"},
28
- {sfHttpBadRequest, "bad_request"},
29
- {sfHttpUnauthorized, "unauthorized"},
30
- {sfHttpForbidden, "forbidden"},
31
- {sfHttpNotFound, "not_found"},
32
- {sfHttpRangeNotSatisfiable, "range_not_satisfiable"},
33
- {sfHttpInternalServerError, "internal_server_error"},
34
- {sfHttpNotImplemented, "not_implemented"},
35
- {sfHttpBadGateway, "bad_gateway"},
36
- {sfHttpServiceNotAvailable, "service_not_available"},
37
- {sfHttpGatewayTimeout, "gateway_timeout"},
38
- {sfHttpVersionNotSupported, "version_not_supported"},
39
- {sfHttpInvalidResponse, "invalid_response"},
40
- {sfHttpConnectionFailed, "connection_failed"}
41
- };
18
+ static const EnumName http_status_names[] = {{sfHttpOk, "ok"},
19
+ {sfHttpCreated, "created"},
20
+ {sfHttpAccepted, "accepted"},
21
+ {sfHttpNoContent, "no_content"},
22
+ {sfHttpResetContent, "reset_content"},
23
+ {sfHttpPartialContent, "partial_content"},
24
+ {sfHttpMultipleChoices, "multiple_choices"},
25
+ {sfHttpMovedPermanently, "moved_permanently"},
26
+ {sfHttpMovedTemporarily, "moved_temporarily"},
27
+ {sfHttpNotModified, "not_modified"},
28
+ {sfHttpBadRequest, "bad_request"},
29
+ {sfHttpUnauthorized, "unauthorized"},
30
+ {sfHttpForbidden, "forbidden"},
31
+ {sfHttpNotFound, "not_found"},
32
+ {sfHttpRangeNotSatisfiable, "range_not_satisfiable"},
33
+ {sfHttpInternalServerError, "internal_server_error"},
34
+ {sfHttpNotImplemented, "not_implemented"},
35
+ {sfHttpBadGateway, "bad_gateway"},
36
+ {sfHttpServiceNotAvailable, "service_not_available"},
37
+ {sfHttpGatewayTimeout, "gateway_timeout"},
38
+ {sfHttpVersionNotSupported, "version_not_supported"},
39
+ {sfHttpInvalidResponse, "invalid_response"},
40
+ {sfHttpConnectionFailed, "connection_failed"}};
42
41
 
43
42
  static const EnumName ftp_status_names[] = {
44
43
  {sfFtpRestartMarkerReply, "restart_marker_reply"},
@@ -83,11 +82,10 @@ static const EnumName ftp_status_names[] = {
83
82
  {sfFtpInvalidResponse, "invalid_response"},
84
83
  {sfFtpConnectionFailed, "connection_failed"},
85
84
  {sfFtpConnectionClosed, "connection_closed"},
86
- {sfFtpInvalidFile, "invalid_file"}
87
- };
85
+ {sfFtpInvalidFile, "invalid_file"}};
88
86
 
89
- static int symbol_index(VALUE rb_symbol, const char *const *names, size_t count) {
90
- const char *name;
87
+ static int symbol_index(VALUE rb_symbol, const char* const* names, size_t count) {
88
+ const char* name;
91
89
  size_t i;
92
90
 
93
91
  if (!SYMBOL_P(rb_symbol)) {
@@ -98,14 +96,14 @@ static int symbol_index(VALUE rb_symbol, const char *const *names, size_t count)
98
96
 
99
97
  for (i = 0; i < count; i++) {
100
98
  if (strcmp(name, names[i]) == 0) {
101
- return (int) i;
99
+ return (int)i;
102
100
  }
103
101
  }
104
102
 
105
103
  return -1;
106
104
  }
107
105
 
108
- const char *socket_status_name(sfSocketStatus status) {
106
+ const char* socket_status_name(sfSocketStatus status) {
109
107
  if (status >= sfSocketDone && status <= sfSocketError) {
110
108
  return socket_status_names[status];
111
109
  }
@@ -117,7 +115,7 @@ sfSocketStatus socket_status_from_rb(VALUE rb_status) {
117
115
  int index;
118
116
 
119
117
  if (RB_INTEGER_TYPE_P(rb_status)) {
120
- return (sfSocketStatus) NUM2INT(rb_status);
118
+ return (sfSocketStatus)NUM2INT(rb_status);
121
119
  }
122
120
 
123
121
  index = symbol_index(rb_status, socket_status_names, 5);
@@ -126,10 +124,10 @@ sfSocketStatus socket_status_from_rb(VALUE rb_status) {
126
124
  rb_raise(rb_eArgError, "unknown socket status");
127
125
  }
128
126
 
129
- return (sfSocketStatus) index;
127
+ return (sfSocketStatus)index;
130
128
  }
131
129
 
132
- const char *http_method_name(sfHttpMethod method) {
130
+ const char* http_method_name(sfHttpMethod method) {
133
131
  if (method >= sfHttpGet && method <= sfHttpDelete) {
134
132
  return http_method_names[method];
135
133
  }
@@ -141,7 +139,7 @@ sfHttpMethod http_method_from_rb(VALUE rb_method) {
141
139
  int index;
142
140
 
143
141
  if (RB_INTEGER_TYPE_P(rb_method)) {
144
- return (sfHttpMethod) NUM2INT(rb_method);
142
+ return (sfHttpMethod)NUM2INT(rb_method);
145
143
  }
146
144
 
147
145
  index = symbol_index(rb_method, http_method_names, 5);
@@ -150,10 +148,10 @@ sfHttpMethod http_method_from_rb(VALUE rb_method) {
150
148
  rb_raise(rb_eArgError, "unknown HTTP method");
151
149
  }
152
150
 
153
- return (sfHttpMethod) index;
151
+ return (sfHttpMethod)index;
154
152
  }
155
153
 
156
- static const char *lookup_name(const EnumName *table, size_t count, int value) {
154
+ static const char* lookup_name(const EnumName* table, size_t count, int value) {
157
155
  size_t i;
158
156
 
159
157
  for (i = 0; i < count; i++) {
@@ -165,14 +163,14 @@ static const char *lookup_name(const EnumName *table, size_t count, int value) {
165
163
  return NULL;
166
164
  }
167
165
 
168
- const char *http_status_name(sfHttpStatus status) {
169
- const char *name = lookup_name(http_status_names,
170
- sizeof(http_status_names) / sizeof(http_status_names[0]), status);
166
+ const char* http_status_name(sfHttpStatus status) {
167
+ const char* name = lookup_name(
168
+ http_status_names, sizeof(http_status_names) / sizeof(http_status_names[0]), status);
171
169
 
172
170
  return name != NULL ? name : "unknown";
173
171
  }
174
172
 
175
- const char *ftp_transfer_mode_name(sfFtpTransferMode mode) {
173
+ const char* ftp_transfer_mode_name(sfFtpTransferMode mode) {
176
174
  if (mode >= sfFtpBinary && mode <= sfFtpEbcdic) {
177
175
  return ftp_transfer_mode_names[mode];
178
176
  }
@@ -184,7 +182,7 @@ sfFtpTransferMode ftp_transfer_mode_from_rb(VALUE rb_mode) {
184
182
  int index;
185
183
 
186
184
  if (RB_INTEGER_TYPE_P(rb_mode)) {
187
- return (sfFtpTransferMode) NUM2INT(rb_mode);
185
+ return (sfFtpTransferMode)NUM2INT(rb_mode);
188
186
  }
189
187
 
190
188
  index = symbol_index(rb_mode, ftp_transfer_mode_names, 3);
@@ -193,106 +191,215 @@ sfFtpTransferMode ftp_transfer_mode_from_rb(VALUE rb_mode) {
193
191
  rb_raise(rb_eArgError, "unknown FTP transfer mode");
194
192
  }
195
193
 
196
- return (sfFtpTransferMode) index;
194
+ return (sfFtpTransferMode)index;
197
195
  }
198
196
 
199
- const char *ftp_status_name(sfFtpStatus status) {
200
- const char *name = lookup_name(ftp_status_names,
197
+ const char* ftp_status_name(sfFtpStatus status) {
198
+ const char* name = lookup_name(ftp_status_names,
201
199
  sizeof(ftp_status_names) / sizeof(ftp_status_names[0]), status);
202
200
 
203
201
  return name != NULL ? name : "unknown";
204
202
  }
205
203
 
206
- #define DEFINE_CONST(module, name, value) rb_define_const(module, name, INT2NUM(value))
207
-
208
- void Init_NetworkEnums(VALUE rb_module) {
209
- VALUE rb_mSocketStatus = rb_define_module_under(rb_module, "SocketStatus");
210
- VALUE rb_mHttpMethod = rb_define_module_under(rb_module, "HttpMethod");
211
- VALUE rb_mHttpStatus = rb_define_module_under(rb_module, "HttpStatus");
212
- VALUE rb_mFtpTransferMode = rb_define_module_under(rb_module, "FtpTransferMode");
213
- VALUE rb_mFtpStatus = rb_define_module_under(rb_module, "FtpStatus");
214
-
215
- DEFINE_CONST(rb_mSocketStatus, "DONE", sfSocketDone);
216
- DEFINE_CONST(rb_mSocketStatus, "NOT_READY", sfSocketNotReady);
217
- DEFINE_CONST(rb_mSocketStatus, "PARTIAL", sfSocketPartial);
218
- DEFINE_CONST(rb_mSocketStatus, "DISCONNECTED", sfSocketDisconnected);
219
- DEFINE_CONST(rb_mSocketStatus, "ERROR", sfSocketError);
220
-
221
- DEFINE_CONST(rb_mHttpMethod, "GET", sfHttpGet);
222
- DEFINE_CONST(rb_mHttpMethod, "POST", sfHttpPost);
223
- DEFINE_CONST(rb_mHttpMethod, "HEAD", sfHttpHead);
224
- DEFINE_CONST(rb_mHttpMethod, "PUT", sfHttpPut);
225
- DEFINE_CONST(rb_mHttpMethod, "DELETE", sfHttpDelete);
226
-
227
- DEFINE_CONST(rb_mHttpStatus, "OK", sfHttpOk);
228
- DEFINE_CONST(rb_mHttpStatus, "CREATED", sfHttpCreated);
229
- DEFINE_CONST(rb_mHttpStatus, "ACCEPTED", sfHttpAccepted);
230
- DEFINE_CONST(rb_mHttpStatus, "NO_CONTENT", sfHttpNoContent);
231
- DEFINE_CONST(rb_mHttpStatus, "RESET_CONTENT", sfHttpResetContent);
232
- DEFINE_CONST(rb_mHttpStatus, "PARTIAL_CONTENT", sfHttpPartialContent);
233
- DEFINE_CONST(rb_mHttpStatus, "MULTIPLE_CHOICES", sfHttpMultipleChoices);
234
- DEFINE_CONST(rb_mHttpStatus, "MOVED_PERMANENTLY", sfHttpMovedPermanently);
235
- DEFINE_CONST(rb_mHttpStatus, "MOVED_TEMPORARILY", sfHttpMovedTemporarily);
236
- DEFINE_CONST(rb_mHttpStatus, "NOT_MODIFIED", sfHttpNotModified);
237
- DEFINE_CONST(rb_mHttpStatus, "BAD_REQUEST", sfHttpBadRequest);
238
- DEFINE_CONST(rb_mHttpStatus, "UNAUTHORIZED", sfHttpUnauthorized);
239
- DEFINE_CONST(rb_mHttpStatus, "FORBIDDEN", sfHttpForbidden);
240
- DEFINE_CONST(rb_mHttpStatus, "NOT_FOUND", sfHttpNotFound);
241
- DEFINE_CONST(rb_mHttpStatus, "RANGE_NOT_SATISFIABLE", sfHttpRangeNotSatisfiable);
242
- DEFINE_CONST(rb_mHttpStatus, "INTERNAL_SERVER_ERROR", sfHttpInternalServerError);
243
- DEFINE_CONST(rb_mHttpStatus, "NOT_IMPLEMENTED", sfHttpNotImplemented);
244
- DEFINE_CONST(rb_mHttpStatus, "BAD_GATEWAY", sfHttpBadGateway);
245
- DEFINE_CONST(rb_mHttpStatus, "SERVICE_NOT_AVAILABLE", sfHttpServiceNotAvailable);
246
- DEFINE_CONST(rb_mHttpStatus, "GATEWAY_TIMEOUT", sfHttpGatewayTimeout);
247
- DEFINE_CONST(rb_mHttpStatus, "VERSION_NOT_SUPPORTED", sfHttpVersionNotSupported);
248
- DEFINE_CONST(rb_mHttpStatus, "INVALID_RESPONSE", sfHttpInvalidResponse);
249
- DEFINE_CONST(rb_mHttpStatus, "CONNECTION_FAILED", sfHttpConnectionFailed);
250
-
251
- DEFINE_CONST(rb_mFtpTransferMode, "BINARY", sfFtpBinary);
252
- DEFINE_CONST(rb_mFtpTransferMode, "ASCII", sfFtpAscii);
253
- DEFINE_CONST(rb_mFtpTransferMode, "EBCDIC", sfFtpEbcdic);
254
-
255
- DEFINE_CONST(rb_mFtpStatus, "RESTART_MARKER_REPLY", sfFtpRestartMarkerReply);
256
- DEFINE_CONST(rb_mFtpStatus, "SERVICE_READY_SOON", sfFtpServiceReadySoon);
257
- DEFINE_CONST(rb_mFtpStatus, "DATA_CONNECTION_ALREADY_OPENED", sfFtpDataConnectionAlreadyOpened);
258
- DEFINE_CONST(rb_mFtpStatus, "OPENING_DATA_CONNECTION", sfFtpOpeningDataConnection);
259
- DEFINE_CONST(rb_mFtpStatus, "OK", sfFtpOk);
260
- DEFINE_CONST(rb_mFtpStatus, "POINTLESS_COMMAND", sfFtpPointlessCommand);
261
- DEFINE_CONST(rb_mFtpStatus, "SYSTEM_STATUS", sfFtpSystemStatus);
262
- DEFINE_CONST(rb_mFtpStatus, "DIRECTORY_STATUS", sfFtpDirectoryStatus);
263
- DEFINE_CONST(rb_mFtpStatus, "FILE_STATUS", sfFtpFileStatus);
264
- DEFINE_CONST(rb_mFtpStatus, "HELP_MESSAGE", sfFtpHelpMessage);
265
- DEFINE_CONST(rb_mFtpStatus, "SYSTEM_TYPE", sfFtpSystemType);
266
- DEFINE_CONST(rb_mFtpStatus, "SERVICE_READY", sfFtpServiceReady);
267
- DEFINE_CONST(rb_mFtpStatus, "CLOSING_CONNECTION", sfFtpClosingConnection);
268
- DEFINE_CONST(rb_mFtpStatus, "DATA_CONNECTION_OPENED", sfFtpDataConnectionOpened);
269
- DEFINE_CONST(rb_mFtpStatus, "CLOSING_DATA_CONNECTION", sfFtpClosingDataConnection);
270
- DEFINE_CONST(rb_mFtpStatus, "ENTERING_PASSIVE_MODE", sfFtpEnteringPassiveMode);
271
- DEFINE_CONST(rb_mFtpStatus, "LOGGED_IN", sfFtpLoggedIn);
272
- DEFINE_CONST(rb_mFtpStatus, "FILE_ACTION_OK", sfFtpFileActionOk);
273
- DEFINE_CONST(rb_mFtpStatus, "DIRECTORY_OK", sfFtpDirectoryOk);
274
- DEFINE_CONST(rb_mFtpStatus, "NEED_PASSWORD", sfFtpNeedPassword);
275
- DEFINE_CONST(rb_mFtpStatus, "NEED_ACCOUNT_TO_LOG_IN", sfFtpNeedAccountToLogIn);
276
- DEFINE_CONST(rb_mFtpStatus, "NEED_INFORMATION", sfFtpNeedInformation);
277
- DEFINE_CONST(rb_mFtpStatus, "SERVICE_UNAVAILABLE", sfFtpServiceUnavailable);
278
- DEFINE_CONST(rb_mFtpStatus, "DATA_CONNECTION_UNAVAILABLE", sfFtpDataConnectionUnavailable);
279
- DEFINE_CONST(rb_mFtpStatus, "TRANSFER_ABORTED", sfFtpTransferAborted);
280
- DEFINE_CONST(rb_mFtpStatus, "FILE_ACTION_ABORTED", sfFtpFileActionAborted);
281
- DEFINE_CONST(rb_mFtpStatus, "LOCAL_ERROR", sfFtpLocalError);
282
- DEFINE_CONST(rb_mFtpStatus, "INSUFFICIENT_STORAGE_SPACE", sfFtpInsufficientStorageSpace);
283
- DEFINE_CONST(rb_mFtpStatus, "COMMAND_UNKNOWN", sfFtpCommandUnknown);
284
- DEFINE_CONST(rb_mFtpStatus, "PARAMETERS_UNKNOWN", sfFtpParametersUnknown);
285
- DEFINE_CONST(rb_mFtpStatus, "COMMAND_NOT_IMPLEMENTED", sfFtpCommandNotImplemented);
286
- DEFINE_CONST(rb_mFtpStatus, "BAD_COMMAND_SEQUENCE", sfFtpBadCommandSequence);
287
- DEFINE_CONST(rb_mFtpStatus, "PARAMETER_NOT_IMPLEMENTED", sfFtpParameterNotImplemented);
288
- DEFINE_CONST(rb_mFtpStatus, "NOT_LOGGED_IN", sfFtpNotLoggedIn);
289
- DEFINE_CONST(rb_mFtpStatus, "NEED_ACCOUNT_TO_STORE", sfFtpNeedAccountToStore);
290
- DEFINE_CONST(rb_mFtpStatus, "FILE_UNAVAILABLE", sfFtpFileUnavailable);
291
- DEFINE_CONST(rb_mFtpStatus, "PAGE_TYPE_UNKNOWN", sfFtpPageTypeUnknown);
292
- DEFINE_CONST(rb_mFtpStatus, "NOT_ENOUGH_MEMORY", sfFtpNotEnoughMemory);
293
- DEFINE_CONST(rb_mFtpStatus, "FILENAME_NOT_ALLOWED", sfFtpFilenameNotAllowed);
294
- DEFINE_CONST(rb_mFtpStatus, "INVALID_RESPONSE", sfFtpInvalidResponse);
295
- DEFINE_CONST(rb_mFtpStatus, "CONNECTION_FAILED", sfFtpConnectionFailed);
296
- DEFINE_CONST(rb_mFtpStatus, "CONNECTION_CLOSED", sfFtpConnectionClosed);
297
- DEFINE_CONST(rb_mFtpStatus, "INVALID_FILE", sfFtpInvalidFile);
204
+ void Init_NetworkEnums(VALUE rb_mSFML) {
205
+ /* Document-module: SFML::SocketStatus
206
+ * Status codes returned by socket send/receive/connect operations.
207
+ */
208
+ VALUE rb_mSocketStatus = rb_define_module_under(rb_mSFML, "SocketStatus");
209
+
210
+ /* Document-module: SFML::HttpMethod
211
+ * The method (verb) of an HttpRequest.
212
+ */
213
+ VALUE rb_mHttpMethod = rb_define_module_under(rb_mSFML, "HttpMethod");
214
+
215
+ /* Document-module: SFML::HttpStatus
216
+ * Status codes returned by an HttpResponse, mirroring standard HTTP
217
+ * status codes with a few SFML-specific additions (1000+) for local
218
+ * connection failures.
219
+ */
220
+ VALUE rb_mHttpStatus = rb_define_module_under(rb_mSFML, "HttpStatus");
221
+
222
+ /* Document-module: SFML::FtpTransferMode
223
+ * The data transfer mode used by Ftp#download and Ftp#upload.
224
+ */
225
+ VALUE rb_mFtpTransferMode = rb_define_module_under(rb_mSFML, "FtpTransferMode");
226
+
227
+ /* Document-module: SFML::FtpStatus
228
+ * Status codes returned by an FtpResponse, mirroring standard FTP
229
+ * reply codes with a few SFML-specific additions (1000+) for local
230
+ * connection failures.
231
+ */
232
+ VALUE rb_mFtpStatus = rb_define_module_under(rb_mSFML, "FtpStatus");
233
+
234
+ /* The socket has sent or received the data. */
235
+ rb_define_const(rb_mSocketStatus, "DONE", INT2NUM(sfSocketDone));
236
+ /* The socket is not ready to send or receive data yet. */
237
+ rb_define_const(rb_mSocketStatus, "NOT_READY", INT2NUM(sfSocketNotReady));
238
+ /* The socket sent a part of the data. */
239
+ rb_define_const(rb_mSocketStatus, "PARTIAL", INT2NUM(sfSocketPartial));
240
+ /* The TCP socket has been disconnected. */
241
+ rb_define_const(rb_mSocketStatus, "DISCONNECTED", INT2NUM(sfSocketDisconnected));
242
+ /* An unexpected error happened. */
243
+ rb_define_const(rb_mSocketStatus, "ERROR", INT2NUM(sfSocketError));
244
+
245
+ /* Request in GET mode, the standard method to retrieve a page. */
246
+ rb_define_const(rb_mHttpMethod, "GET", INT2NUM(sfHttpGet));
247
+ /* Request in POST mode, usually to send data to a page. */
248
+ rb_define_const(rb_mHttpMethod, "POST", INT2NUM(sfHttpPost));
249
+ /* Request a page's header only. */
250
+ rb_define_const(rb_mHttpMethod, "HEAD", INT2NUM(sfHttpHead));
251
+ /* Request in PUT mode, useful for a REST API. */
252
+ rb_define_const(rb_mHttpMethod, "PUT", INT2NUM(sfHttpPut));
253
+ /* Request in DELETE mode, useful for a REST API. */
254
+ rb_define_const(rb_mHttpMethod, "DELETE", INT2NUM(sfHttpDelete));
255
+
256
+ /* 200: most common code, returned when the operation was successful. */
257
+ rb_define_const(rb_mHttpStatus, "OK", INT2NUM(sfHttpOk));
258
+ /* 201: the resource has successfully been created. */
259
+ rb_define_const(rb_mHttpStatus, "CREATED", INT2NUM(sfHttpCreated));
260
+ /* 202: the request has been accepted, but will be processed later by the server. */
261
+ rb_define_const(rb_mHttpStatus, "ACCEPTED", INT2NUM(sfHttpAccepted));
262
+ /* 204: the server didn't send any data in return. */
263
+ rb_define_const(rb_mHttpStatus, "NO_CONTENT", INT2NUM(sfHttpNoContent));
264
+ /* 205: the server informs the client that it should clear the view (form) that caused the
265
+ * request to be sent. */
266
+ rb_define_const(rb_mHttpStatus, "RESET_CONTENT", INT2NUM(sfHttpResetContent));
267
+ /* 206: the server has sent a part of the resource, as a response to a partial GET request. */
268
+ rb_define_const(rb_mHttpStatus, "PARTIAL_CONTENT", INT2NUM(sfHttpPartialContent));
269
+ /* 300: the requested page can be accessed from several locations. */
270
+ rb_define_const(rb_mHttpStatus, "MULTIPLE_CHOICES", INT2NUM(sfHttpMultipleChoices));
271
+ /* 301: the requested page has permanently moved to a new location. */
272
+ rb_define_const(rb_mHttpStatus, "MOVED_PERMANENTLY", INT2NUM(sfHttpMovedPermanently));
273
+ /* 302: the requested page has temporarily moved to a new location. */
274
+ rb_define_const(rb_mHttpStatus, "MOVED_TEMPORARILY", INT2NUM(sfHttpMovedTemporarily));
275
+ /* 304: for conditional requests, the requested page hasn't changed and doesn't need to be
276
+ * refreshed. */
277
+ rb_define_const(rb_mHttpStatus, "NOT_MODIFIED", INT2NUM(sfHttpNotModified));
278
+ /* 400: the server couldn't understand the request (syntax error). */
279
+ rb_define_const(rb_mHttpStatus, "BAD_REQUEST", INT2NUM(sfHttpBadRequest));
280
+ /* 401: the requested page needs an authentication to be accessed. */
281
+ rb_define_const(rb_mHttpStatus, "UNAUTHORIZED", INT2NUM(sfHttpUnauthorized));
282
+ /* 403: the requested page cannot be accessed at all, even with authentication. */
283
+ rb_define_const(rb_mHttpStatus, "FORBIDDEN", INT2NUM(sfHttpForbidden));
284
+ /* 404: the requested page doesn't exist. */
285
+ rb_define_const(rb_mHttpStatus, "NOT_FOUND", INT2NUM(sfHttpNotFound));
286
+ /* 407: the server can't satisfy the partial GET request (with a "Range" header field). */
287
+ rb_define_const(rb_mHttpStatus, "RANGE_NOT_SATISFIABLE", INT2NUM(sfHttpRangeNotSatisfiable));
288
+ /* 500: the server encountered an unexpected error. */
289
+ rb_define_const(rb_mHttpStatus, "INTERNAL_SERVER_ERROR", INT2NUM(sfHttpInternalServerError));
290
+ /* 501: the server doesn't implement this request method. */
291
+ rb_define_const(rb_mHttpStatus, "NOT_IMPLEMENTED", INT2NUM(sfHttpNotImplemented));
292
+ /* 502: the gateway server has received an error from the source server. */
293
+ rb_define_const(rb_mHttpStatus, "BAD_GATEWAY", INT2NUM(sfHttpBadGateway));
294
+ /* 503: the service has not been found. */
295
+ rb_define_const(rb_mHttpStatus, "SERVICE_NOT_AVAILABLE", INT2NUM(sfHttpServiceNotAvailable));
296
+ /* 504: the gateway server didn't receive a response from the source server in a proper delay.
297
+ */
298
+ rb_define_const(rb_mHttpStatus, "GATEWAY_TIMEOUT", INT2NUM(sfHttpGatewayTimeout));
299
+ /* 505: the server doesn't support the version of the HTTP protocol used. */
300
+ rb_define_const(rb_mHttpStatus, "VERSION_NOT_SUPPORTED", INT2NUM(sfHttpVersionNotSupported));
301
+ /* 1000 (SFML-specific): the response is not a valid HTTP one. */
302
+ rb_define_const(rb_mHttpStatus, "INVALID_RESPONSE", INT2NUM(sfHttpInvalidResponse));
303
+ /* 1001 (SFML-specific): the connection with the server failed. */
304
+ rb_define_const(rb_mHttpStatus, "CONNECTION_FAILED", INT2NUM(sfHttpConnectionFailed));
305
+
306
+ /* Binary transfer mode: files are transferred as raw bytes, unmodified. */
307
+ rb_define_const(rb_mFtpTransferMode, "BINARY", INT2NUM(sfFtpBinary));
308
+ /* Text (ASCII) transfer mode: files are converted to/from the text format of the receiving
309
+ * system. */
310
+ rb_define_const(rb_mFtpTransferMode, "ASCII", INT2NUM(sfFtpAscii));
311
+ /* EBCDIC text transfer mode. */
312
+ rb_define_const(rb_mFtpTransferMode, "EBCDIC", INT2NUM(sfFtpEbcdic));
313
+
314
+ /* 110: restart marker reply. */
315
+ rb_define_const(rb_mFtpStatus, "RESTART_MARKER_REPLY", INT2NUM(sfFtpRestartMarkerReply));
316
+ /* 120: service ready in N minutes. */
317
+ rb_define_const(rb_mFtpStatus, "SERVICE_READY_SOON", INT2NUM(sfFtpServiceReadySoon));
318
+ /* 125: data connection already opened, transfer starting. */
319
+ rb_define_const(rb_mFtpStatus, "DATA_CONNECTION_ALREADY_OPENED",
320
+ INT2NUM(sfFtpDataConnectionAlreadyOpened));
321
+ /* 150: file status ok, about to open data connection. */
322
+ rb_define_const(rb_mFtpStatus, "OPENING_DATA_CONNECTION", INT2NUM(sfFtpOpeningDataConnection));
323
+ /* 200: command ok. */
324
+ rb_define_const(rb_mFtpStatus, "OK", INT2NUM(sfFtpOk));
325
+ /* 202: command not implemented. */
326
+ rb_define_const(rb_mFtpStatus, "POINTLESS_COMMAND", INT2NUM(sfFtpPointlessCommand));
327
+ /* 211: system status, or system help reply. */
328
+ rb_define_const(rb_mFtpStatus, "SYSTEM_STATUS", INT2NUM(sfFtpSystemStatus));
329
+ /* 212: directory status. */
330
+ rb_define_const(rb_mFtpStatus, "DIRECTORY_STATUS", INT2NUM(sfFtpDirectoryStatus));
331
+ /* 213: file status. */
332
+ rb_define_const(rb_mFtpStatus, "FILE_STATUS", INT2NUM(sfFtpFileStatus));
333
+ /* 214: help message. */
334
+ rb_define_const(rb_mFtpStatus, "HELP_MESSAGE", INT2NUM(sfFtpHelpMessage));
335
+ /* 215: NAME system type, where NAME is an official system name from the Assigned Numbers
336
+ * document. */
337
+ rb_define_const(rb_mFtpStatus, "SYSTEM_TYPE", INT2NUM(sfFtpSystemType));
338
+ /* 220: service ready for a new user. */
339
+ rb_define_const(rb_mFtpStatus, "SERVICE_READY", INT2NUM(sfFtpServiceReady));
340
+ /* 221: service closing the control connection. */
341
+ rb_define_const(rb_mFtpStatus, "CLOSING_CONNECTION", INT2NUM(sfFtpClosingConnection));
342
+ /* 225: data connection open, no transfer in progress. */
343
+ rb_define_const(rb_mFtpStatus, "DATA_CONNECTION_OPENED", INT2NUM(sfFtpDataConnectionOpened));
344
+ /* 226: closing data connection, requested file action successful. */
345
+ rb_define_const(rb_mFtpStatus, "CLOSING_DATA_CONNECTION", INT2NUM(sfFtpClosingDataConnection));
346
+ /* 227: entering passive mode. */
347
+ rb_define_const(rb_mFtpStatus, "ENTERING_PASSIVE_MODE", INT2NUM(sfFtpEnteringPassiveMode));
348
+ /* 230: user logged in, proceed (logged out if appropriate). */
349
+ rb_define_const(rb_mFtpStatus, "LOGGED_IN", INT2NUM(sfFtpLoggedIn));
350
+ /* 250: requested file action ok. */
351
+ rb_define_const(rb_mFtpStatus, "FILE_ACTION_OK", INT2NUM(sfFtpFileActionOk));
352
+ /* 257: PATHNAME created. */
353
+ rb_define_const(rb_mFtpStatus, "DIRECTORY_OK", INT2NUM(sfFtpDirectoryOk));
354
+ /* 331: user name ok, password needed. */
355
+ rb_define_const(rb_mFtpStatus, "NEED_PASSWORD", INT2NUM(sfFtpNeedPassword));
356
+ /* 332: account needed for login. */
357
+ rb_define_const(rb_mFtpStatus, "NEED_ACCOUNT_TO_LOG_IN", INT2NUM(sfFtpNeedAccountToLogIn));
358
+ /* 350: requested file action pending further information. */
359
+ rb_define_const(rb_mFtpStatus, "NEED_INFORMATION", INT2NUM(sfFtpNeedInformation));
360
+ /* 421: service not available, closing the control connection. */
361
+ rb_define_const(rb_mFtpStatus, "SERVICE_UNAVAILABLE", INT2NUM(sfFtpServiceUnavailable));
362
+ /* 425: can't open the data connection. */
363
+ rb_define_const(rb_mFtpStatus, "DATA_CONNECTION_UNAVAILABLE",
364
+ INT2NUM(sfFtpDataConnectionUnavailable));
365
+ /* 426: connection closed, transfer aborted. */
366
+ rb_define_const(rb_mFtpStatus, "TRANSFER_ABORTED", INT2NUM(sfFtpTransferAborted));
367
+ /* 450: requested file action not taken. */
368
+ rb_define_const(rb_mFtpStatus, "FILE_ACTION_ABORTED", INT2NUM(sfFtpFileActionAborted));
369
+ /* 451: requested action aborted, local error in processing. */
370
+ rb_define_const(rb_mFtpStatus, "LOCAL_ERROR", INT2NUM(sfFtpLocalError));
371
+ /* 452: requested action not taken; insufficient storage space in system, file unavailable. */
372
+ rb_define_const(rb_mFtpStatus, "INSUFFICIENT_STORAGE_SPACE",
373
+ INT2NUM(sfFtpInsufficientStorageSpace));
374
+ /* 500: syntax error, command unrecognized. */
375
+ rb_define_const(rb_mFtpStatus, "COMMAND_UNKNOWN", INT2NUM(sfFtpCommandUnknown));
376
+ /* 501: syntax error in parameters or arguments. */
377
+ rb_define_const(rb_mFtpStatus, "PARAMETERS_UNKNOWN", INT2NUM(sfFtpParametersUnknown));
378
+ /* 502: command not implemented. */
379
+ rb_define_const(rb_mFtpStatus, "COMMAND_NOT_IMPLEMENTED", INT2NUM(sfFtpCommandNotImplemented));
380
+ /* 503: bad sequence of commands. */
381
+ rb_define_const(rb_mFtpStatus, "BAD_COMMAND_SEQUENCE", INT2NUM(sfFtpBadCommandSequence));
382
+ /* 504: command not implemented for that parameter. */
383
+ rb_define_const(rb_mFtpStatus, "PARAMETER_NOT_IMPLEMENTED",
384
+ INT2NUM(sfFtpParameterNotImplemented));
385
+ /* 530: not logged in. */
386
+ rb_define_const(rb_mFtpStatus, "NOT_LOGGED_IN", INT2NUM(sfFtpNotLoggedIn));
387
+ /* 532: account needed for storing files. */
388
+ rb_define_const(rb_mFtpStatus, "NEED_ACCOUNT_TO_STORE", INT2NUM(sfFtpNeedAccountToStore));
389
+ /* 550: requested action not taken, file unavailable. */
390
+ rb_define_const(rb_mFtpStatus, "FILE_UNAVAILABLE", INT2NUM(sfFtpFileUnavailable));
391
+ /* 551: requested action aborted, page type unknown. */
392
+ rb_define_const(rb_mFtpStatus, "PAGE_TYPE_UNKNOWN", INT2NUM(sfFtpPageTypeUnknown));
393
+ /* 552: requested file action aborted, exceeded storage allocation. */
394
+ rb_define_const(rb_mFtpStatus, "NOT_ENOUGH_MEMORY", INT2NUM(sfFtpNotEnoughMemory));
395
+ /* 553: requested action not taken, file name not allowed. */
396
+ rb_define_const(rb_mFtpStatus, "FILENAME_NOT_ALLOWED", INT2NUM(sfFtpFilenameNotAllowed));
397
+ /* 1000 (SFML-specific): the response is not a valid FTP one. */
398
+ rb_define_const(rb_mFtpStatus, "INVALID_RESPONSE", INT2NUM(sfFtpInvalidResponse));
399
+ /* 1001 (SFML-specific): the connection with the server failed. */
400
+ rb_define_const(rb_mFtpStatus, "CONNECTION_FAILED", INT2NUM(sfFtpConnectionFailed));
401
+ /* 1002 (SFML-specific): the connection with the server closed. */
402
+ rb_define_const(rb_mFtpStatus, "CONNECTION_CLOSED", INT2NUM(sfFtpConnectionClosed));
403
+ /* 1003 (SFML-specific): invalid file for upload/download. */
404
+ rb_define_const(rb_mFtpStatus, "INVALID_FILE", INT2NUM(sfFtpInvalidFile));
298
405
  }