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
@@ -372,9 +372,9 @@ module WXRuby3
372
372
  fsrc.puts "WXRB_IMPORT_FLAG VALUE wxRuby_Core();" unless is_core?
373
373
  fsrc.puts
374
374
  if is_core?
375
- fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigrun.inc'))
375
+ fsrc << File.read(File.join(File.dirname(__FILE__), 'include', SwigRunner.swig_ruby_type, 'swigrun.inc'))
376
376
  fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigrubyerrors.inc'))
377
- fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigrubyrun.inc'))
377
+ fsrc << File.read(File.join(File.dirname(__FILE__), 'include', SwigRunner.swig_ruby_type, 'swigrubyrun.inc'))
378
378
  fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigdirector.inc'))
379
379
  fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'funcall.inc'))
380
380
  fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'enum.inc'))
@@ -24,6 +24,17 @@ module WXRuby3
24
24
  # wxDarkModeSettings does has have virt dtor; it's just not documented
25
25
  spec.suppress_warning(514, 'wxDarkModeSettings')
26
26
  end
27
+ if Config.instance.wx_version_check('3.3.4') >= 0
28
+ if Config.instance.features_set?('WXMSW')
29
+ spec.ignore('wxApp::MSWEnableDarkMode', ignore_doc: false)
30
+ spec.add_extend_code 'wxApp', <<~__HEREDOC
31
+ bool MSWEnableDarkMode(int flags = 0, wxDarkModeSettings* settings = nullptr)
32
+ {
33
+ return $self->MSWEnableDarkMode(static_cast<wxApp::DarkMode> (flags), settings);
34
+ }
35
+ __HEREDOC
36
+ end
37
+ end
27
38
  end
28
39
  spec.fold_bases('wxApp' => 'wxAppConsole', 'wxAppConsole' => 'wxEventFilter')
29
40
  spec.override_inheritance_chain('wxApp', %w[wxEvtHandler wxObject])
@@ -195,6 +206,11 @@ module WXRuby3
195
206
  << ' ' << StringValuePtr(msg) << '(' << StringValuePtr(err_name) << ')' << std::endl
196
207
  << "\\tfrom " << StringValuePtr(bt) << std::endl << std::endl;
197
208
  }
209
+
210
+ WXRUBY_EXPORT void wxRuby_RegisterDeferredObjectDestroy(void* object, void(*free)(void*))
211
+ {
212
+ wxRubyApp::wxRuby_RegisterDeferredObjectDestroy(object, free);
213
+ }
198
214
  __HEREDOC
199
215
  super
200
216
  end
@@ -88,7 +88,7 @@ module WXRuby3
88
88
  v_ret = rb_funcall(self, create_bitmap_id(), 3, v_id, v_client, v_size);
89
89
 
90
90
  if (v_ret != Qnil)
91
- return *((wxBitmap *)DATA_PTR(v_ret));
91
+ return *((wxBitmap *)WXRUBY_WRAPPER_DATA_PTR(v_ret));
92
92
  else
93
93
  return wxNullBitmap;
94
94
  }
@@ -106,7 +106,7 @@ module WXRuby3
106
106
  v_ret = rb_funcall(self, create_bitmap_bundle_id(), 3, v_id, v_client, v_size);
107
107
 
108
108
  if (v_ret != Qnil)
109
- return *((wxBitmapBundle *)DATA_PTR(v_ret));
109
+ return *((wxBitmapBundle *)WXRUBY_WRAPPER_DATA_PTR(v_ret));
110
110
  else
111
111
  return wxBitmapBundle();
112
112
  }
@@ -124,7 +124,7 @@ module WXRuby3
124
124
  v_ret = rb_funcall(self, create_icon_bundle_id(), 2, v_id, v_client);
125
125
 
126
126
  if (v_ret != Qnil)
127
- return *((wxIconBundle *)DATA_PTR(v_ret));
127
+ return *((wxIconBundle *)WXRUBY_WRAPPER_DATA_PTR(v_ret));
128
128
  else
129
129
  return wxIconBundle();
130
130
  }
@@ -16,6 +16,7 @@ module WXRuby3
16
16
 
17
17
  def setup
18
18
  super
