wxruby3 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d56d06b3a74584ca43ec7314bc816c34175dbb7c68d722dfb88f2d1702dc295b
4
- data.tar.gz: 60d6432e98d834f8eaea4e0e13c8a2bed3fd8a9419cc6331d74c945f9695d223
3
+ metadata.gz: 4bac7565182a0ae6badaee56d7b323459bdc2b198281a50639fafd6fcb2d2499
4
+ data.tar.gz: 5dc08857adaf213871ec7fce09117bac4cc19f00cac50638de552dc2219ea803
5
5
  SHA512:
6
- metadata.gz: ef773e93094cfad19757c3d7ecfed29135d920a9f4e810521eadd6b226b8e13a10a735763853c1061d0256ce5fc84a2d5b0c28810874c99443c2a3e2548b753d
7
- data.tar.gz: 92df4dfe100a6ec2c4353451d237a1a1819ac2777ac1fdbc9a4a8e6cb4996e8fc3254454582a5465e97c7613eaebca4a29e26935c87286798c24c5d235ef2d36
6
+ metadata.gz: cbd4920bcc8ae2085ed85b49ee218642c1eb8a58c6bae7132fd653f479e5af6a60c716f61a9ad38bfdcc5cdc1e3560eb4152365127414bf0c401f266b39228c9
7
+ data.tar.gz: 60bba874185fe173a83d8878e458721a3f3fe58cbf484be2826c100a6009dff062972af7ecbaa9bc7dd3095d100aafdf326ac2dd994e1e50e7939654673d2466
@@ -42,6 +42,14 @@
42
42
  * wxWidgets we define our own.
43
43
  */
44
44
 
45
+ #if defined(__GNUC__)
46
+ # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
47
+ # ifndef GCC_HASCLASSVISIBILITY
48
+ # define GCC_HASCLASSVISIBILITY
49
+ # endif
50
+ # endif
51
+ #endif
52
+
45
53
  #ifndef WXRB_EXPORT_FLAG
46
54
  # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
47
55
  # if defined(WXRUBY_STATIC_BUILD)
data/lib/wx/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # This software is released under the MIT license.
4
4
 
5
5
  module Wx
6
- WXRUBY_VERSION = '1.0.1'
6
+ WXRUBY_VERSION = '1.2.0'
7
7
  end
data/rakelib/build.rb CHANGED
@@ -55,8 +55,18 @@ if WXRuby3.is_bootstrapped?
55
55
  pkg.generate_initializer
56
56
  end
57
57
 
58
- # Target to run the linker to create a final .so/.dll wxruby3 package library
59
- file pkg.lib_target => [*pkg.all_obj_files, *pkg.dep_libs] do | t |
58
+ # only for MacOSX
59
+ file pkg.initializer_loader_src => pkg.initializer_src do
60
+ pkg.generate_initializer_loader
61
+ end
62
+
63
+ # Target to run the linker to create a final wxruby package shared library (MacOSX only)
64
+ file pkg.shlib_target => [*pkg.all_obj_files, *pkg.dep_libs] do |t|
65
+ WXRuby3.config.do_shlib_link(pkg)
66
+ end
67
+
68
+ # Target to run the linker to create a final .so/.dll/.bundle wxruby3 package library
69
+ file pkg.lib_target => pkg.lib_target_deps do | t |
60
70
  WXRuby3.config.do_link(pkg)
61
71
  end
62
72
 
data/rakelib/install.rb CHANGED
@@ -152,7 +152,10 @@ module WXRuby3
152
152
  [File.join(WXRuby3.config.get_cfg_string('siterubyver'), 'wx'), ['lib/wx'], 0644],
153
153
  ]
154
154
  # add wxRuby shared libraries
