wxruby3 1.8.1 → 2.0.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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +20 -10
  3. data/README.md +3 -3
  4. data/ext/wxruby3/include/wxRubyApp.h +49 -3
  5. data/ext/wxruby3/include/wxruby-ComboPopup.h +17 -32
  6. data/ext/wxruby3/include/wxruby-Config.h +34 -11
  7. data/ext/wxruby3/include/wxruby-GCTracking.h +23 -5
  8. data/ext/wxruby3/include/wxruby-SharedEventHandler.h +7 -7
  9. data/ext/wxruby3/include/wxruby-runtime.h +65 -0
  10. data/ext/wxruby3/swig/common.i +6 -0
  11. data/ext/wxruby3/swig/custom/typed_data/rubyhead.swg +220 -0
  12. data/ext/wxruby3/swig/custom/typed_data/rubyprimtypes.swg +265 -0
  13. data/ext/wxruby3/swig/custom/typed_data/rubyrun.swg +243 -0
  14. data/ext/wxruby3/swig/custom/typed_data/swigrun.swg +689 -0
  15. data/ext/wxruby3/swig/custom/{rubyprimtypes.swg → untyped_data/rubyprimtypes.swg} +8 -0
  16. data/ext/wxruby3/swig/mark_free_impl.i +2 -2
  17. data/ext/wxruby3/swig/memory_management.i +1 -0
  18. data/ext/wxruby3/swig/wx.i +19 -6
  19. data/lib/wx/core/file_dialog.rb +3 -10
  20. data/lib/wx/doc/rbn/events.rb +32 -0
  21. data/lib/wx/doc/rbn/ribbon_backstage_mrulist.rb +25 -0
  22. data/lib/wx/keyword_ctors.rb +3 -13
  23. data/lib/wx/rbn/events.rb +18 -0
  24. data/lib/wx/rbn/require.rb +1 -0
  25. data/lib/wx/rbn/ribbon_backstage_mrulist.rb +39 -0
  26. data/lib/wx/version.rb +1 -1
  27. data/rakelib/lib/config.rb +3 -3
  28. data/rakelib/lib/core/include/typed_data/swigrubyrun.inc +629 -0
  29. data/rakelib/lib/core/include/typed_data/swigrun.inc +870 -0
  30. data/rakelib/lib/core/package.rb +2 -2
  31. data/rakelib/lib/director/app.rb +16 -0
  32. data/rakelib/lib/director/art_provider.rb +3 -3
  33. data/rakelib/lib/director/aui_mdi_child_frame.rb +24 -0
  34. data/rakelib/lib/director/aui_mdi_parent_frame.rb +0 -2
  35. data/rakelib/lib/director/aui_tab_ctrl.rb +3 -3
  36. data/rakelib/lib/director/comboctrl.rb +35 -2
  37. data/rakelib/lib/director/config_base.rb +79 -33
  38. data/rakelib/lib/director/data_object.rb +1 -1
  39. data/rakelib/lib/director/date_event.rb +10 -3
  40. data/rakelib/lib/director/event.rb +16 -7
  41. data/rakelib/lib/director/event_handler.rb +48 -10
  42. data/rakelib/lib/director/events.rb +4 -2
  43. data/rakelib/lib/director/file_history.rb +46 -0
  44. data/rakelib/lib/director/frame.rb +29 -0
  45. data/rakelib/lib/director/fs_file.rb +2 -4
  46. data/rakelib/lib/director/functions.rb +2 -2
  47. data/rakelib/lib/director/graphics_context.rb +6 -6
  48. data/rakelib/lib/director/grid_cell_editor.rb +1 -1
  49. data/rakelib/lib/director/grid_cell_renderer.rb +1 -1
  50. data/rakelib/lib/director/grid_ctrl.rb +39 -12
  51. data/rakelib/lib/director/help_controller.rb +17 -0
  52. data/rakelib/lib/director/html_help_data.rb +20 -2
  53. data/rakelib/lib/director/icon.rb +3 -0
  54. data/rakelib/lib/director/log.rb +25 -1
  55. data/rakelib/lib/director/menu.rb +38 -106
  56. data/rakelib/lib/director/menu_bar.rb +36 -70
  57. data/rakelib/lib/director/num_validator.rb +3 -3
  58. data/rakelib/lib/director/numeric_property_validator.rb +1 -1
  59. data/rakelib/lib/director/page_setup_dialog.rb +18 -1
  60. data/rakelib/lib/director/pgeditor.rb +1 -1
  61. data/rakelib/lib/director/pgvalidation_info.rb +1 -0
  62. data/rakelib/lib/director/popup_window.rb +7 -0
  63. data/rakelib/lib/director/preview_frame.rb +8 -1
  64. data/rakelib/lib/director/print_dialog.rb +17 -0
  65. data/rakelib/lib/director/printer.rb +1 -1
  66. data/rakelib/lib/director/property_grid_page.rb +2 -0
  67. data/rakelib/lib/director/region_iterator.rb +1 -1
  68. data/rakelib/lib/director/ribbon_backstage.rb +28 -0
  69. data/rakelib/lib/director/ribbon_backstage_button.rb +25 -0
  70. data/rakelib/lib/director/ribbon_backstage_callout.rb +26 -0
  71. data/rakelib/lib/director/ribbon_backstage_heading.rb +26 -0
  72. data/rakelib/lib/director/ribbon_backstage_itemlist.rb +27 -0
  73. data/rakelib/lib/director/ribbon_backstage_mrulist.rb +112 -0
  74. data/rakelib/lib/director/ribbon_bar.rb +14 -0
  75. data/rakelib/lib/director/ribbon_gallery.rb +6 -2
  76. data/rakelib/lib/director/ribbon_tool_bar.rb +6 -4
  77. data/rakelib/lib/director/richtext_composite_object.rb +4 -4
  78. data/rakelib/lib/director/richtext_paragraph_layout_box.rb +1 -1
  79. data/rakelib/lib/director/scrolled_t.rb +1 -1
  80. data/rakelib/lib/director/sizer.rb +7 -0
  81. data/rakelib/lib/director/sizer_item.rb +4 -1
  82. data/rakelib/lib/director/splitter_event.rb +2 -2
  83. data/rakelib/lib/director/task_bar_icon.rb +4 -1
  84. data/rakelib/lib/director/text_validator.rb +1 -1
  85. data/rakelib/lib/director/tree_event.rb +3 -3
  86. data/rakelib/lib/director/validator.rb +1 -1
  87. data/rakelib/lib/director/variant.rb +2 -2
  88. data/rakelib/lib/director/window.rb +27 -5
  89. data/rakelib/lib/director/window_disabler.rb +1 -1
  90. data/rakelib/lib/director/xml_resource.rb +33 -8
  91. data/rakelib/lib/extractor/class.rb +2 -1
  92. data/rakelib/lib/extractor.rb +3 -2
  93. data/rakelib/lib/generate/interface.rb +2 -3
  94. data/rakelib/lib/specs/interfaces.rb +7 -0
  95. data/rakelib/lib/swig_runner.rb +14 -3
  96. data/rakelib/lib/typemap/common.rb +2 -36
  97. data/rakelib/lib/typemap/config.rb +22 -0
  98. data/samples/ribbon/ribbon.rb +277 -20
  99. data/tests/test_shared_event_handler.rb +3 -3
  100. metadata +32 -16
  101. /data/ext/wxruby3/swig/custom/{director.swg → common/director.swg} +0 -0
  102. /data/ext/wxruby3/swig/custom/{rubyapi.swg → common/rubyapi.swg} +0 -0
  103. /data/ext/wxruby3/swig/custom/{rubyerrors.swg → common/rubyerrors.swg} +0 -0
  104. /data/ext/wxruby3/swig/custom/{rubytracking.swg → common/rubytracking.swg} +0 -0
  105. /data/ext/wxruby3/swig/custom/{swiglabels.swg → common/swiglabels.swg} +0 -0
  106. /data/ext/wxruby3/swig/custom/{typemaps → common/typemaps}/swigtypemaps.swg +0 -0
  107. /data/ext/wxruby3/swig/custom/{wx_ruby_shared_ptr.i → common/wx_ruby_shared_ptr.i} +0 -0
  108. /data/ext/wxruby3/swig/custom/{wx_shared_ptr.i → common/wx_shared_ptr.i} +0 -0
  109. /data/ext/wxruby3/swig/custom/{rubyhead.swg → untyped_data/rubyhead.swg} +0 -0
  110. /data/ext/wxruby3/swig/custom/{rubyrun.swg → untyped_data/rubyrun.swg} +0 -0
  111. /data/ext/wxruby3/swig/custom/{swigrun.swg → untyped_data/swigrun.swg} +0 -0
  112. /data/rakelib/lib/core/include/{swigrubyrun.inc → untyped_data/swigrubyrun.inc} +0 -0
  113. /data/rakelib/lib/core/include/{swigrun.inc → untyped_data/swigrun.inc} +0 -0