19
+ spec.add_swig_code '%markfunc wxAuiMDIChildFrame "GC_mark_wxAuiMDIChildFrame";'
19
20
  spec.no_proxy 'wxAuiMDIChildFrame::Layout'
20
21
  # incorrectly documented non-existent virtual method
21
22
  # (does exist as non-virtual method in TopLevelWindow with return by value)
@@ -68,6 +69,29 @@ module WXRuby3
68
69
  }
69
70
  __CODE
70
71
  end
72
+ spec.add_header_code <<~__HEREDOC
73
+ WXRUBY_TRACE_GUARD(WxRubyTraceMarkAuiMDIChildFrame, "GC_MARK_AUI_MDI_CHILD_FRAME")
74
+ static void GC_mark_wxAuiMDIChildFrame(void* ptr)
75
+ {
76
+ WXRUBY_TRACE_IF(WxRubyTraceMarkAuiMDIChildFrame, 2)
77
+ WXRUBY_TRACE("> GC_mark_wxAuiMDIChildFrame : " << ptr)
78
+ WXRUBY_TRACE_END
79
+
80
+ if (GC_IsWindowDeleted(ptr)) return;
81
+
82
+ GC_mark_wxWindow(ptr);
83
+
84
+ wxAuiMDIChildFrame* wx_frame = reinterpret_cast<wxAuiMDIChildFrame*> (ptr);
85
+
86
+ // Mark attached menu bars
87
+ wxMenuBar* wx_mb = wx_frame->GetMenuBar();
88
+ rb_gc_mark(SWIG_RubyInstanceFor(wx_mb));
89
+
90
+ WXRUBY_TRACE_IF(WxRubyTraceMarkAuiMDIChildFrame, 2)
91
+ WXRUBY_TRACE("< GC_mark_wxAuiMDIChildFrame : " << ptr)
92
+ WXRUBY_TRACE_END
93
+ }
94
+ __HEREDOC
71
95
  end
72
96
  end # class AuiMDIChildFrame
73
97
 
@@ -23,8 +23,6 @@ module WXRuby3
23
23
  spec.suppress_warning(473, 'wxAuiMDIParentFrame::OnCreateClient')
24
24
  # for SetWindowMenu
25
25
  spec.disown 'wxMenu *'
26
- # for SetMenuBar
27
- spec.disown 'wxMenuBar *'
28
26
  end
29
27
  end # class AuiParentMDIFrame
30
28
 
@@ -46,10 +46,10 @@ module WXRuby3
46
46
 
47
47
  static const rb_data_type_t __wxAuiTabCtrl_type = {
48
48
  "AuiTabCtrl",
49
- #if RUBY_API_VERSION_MAJOR >= 3
50
- { NULL, NULL, __wxAuiTabCtrl_size, 0, {}},
49
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
50
+ { NULL, NULL, __wxAuiTabCtrl_size, 0, 0, {}},
51
51
  #else
52
- { NULL, NULL, __wxAuiTabCtrl_size, {}},
52
+ { NULL, NULL, __wxAuiTabCtrl_size, 0, {}},
53
53
  #endif
54
54
  NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
55
55
  };
@@ -51,17 +51,41 @@ module WXRuby3
51
51
  if (NIL_P(rb_cp_proxy))
52
52
  {
53
53
  cpp = new WxRubyComboPopup(popup);
54
+ // wrap the anonymously as we only use the Ruby object as a container for the C++ object
55
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
54
56
  rb_cp_proxy = Data_Wrap_Struct(rb_cObject, 0, 0, cpp);
57
+ #else
58
+ struct swig_ruby_wrapped_object *wrobj;
59
+ rb_cp_proxy = TypedData_Make_Struct(rb_cObject, struct swig_ruby_wrapped_object, &swig_type_data_type, wrobj);
60
+ wrobj->data = cpp;
61
+ #endif
55
62
  rb_iv_set(popup, "@_wx_combo_popup_proxy", rb_cp_proxy);
56
63
  }
57
64
  else
58
65
  {
59
- Data_Get_Struct(rb_cp_proxy, wxComboPopup, cpp);
66
+ cpp = WXRUBY_WRAPPER_DATA_GET(rb_cp_proxy, wxComboPopup);
60
67
  }
61
68
  }
62
69
  return cpp;
63
70
  }
64
71
 