155
- WXRuby3::Director.each_package { |pkg| specs << [WXRuby3.config.get_cfg_string('siterubyverarch'), [pkg.lib_target], 0555] }
155
+ WXRuby3::Director.each_package do |pkg|
156
+ specs << [WXRuby3.config.get_cfg_string('siterubyverarch'), [pkg.lib_target], 0555]
157
+ specs << [WXRuby3.config.get_cfg_string('siterubyverarch'), [pkg.lib_target.sub(/\.#{WXRuby3.config.dll_ext}\Z/, '.dylib')], 0555] if WXRuby3.config.macosx?
158
+ end
156
159
  if WXRuby3.config.get_config('with-wxwin')
157
160
  specs << [WXRuby3.config.get_cfg_string('siterubyverarch'), Install.wxwin_shlibs, 0555]
158
161
  end
@@ -46,6 +46,19 @@ module WXRuby3
46
46
  end
47
47
  protected :patch_rpath
48
48
 
49
+ # add deployment lookup paths for wxruby shared libraries
50
+ # and make loadpath for initializer dylibs relative
51
+ def update_shlib_loadpaths(shlib)
52
+ # in case of a .bundle library
53
+ if /\.bundle\Z/ =~ shlib
54
+ # change the full path of the complementary initializer .dylib to a path relative to any rpath-s
55
+ dylib = "lib#{File.basename(shlib, '.bundle')}.dylib"
56
+ dylib_path = File.expand_path(File.join(Config.instance.dest_dir, dylib))
57
+ sh("install_name_tool -change #{dylib_path} '@rpath/#{dylib}' #{shlib}")
58
+ end
59
+ super
60
+ end
61
+
49
62
  # add Ruby library path for wxruby shared libraries
50
63
  def update_shlib_ruby_libpath(shlib)
51
64
  # fix lookup for the Ruby shared library
@@ -123,10 +136,23 @@ module WXRuby3
123
136
  wx_libset.collect { |s| s.dup }
124
137
  end
125
138
 
126
- def do_link(pkg)
139
+ def do_shlib_link(pkg)
127
140
  objs = pkg.all_obj_files.collect { |o| File.join('..', o) }.join(' ') + ' '
128
- sh "cd lib && #{WXRuby3.config.ld} #{WXRuby3.config.ldflags(pkg.lib_target)} #{objs} " +
129
- "#{WXRuby3.config.libs} #{WXRuby3.config.link_output_flag}#{pkg.lib_target}"
141
+ depsh = pkg.dep_libs.join(' ')
142
+ ldsh = WXRuby3.config.ld.sub(/-bundle/, '')
143
+ ldsh.sub!(/-dynamic/, '-dynamiclib')
144
+ sh "cd lib && " +
145
+ "#{ldsh} #{WXRuby3.config.ldflags(pkg.lib_target)} #{objs} #{depsh} " +
146
+ "#{WXRuby3.config.libs} #{WXRuby3.config.link_output_flag}#{pkg.shlib_target}",
147
+ fail_on_error: true
148
+ end
149
+
150
+ def do_link(pkg)
151
+ sh "cd lib && " +
152
+ "#{WXRuby3.config.ld} #{WXRuby3.config.ldflags(pkg.lib_target)} #{File.join('..', pkg.init_obj_file)} " +
153
+ "-L. -l#{pkg.libname} " +
154
+ "#{WXRuby3.config.libs} #{WXRuby3.config.link_output_flag}#{pkg.lib_target}",
155
+ fail_on_error: true
130
156
  end
131
157
 
132
158
  private
@@ -151,15 +177,14 @@ module WXRuby3
151
177
 
152
178
  if @wx_version
153
179
  @cpp.sub!(/-std=gnu\+\+11/, '-std=gnu++14')
154
- @ld.sub!(/-o\s*\Z/, '')
180
+ # on Mac OSX this differs from the wxWidgets linking setup
181
+ @ld = RB_CONFIG['LDSHAREDXX'] || 'g++ -std=gnu++14 -dynamic -bundle'
182
+ @ld.sub!(/-std=gnu\+\+11/, '-std=gnu++14')
155
183
 
156
184
  @extra_cflags.concat %w[-Wno-unused-function -Wno-conversion-null -Wno-sometimes-uninitialized
157
185
  -Wno-overloaded-virtual -Wno-deprecated-copy]
158
186
  @extra_cflags << ' -Wno-deprecated-declarations' unless @no_deprecated
159
187
 
160
- # create a .dylib binary
161
- @extra_ldflags << '-dynamic -bundle'
162
-
163
188
  unless @wx_path.empty?
164
189
  libdirs = @wx_libs.select {|s| s.start_with?('-L')}.collect {|s| s.sub(/^-L/,'')}
165
190
  @exec_env['DYLD_LIBRARY_PATH'] = "#{ENV['DYLD_LIBRARY_PATH']}:#{dest_dir}:#{libdirs.join(':')}"
@@ -218,10 +218,6 @@ module WXRuby3
218
218
  @ruby_libs << "-L#{RB_CONFIG['libdir']}" # add ruby lib dir
219
219
  # add ruby defined shared ruby lib(s); not any other flags
220
220
  @ruby_libs.concat RB_CONFIG['LIBRUBYARG_SHARED'].split(' ').select { |s| s.start_with?('-l')}
221
-
222
- # maintain minimum compatibility with ABI 3.0.1
223
- @wx_abi_version = [ @wx_version, "3.0.1" ].min
224
- @wx_cppflags << "-DwxABI_VERSION=%s" % @wx_abi_version.tr(".", "0")
225
221
  end
226
222
  end
227
223
  end
@@ -728,10 +728,6 @@ module WXRuby3
728
728
  @wx_version || ''
729
729
  end
730
730
 
731
- def wx_abi_version
732
- @wx_abi_version || ''
733
- end
734
-
735
731
  def mingw?
736
732
  @platform == :mingw
737
733
  end
@@ -69,6 +69,10 @@ module WXRuby3
69
69
  File.join(Config.instance.dest_dir, "#{libname}.#{Config.instance.dll_ext}")
70
70
  end
71
71
 
72
+ def shlib_target
73
+ Config.instance.macosx? ? File.join(Config.instance.dest_dir, "lib#{libname}.dylib") : nil
74
+ end
75
+
72
76
  def package(pkgname)
73
77
  subpackages[pkgname] ||= Package.new(pkgname, self)
74
78
  end
@@ -110,11 +114,20 @@ module WXRuby3
110
114
  directors.select { |dir| Package.full_docs? || !Config.instance.excluded_module?(dir.spec) }
111
115
  end
112
116
 
113
- def director_for_class(class_name)
114
- dir = included_directors.detect { |dir| dir.spec.module_name == class_name || dir.spec.items.include?(class_name) }
115
- subpackages.each_value.detect { |spkg| dir = spkg.director_for_class(class_name) } if dir.nil?
116
- dependencies.detect { |pkgdep| dir = pkgdep.director_for_class(class_name) } if dir.nil?
117
- dir = parent.director_for_class(class_name) if dir.nil? && parent
117
+ def director_for_class(class_name, pkg_stack=[])
118
+ dir = included_directors.detect { |dir| dir.spec.module_name == class_name || dir.spec.items.include?(dir.spec.classdef_name(class_name)) }
119
+ pkg_stack << self
120
+ subpackages.each_value.detect do |spkg|
121
+ unless pkg_stack.include?(spkg) # should never happen
122
+ dir = spkg.director_for_class(class_name, pkg_stack)
123
+ end
124
+ end if dir.nil?
125
+ dependencies.detect do |pkgdep|
126
+ unless pkg_stack.include?(pkgdep)
127
+ dir = pkgdep.director_for_class(class_name)
128
+ end
129
+ end if dir.nil?
130
+ dir = parent.director_for_class(class_name) if dir.nil? && parent && !pkg_stack.include?(parent)
118
131
  dir
119
132
  end
120
133
 
@@ -156,9 +169,30 @@ module WXRuby3
156
169
  @all_obj_files
157
170
  end
158
171
 
172
+ # only used for MacOSX
173
+ def init_obj_file
174
+ if Config.instance.macosx?
175
+ File.join(Config.instance.obj_dir, "#{libname}_init_loader.#{Config.instance.obj_ext}")
176
+ else
177
+ File.join(Config.instance.obj_dir, "#{libname}_init.#{Config.instance.obj_ext}")
178
+ end
179
+ end
180
+
181
+ def lib_target_deps
182
+ if Config.instance.macosx?
183
+ [init_obj_file, shlib_target, *dep_libs]
184
+ else
185
+ [*all_obj_files, *dep_libs]
186
+ end
187
+ end
188
+
159
189
  def dep_libs
160
190
  if parent
161
- parent.dep_libs + [File.join(Config.instance.dest_dir, "#{parent.libname}.#{Config.instance.dll_ext}")]
191
+ parent.dep_libs + if Config.instance.macosx?
192
+ [parent.shlib_target]
193
+ else
194
+ [parent.lib_target]
195
+ end
162
196
  else
163
197
  []
164
198
  end
@@ -176,6 +210,11 @@ module WXRuby3
176
210
  File.join(Config.instance.src_dir, "#{libname}_init.cpp")
177
211
  end
178
212
 
213
+ # only for MacOSX
214
+ def initializer_loader_src
215
+ File.join(Config.instance.src_dir, "#{libname}_init_loader.cpp")
216
+ end
217
+
179
218
  def is_dir_with_fulfilled_deps?(dir, cls_set)
180
219
  if (modreg = Spec.module_registry[dir.spec.module_name]) && !modreg.empty?
181
220
  # check if all base classes are defined previously or part of the same director or outside the current package
@@ -286,6 +325,14 @@ module WXRuby3
286
325
  fsrc.puts '#include <ruby.h>'
287
326
  fsrc.puts '#include <ruby/version.h>'
288
327
  fsrc.puts <<~__HEREDOC
328
+ #if defined(__GNUC__)
329
+ # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
330
+ # ifndef GCC_HASCLASSVISIBILITY
331
+ # define GCC_HASCLASSVISIBILITY
332
+ # endif
333
+ # endif
334
+ #endif
335
+
289
336
  #ifndef WXRB_EXPORT_FLAG
290
337
  # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
291
338
  # if defined(WXRUBY_STATIC_BUILD)
@@ -338,7 +385,11 @@ module WXRuby3
338
385
  fsrc.puts '#ifdef __cplusplus'
339
386
  fsrc.puts 'extern "C"'
340
387
  fsrc.puts '#endif'
341
- fsrc.puts "WXRB_EXPORT_FLAG void Init_#{libname}()"
388
+ if Config.instance.macosx?
389
+ fsrc.puts "WXRB_EXPORT_FLAG void wxruby_init_#{libname}()"
390
+ else
391
+ fsrc.puts "WXRB_EXPORT_FLAG void Init_#{libname}()"
392
+ end
342
393
  fsrc.puts '{'
343
394
  fsrc.indent do
344
395
  fsrc.puts 'static bool initialized;'
@@ -357,7 +408,7 @@ module WXRuby3
357
408
  fsrc << <<~__HERDOC
358
409
  // define Enum class
359
410
  wx_define_Enum_class();
360
- __HERDOC
411
+ __HERDOC
361
412
  fsrc.puts
362
413
  # generate constant definitions for feature defines from setup.h
363
414
  fsrc.puts %Q{VALUE mWxSetup = rb_define_module_under(#{module_variable}, "Setup");}
@@ -391,6 +442,72 @@ module WXRuby3
391
442
  generate_event_list if included_directors.any? {|dir| dir.has_events? }
392
443
  end
393
444
 
445
+ # only for MacOSX
446
+ def generate_initializer_loader
447
+ STDERR.puts "* generating package #{name} initializer : #{initializer_src}" if Director.verbose?
448
+
449
+ Stream.transaction do
450
+ fsrc = CodeStream.new(initializer_loader_src)
451
+ fsrc.puts '#include <ruby.h>'
452
+ fsrc.puts '#include <ruby/version.h>'
453
+ fsrc.puts <<~__HEREDOC
454
+ #if defined(__GNUC__)
455
+ # if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
456
+ # ifndef GCC_HASCLASSVISIBILITY
457
+ # define GCC_HASCLASSVISIBILITY
458
+ # endif
459
+ # endif
460
+ #endif
461
+
462
+ #ifndef WXRB_EXPORT_FLAG
463
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
464
+ # if defined(WXRUBY_STATIC_BUILD)
465
+ # define WXRB_EXPORT_FLAG
466
+ # else
467
+ # define WXRB_EXPORT_FLAG __declspec(dllexport)
468
+ # endif
469
+ # else
470
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
471
+ # define WXRB_EXPORT_FLAG __attribute__ ((visibility("default")))
472
+ # else
473
+ # define WXRB_EXPORT_FLAG
474
+ # endif
475
+ # endif
476
+ #endif
477
+
478
+ #ifndef WXRB_IMPORT_FLAG
479
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
480
+ # if defined(WXRUBY_STATIC_BUILD)
481
+ # define WXRB_IMPORT_FLAG
482
+ # else
483
+ # define WXRB_IMPORT_FLAG __declspec(dllimport)
484
+ # endif
485
+ # else
486
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
487
+ # define WXRB_IMPORT_FLAG __attribute__ ((visibility("default")))
488
+ # else
489
+ # define WXRB_IMPORT_FLAG
490
+ # endif
491
+ # endif
492
+ #endif
493
+ __HEREDOC
494
+ fsrc.puts '#ifdef __cplusplus'
495
+ fsrc.puts 'extern "C"'
496
+ fsrc.puts '#endif'
497
+ fsrc.puts "WXRB_IMPORT_FLAG void wxruby_init_#{libname}();"
498
+ fsrc.puts
499
+ fsrc.puts '#ifdef __cplusplus'
500
+ fsrc.puts 'extern "C"'
501
+ fsrc.puts '#endif'
502
+ fsrc.puts "WXRB_EXPORT_FLAG void Init_#{libname}()"
503
+ fsrc.puts '{'
504
+ fsrc.indent do
505
+ fsrc.puts "wxruby_init_#{libname}();"
506
+ end
507
+ fsrc.puts '}'
508
+ end
509
+ end
510
+
394
511
  def extract(*mods, genint: true)
395
512
  included_directors.each do |dir|
396
513
  dir.extract_interface(genint) if (mods.empty? || mods.include?(dir.spec.name))
@@ -420,11 +537,11 @@ module WXRuby3
420
537
  raise "Don't know Event class for #{evh_name} event type (from #{item.name})"
421
538
  end
422
539
  fout.puts ' '+<<~__HEREDOC.split("\n").join("\n ")
423
- self.register_event_type EventType[
424
- '#{evh_name}', #{evt_arity},
425
- #{fullname}::#{evt_type},
426
- #{fullname}::#{evt_klass.sub(/\Awx/i, '')}
427
- ] if #{fullname}.const_defined?(:#{evt_type})
540
+ self.register_event_type EventType[
541
+ '#{evh_name}', #{evt_arity},
542
+ #{fullname}::#{evt_type},
543
+ #{fullname}::#{evt_klass.sub(/\Awx/i, '')}
544
+ ] if #{fullname}.const_defined?(:#{evt_type})
428
545
  __HEREDOC
429
546
  evts_handled << evh_name
430
547
  end
@@ -562,7 +679,7 @@ module WXRuby3
562
679
 
563
680
  class EvtHandler
564
681
 
565
- __HEREDOC
682
+ __HEREDOC
566
683
  fdoc.indent(2) do
567
684
  fdoc.doc.puts "@!group #{name} Event handler methods"
568
685
  fdoc.puts
@@ -651,7 +768,7 @@ module WXRuby3
651
768
 
652
769
  end
653
770
  __HEREDOC
654
- __SCRIPT
771
+ __SCRIPT
655
772
  begin
656
773
  tmpfile = Tempfile.new('script')
657
774
  ftmp_name = tmpfile.path.dup
@@ -69,7 +69,7 @@ module WXRuby3
69
69
  wxExit
70
70
  }
71
71
  spec.ignore 'wxApp::GetGUIInstance'
72
- unless Config.instance.wx_abi_version >= '3.2.1' || Config.instance.wx_version < '3.2.1'
72
+ unless Config.instance.wx_version < '3.2.1'
73
73
  spec.ignore 'wxApp::GTKAllowDiagnosticsControl'
74
74
  end
75
75
  spec.add_extend_code 'wxApp', <<~__HEREDOC
@@ -16,6 +16,7 @@ module WXRuby3
16
16
  super
17
17
  spec.items << 'wxAuiDefaultTabArt' << 'wxAuiSimpleTabArt'
18
18
  spec.gc_as_object
19
+ spec.disable_proxies
19
20
  # missing from interface documentation
20
21
  spec.extend_interface('wxAuiTabArt',
21
22
  'virtual ~wxAuiTabArt ()',
@@ -16,7 +16,8 @@ module WXRuby3
16
16
  super
17
17
  spec.items << 'wxAuiDefaultToolBarArt'
18
18
  spec.gc_as_object
19
- spec.extend_interface('wxAuiToolBarArt', 'virtual ~wxAuiToolBarArt ()')
19
+ spec.make_abstract 'wxAuiToolBarArt'
20
+ spec.disable_proxies
20
21
  spec.suppress_warning(473, 'wxAuiToolBarArt::Clone', 'wxAuiDefaultToolBarArt::Clone')
21
22
  spec.map 'const wxAuiToolBarItemArray&' => 'Array<Wx::AUI::AuiToolBarItem>,nil' do
22
23
  map_in temp: 'wxAuiToolBarItemArray tmp', code: <<~__CODE
@@ -16,6 +16,13 @@ module WXRuby3
16
16
 
17
17
  def setup
18
18
  super
19
+ _readDC = if Config.instance.wx_version >= '3.3.0'
20
+ spec.items.unshift 'wxReadOnlyDC' # prepend before wxDC
21
+ spec.items << 'wxInfoDC'
22
+ 'wxReadOnlyDC'
23
+ else
24
+ 'wxDC'
25
+ end
19
26
  spec.items << 'wxFontMetrics'
20
27
  # it's not safe to track DC objects as these are often created on the stack in C++
21
28
  # before being passed to Ruby methods
@@ -29,22 +36,24 @@ module WXRuby3
29
36
  'wxFontMetrics::externalLeading',
30
37
  'wxFontMetrics::averageWidth'
31
38
  spec.ignore [
32
- 'wxDC::GetPartialTextExtents',
33
- 'wxDC::DrawLines(const wxPointList *,wxCoord,wxCoord)',
34
- 'wxDC::DrawPolygon(const wxPointList *,wxCoord,wxCoord,wxPolygonFillMode)',
35
- 'wxDC::DrawSpline(const wxPointList *)',
36
- 'wxDC::GetLogicalOrigin(wxCoord *,wxCoord *) const',
37
- 'wxDC::GetHandle'
39
+ 'wxDC::DrawLines(const wxPointList *,wxCoord,wxCoord)',
40
+ 'wxDC::DrawPolygon(const wxPointList *,wxCoord,wxCoord,wxPolygonFillMode)',
41
+ 'wxDC::DrawSpline(const wxPointList *)',
42
+ 'wxDC::GetHandle'
43
+ ]
44
+ spec.ignore [
45
+ "#{_readDC}::GetPartialTextExtents",
46
+ "#{_readDC}::GetLogicalOrigin(wxCoord *,wxCoord *) const",
38
47
  ]
48
+ spec.rename_for_ruby({
49
+ 'GetDimensions' => "#{_readDC}::GetSize(wxCoord *, wxCoord *) const",
50
+ 'GetDimensionsMM' => "#{_readDC}::GetSizeMM(wxCoord *, wxCoord *) const",
51
+ 'GetTextSize' => "#{_readDC}::GetTextExtent(const wxString &) const",
52
+ 'GetMultiLineTextSize' => "#{_readDC}::GetMultiLineTextExtent(const wxString &) const"
53
+ })
39
54
  spec.disable_proxies
40
55
  spec.disown 'wxGraphicsContext *ctx'
41
- spec.rename_for_ruby({
42
- 'GetDimensions' => 'wxDC::GetSize(wxCoord *, wxCoord *) const',
43
- 'GetDimensionsMM' => 'wxDC::GetSizeMM(wxCoord *, wxCoord *) const',
44
- 'GetTextSize' => 'wxDC::GetTextExtent(const wxString &) const',
45
- 'GetMultiLineTextSize' => 'wxDC::GetMultiLineTextExtent(const wxString &) const'
46
- })
47
- spec.add_extend_code 'wxDC', <<~__HEREDOC
56
+ spec.add_extend_code _readDC, <<~__HEREDOC
48
57
  // Needs to return input parameter with list of lengths
49
58
  VALUE get_partial_text_extents(VALUE text) {
50
59
  wxString str = wxString(StringValuePtr(text), wxConvUTF8);
@@ -57,10 +66,31 @@ module WXRuby3
57
66
  }
58
67
  return rb_result;
59
68
  }
60
- __HEREDOC
69
+ __HEREDOC
61
70
  # for GetUserScale and GetLogicalScale
62
71
  spec.map_apply 'double * OUTPUT' => 'double *'
63
72
  spec.swig_import 'swig/classes/include/wxGDICommon.h'
73
+ if Config.instance.wx_version >= '3.3.0'
74
+ # add similar block-style creator as #draw_on methods
75
+ spec.add_extend_code 'wxInfoDC', <<~__HEREDOC
76
+ static VALUE inform_on(wxWindow* win)
77
+ {
78
+ if (!wxRuby_IsAppRunning())
79
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
80
+ if (!win)
81
+ rb_raise(rb_eRuntimeError, "A running valid Wx::Window is required for argument.");
82
+ VALUE rc = Qnil;
83
+ if (rb_block_given_p ())
84
+ {
85
+ wxInfoDC info_dc(win);
86
+ wxReadOnlyDC* dc_ptr = &info_dc; // wxInfoDC::operator&() returns wxReadOnlyDC*
87
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxInfoDC, 0);
88
+ rc = rb_yield(rb_dc);
89
+ }
90
+ return rc;
91
+ }
92
+ __HEREDOC
93
+ end
64
94
  end
65
95
  end # class DC
66
96
 
@@ -18,6 +18,7 @@ module WXRuby3
18
18
  spec.gc_as_untracked spec.module_name
19
19
  case spec.module_name
20
20
  when 'wxScreenDC'
21
+ spec.override_inheritance_chain('wxScreenDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
21
22
  spec.make_abstract 'wxScreenDC'
22
23
  # as a ScreenDC should always be a temporary stack object
23
24
  # we do not allow creation in Ruby but rather provide a class
@@ -43,6 +44,7 @@ module WXRuby3
43
44
  'wxScreenDC::EndDrawingOnTop',
44
45
  'wxScreenDC::wxScreenDC'
45
46
  when 'wxClientDC'
47
+ spec.override_inheritance_chain('wxClientDC', ['wxWindowDC', 'wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
46
48
  spec.make_abstract 'wxClientDC'
47
49
  spec.ignore 'wxClientDC::wxClientDC'
48
50
  # as a ClientDC should best always be a temporary stack object
@@ -65,6 +67,7 @@ module WXRuby3
65
67
  }
66
68
  __HEREDOC
67
69
  when 'wxPaintDC'
70
+ spec.override_inheritance_chain('wxPaintDC', ['wxClientDC', 'wxWindowDC', 'wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
68
71
  spec.make_abstract 'wxPaintDC'
69
72
  spec.ignore 'wxPaintDC::wxPaintDC'
70
73
  spec.add_header_code <<~__HEREDOC
@@ -89,7 +92,10 @@ module WXRuby3
89
92
  __HEREDOC
90
93
  when 'wxMemoryDC'
91
94
  spec.items << 'wxBufferedDC' << 'wxBufferedPaintDC'
95
+ spec.override_inheritance_chain('wxMemoryDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
92
96
  spec.gc_as_untracked %w[wxBufferedDC wxBufferedPaintDC]
97
+ spec.override_inheritance_chain('wxBufferedDC', ['wxMemoryDC', 'wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
98
+ spec.override_inheritance_chain('wxBufferedPaintDC', ['wxBufferedDC', 'wxMemoryDC', 'wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
93
99
  spec.make_abstract 'wxMemoryDC'
94
100
  spec.make_abstract 'wxBufferedDC'
95
101
  spec.make_abstract 'wxBufferedPaintDC'
@@ -218,6 +224,7 @@ module WXRuby3
218
224
  }
219
225
  __HEREDOC
220
226
  when 'wxMirrorDC'
227
+ spec.override_inheritance_chain('wxMirrorDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
221
228
  spec.make_abstract 'wxMirrorDC'
222
229
  spec.ignore 'wxMirrorDC::wxMirrorDC'
223
230
  # as a MirrorDC should best always be a temporary stack object
@@ -240,6 +247,7 @@ module WXRuby3
240
247
  }
241
248
  __HEREDOC
242
249
  when 'wxSVGFileDC'
250
+ spec.override_inheritance_chain('wxSVGFileDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
243
251
  spec.items.concat %w[wxSVGBitmapHandler wxSVGBitmapFileHandler wxSVGBitmapEmbedHandler]
244
252
  spec.make_abstract 'wxSVGFileDC'
245
253
  spec.ignore 'wxSVGFileDC::wxSVGFileDC'
@@ -277,6 +285,7 @@ module WXRuby3
277
285
  'wxSVGFileDC::StartPage',
278
286
  'wxSVGFileDC::EndPage'
279
287
  when 'wxGCDC'
288
+ spec.override_inheritance_chain('wxGCDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
280
289
  spec.make_abstract 'wxGCDC'
281
290
  spec.ignore 'wxGCDC::wxGCDC'
282
291
  # like all DC this should best always be a temporary stack object
@@ -382,7 +391,11 @@ module WXRuby3
382
391
  spec.ignore 'wxGCDC::wxGCDC(const wxEnhMetaFileDC &)'
383
392
  when 'wxScaledDC'
384
393
  spec.items.clear # wxRuby extension; no XML docs
385
- spec.override_inheritance_chain('wxScaledDC', %w[wxDC wxObject])
394
+ if Config.instance.wx_version >= '3.3.0'
395
+ spec.override_inheritance_chain('wxScaledDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject'])
396
+ else
397
+ spec.override_inheritance_chain('wxScaledDC', %w[wxDC wxObject])
398
+ end
386
399
  # as there are no dependencies parsed from XML make sure we're initialized after Wx::DC
387
400
  spec.initialize_at_end = true
388
401
  spec.no_proxy 'wxScaledDC'
@@ -422,6 +435,7 @@ module WXRuby3
422
435
  };
423
436
  __HEREDOC
424
437
  when 'wxPrinterDC'
438
+ spec.override_inheritance_chain('wxPrinterDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
425
439
  spec.make_abstract 'wxPrinterDC'
426
440
  spec.ignore 'wxPrinterDC::wxPrinterDC'
427
441
  # as a PrinterDC should best always be a temporary stack object
@@ -444,6 +458,7 @@ module WXRuby3
444
458
  }
445
459
  __HEREDOC
446
460
  when 'wxPostScriptDC'
461
+ spec.override_inheritance_chain('wxPostScriptDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
447
462
  spec.make_abstract 'wxPostScriptDC'
448
463
  spec.ignore 'wxPostScriptDC::wxPostScriptDC'
449
464
  # as a PostScriptDC should best always be a temporary stack object
@@ -499,7 +514,44 @@ module WXRuby3
499
514
  return rc;
500
515
  }
501
516
  __HEREDOC
517
+ if Config.instance.wx_version >= '3.3.0'
518
+ spec.items << 'wxOverlayDC'
519
+ spec.override_inheritance_chain('wxOverlayDC', ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject'])
520
+ spec.make_abstract 'wxOverlayDC'
521
+ spec.ignore 'wxOverlayDC::wxOverlayDC'
522
+ spec.add_extend_code 'wxOverlayDC', <<~__HEREDOC
523
+ static VALUE draw_on(wxOverlay &overlay, wxWindow *win)
524
+ {
525
+ if (!wxRuby_IsAppRunning())
526
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
527
+ VALUE rc = Qnil;
528
+ if (rb_block_given_p ())
529
+ {
530
+ wxOverlayDC ovl_dc(overlay, win);
531
+ wxOverlayDC* ovl_dc_ptr = &ovl_dc;
532
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(ovl_dc_ptr), SWIGTYPE_p_wxOverlayDC, 0);
533
+ rc = rb_yield(rb_dc);
534
+ }
535
+ return rc;
536
+ }
537
+ static VALUE draw_on(wxOverlay &overlay, wxWindow *win, const wxRect &rect)
538
+ {
539
+ if (!wxRuby_IsAppRunning())
540
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
541
+ VALUE rc = Qnil;
542
+ if (rb_block_given_p ())
543
+ {
544
+ wxOverlayDC ovl_dc(overlay, win, rect);
545
+ wxOverlayDC* ovl_dc_ptr = &ovl_dc;
546
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(ovl_dc_ptr), SWIGTYPE_p_wxOverlayDC, 0);
547
+ rc = rb_yield(rb_dc);
548
+ }
549
+ return rc;
550
+ }
551
+ __HEREDOC
552
+ end
502
553
  else
554
+ spec.override_inheritance_chain(spec.module_name, ['wxDC', { 'wxReadOnlyDC' => 'wxDC' }, 'wxObject']) if Config.instance.wx_version >= '3.3.0'
503
555
  # ctors of all other derived DC require a running App
504
556
  spec.require_app spec.module_name
505
557
  end
@@ -43,6 +43,55 @@ module WXRuby3
43
43
  spec.add_swig_code '%markfunc wxDropSource "mark_wxDropSource";',
44
44
  '%markfunc wxDropTarget "mark_wxDropTarget";'
45
45
  spec.extend_interface 'wxDropSource', 'virtual ~wxDropSource()' # correct interface omission
46
+ # make Ruby director and wrappers use custom implementation
47
+ spec.use_class_implementation('wxDropTarget', 'wxRubyDropTarget')
48
+ spec.make_concrete('wxDropTarget')
49
+ spec.no_proxy %w[wxDropTarget::OnData] # prevent director overload; custom impl handles this
50
+ spec.add_header_code <<~__HEREDOC
51
+ class wxRubyDropTarget : public wxDropTarget
52
+ {
53
+ public:
54
+ wxRubyDropTarget(wxDataObject *dataObject = nullptr ) : wxDropTarget(dataObject) {}
55
+
56
+ virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult dflt) override
57
+ {
58
+ static WxRuby_ID on_data_id("on_data");
59
+ wxDragResult c_result = wxDragError;
60
+ VALUE SWIGUNUSED result;
61
+
62
+ VALUE rb_x = INT2NUM(static_cast< int >(x));
63
+ VALUE rb_y = INT2NUM(static_cast< int >(y));
64
+ VALUE rb_dflt = wxRuby_GetEnumValueObject("DragResult", static_cast<int>(dflt));
65
+ if (rb_dflt == Qnil)
66
+ {
67
+ std::cerr << "Unexpected argument error: invalid value for Wx::DragResult in wxDropTarget::OnData [" << dflt << "]" << std::endl;
68
+ }
69
+ else
70
+ {
71
+ VALUE self = SWIG_RubyInstanceFor(this);
72
+ bool ex = false;
73
+ result = wxRuby_Funcall(ex, self, rb_intern("on_data"), 3,rb_x, rb_y, rb_dflt);
74
+ if (ex)
75
+ {
76
+ wxRuby_PrintException(result);
77
+ }
78
+ else
79
+ {
80
+ int eval;
81
+ if (!wxRuby_GetEnumValue("DragResult", result, eval))
82
+ {
83
+ std::cerr << "Type Error: invalid value for Wx::DragResult returned from Wx::DropTarget#on_data" << std::endl;
84
+ }
85
+ else
86
+ {
87
+ c_result = static_cast<wxDragResult>(eval);
88
+ }
89
+ }
90
+ }
91
+ return (wxDragResult) c_result;
92
+ }
93
+ };
94
+ __HEREDOC
46
95
  spec.ignore %w[wxFileDropTarget::OnDrop wxTextDropTarget::OnDrop]
47
96
  spec.no_proxy %w[wxFileDropTarget::OnDrop wxFileDropTarget::OnData]
48
97
  spec.no_proxy %w[wxTextDropTarget::OnDrop wxTextDropTarget::OnData]
@@ -16,7 +16,9 @@ module WXRuby3
16
16
  spec.items << 'wxRibbonPageTabInfo' << 'wxRibbonMSWArtProvider' << 'wxRibbonAUIArtProvider'
17
17
  super
18
18
  spec.gc_as_object 'wxRibbonArtProvider'
19
+ spec.make_abstract 'wxRibbonArtProvider'
19
20
  spec.gc_as_untracked 'wxRibbonPageTabInfo'
21
+ spec.disable_proxies
20
22
  spec.suppress_warning(473,
21
23
  'wxRibbonArtProvider::Clone',
22
24
  'wxRibbonMSWArtProvider::Clone',
@@ -20,6 +20,22 @@ module WXRuby3
20
20
  super
21
21
  spec.items << 'wxRichTextFontTable' << 'wxRichTextFieldType' << 'wxRichTextFieldTypeStandard' << 'wxRichTextDrawingHandler'
22
22
  spec.make_abstract 'wxRichTextFieldType'
23
+ if Config.instance.wx_version >= '3.3.0'
24
+ # make Ruby director and wrappers use custom implementation
25
+ spec.use_class_implementation('wxRichTextFieldType', 'wxRubyRichTextFieldType')
26
+ spec.add_header_code <<~__HEREDOC
27
+ class wxRubyRichTextFieldType : public wxRichTextFieldType
28
+ {
29
+ public:
30
+ virtual ~wxRubyRichTextFieldType() {}
31
+ wxRubyRichTextFieldType(const wxString &name=wxEmptyString) : wxRichTextFieldType(name) {}
32
+ wxRubyRichTextFieldType(const wxRichTextFieldType &fieldType) : wxRichTextFieldType(fieldType) {}
33
+ virtual bool Draw(wxRichTextField *, wxDC &, wxRichTextDrawingContext &, const wxRichTextRange &, const wxRichTextSelection &, const wxRect &, int , int ) { return false; }
34
+ virtual bool Layout(wxRichTextField *, wxReadOnlyDC &, wxRichTextDrawingContext &, const wxRect &, const wxRect &, int) { return false; }
35
+ virtual bool GetRangeSize(wxRichTextField *, const wxRichTextRange &, wxSize &, int &, wxReadOnlyDC &, wxRichTextDrawingContext &, int, const wxPoint &, const wxSize &, wxArrayInt *) const { return false; }
36
+ };
37
+ __HEREDOC
38
+ end
23
39
  spec.no_proxy 'wxRichTextFontTable'
24
40
  spec.include 'wx/richtext/richtextstyles.h'
25
41
  spec.ignore %w[
@@ -61,6 +61,9 @@ module WXRuby3
61
61
  spec.ignore 'wxGetEmailAddress(char *,int)',
62
62
  'wxGetUserId(char *,int)',
63
63
  'wxGetUserName(char *,int)'
64
+ if Config.instance.wx_version >= '3.3.0'
65
+ spec.ignore_unless('WXMSW', 'wxMSWIsOnSecureScreen')
66
+ end
64
67
  spec.map 'wxMemorySize' => 'Integer' do
65
68
  map_out code: <<~__CODE
66
69
  $result = LL2NUM(wxLongLongNative($1).GetValue());
@@ -120,6 +120,7 @@ module WXRuby3
120
120
  end
121
121
  if Config.instance.wx_version >= '3.3.0'
122
122
  spec.ignore_unless('WXMSW', 'wxWindow::MSWDisableComposited')
123
+ spec.ignore('wxWindow::GTKGetWin32Handle')
123
124
  end
124
125
  if Config.instance.features_set?('USE_ACCESSIBILITY')
125
126
  spec.disown 'wxAccessible *accessible'
@@ -703,7 +703,7 @@ module WXRuby3
703
703
  fdoc.puts
704
704
  mod_indent = 0
705
705
  package.all_modules.each do |modnm|
706
- fdoc.iputs("module #{package.fullname}", mod_indent)
706
+ fdoc.iputs("module #{modnm}", mod_indent)
707
707
  fdoc.puts
708
708
  mod_indent += 1
709
709
  end
@@ -628,7 +628,12 @@ module WXRuby3
628
628
  end
629
629
 
630
630
  def run
631
- member_map = collect_methods rescue $!
631
+ begin
632
+ member_map = collect_methods
633
+ rescue Exception
634
+ STDERR.puts "#{$!}\n#{$!.backtrace.join("\n")}"
635
+ exit(1)
636
+ end
632
637
  return if member_map.empty?
633
638
 
634
639
  # create re match list for class names
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wxruby3
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Corino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-02 00:00:00.000000000 Z
11
+ date: 2024-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -1191,7 +1191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1191
1191
  - !ruby/object:Gem::Version
1192
1192
  version: '0'
1193
1193
  requirements: []
1194
- rubygems_version: 3.5.9
1194
+ rubygems_version: 3.5.16
1195
1195
  signing_key:
1196
1196
  specification_version: 4
1197
1197
  summary: wxWidgets extension for Ruby