@@ -0,0 +1,629 @@
1
+ // Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ //
3
+ // This software is released under the MIT license.
4
+
5
+ // SWIG Ruby runtime
6
+
7
+ /* From rubytracking.swg */
8
+
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+ // Shared custom swig tracking functions
13
+ WXRB_EXPORT_FLAG void wxRuby_InitializeTracking();
14
+ WXRB_EXPORT_FLAG void wxRuby_AddTracking(void* ptr, VALUE object);
15
+ WXRB_EXPORT_FLAG VALUE wxRuby_FindTracking(void* ptr);
16
+ WXRB_EXPORT_FLAG void wxRuby_RemoveTracking(void* ptr);
17
+ WXRB_EXPORT_FLAG void wxRuby_UnlinkObject(void* ptr);
18
+
19
+ /* Setup a Ruby hash table to store Trackings */
20
+ #define SWIG_RubyInitializeTrackings()
21
+
22
+ /* Add a Tracking from a C/C++ struct to a Ruby object */
23
+ #define SWIG_RubyAddTracking wxRuby_AddTracking
24
+
25
+ /* Get the Ruby object that owns the specified C/C++ struct */
26
+ #define SWIG_RubyInstanceFor wxRuby_FindTracking
27
+
28
+ /* Remove a Tracking from a C/C++ struct to a Ruby object. It
29
+ is very important to remove objects once they are destroyed
30
+ since the same memory address may be reused later to create
31
+ a new object. */
32
+ #define SWIG_RubyRemoveTracking wxRuby_RemoveTracking
33
+
34
+ /* This is a helper method that unlinks a Ruby object from its
35
+ underlying C++ object. This is needed if the lifetime of the
36
+ Ruby object is longer than the C++ object */
37
+ #define SWIG_RubyUnlinkObjects wxRuby_UnlinkObject
38
+
39
+ #ifdef __cplusplus
40
+ }
41
+ #endif
42
+
43
+ /* From rubyapi.swg */
44
+
45
+ #ifdef __cplusplus
46
+ extern "C" {
47
+ #endif
48
+
49
+ WXRB_EXPORT_FLAG VALUE
50
+ SWIG_wxRuby_AppendOutput(VALUE target, VALUE o, int is_void)
51
+ {
52
+ if (NIL_P(target) && is_void != 0)
53
+ {
54
+ target = o;
55
+ }
56
+ else
57
+ {
58
+ if (TYPE(target) != T_ARRAY)
59
+ {
60
+ VALUE o2 = target;
61
+ target = rb_ary_new();
62
+ rb_ary_push(target, o2);
63
+ }
64
+ rb_ary_push(target, o);
65
+ }
66
+ return target;
67
+ }
68
+
69
+ #ifdef __cplusplus
70
+ }
71
+ #endif
72
+
73
+ /*
74
+ * The following macros are used for providing the correct type of a
75
+ * function pointer to the Ruby C API.
76
+ *
77
+ * Starting with Ruby 2.7 these macros act transparently due to Ruby's moving
78
+ * moving away from ANYARGS and instead employing strict function signatures.
79
+ *
80
+ * Note: In case of C (not C++) the macros are transparent even before
81
+ * Ruby 2.7 due to the fact that the Ruby C API used function declarators
82
+ * with empty parentheses, which allows for an unspecified number of
83
+ * arguments.
84
+ *
85
+ * PROTECTFUNC(f) is used for the function pointer argument of the Ruby
86
+ * C API function rb_protect().
87
+ *
88
+ * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API
89
+ * functions like rb_define_method() and rb_define_singleton_method().
90
+ *
91
+ * VOIDFUNC(f) is used to typecast a C function that implements either
92
+ * the "mark" or "free" stuff for a Ruby Data object, so that it can be
93
+ * passed as an argument to Ruby C API functions like Data_Wrap_Struct()
94
+ * and Data_Make_Struct().
95
+ *
96
+ * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer
97
+ * argument(s) of Ruby C API functions like rb_define_virtual_variable().
98
+ *
99
+ * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer
100
+ * argument(s) of Ruby C API functions like st_foreach().
101
+ */
102
+ #if defined(__cplusplus) && RUBY_API_VERSION_CODE < 20700
103
+ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
104
+ # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
105
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
106
+ # define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f))
107
+ # define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f))
108
+ #else
109
+ # define PROTECTFUNC(f) (f)
110
+ # define VALUEFUNC(f) (f)
111
+ # define VOIDFUNC(f) (f)
112
+ # define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f)
113
+ # define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f)
114
+ #endif
115
+
116
+ #define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
117
+ #define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
118
+
119
+ static VALUE _mSWIG = Qnil;
120
+
121
+ #include "assert.h"
122
+
123
+ /* -----------------------------------------------------------------------------
124
+ * pointers/data manipulation
125
+ * ----------------------------------------------------------------------------- */
126
+
127
+ #ifdef __cplusplus
128
+ extern "C" {
129
+ #endif
130
+
131
+ typedef struct WXRB_EXPORT_FLAG swig_class
132
+ {
133
+ VALUE klass;
134
+ VALUE mImpl;
135
+ void (*mark)(void *);
136
+ void (*destroy)(void *);
137
+ rb_data_type_t cext_type;
138
+ int trackObjects;
139
+ } swig_class;
140
+
141
+ /* Global pointer used to keep some internal SWIG stuff */
142
+ static VALUE _cSWIG_Pointer = Qnil;
143
+ static VALUE swig_runtime_data_type_pointer = Qnil;
144
+
145
+ /* Global IDs used to keep some internal SWIG stuff */
146
+ static ID swig_arity_id = 0;
147
+ static ID swig_call_id = 0;
148
+ WXRB_EXPORT_FLAG ID swig_lowerthan_id = 0;
149
+
150
+ /*
151
+ If your swig extension is to be run within an embedded ruby and has
152
+ director callbacks, you should set -DRUBY_EMBEDDED during compilation.
153
+ This will reset ruby's stack frame on each entry point from the main
154
+ program the first time a virtual director function is invoked (in a
155
+ non-recursive way).
156
+ If this is not done, you run the risk of Ruby trashing the stack.
157
+ */
158
+
159
+ #ifdef RUBY_EMBEDDED
160
+
161
+ # define SWIG_INIT_STACK \
162
+ if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \
163
+ ++swig_virtual_calls;
164
+ # define SWIG_RELEASE_STACK --swig_virtual_calls;
165
+ # define Ruby_DirectorTypeMismatchException(x) \
166
+ rb_raise( rb_eTypeError, "%s", x ); return c_result;
167
+
168
+ static unsigned int swig_virtual_calls = 0;
169
+
170
+ #else /* normal non-embedded extension */
171
+
172
+ # define SWIG_INIT_STACK
173
+ # define SWIG_RELEASE_STACK
174
+ # define Ruby_DirectorTypeMismatchException(x) \
175
+ throw Swig::DirectorTypeMismatchException( x );
176
+
177
+ #endif /* RUBY_EMBEDDED */
178
+
179
+
180
+ SWIGRUNTIME VALUE
181
+ getExceptionClass(void)
182
+ {
183
+ static VALUE rubyExceptionClass = Qnil;
184
+ if (rubyExceptionClass == Qnil)
185
+ {
186
+ rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception"));
187
+ }
188
+ return rubyExceptionClass;
189
+ }
190
+
191
+ /* This code checks to see if the Ruby object being raised as part
192
+ of an exception inherits from the Ruby class Exception. If so,
193
+ the object is simply returned. If not, then a new Ruby exception
194
+ object is created and that will be returned to Ruby.*/
195
+ WXRB_EXPORT_FLAG VALUE
196
+ SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj)
197
+ {
198
+ VALUE exceptionClass = getExceptionClass();
199
+ if (rb_obj_is_kind_of(obj, exceptionClass))
200
+ {
201
+ return obj;
202
+ }
203
+ else
204
+ {
205
+ return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj));
206
+ }
207
+ }
208
+
209
+ /* Initialize Ruby runtime support */
210
+ WXRB_EXPORT_FLAG void
211
+ SWIG_Ruby_InitRuntime(void)
212
+ {
213
+ if (_mSWIG == Qnil)
214
+ {
215
+ _mSWIG = rb_define_module("SWIG");
216
+ swig_call_id = rb_intern("call");
217
+ swig_arity_id = rb_intern("arity");
218
+ swig_lowerthan_id = rb_intern("<");
219
+ }
220
+ }
221
+
222
+ /* Define Ruby class for C type */
223
+ WXRB_EXPORT_FLAG void
224
+ SWIG_Ruby_define_class(swig_type_info *type)
225
+ {
226
+ size_t klass_len = 4 + strlen(type->name) + 1;
227
+ char *klass_name = (char *) malloc(klass_len);
228
+ SWIG_snprintf(klass_name, klass_len, "TYPE%s", type->name);
229
+ if (NIL_P(_cSWIG_Pointer))
230
+ {
231
+ _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
232
+ rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
233
+ }
234
+ rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
235
+ free((void *) klass_name);
236
+ }
237
+
238
+ /* ---------------------------------------------------------------------------
239
+ * SWIG_Ruby_free_swig_type()
240
+ *
241
+ * Generic free callback for the TypedData wrapper. It forwards to the per-object
242
+ * free function recorded in the wrapper, if one was set, then frees the wrapper.
243
+ * --------------------------------------------------------------------------- */
244
+ static void SWIG_Ruby_free_swig_type(void *data) {
245
+ struct swig_ruby_wrapped_object *wrobj = (struct swig_ruby_wrapped_object *)data;
246
+ if (!wrobj)
247
+ return;
248
+ if (wrobj->dfree)
249
+ wrobj->dfree(wrobj->data);
250
+ #ifndef TYPED_DATA_EMBEDDED
251
+ ruby_xfree(wrobj);
252
+ #endif
253
+ }
254
+
255
+ /* TypedData descriptor for the anonymous SWIG::TYPE* pointer wrappers (types
256
+ without a Ruby class). Classes use their own SwigClass*.cext_type so heap
257
+ dumps show the C++ class name. */
258
+ extern const WXRB_EXPORT_FLAG rb_data_type_t swig_type_data_type = {
259
+ "swig_type",
260
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
261
+ { 0, SWIG_Ruby_free_swig_type, 0, 0, 0, {}},
262
+ #else
263
+ { 0, SWIG_Ruby_free_swig_type, 0, 0, {}},
264
+ #endif
265
+ 0, 0
266
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
267
+ , SWIG_RUBY_TYPED_DATA_FLAGS
268
+ #endif
269
+ };
270
+
271
+ /* Create a new pointer object */
272
+ WXRB_EXPORT_FLAG VALUE
273
+ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
274
+ {
275
+ int own = flags & SWIG_POINTER_OWN;
276
+ int track;
277
+ char *klass_name;
278
+ swig_class *sklass;
279
+ VALUE klass;
280
+ VALUE obj;
281
+ struct swig_ruby_wrapped_object *wrobj;
282
+
283
+ if (!ptr)
284
+ return Qnil;
285
+
286
+ assert(type);
287
+ if (type->clientdata) {
288
+ sklass = (swig_class *) type->clientdata;
289
+
290
+ /* Are we tracking this class and have we already returned this Ruby object? */
291
+ track = sklass->trackObjects;
292
+ if (track) {
293
+ obj = SWIG_RubyInstanceFor(ptr);
294
+
295
+ /* Check the object's type and make sure it has the correct type.
296
+ It might not in cases where methods do things like
297
+ downcast methods. */
298
+ if (obj != Qnil) {
299
+ // wxRuby : Note that we also track non-SWIG types so the return
300
+ // value might be nil
301
+ VALUE value = rb_iv_get(obj, "@__swigtype__");
302
+
303
+ // wxRuby : allow returning tracked objects of derived classes
304
+ if (!NIL_P(value) && rb_obj_is_kind_of(obj, sklass->klass))
305
+ {
306
+ return obj;
307
+ }
308
+ }
309
+ }
310
+
311
+ /* Create a new Ruby object */
312
+ obj = TypedData_Make_Struct(sklass->klass, struct swig_ruby_wrapped_object, &sklass->cext_type, wrobj);
313
+ wrobj->data = ptr;
314
+ wrobj->dmark = sklass->mark;
315
+ wrobj->dfree = own ? sklass->destroy : (track ? SWIG_RubyRemoveTracking : 0);
316
+
317
+ /* If tracking is on for this class then track this object. */
318
+ if (track) {
319
+ SWIG_RubyAddTracking(ptr, obj);
320
+ }
321
+ } else {
322
+ size_t klass_len = 4 + strlen(type->name) + 1;
323
+ klass_name = (char *) malloc(klass_len);
324
+ SWIG_snprintf(klass_name, klass_len, "TYPE%s", type->name);
325
+ klass = rb_const_get(_mSWIG, rb_intern(klass_name));
326
+ free((void *) klass_name);
327
+
328
+ obj = TypedData_Make_Struct(klass, struct swig_ruby_wrapped_object, &swig_type_data_type, wrobj);
329
+ wrobj->data = ptr;
330
+ wrobj->dmark = 0;
331
+ wrobj->dfree = 0;
332
+ }
333
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
334
+
335
+ return obj;
336
+ }
337
+
338
+ /* Create a new class instance (always owned) */
339
+ WXRB_EXPORT_FLAG VALUE
340
+ SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
341
+ {
342
+ VALUE obj;
343
+ struct swig_ruby_wrapped_object *wrobj;
344
+ swig_class *sklass = (swig_class *) type->clientdata;
345
+ obj = TypedData_Make_Struct(klass, struct swig_ruby_wrapped_object, &sklass->cext_type, wrobj);
346
+ wrobj->data = 0;
347
+ wrobj->dmark = sklass->mark;
348
+ wrobj->dfree = sklass->destroy;
349
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
350
+ return obj;
351
+ }
352
+
353
+ /* Get type mangle from class name */
354
+ WXRB_EXPORT_FLAG char *
355
+ SWIG_Ruby_MangleStr(VALUE obj)
356
+ {
357
+ VALUE stype = rb_iv_get(obj, "@__swigtype__");
358
+ if (NIL_P(stype))
359
+ return NULL;
360
+ return StringValuePtr(stype);
361
+ }
362
+
363
+ /* Acquire a pointer value */
364
+ typedef struct WXRB_EXPORT_FLAG swig_ruby_owntype
365
+ {
366
+ void (*datafree)(void *);
367
+ int own;
368
+ } swig_ruby_owntype;
369
+
370
+ WXRB_EXPORT_FLAG swig_ruby_owntype
371
+ SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own)
372
+ {
373
+ swig_ruby_owntype oldown = {0, 0};
374
+ if (RB_TYPE_P(obj, RUBY_T_DATA) && RTYPEDDATA_P(obj)) {
375
+ struct swig_ruby_wrapped_object *wrobj = (struct swig_ruby_wrapped_object *)RTYPEDDATA_GET_DATA(obj);
376
+ if (wrobj) {
377
+ oldown.datafree = wrobj->dfree;
378
+ wrobj->dfree = own.datafree;
379
+ }
380
+ }
381
+ return oldown;
382
+ }
383
+
384
+ /* Convert a pointer value */
385
+ WXRB_EXPORT_FLAG int
386
+ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, swig_ruby_owntype *own)
387
+ {
388
+ char *c;
389
+ swig_cast_info *tc;
390
+ void *vptr = 0;
391
+ struct swig_ruby_wrapped_object *wrobj = 0;
392
+ /* Stand in used when the Ruby object has been detached from its wrapper, so that the ownership
393
+ handling below can run unchanged with any write to it harmlessly discarded. */
394
+ struct swig_ruby_wrapped_object detached = {0, 0, 0};
395
+
396
+ /* Grab the pointer */
397
+ if (NIL_P(obj)) {
398
+ if (ptr)
399
+ *ptr = 0;
400
+ return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
401
+ } else if (RB_TYPE_P(obj, RUBY_T_DATA) && RTYPEDDATA_P(obj)) {
402
+ wrobj = (struct swig_ruby_wrapped_object *)RTYPEDDATA_GET_DATA(obj);
403
+ /* Hand written code targeting SWIG 4.4 and earlier sometimes invalidates a proxy with
404
+ 'DATA_PTR(obj) = NULL'. Before SWIG 4.5 that cleared the wrapped pointer itself, but now it
405
+ detaches the whole wrapper unless Ruby embedded it in the object slot. Treat the detached
406
+ object as one whose pointer has been cleared, which is what such code intends. */
407
+ if (!wrobj)
408
+ wrobj = &detached;
409
+ vptr = wrobj->data;
410
+ } else {
411
+ return SWIG_ERROR;
412
+ }
413
+
414
+ if (own) {
415
+ own->datafree = wrobj->dfree;
416
+ own->own = 0;
417
+ }
418
+
419
+ if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE)) {
420
+ if (!wrobj->dfree)
421
+ return SWIG_ERROR_RELEASE_NOT_OWNED;
422
+ }
423
+
424
+ /* Check to see if the input object is giving up ownership
425
+ of the underlying C struct or C++ object. If so then we
426
+ need to reset the destructor since the Ruby object no
427
+ longer owns the underlying C++ object.*/
428
+ if (flags & SWIG_POINTER_DISOWN) {
429
+ /* Is tracking on for this class? */
430
+ int track = 0;
431
+ if (ty && ty->clientdata) {
432
+ swig_class *sklass = (swig_class *) ty->clientdata;
433
+ track = sklass->trackObjects;
434
+ }
435
+
436
+ if (track) {
437
+ /* We are tracking objects for this class. Thus we change the destructor
438
+ * to SWIG_RubyRemoveTracking. This allows us to
439
+ * remove the mapping from the C++ to Ruby object
440
+ * when the Ruby object is garbage collected. If we don't
441
+ * do this, then it is possible we will return a reference
442
+ * to a Ruby object that no longer exists thereby crashing Ruby. */
443
+ wrobj->dfree = SWIG_RubyRemoveTracking;
444
+ } else {
445
+ wrobj->dfree = 0;
446
+ }
447
+ }
448
+
449
+ if (flags & SWIG_POINTER_CLEAR) {
450
+ wrobj->data = 0;
451
+ }
452
+
453
+ /* Do type-checking if type info was provided */
454
+ if (ty) {
455
+ if (ty->clientdata) {
456
+ if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
457
+ if (vptr == 0) {
458
+ /* The object has already been deleted */
459
+ return SWIG_ObjectPreviouslyDeletedError;
460
+ }
461
+ }
462
+ }
463
+ if ((c = SWIG_MangleStr(obj)) == NULL) {
464
+ return SWIG_ERROR;
465
+ }
466
+ tc = SWIG_TypeCheck(c, ty);
467
+ if (!tc) {
468
+ return SWIG_ERROR;
469
+ } else {
470
+ if (ptr) {
471
+ if (tc->type == ty) {
472
+ *ptr = vptr;
473
+ } else {
474
+ int newmemory = 0;
475
+ *ptr = SWIG_TypeCast(tc, vptr, &newmemory);
476
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
477
+ assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
478
+ if (own)
479
+ own->own = own->own | SWIG_CAST_NEW_MEMORY;
480
+ }
481
+ }
482
+ }
483
+ }
484
+ } else {
485
+ if (ptr)
486
+ *ptr = vptr;
487
+ }
488
+
489
+ return SWIG_OK;
490
+ }
491
+
492
+ /* Check convert */
493
+ WXRB_EXPORT_FLAG int
494
+ SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty)
495
+ {
496
+ char *c = SWIG_MangleStr(obj);
497
+ if (!c) return 0;
498
+ return SWIG_TypeCheck(c,ty) != 0;
499
+ }
500
+
501
+ WXRB_EXPORT_FLAG VALUE
502
+ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type)
503
+ {
504
+ char result[1024];
505
+ char *r = result;
506
+ if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
507
+ *(r++) = '_';
508
+ r = SWIG_PackData(r, ptr, sz);
509
+ strcpy(r, type->name);
510
+ return rb_str_new2(result);
511
+ }
512
+
513
+ /* Convert a packed pointer value */
514
+ WXRB_EXPORT_FLAG int
515
+ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty)
516
+ {
517
+ swig_cast_info *tc;
518
+ const char *c;
519
+
520
+ if (TYPE(obj) != T_STRING) goto type_error;
521
+ c = StringValuePtr(obj);
522
+ /* Pointer values must start with leading underscore */
523
+ if (*c != '_') goto type_error;
524
+ c++;
525
+ c = SWIG_UnpackData(c, ptr, sz);
526
+ if (ty)
527
+ {
528
+ tc = SWIG_TypeCheck(c, ty);
529
+ if (!tc) goto type_error;
530
+ }
531
+ return SWIG_OK;
532
+
533
+ type_error:
534
+ return SWIG_ERROR;
535
+ }
536
+
537
+ /* TypedData descriptor for the per-module runtime data. The struct name is
538
+ versioned so a module only ever reads runtime data written by a compatible
539
+ SWIG version. */
540
+ static const rb_data_type_t swig_runtime_data_type = {
541
+ "swig_runtime_data" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME,
542
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
543
+ { 0, 0, 0, 0, 0, {}},
544
+ #else
545
+ { 0, 0, 0, 0, {}},
546
+ #endif
547
+ 0, 0
548
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
549
+ , RUBY_TYPED_FREE_IMMEDIATELY
550
+ #endif
551
+ };
552
+
553
+ WXRB_EXPORT_FLAG swig_module_info *
554
+ SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata))
555
+ {
556
+ VALUE pointer;
557
+ swig_module_info *ret = 0;
558
+ VALUE verbose = rb_gv_get("VERBOSE");
559
+
560
+ /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */
561
+ rb_gv_set("VERBOSE", Qfalse);
562
+
563
+ /* first check if pointer already created */
564
+ pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
565
+ if (pointer != Qnil) {
566
+ /* Each module defines its own swig_runtime_data_type, so the data is read
567
+ directly rather than through TypedData_Get_Struct, which would reject a
568
+ wrapper created by another module's (equivalent) descriptor. */
569
+ if (!RB_TYPE_P(pointer, RUBY_T_DATA)) rb_check_typeddata(pointer, &swig_runtime_data_type);
570
+ ret = (swig_module_info *)RTYPEDDATA_GET_DATA(pointer);
571
+ }
572
+
573
+ /* reinstate warnings */
574
+ rb_gv_set("VERBOSE", verbose);
575
+ return ret;
576
+ }
577
+
578
+ WXRB_EXPORT_FLAG void
579
+ SWIG_Ruby_SetModule(swig_module_info *pointer)
580
+ {
581
+ /* register a new class - undefine its allocator before wrapping an instance,
582
+ otherwise wrapping marks the class as a T_DATA class and Ruby 3.x warns when
583
+ the allocator is undefined afterwards. The class still can not be instantiated
584
+ from Ruby. */
585
+ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
586
+ rb_undef_alloc_func(cl);
587
+ swig_runtime_data_type_pointer = TypedData_Wrap_Struct(cl, &swig_runtime_data_type, pointer);
588
+ /* create and store the structure pointer to a global variable */
589
+ rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
590
+ }
591
+
592
+ /* This function can be used to check whether a proc or method or similarly
593
+ callable function has been passed. Usually used in a %typecheck, like:
594
+
595
+ %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) {
596
+ $result = SWIG_Ruby_isCallable( $input );
597
+ }
598
+ */
599
+ WXRB_EXPORT_FLAG
600
+ int SWIG_Ruby_isCallable( VALUE proc )
601
+ {
602
+ if ( rb_respond_to( proc, swig_call_id ) )
603
+ return 1;
604
+ return 0;
605
+ }
606
+
607
+ /* This function can be used to check the arity (number of arguments)
608
+ a proc or method can take. Usually used in a %typecheck.
609
+ Valid arities will be that equal to minimal or those < 0
610
+ which indicate a variable number of parameters at the end.
611
+ */
612
+ WXRB_EXPORT_FLAG
613
+ int SWIG_Ruby_arity( VALUE proc, int minimal )
614
+ {
615
+ if ( rb_respond_to( proc, swig_arity_id ) )
616
+ {
617
+ VALUE num = rb_funcall2( proc, swig_arity_id, 0, 0 );
618
+ int arity = NUM2INT(num);
619
+ if ( arity < 0 && (arity+1) < -minimal ) return 1;
620
+ if ( arity == minimal ) return 1;
621
+ return 1;
622
+ }
623
+ return 0;
624
+ }
625
+
626
+
627
+ #ifdef __cplusplus
628
+ }
629
+ #endif