72
+ #ifdef WXRUBY_SWIG_TYPED_DATA
73
+
74
+ static const rb_data_type_t wxruby_wx_combo_popup_data_type = {
75
+ "C++ wxComboPopup class",
76
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
77
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, 0, {}},
78
+ #else
79
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, {}},
80
+ #endif
81
+ 0, 0
82
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
83
+ , SWIG_RUBY_TYPED_DATA_FLAGS
84
+ #endif
85
+ };
86
+
87
+ #endif
88
+
65
89
  WXRUBY_EXPORT VALUE wxRuby_ComboPopupToRuby(wxComboPopup* cpp)
66
90
  {
67
91
  VALUE rb_cpp = Qnil;
@@ -77,7 +101,16 @@ module WXRuby3
77
101
  // in this case we're probably working for a wxOwnerDrawnComboBox or wxRichTextListbox
78
102
  // with default popup control which is a C++ implemented class without any Ruby linkage.
79
103
  // wrap this in the Wx::ComboPopupWx class to provide a Ruby interface
80
- rb_cpp = Data_Wrap_Struct(g_rb_cComboPopupWx, 0, 0, cpp); // do not own or track
104
+
105
+ // do not own or track
106
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
107
+ rb_cpp = Data_Wrap_Struct(g_rb_cComboPopupWx, 0, 0, cpp);
108
+ #else
109
+ struct swig_ruby_wrapped_object *wrobj;
110
+ rb_cpp = TypedData_Make_Struct(g_rb_cComboPopupWx, struct swig_ruby_wrapped_object, &wxruby_wx_combo_popup_data_type, wrobj);
111
+ wrobj->data = cpp;
112
+ #endif
113
+ rb_iv_set(rb_cpp, "@__swigtype__", rb_str_new2("ComboPopup"));
81
114
  }
82
115
  }
83
116
  return rb_cpp;
@@ -16,13 +16,44 @@ module WXRuby3
16
16
  super
17
17
  spec.items.clear
18
18
  spec.add_header_code <<~__HEREDOC
19
- #include "wxruby-Config.h"
20
19
  #include <limits>
21
20
 
22
21
  static const char * __iv_ConfigBase_sc_config = "@config";
23
22
 
24
23
  static WxRuby_ID s_use_hash_config_id("use_hash_config");
25
24
 
25
+ #ifdef WXRUBY_SWIG_TYPED_DATA
26
+
27
+ static const rb_data_type_t wxruby_config_wx_data_type = {
28
+ "ConfigWx",
29
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
30
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, 0, {}},
31
+ #else
32
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, {}},
33
+ #endif
34
+ 0, 0
35
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
36
+ , SWIG_RUBY_TYPED_DATA_FLAGS
37
+ #endif
38
+ };
39
+
40
+ static const rb_data_type_t wxruby_rb_hash_config_data_type = {
41
+ "Config",
42
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
43
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, 0, {}},
44
+ #else
45
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, {}},
46
+ #endif
47
+ 0, 0
48
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
49
+ , SWIG_RUBY_TYPED_DATA_FLAGS
50
+ #endif
51
+ };
52
+
53
+ #endif
54
+
55
+ #include "wxruby-Config.h"
56
+
26
57
  static void
27
58
  _free_config_wx(void* cfg)
28
59
  {
@@ -56,7 +87,14 @@ module WXRuby3
56
87
  if (cfg)
57
88
  {
58
89
  // wrap the C++ config object
90
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
59
91
  curConfig = Data_Wrap_Struct(g_cConfigWx, 0, 0, cfg);
92
+ #else
93
+ struct swig_ruby_wrapped_object *wrobj;
94
+ curConfig = TypedData_Make_Struct(g_cConfigWx, struct swig_ruby_wrapped_object, &wxruby_config_wx_data_type, wrobj);
95
+ wrobj->data = cfg;
96
+ #endif
97
+ rb_iv_set(curConfig, "@__swigtype__", rb_str_new2("ConfigWx"));
60
98
  // store global ConfigBase instance as Ruby instance variable of ConfigBase singleton class
61
99
  rb_iv_set(cConfigBase_Singleton, __iv_ConfigBase_sc_config, curConfig);
62
100
  }
@@ -121,7 +159,14 @@ module WXRuby3
121
159
  if (config) wxConfigBase::Set(nullptr); // reset
122
160
  wxConfigBase* new_cfg = wxConfigBase::Create(); // create new C++ instance
123
161
  // wrap the C++ config object
162
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
124
163
  curConfig = Data_Wrap_Struct(g_cConfigWx, 0, 0, new_cfg);
164
+ #else
165
+ struct swig_ruby_wrapped_object *wrobj;
166
+ curConfig = TypedData_Make_Struct(g_cConfigWx, struct swig_ruby_wrapped_object, &wxruby_config_wx_data_type, wrobj);
167
+ wrobj->data = new_cfg;
168
+ #endif
169
+ rb_iv_set(curConfig, "@__swigtype__", rb_str_new2("ConfigWx"));
125
170
  }
126
171
  // store global ConfigBase instance as Ruby instance variable of ConfigBase singleton class
127
172
  // (keeps it safe from GC)
@@ -140,7 +185,14 @@ module WXRuby3
140
185
  {
141
186
  // no global Ruby instance known so can't be wrapped yet (must be C++ instance than)
142
187
  // wrap the C++ config object
188
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
143
189
  curConfig = Data_Wrap_Struct(g_cConfigWx, 0, 0, config);
190
+ #else
191
+ struct swig_ruby_wrapped_object *wrobj;
192
+ curConfig = TypedData_Make_Struct(g_cConfigWx, struct swig_ruby_wrapped_object, &wxruby_config_wx_data_type, wrobj);
193
+ wrobj->data = config;
194
+ #endif
195
+ rb_iv_set(curConfig, "@__swigtype__", rb_str_new2("ConfigWx"));
144
196
  // store global ConfigBase instance as Ruby instance variable of ConfigBase singleton class
145
197
  // (keeps it safe from GC)
146
198
  rb_iv_set(cConfigBase_Singleton, __iv_ConfigBase_sc_config, curConfig);
@@ -180,7 +232,7 @@ module WXRuby3
180
232
  {
181
233
  // need to make config Ruby owned to it gets proper GC handling
182
234
  // and the C++ allocated config instance gets destroyed
183
- RDATA(curConfig)->dfree = _free_config_wx;
235
+ WXRUBY_WRAPPER_DATA_DFREE_SET(curConfig, _free_config_wx);
184
236
  }
185
237
 
186
238
  return curConfig; // return old config (if any)
@@ -202,8 +254,7 @@ module WXRuby3
202
254
 
203
255
  static VALUE config_wx_read(int argc, VALUE *argv, VALUE self)
204
256
  {
205
- wxConfigBase *cfg;
206
- Data_Get_Struct(self, wxConfigBase, cfg);
257
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
207
258
 
208
259
  if (argc < 1 || argc > 1)
209
260
  {
@@ -257,8 +308,7 @@ module WXRuby3
257
308
 
258
309
  static VALUE config_wx_write(int argc, VALUE *argv, VALUE self)
259
310
  {
260
- wxConfigBase *cfg;
261
- Data_Get_Struct(self, wxConfigBase, cfg);
311
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
262
312
 
263
313
  if (argc < 2 || argc > 2)
264
314
  {
@@ -325,8 +375,7 @@ module WXRuby3
325
375
 
326
376
  static VALUE config_wx_for_path(int argc, VALUE *argv, VALUE self)
327
377
  {
328
- wxConfigBase *cfg;
329
- Data_Get_Struct(self, wxConfigBase, cfg);
378
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
330
379
 
331
380
  if (argc < 1 || argc > 1)
332
381
  {
@@ -345,8 +394,7 @@ module WXRuby3
345
394
 
346
395
  static VALUE config_wx_delete(int argc, VALUE *argv, VALUE self)
347
396
  {
348
- wxConfigBase *cfg;
349
- Data_Get_Struct(self, wxConfigBase, cfg);
397
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
350
398
 
351
399
  if (argc < 1 || argc > 1)
352
400
  {
@@ -367,8 +415,7 @@ module WXRuby3
367
415
 
368
416
  static VALUE config_wx_rename(int argc, VALUE *argv, VALUE self)
369
417
  {
370
- wxConfigBase *cfg;
371
- Data_Get_Struct(self, wxConfigBase, cfg);
418
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
372
419
 
373
420
  if (argc < 2 || argc > 2)
374
421
  {
@@ -390,8 +437,7 @@ module WXRuby3
390
437
 
391
438
  static VALUE config_wx_each_entry(int argc, VALUE *argv, VALUE self)
392
439
  {
393
- wxConfigBase *cfg;
394
- Data_Get_Struct(self, wxConfigBase, cfg);
440
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
395
441
 
396
442
  if (argc < 0 || argc > 0)
397
443
  {
@@ -415,8 +461,7 @@ module WXRuby3
415
461
 
416
462
  static VALUE config_wx_each_group(int argc, VALUE *argv, VALUE self)
417
463
  {
418
- wxConfigBase *cfg;
419
- Data_Get_Struct(self, wxConfigBase, cfg);
464
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
420
465
 
421
466
  if (argc < 0 || argc > 0)
422
467
  {
@@ -440,8 +485,7 @@ module WXRuby3
440
485
 
441
486
  static VALUE config_wx_number_of_entries(int argc, VALUE *argv, VALUE self)
442
487
  {
443
- wxConfigBase *cfg;
444
- Data_Get_Struct(self, wxConfigBase, cfg);
488
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
445
489
 
446
490
  if (argc < 0 || argc > 2)
447
491
  {
@@ -454,8 +498,7 @@ module WXRuby3
454
498
 
455
499
  static VALUE config_wx_number_of_groups(int argc, VALUE *argv, VALUE self)
456
500
  {
457
- wxConfigBase *cfg;
458
- Data_Get_Struct(self, wxConfigBase, cfg);
501
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
459
502
 
460
503
  if (argc < 0 || argc > 2)
461
504
  {
@@ -468,8 +511,7 @@ module WXRuby3
468
511
 
469
512
  static VALUE config_wx_has_entry(int argc, VALUE *argv, VALUE self)
470
513
  {
471
- wxConfigBase *cfg;
472
- Data_Get_Struct(self, wxConfigBase, cfg);
514
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
473
515
 
474
516
  if (argc < 1 || argc > 1)
475
517
  {
@@ -481,8 +523,7 @@ module WXRuby3
481
523
 
482
524
  static VALUE config_wx_has_group(int argc, VALUE *argv, VALUE self)
483
525
  {
484
- wxConfigBase *cfg;
485
- Data_Get_Struct(self, wxConfigBase, cfg);
526
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
486
527
 
487
528
  if (argc < 1 || argc > 1)
488
529
  {
@@ -494,8 +535,7 @@ module WXRuby3
494
535
 
495
536
  static VALUE config_wx_path(int argc, VALUE *argv, VALUE self)
496
537
  {
497
- wxConfigBase *cfg;
498
- Data_Get_Struct(self, wxConfigBase, cfg);
538
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
499
539
 
500
540
  if (argc < 0 || argc > 2)
501
541
  {
@@ -506,8 +546,7 @@ module WXRuby3
506
546
 
507
547
  static VALUE config_wx_clear(int argc, VALUE *argv, VALUE self)
508
548
  {
509
- wxConfigBase *cfg;
510
- Data_Get_Struct(self, wxConfigBase, cfg);
549
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
511
550
 
512
551
  if (argc < 0 || argc > 2)
513
552
  {
@@ -518,8 +557,7 @@ module WXRuby3
518
557
 
519
558
  static VALUE config_wx_is_expanding_env_vars(int argc, VALUE *argv, VALUE self)
520
559
  {
521
- wxConfigBase *cfg;
522
- Data_Get_Struct(self, wxConfigBase, cfg);
560
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
523
561
 
524
562
  if (argc != 0)
525
563
  {
@@ -530,8 +568,7 @@ module WXRuby3
530
568
 
531
569
  static VALUE config_wx_set_expand_env_vars(int argc, VALUE *argv, VALUE self)
532
570
  {
533
- wxConfigBase *cfg;
534
- Data_Get_Struct(self, wxConfigBase, cfg);
571
+ wxConfigBase *cfg = WXRUBY_WRAPPER_DATA_GET(self, wxConfigBase);
535
572
 
536
573
  if (argc < 1 || argc > 1)
537
574
  {
@@ -561,7 +598,16 @@ module WXRuby3
561
598
  config_allocate(int argc, VALUE *argv, VALUE self)
562
599
  #endif
563
600
  {
564
- VALUE vresult = Data_Wrap_Struct(g_cConfig, 0, _free_config, 0);
601
+ VALUE vresult;
602
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
603
+ vresult = Data_Wrap_Struct(g_cConfig, 0, _free_config, 0);
604
+ #else
605
+ struct swig_ruby_wrapped_object *wrobj;
606
+ vresult = TypedData_Make_Struct(g_cConfig, struct swig_ruby_wrapped_object, &wxruby_rb_hash_config_data_type, wrobj);
607
+ wrobj->data = 0;
608
+ wrobj->dfree = _free_config;
609
+ #endif
610
+ rb_iv_set(vresult, "@__swigtype__", rb_str_new2("Config"));
565
611
  #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
566
612
  rb_obj_call_init(vresult, argc, argv);
567
613
  #endif
@@ -82,7 +82,7 @@ module WXRuby3
82
82
  for (VALUE data_obj : do_list)
83
83
  {
84
84
  WXRUBY_TRACE_IF(WxRubyTraceGCCompositeDataObject, 2)
85
- WXRUBY_TRACE_WITH(void *c_ptr = (TYPE(data_obj) == T_DATA ? DATA_PTR(data_obj) : 0))
85
+ WXRUBY_TRACE_WITH(void *c_ptr = (WXRUBY_HAS_WRAPPED_DATA(data_obj) ? WXRUBY_WRAPPER_DATA_PTR(data_obj) : 0))
86
86
  WXRUBY_TRACE("| GC_mark_wxCompositeDataObject : " << it->first << "|" << (void*)c_ptr)
87
87
  WXRUBY_TRACE_END
88
88
 
@@ -46,8 +46,7 @@ module WXRuby3
46
46
 
47
47
  static VALUE wxRuby_WXDT2RBT(VALUE rbdt)
48
48
  {
49
- wxDateTime* wxdt = 0;
50
- Data_Get_Struct(rbdt, wxDateTime, wxdt);
49
+ wxDateTime* wxdt = WXRUBY_WRAPPER_DATA_GET(rbdt, wxDateTime);
51
50
  int year = wxdt->GetYear();
52
51
  VALUE y = INT2NUM(year);
53
52
  VALUE mon = INT2NUM(wxdt->GetMonth() + 1);
@@ -67,7 +66,15 @@ module WXRuby3
67
66
  // depending on the timezone, the local January the first 1970 may be out of range.
68
67
  // for 2038 not the entire year is available in the numerical representation.
69
68
  void* ptr = const_cast<wxDateTime*> (&dt);
70
- VALUE rbdt = Data_Wrap_Struct(rb_cObject, 0, 0, ptr);
69
+ VALUE rbdt;
70
+ // wrap the wxDateTime* anonymously (we only want to temporarily pass it here to the conversion method)
71
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
72
+ rbdt = Data_Wrap_Struct(rb_cObject, 0, 0, ptr);
73
+ #else
74
+ struct swig_ruby_wrapped_object *wrobj;
75
+ rbdt = TypedData_Make_Struct(rb_cObject, struct swig_ruby_wrapped_object, &swig_type_data_type, wrobj);
76
+ wrobj->data = ptr;
77
+ #endif
71
78
  ruby_value = rb_rescue2(VALUEFUNC(wxRuby_WXDT2RBT), rbdt, VALUEFUNC(rescue), Qnil, rb_eException, 0);
72
79
  if (ruby_value == Qnil)
73
80
  {
@@ -84,13 +84,22 @@ module WXRuby3
84
84
  swig_type_info* type = wxRuby_GetSwigTypeForClass(rb_event_class);
85
85
  swig_class* class_info = (swig_class*)type->clientdata;
86
86
  // Create a new (owned) Ruby event object
87
- VALUE rb_evt = Data_Wrap_Struct(class_info->klass, VOIDFUNC(class_info->mark),
88
- VOIDFUNC(class_info->destroy),
89
- wx_evt);
90
- // track new event object
91
- SWIG_RubyAddTracking(wx_evt, rb_evt);
87
+ VALUE rb_evt;
88
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
89
+ rb_evt = Data_Wrap_Struct(class_info->klass, VOIDFUNC(class_info->mark),
90
+ VOIDFUNC(class_info->destroy),
91
+ wx_evt);
92
+ #else
93
+ struct swig_ruby_wrapped_object *wrobj;
94
+ rb_evt = TypedData_Make_Struct(class_info->klass, struct swig_ruby_wrapped_object, &class_info->cext_type, wrobj);
95
+ wrobj->data = wx_evt;
96
+ wrobj->dmark = class_info->mark;
97
+ wrobj->dfree = class_info->destroy;
98
+ #endif
92
99
  // do not forget to mark the instance with the mangled swig type name
93
100
  rb_iv_set(rb_evt, "@__swigtype__", rb_str_new2(type->name));
101
+ // track new event object
102
+ SWIG_RubyAddTracking(wx_evt, rb_evt);
94
103
 
95
104
  WXRUBY_TRACE_IF(WxRubyTraceGCWrapEvents, 2)
96
105
  WXRUBY_TRACE("< wxRuby_WrapClonedWxEvent - wrapped cloned event " << wx_evt << "{" << type->name << "}")
@@ -129,7 +138,7 @@ module WXRuby3
129
138
  VALUE r_obj = SWIG_RubyInstanceFor((void *)this);
130
139
  VALUE r_obj_dup = rb_obj_clone(r_obj);
131
140
 
132
- DATA_PTR(r_obj_dup) = wx_ev;
141
+ WXRUBY_WRAPPER_DATA_PTR_SET(r_obj_dup, wx_ev);
133
142
  wxRuby_AddTracking( (void*)wx_ev, r_obj_dup );
134
143
  return wx_ev;
135
144
  }
@@ -203,7 +212,7 @@ module WXRuby3
203
212
  VALUE r_obj = SWIG_RubyInstanceFor((void *)this);
204
213
  VALUE r_obj_dup = rb_obj_clone(r_obj);
205
214
 
206
- DATA_PTR(r_obj_dup) = wx_ev;
215
+ WXRUBY_WRAPPER_DATA_PTR_SET(r_obj_dup, wx_ev);
207
216
  wxRuby_AddTracking( (void*)wx_ev, r_obj_dup );
208
217
  return wx_ev;
209
218
  }
@@ -53,7 +53,7 @@ module WXRuby3
53
53
  # User defined events however need to maintain their tracking register as we need to keep
54
54
  # the state of the linked Ruby objects. As WxW will clean up later we can however release ownership.
55
55
  map_in code: <<~__CODE
56
- $1 = (wxEvent*)DATA_PTR($input);
56
+ $1 = (wxEvent*)WXRUBY_WRAPPER_DATA_PTR($input);
57
57
  if (!wxRuby_Is_RubyEvent($1))
58
58
  {
59
59
  SWIG_RubyUnlinkObjects((void*)$1);
@@ -62,7 +62,7 @@ module WXRuby3
62
62
  else
63
63
  {
64
64
  // no need to do anything as c++ dtor will untrack/unlink
65
- RDATA($input)->dfree = 0;
65
+ WXRUBY_WRAPPER_DATA_DFREE_RESET($input);
66
66
  }
67
67
  __CODE
68
68
  end
@@ -234,6 +234,23 @@ module WXRuby3
234
234
  static void GC_mark_AsyncMethodCallEvent(void *ptr);
235
235
  static void free_AsyncMethodCallEvent(void *ptr);
236
236
 
237
+ #ifdef WXRUBY_SWIG_TYPED_DATA
238
+
239
+ static const rb_data_type_t wxruby_async_call_event_data_type = {
240
+ "RbAsyncProcCallEvent",
241
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
242
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, 0, {}},
243
+ #else
244
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, {}},
245
+ #endif
246
+ 0, 0
247
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
248
+ , SWIG_RUBY_TYPED_DATA_FLAGS
249
+ #endif
250
+ };
251
+
252
+ #endif
253
+
237
254
  class RbAsyncProcCallEvent : public wxAsyncMethodCallEvent
238
255
  {
239
256
  public:
@@ -256,10 +273,21 @@ module WXRuby3
256
273
  {
257
274
  RbAsyncProcCallEvent* wx_ev = new RbAsyncProcCallEvent(*this);
258
275
  // Create a new Ruby event object (owned)
259
- VALUE rb_evt = Data_Wrap_Struct(WxRuby_GetAsyncProcCallEvent_Class(),
260
- VOIDFUNC(GC_mark_AsyncMethodCallEvent),
261
- VOIDFUNC(free_AsyncMethodCallEvent),
262
- wx_ev);
276
+ VALUE rb_evt;
277
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
278
+ rb_evt = Data_Wrap_Struct(WxRuby_GetAsyncProcCallEvent_Class(),
279
+ VOIDFUNC(GC_mark_AsyncMethodCallEvent),
280
+ VOIDFUNC(free_AsyncMethodCallEvent),
281
+ wx_ev);
282
+ #else
283
+ struct swig_ruby_wrapped_object *wrobj;
284
+ rb_evt = TypedData_Make_Struct(WxRuby_GetAsyncProcCallEvent_Class(), struct swig_ruby_wrapped_object,
285
+ &wxruby_async_call_event_data_type, wrobj);
286
+ wrobj->data = wx_ev;
287
+ wrobj->dmark = GC_mark_AsyncMethodCallEvent;
288
+ wrobj->dfree = free_AsyncMethodCallEvent;
289
+ #endif
290
+ rb_iv_set(rb_evt, "@__swigtype__", rb_str_new2("RbAsyncProcCallEvent"));
263
291
  wxRuby_AddTracking( (void*)wx_ev, rb_evt);
264
292
  return wx_ev;
265
293
  }
@@ -398,10 +426,20 @@ module WXRuby3
398
426
  // create C++ event
399
427
  RbAsyncProcCallEvent * evt = new RbAsyncProcCallEvent(self, call);
400
428
  // Create a new Ruby event object (leave ownership to wxWidgets C++)
401
- VALUE rb_evt = Data_Wrap_Struct(WxRuby_GetAsyncProcCallEvent_Class(),
402
- VOIDFUNC(GC_mark_AsyncMethodCallEvent),
403
- 0,
404
- evt);
429
+ VALUE rb_evt;
430
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
431
+ rb_evt = Data_Wrap_Struct(WxRuby_GetAsyncProcCallEvent_Class(),
432
+ VOIDFUNC(GC_mark_AsyncMethodCallEvent),
433
+ 0,
434
+ evt);
435
+ #else
436
+ struct swig_ruby_wrapped_object *wrobj;
437
+ rb_evt = TypedData_Make_Struct(WxRuby_GetAsyncProcCallEvent_Class(), struct swig_ruby_wrapped_object,
438
+ &wxruby_async_call_event_data_type, wrobj);
439
+ wrobj->data = evt;
440
+ wrobj->dmark = GC_mark_AsyncMethodCallEvent;
441
+ #endif
442
+ rb_iv_set(rb_evt, "@__swigtype__", rb_str_new2("RbAsyncProcCallEvent"));
405
443
  // track it and the call object
406
444
  wxRuby_AddTracking( (void*)evt, rb_evt);
407
445
  // queue it (wxWidgets takes ownership of C++ event object)
@@ -30,10 +30,12 @@ module WXRuby3
30
30
  spec.items.concat %w[wxMouseCaptureChangedEvent wxMouseCaptureLostEvent wxDisplayChangedEvent]
31
31
  end
32
32
  spec.fold_bases('wxMouseEvent' => %w[wxMouseState wxKeyboardState], 'wxKeyEvent' => 'wxKeyboardState')
33
- spec.ignore 'wxShowEvent::GetShow', 'wxIconizeEvent::Iconized'
33
+ if Config.instance.wx_version_check('3.3.4') < 0
34
+ spec.ignore 'wxShowEvent::GetShow'
35
+ end
36
+ spec.ignore 'wxIconizeEvent::Iconized'
34
37
  spec.ignore 'wxKeyEvent::GetPosition(wxCoord *,wxCoord *) const'
35
38
  spec.ignore 'wxMouseState::GetPosition(int *,int *)'
36
- spec.ignore 'wxShowEvent::GetShow', 'wxIconizeEvent::Iconized'
37
39
  spec.do_not_generate(:variables, :defines, :enums, :functions)
38
40
  end
39
41