wxruby3 0.9.7 → 0.9.8
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.
- checksums.yaml +4 -4
- data/INSTALL.md +161 -42
- data/README.md +28 -22
- data/ext/mkrf_conf_ext.rb +68 -0
- data/lib/wx/core/secret_store.rb +38 -0
- data/lib/wx/doc/extra/02_lifecycles.md +4 -4
- data/lib/wx/doc/extra/14_config.md +1 -1
- data/lib/wx/doc/secret_store.rb +55 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wx/wxruby/base.rb +3 -5
- data/lib/wx/wxruby/cmd/check.rb +182 -0
- data/lib/wx/wxruby/cmd/sampler.rb +1 -1
- data/lib/wx/wxruby/cmd/setup.rb +6 -3
- data/lib/wx/wxruby/cmd/test.rb +1 -1
- data/rakelib/configure.rb +60 -52
- data/rakelib/gem.rake +97 -67
- data/rakelib/gem.rb +293 -41
- data/rakelib/install.rb +3 -3
- data/rakelib/lib/config/{cygwin.rb → freebsd.rb} +1 -1
- data/rakelib/lib/config/linux.rb +3 -1
- data/rakelib/lib/config/macosx.rb +42 -11
- data/rakelib/lib/config/mingw.rb +2 -2
- data/rakelib/lib/config/pkgman/{base.rb → linux.rb} +36 -61
- data/rakelib/lib/config/pkgman/macosx.rb +17 -78
- data/rakelib/lib/config/unixish.rb +11 -1
- data/rakelib/lib/config/{netbsd.rb → unknown.rb} +3 -2
- data/rakelib/lib/config.rb +49 -29
- data/rakelib/lib/director/aui_manager.rb +1 -1
- data/rakelib/lib/director/dialog.rb +8 -0
- data/rakelib/lib/director/grid_ctrl.rb +2 -2
- data/rakelib/lib/director/richtext_composite_object.rb +2 -4
- data/rakelib/lib/director/secret_store.rb +117 -0
- data/rakelib/lib/director/tree_event.rb +2 -2
- data/rakelib/lib/generate/doc/secret_store.yaml +55 -0
- data/rakelib/lib/generate/doc.rb +1 -1
- data/rakelib/lib/specs/interfaces.rb +1 -0
- data/rakelib/lib/typemap/common.rb +10 -0
- data/rakelib/prepost.rake +8 -1
- data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +4 -0
- data/samples/sampler/sample.rb +2 -0
- data/tests/lib/wxapp_runner.rb +1 -1
- data/tests/test_config.rb +7 -4
- data/tests/test_secret_store.rb +83 -0
- metadata +41 -22
- data/rakefile +0 -14
- data/rakelib/lib/config/pkgman/arch.rb +0 -53
- data/rakelib/lib/config/pkgman/debian.rb +0 -66
- data/rakelib/lib/config/pkgman/rhel.rb +0 -54
- data/rakelib/lib/config/pkgman/suse.rb +0 -54
@@ -18,7 +18,7 @@ module WXRuby3
|
|
18
18
|
|
19
19
|
def install(pkgs)
|
20
20
|
# do we need to install anything?
|
21
|
-
|
21
|
+
unless pkgs.empty?
|
22
22
|
# can we install XCode commandline tools?
|
23
23
|
unless no_autoinstall? || !pkgs.include?('xcode') || has_sudo? || is_root?
|
24
24
|
STDERR.puts 'ERROR: Cannot check for or install required packages. Please install sudo or run as root and try again.'
|
@@ -50,18 +50,20 @@ module WXRuby3
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
+
def pkgman
|
54
|
+
@pkgman ||= WXRuby3.config.sysinfo.os.pkgman
|
55
|
+
end
|
56
|
+
|
53
57
|
def do_install(pkgs)
|
54
58
|
rc = true
|
55
59
|
# first see if we need to install XCode commandline tools
|
56
60
|
if pkgs.include?('xcode')
|
57
61
|
pkgs.delete('xcode')
|
58
|
-
rc =
|
62
|
+
rc = auth_run('xcode-select --install')
|
59
63
|
end
|
60
|
-
# now check if we need any other packages
|
64
|
+
# now check if we need any other packages
|
61
65
|
if rc && !pkgs.empty?
|
62
|
-
|
63
|
-
if has_macports? &&
|
64
|
-
(ruby_info = expand('port -q installed installed').strip.split("\n").find { |ln| ln.strip =~ /\Aruby\d+\s/ })
|
66
|
+
if pkgman.macports?
|
65
67
|
|
66
68
|
# this is really crap; with MacPorts we need to install swig-ruby instead of simply swig
|
67
69
|
# which for whatever nonsensical reason will pull in another (older) Ruby version (probably 2.3 or such)
|
@@ -70,59 +72,15 @@ module WXRuby3
|
|
70
72
|
pkgs.delete('swig')
|
71
73
|
pkgs << 'swig-ruby'
|
72
74
|
end
|
73
|
-
# in case MacPorts was installed with root privileges this install would also have to be run
|
74
|
-
# with root privileges (otherwise it would fail early on with access problems) so we can
|
75
|
-
# just run without sudo as we either have root privileges for root-installed MacPorts or
|
76
|
-
# we're running without root privileges for user-installed MacPorts
|
77
|
-
pkgs.each { |pkg| rc &&= sh("port install #{pkg}") }
|
78
|
-
|
79
|
-
# or are we running without root privileges and have Homebrew installed?
|
80
|
-
# (Ruby may be installed using Homebrew itself or using a Ruby version manager like RVM)
|
81
|
-
elsif !is_root? && has_homebrew?
|
82
75
|
|
83
|
-
pkgs.each { |pkg| rc &&= sh("brew install #{pkg}") }
|
84
|
-
|
85
|
-
# or do we have MacPorts (running either privileged or not) and
|
86
|
-
# a Ruby installed using a Ruby version manager.
|
87
|
-
elsif has_macports?
|
88
|
-
|
89
|
-
# same crap as above
|
90
|
-
if pkgs.include?('swig')
|
91
|
-
pkgs.delete('swig')
|
92
|
-
pkgs << 'swig-ruby'
|
93
|
-
end
|
94
|
-
# in case MacPorts was installed with root privileges this install would also have to be run
|
95
|
-
# with root privileges (otherwise it would fail early on with access problems) so we can
|
96
|
-
# just run without sudo as we either have root privileges for root-installed MacPorts or
|
97
|
-
# we're running without root privileges for user-installed MacPorts
|
98
|
-
pkgs.each { |pkg| rc &&= sh("port install #{pkg}") }
|
99
|
-
|
100
|
-
else
|
101
|
-
if has_homebrew? || is_root?
|
102
|
-
$stderr.puts <<~__ERROR_TXT
|
103
|
-
ERROR: Unsupported Ruby installation. wxRuby3 can only be installed for Ruby with root privileges
|
104
|
-
in case Ruby was installed with MacPorts. Homebrew should not be run with root privileges.
|
105
|
-
|
106
|
-
Re-install a supported Ruby setup and try again.
|
107
|
-
__ERROR_TXT
|
108
|
-
else
|
109
|
-
$stderr.puts <<~__ERROR_TXT
|
110
|
-
ERROR: Unsupported Ruby installation. wxRuby3 requires either a MacPorts installed Ruby version
|
111
|
-
or a non-privileged Ruby installation and have Homebrew installed.
|
112
|
-
|
113
|
-
Install either Homebrew or MacPorts and try again.
|
114
|
-
__ERROR_TXT
|
115
|
-
end
|
116
|
-
exit(1)
|
117
76
|
end
|
77
|
+
|
78
|
+
# actually install packages
|
79
|
+
pkgs.each { |pkg| rc &&= run(pkgman.make_install_command(pkg)); break unless rc }
|
118
80
|
end
|
119
81
|
rc
|
120
82
|
end
|
121
83
|
|
122
|
-
def builds_wxwidgets?
|
123
|
-
Config.get_config('with-wxwin') && Config.get_cfg_string('wxwin').empty?
|
124
|
-
end
|
125
|
-
|
126
84
|
def no_autoinstall?
|
127
85
|
Config.get_config('autoinstall') == false
|
128
86
|
end
|
@@ -132,46 +90,27 @@ module WXRuby3
|
|
132
90
|
end
|
133
91
|
|
134
92
|
def has_sudo?
|
135
|
-
|
93
|
+
WXRuby3.config.sysinfo.os.has_sudo?
|
136
94
|
end
|
137
95
|
|
138
96
|
def is_root?
|
139
|
-
|
140
|
-
@is_root = (`id -u 2>/dev/null`.chomp == '0')
|
141
|
-
end
|
142
|
-
@is_root
|
143
|
-
end
|
144
|
-
|
145
|
-
def has_macports?
|
146
|
-
if @has_macports.nil?
|
147
|
-
@has_macports = system('command -v port>/dev/null')
|
148
|
-
end
|
97
|
+
WXRuby3.config.sysinfo.os.is_root?
|
149
98
|
end
|
150
99
|
|
151
|
-
def
|
152
|
-
if @has_homebrew.nil?
|
153
|
-
@has_homebrew = system('command -v brew>/dev/null')
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def run(cmd)
|
100
|
+
def auth_run(cmd)
|
158
101
|
$stdout.print "Running #{cmd}..."
|
159
102
|
rc = WXRuby3.config.sh("#{is_root? ? '' : 'sudo '}#{cmd}")
|
160
|
-
$stderr.puts
|
103
|
+
$stderr.puts(rc ? 'done!' : 'FAILED!')
|
161
104
|
rc
|
162
105
|
end
|
163
106
|
|
164
|
-
def
|
107
|
+
def run(*cmd, title: nil)
|
165
108
|
$stdout.print(title ? title : "Running #{cmd}...")
|
166
109
|
rc = WXRuby3.config.sh(*cmd)
|
167
|
-
$stderr.puts
|
110
|
+
$stderr.puts(rc ? 'done!' : 'FAILED!')
|
168
111
|
rc
|
169
112
|
end
|
170
113
|
|
171
|
-
def expand(cmd)
|
172
|
-
WXRuby3.config.expand(cmd)
|
173
|
-
end
|
174
|
-
|
175
114
|
end
|
176
115
|
|
177
116
|
end
|
@@ -66,6 +66,12 @@ module WXRuby3
|
|
66
66
|
def get_rpath_origin
|
67
67
|
"$ORIGIN"
|
68
68
|
end
|
69
|
+
protected :get_rpath_origin
|
70
|
+
|
71
|
+
# add deployment lookup paths for wxruby shared libraries
|
72
|
+
def update_shlib_loadpaths(shlib)
|
73
|
+
WXRuby3.config.patch_rpath(shlib, WXRuby3.config.get_rpath_origin, "#{WXRuby3.config.get_rpath_origin}/../ext")
|
74
|
+
end
|
69
75
|
|
70
76
|
def expand(cmd)
|
71
77
|
STDERR.puts "> sh: #{cmd}" if verbose?
|
@@ -74,6 +80,10 @@ module WXRuby3
|
|
74
80
|
s
|
75
81
|
end
|
76
82
|
|
83
|
+
def download_file(url, dest)
|
84
|
+
sh("curl -L #{url} --output #{dest}")
|
85
|
+
end
|
86
|
+
|
77
87
|
private
|
78
88
|
|
79
89
|
def wx_checkout
|
@@ -101,7 +111,7 @@ module WXRuby3
|
|
101
111
|
end
|
102
112
|
|
103
113
|
def wx_configure
|
104
|
-
bash('./configure --prefix=`pwd`/install --disable-tests --without-subdirs --disable-debug_info')
|
114
|
+
bash('./configure --prefix=`pwd`/install --disable-tests --without-subdirs --without-regex --disable-debug_info')
|
105
115
|
end
|
106
116
|
|
107
117
|
def wx_make
|
data/rakelib/lib/config.rb
CHANGED
@@ -11,6 +11,7 @@ require 'fileutils'
|
|
11
11
|
require 'json'
|
12
12
|
require 'open3'
|
13
13
|
require 'monitor'
|
14
|
+
require 'plat4m'
|
14
15
|
|
15
16
|
module FileUtils
|
16
17
|
# add convenience methods
|
@@ -67,7 +68,8 @@ module WXRuby3
|
|
67
68
|
'sodir' => '$siterubyverarch',
|
68
69
|
}
|
69
70
|
|
70
|
-
CFG_KEYS.concat(%w{wxwin wxxml wxwininstdir with-wxwin with-debug swig doxygen})
|
71
|
+
CFG_KEYS.concat(%w{wxwin wxxml wxwininstdir with-wxwin with-debug swig doxygen git})
|
72
|
+
WXW_SYS_KEY = 'with-system-wxwin'
|
71
73
|
CONFIG.merge!({
|
72
74
|
'wxwin' => ENV['WXWIN'] || '',
|
73
75
|
'wxxml' => ENV['WXXML'] || '',
|
@@ -280,7 +282,7 @@ module WXRuby3
|
|
280
282
|
end
|
281
283
|
begin
|
282
284
|
# setup ENV for child execution
|
283
|
-
ENV.
|
285
|
+
ENV.update(Config.instance.exec_env)
|
284
286
|
output = `#{cmd.join(' ')}`
|
285
287
|
ensure
|
286
288
|
# restore ENV
|
@@ -350,7 +352,7 @@ module WXRuby3
|
|
350
352
|
|
351
353
|
def test(*tests, **options)
|
352
354
|
errors = 0
|
353
|
-
excludes = (ENV['WXRUBY_TEST_EXCLUDE'] || '').split('
|
355
|
+
excludes = (ENV['WXRUBY_TEST_EXCLUDE'] || '').split(':')
|
354
356
|
tests = Dir.glob(File.join(Config.instance.test_dir, '*.rb')) if tests.empty?
|
355
357
|
tests.each do |test|
|
356
358
|
unless excludes.include?(File.basename(test, '.*'))
|
@@ -381,6 +383,10 @@ module WXRuby3
|
|
381
383
|
[]
|
382
384
|
end
|
383
385
|
|
386
|
+
def download_file(_url, _dest)
|
387
|
+
raise NoMethodError
|
388
|
+
end
|
389
|
+
|
384
390
|
def install_prerequisites
|
385
391
|
pkg_deps = check_tool_pkgs
|
386
392
|
if get_config('autoinstall') == false
|
@@ -443,16 +449,22 @@ module WXRuby3
|
|
443
449
|
def get_rpath_origin
|
444
450
|
''
|
445
451
|
end
|
452
|
+
protected :get_rpath_origin
|
446
453
|
|
447
|
-
def
|
454
|
+
def patch_rpath(_shlib, *)
|
448
455
|
true
|
449
456
|
end
|
457
|
+
protected :patch_rpath
|
450
458
|
|
451
|
-
def
|
459
|
+
def update_shlib_loadpaths(_shlib)
|
460
|
+
true
|
461
|
+
end
|
462
|
+
|
463
|
+
def update_shlib_ruby_libpath(_shlib)
|
452
464
|
true
|
453
465
|
end
|
454
466
|
|
455
|
-
def
|
467
|
+
def update_shlib_wxwin_libpaths(_shlib, _deplibs)
|
456
468
|
true
|
457
469
|
end
|
458
470
|
|
@@ -494,15 +506,23 @@ module WXRuby3
|
|
494
506
|
end
|
495
507
|
|
496
508
|
def save
|
509
|
+
cfg = WXRuby3::CONFIG.dup
|
510
|
+
wxw_system = !!cfg.delete(WXW_SYS_KEY)
|
511
|
+
cfg['wxwin'] = '@system' if wxw_system
|
497
512
|
File.open(build_cfg, 'w') do |f|
|
498
|
-
f << JSON.pretty_generate(
|
513
|
+
f << JSON.pretty_generate(cfg)
|
499
514
|
end
|
500
515
|
end
|
501
516
|
|
502
517
|
def load
|
503
518
|
if File.file?(build_cfg)
|
504
519
|
File.open(build_cfg, 'r') do |f|
|
505
|
-
|
520
|
+
cfg = JSON.load(f.read)
|
521
|
+
if cfg['wxwin'] == '@system'
|
522
|
+
cfg[WXW_SYS_KEY] = true
|
523
|
+
cfg.delete('wxwin')
|
524
|
+
end
|
525
|
+
WXRuby3::CONFIG.merge!(cfg)
|
506
526
|
end
|
507
527
|
end
|
508
528
|
end
|
@@ -515,10 +535,8 @@ module WXRuby3
|
|
515
535
|
case RUBY_PLATFORM
|
516
536
|
when /mingw/
|
517
537
|
:mingw
|
518
|
-
when /
|
519
|
-
:
|
520
|
-
when /netbsd/
|
521
|
-
:netbsd
|
538
|
+
when /freebsd/
|
539
|
+
:freebsd
|
522
540
|
when /darwin/
|
523
541
|
:macosx
|
524
542
|
when /linux/
|
@@ -538,15 +556,26 @@ module WXRuby3
|
|
538
556
|
def initialize
|
539
557
|
@ruby_exe = RB_CONFIG["ruby_install_name"]
|
540
558
|
|
541
|
-
@
|
542
|
-
@platform =
|
543
|
-
|
559
|
+
@sysinfo = Plat4m.current rescue nil
|
560
|
+
@platform = if @sysinfo
|
561
|
+
case @sysinfo.os.id
|
562
|
+
when :darwin
|
563
|
+
:macosx
|
564
|
+
when :windows
|
565
|
+
RUBY_PLATFORM =~ /mingw/ ? :mingw : :unknown
|
566
|
+
else
|
567
|
+
@sysinfo.os.id
|
568
|
+
end
|
569
|
+
else
|
570
|
+
:unknown
|
571
|
+
end
|
572
|
+
require_relative File.join('config', @platform.to_s)
|
544
573
|
self.class.include(WXRuby3::Config::Platform)
|
545
574
|
|
546
575
|
init # initialize settings
|
547
576
|
end
|
548
577
|
|
549
|
-
attr_reader :ruby_exe, :
|
578
|
+
attr_reader :ruby_exe, :sysinfo, :platform, :helper_modules, :helper_inits, :include_modules, :verbosity
|
550
579
|
attr_reader :release_build, :debug_build, :verbose_debug, :no_deprecate
|
551
580
|
attr_reader :ruby_cppflags, :ruby_ldflags, :ruby_libs, :extra_cflags, :extra_cppflags, :extra_ldflags,
|
552
581
|
:extra_libs, :cpp_out_flag, :link_output_flag, :obj_ext, :dll_ext,
|
@@ -593,11 +622,6 @@ module WXRuby3
|
|
593
622
|
|
594
623
|
# Extra swig helper files to be built
|
595
624
|
@helper_modules = %w|RubyStockObjects|
|
596
|
-
# if macosx?
|
597
|
-
# %w|RubyStockObjects Mac|
|
598
|
-
# else
|
599
|
-
# %w|RubyStockObjects|
|
600
|
-
# end
|
601
625
|
# helper to initialize on startup (stock objects can only be initialized after App creation)
|
602
626
|
@helper_inits = @helper_modules - %w|RubyStockObjects|
|
603
627
|
|
@@ -640,7 +664,7 @@ module WXRuby3
|
|
640
664
|
@obj_ext = RB_CONFIG["OBJEXT"]
|
641
665
|
@dll_ext = RB_CONFIG['DLEXT']
|
642
666
|
|
643
|
-
# Exclude
|
667
|
+
# Exclude certain classes from being built, even if they are present
|
644
668
|
# in the configuration of wxWidgets.
|
645
669
|
if ENV['WXRUBY_EXCLUDED']
|
646
670
|
ENV['WXRUBY_EXCLUDED'].split(",").each { |classname| exclude_module(classname) }
|
@@ -704,16 +728,12 @@ module WXRuby3
|
|
704
728
|
@wx_abi_version || ''
|
705
729
|
end
|
706
730
|
|
707
|
-
def cygwin?
|
708
|
-
@platform == :cygwin
|
709
|
-
end
|
710
|
-
|
711
731
|
def mingw?
|
712
732
|
@platform == :mingw
|
713
733
|
end
|
714
734
|
|
715
|
-
def
|
716
|
-
@platform == :
|
735
|
+
def freebsd?
|
736
|
+
@platform == :freebsd
|
717
737
|
end
|
718
738
|
|
719
739
|
def macosx?
|
@@ -725,7 +745,7 @@ module WXRuby3
|
|
725
745
|
end
|
726
746
|
|
727
747
|
def windows?
|
728
|
-
mingw?
|
748
|
+
mingw?
|
729
749
|
end
|
730
750
|
|
731
751
|
def ldflags(_target)
|
@@ -53,7 +53,7 @@ module WXRuby3
|
|
53
53
|
m_actionWindow = NULL;
|
54
54
|
m_hoverButton = NULL;
|
55
55
|
m_art = new wxAuiDefaultDockArt;
|
56
|
-
m_hintWnd = NULL;
|
56
|
+
#{Config.instance.wx_version < '3.3.0' ? 'm_hintWnd = NULL;' : ''}
|
57
57
|
m_flags = wxAUI_MGR_DEFAULT;
|
58
58
|
m_hasMaximized = false;
|
59
59
|
m_dockConstraintX = 0.3;
|
@@ -212,6 +212,14 @@ module WXRuby3
|
|
212
212
|
return Qfalse;
|
213
213
|
}
|
214
214
|
__HEREDOC
|
215
|
+
when 'wxSymbolPickerDialog'
|
216
|
+
# redefine these to prevent problematic handling of title/caption defaults
|
217
|
+
spec.ignore 'wxSymbolPickerDialog::wxSymbolPickerDialog(const wxString &, const wxString &, const wxString &, wxWindow *, wxWindowID, const wxString &, const wxPoint &, const wxSize &, long)',
|
218
|
+
'wxSymbolPickerDialog::Create',
|
219
|
+
ignore_doc: false
|
220
|
+
spec.extend_interface 'wxSymbolPickerDialog',
|
221
|
+
'wxSymbolPickerDialog(const wxString &symbol, const wxString &initialFont, const wxString &normalTextFont, wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style)',
|
222
|
+
'bool Create(const wxString &symbol, const wxString &initialFont, const wxString &normalTextFont, wxWindow *parent, wxWindowID id, const wxString &caption, const wxPoint &pos, const wxSize &size, long style)'
|
215
223
|
when 'wxWizard'
|
216
224
|
# special handling
|
217
225
|
spec.ignore 'wxWizard::GetBitmap'
|
@@ -237,9 +237,9 @@ module WXRuby3
|
|
237
237
|
static const rb_data_type_t __wxGridWindow_type = {
|
238
238
|
"GridWindow",
|
239
239
|
#if RUBY_API_VERSION_MAJOR >= 3
|
240
|
-
{ NULL, NULL, __wxGridWindow_size, 0,
|
240
|
+
{ NULL, NULL, __wxGridWindow_size, 0, {}},
|
241
241
|
#else
|
242
|
-
{ NULL, NULL, __wxGridWindow_size,
|
242
|
+
{ NULL, NULL, __wxGridWindow_size, {}},
|
243
243
|
#endif
|
244
244
|
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
|
245
245
|
};
|
@@ -93,9 +93,9 @@ module WXRuby3
|
|
93
93
|
static const rb_data_type_t __wxRichTextFloatCollector_type = {
|
94
94
|
"RichTextFloatCollector",
|
95
95
|
#if RUBY_API_VERSION_MAJOR >= 3
|
96
|
-
{ NULL, NULL, __wxRichTextFloatCollector_size, 0,
|
96
|
+
{ NULL, NULL, __wxRichTextFloatCollector_size, 0, {}},
|
97
97
|
#else
|
98
|
-
{ NULL, NULL, __wxRichTextFloatCollector_size,
|
98
|
+
{ NULL, NULL, __wxRichTextFloatCollector_size, {}},
|
99
99
|
#endif
|
100
100
|
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
|
101
101
|
};
|
@@ -177,12 +177,10 @@ module WXRuby3
|
|
177
177
|
{
|
178
178
|
VALUE rc = Qnil;
|
179
179
|
const wxRichTextLineVector &lines = $self->GetLines();
|
180
|
-
int lnr = 0;
|
181
180
|
for (const wxRichTextLine* line : lines)
|
182
181
|
{
|
183
182
|
VALUE rb_ln = SWIG_NewPointerObj(SWIG_as_voidptr(const_cast<wxRichTextLine*> (line)), SWIGTYPE_p_wxRichTextLine, 0);
|
184
183
|
rc = rb_yield(rb_ln);
|
185
|
-
++lnr;
|
186
184
|
}
|
187
185
|
return rc;
|
188
186
|
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
###
|
6
|
+
# wxRuby3 wxWidgets interface director
|
7
|
+
###
|
8
|
+
|
9
|
+
module WXRuby3
|
10
|
+
|
11
|
+
class Director
|
12
|
+
|
13
|
+
class SecretStore < Director
|
14
|
+
|
15
|
+
def setup
|
16
|
+
super
|
17
|
+
spec.items << 'wxSecretValue'
|
18
|
+
spec.gc_as_untracked # don't even track SecretStore and SecretValue objects
|
19
|
+
# there is no possibility of SecretStore derivatives
|
20
|
+
# not least because wxRuby only ever allows a single global SecretStore
|
21
|
+
spec.disable_proxies
|
22
|
+
spec.make_abstract 'wxSecretStore'
|
23
|
+
|
24
|
+
spec.include 'ruby/encoding.h'
|
25
|
+
|
26
|
+
spec.ignore 'wxSecretValue::GetAsString',
|
27
|
+
'wxSecretValue::GetSize',
|
28
|
+
'wxSecretValue::GetData',
|
29
|
+
'wxSecretValue::Wipe',
|
30
|
+
'wxSecretValue::WipeString',
|
31
|
+
'wxSecretValue::wxSecretValue(const wxString&)',
|
32
|
+
'wxSecretValue::wxSecretValue(size_t, const void *)'
|
33
|
+
spec.regard 'wxSecretValue::wxSecretValue()',
|
34
|
+
'wxSecretValue::wxSecretValue(const wxSecretValue&)',
|
35
|
+
regard_doc: false
|
36
|
+
# customize string arg ctor
|
37
|
+
spec.add_extend_code 'wxSecretValue', <<~__HEREDOC
|
38
|
+
wxSecretValue(VALUE secret_string)
|
39
|
+
{
|
40
|
+
if (RTEST(secret_string) && TYPE(secret_string) == T_STRING)
|
41
|
+
{
|
42
|
+
if (ENCODING_GET(secret_string) == rb_utf8_encindex())
|
43
|
+
{
|
44
|
+
return new wxSecretValue(RSTR_TO_WXSTR(secret_string));
|
45
|
+
}
|
46
|
+
else
|
47
|
+
{
|
48
|
+
return new wxSecretValue(RSTRING_LEN(secret_string), (void*)StringValuePtr(secret_string));
|
49
|
+
}
|
50
|
+
}
|
51
|
+
else
|
52
|
+
{
|
53
|
+
rb_raise(rb_eArgError, "Expected String or Wx::SecretValue for #0");
|
54
|
+
}
|
55
|
+
}
|
56
|
+
__HEREDOC
|
57
|
+
|
58
|
+
# customize GetData
|
59
|
+
spec.map 'const void*' => 'String', swig: false do
|
60
|
+
map_out code: ''
|
61
|
+
end
|
62
|
+
spec.add_extend_code 'wxSecretValue', <<~__HEREDOC
|
63
|
+
VALUE get_data()
|
64
|
+
{
|
65
|
+
size_t sz = $self->GetSize();
|
66
|
+
const void* data = $self->GetData();
|
67
|
+
return rb_enc_str_new(static_cast<const char*>(data), sz, rb_ascii8bit_encoding());
|
68
|
+
}
|
69
|
+
|
70
|
+
VALUE get_as_string()
|
71
|
+
{
|
72
|
+
size_t sz = $self->GetSize();
|
73
|
+
const void* data = $self->GetData();
|
74
|
+
return rb_utf8_str_new(static_cast<const char*>(data), sz);
|
75
|
+
}
|
76
|
+
__HEREDOC
|
77
|
+
|
78
|
+
# customize GetDefault
|
79
|
+
spec.ignore 'wxSecretStore::GetDefault', ignore_doc: false
|
80
|
+
spec.add_extend_code 'wxSecretStore', <<~__HEREDOC
|
81
|
+
static VALUE get_default()
|
82
|
+
{
|
83
|
+
wxSecretStore* result = new wxSecretStore(wxSecretStore::GetDefault());
|
84
|
+
return SWIG_NewPointerObj(result, SWIGTYPE_p_wxSecretStore, SWIG_POINTER_OWN);
|
85
|
+
}
|
86
|
+
__HEREDOC
|
87
|
+
spec.map 'wxString *errmsg' => 'String' do
|
88
|
+
map_in ignore: true, temp: 'wxString tmp', code: '$1 = &tmp;'
|
89
|
+
map_argout code: <<~__CODE
|
90
|
+
if ($result == Qfalse)
|
91
|
+
{
|
92
|
+
$result = SWIG_Ruby_AppendOutput($result, WXSTR_TO_RSTR(tmp$argnum));
|
93
|
+
}
|
94
|
+
__CODE
|
95
|
+
end
|
96
|
+
spec.map 'wxString& username' => 'String' do
|
97
|
+
map_in ignore: true, temp: 'wxString tmp', code: '$1 = &tmp;'
|
98
|
+
map_argout code: <<~__CODE
|
99
|
+
if ($result == Qtrue)
|
100
|
+
{
|
101
|
+
$result = SWIG_Ruby_AppendOutput($result, WXSTR_TO_RSTR(tmp$argnum));
|
102
|
+
}
|
103
|
+
__CODE
|
104
|
+
end
|
105
|
+
# the type matching of the username argument is tricky here since there only is the const difference
|
106
|
+
# have to explicitly overrule here for Save() incl. explicitly negating the argout mapping
|
107
|
+
spec.map 'const wxString& username' => 'String' do
|
108
|
+
map_in temp: 'wxString tmp', code: 'tmp = RSTR_TO_WXSTR($input); $1 = &tmp;'
|
109
|
+
map_argout by_ref: true
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end # class SecretStore
|
114
|
+
|
115
|
+
end # class Director
|
116
|
+
|
117
|
+
end # module WXRuby3
|
@@ -55,9 +55,9 @@ module WXRuby3
|
|
55
55
|
static const rb_data_type_t __wxTreeItemId_type = {
|
56
56
|
"TreeItemId",
|
57
57
|
#if RUBY_API_VERSION_MAJOR >= 3
|
58
|
-
{ NULL, NULL, __wxTreeItemId_size, 0,
|
58
|
+
{ NULL, NULL, __wxTreeItemId_size, 0, {}},
|
59
59
|
#else
|
60
|
-
{ NULL, NULL, __wxTreeItemId_size,
|
60
|
+
{ NULL, NULL, __wxTreeItemId_size, {}},
|
61
61
|
#endif
|
62
62
|
NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
|
63
63
|
};
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
:wxSecretStore:
|
3
|
+
:detail:
|
4
|
+
:pre:
|
5
|
+
:programlisting:
|
6
|
+
- :pattern: !ruby/regexp /\!store\..*Save.*username.*password\)/
|
7
|
+
:replace: |
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
store = Wx::SecretStore.get_default
|
11
|
+
rc, err = store.ok?
|
12
|
+
if rc
|
13
|
+
unless store.save('MyApp/MyService', username, password)
|
14
|
+
Wx.log_warning('Failed to save credentials to the system secret store.')
|
15
|
+
end
|
16
|
+
else
|
17
|
+
Wx.log_warning("This system doesn't support storing passwords securely (#{err}).")
|
18
|
+
end
|
19
|
+
```
|
20
|
+
- :pattern: !ruby/regexp /store\..*Load.*username.*password\)/
|
21
|
+
:replace: |
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
store = Wx::SecretStore.get_default
|
25
|
+
rc, _ = store.ok?
|
26
|
+
if rc
|
27
|
+
password = Wx::SecretValue.new
|
28
|
+
rc, username = store.load('MyApp/MyService', password)
|
29
|
+
if rc
|
30
|
+
# ... use the password ...
|
31
|
+
end
|
32
|
+
end
|
33
|
+
```
|
34
|
+
:wxSecretStore.IsOk:
|
35
|
+
:brief:
|
36
|
+
:replace:
|
37
|
+
:text: |
|
38
|
+
Check if this object can actually be used.
|
39
|
+
Returns true if the object can be used.
|
40
|
+
Returns false and an error message describing the reason if not.
|
41
|
+
|
42
|
+
:wxSecretStore.Load:
|
43
|
+
:detail:
|
44
|
+
:post:
|
45
|
+
- :pattern: !ruby/regexp /Otherwise\s+the\s+function.*arguments\./
|
46
|
+
:subst: |
|
47
|
+
Otherwise the function returns true and the username and updates the provided password argument.
|
48
|
+
|
49
|
+
:wxSecretValue:
|
50
|
+
:detail:
|
51
|
+
:post:
|
52
|
+
- :pattern: !ruby/regexp /\s+\Z/
|
53
|
+
:subst: |
|
54
|
+
|
55
|
+
@note Due to a bug using binary secrets will not work for WXGTK wxWidgets<=3.2.4 (WXOSX and WXMSW work fine). This has been fixed for later versions.
|
data/rakelib/lib/generate/doc.rb
CHANGED
@@ -233,6 +233,7 @@ module WXRuby3
|
|
233
233
|
Director.Spec(pkg, 'wxPersistenceManager', requirements: %w[USE_CONFIG])
|
234
234
|
Director.Spec(pkg, 'wxPersistentObject', requirements: %w[USE_CONFIG])
|
235
235
|
Director.Spec(pkg, 'wxPersistentWindow', requirements: %w[USE_CONFIG])
|
236
|
+
Director.Spec(pkg, 'wxSecretStore', requirements: %w[USE_SECRETSTORE])
|
236
237
|
}
|
237
238
|
|
238
239
|
Director.Package('Wx::PRT', 'USE_PRINTING_ARCHITECTURE') do |pkg|
|
@@ -262,6 +262,16 @@ module WXRuby3
|
|
262
262
|
|
263
263
|
end
|
264
264
|
|
265
|
+
# output typemaps for common value objects like wxPoint, wxSize, wxRect and wxRealPoint,
|
266
|
+
# making sure to ALWAYS create managed copies
|
267
|
+
%w[Point Size Rect RealPoint].each do |klass|
|
268
|
+
map "const wx#{klass}&", "const wx#{klass}*", as: "Wx::#{klass}" do
|
269
|
+
map_out code: <<~__CODE
|
270
|
+
$result = SWIG_NewPointerObj((new wx#{klass}(*static_cast< const wx#{klass}* >($1))), SWIGTYPE_p_wx#{klass}, SWIG_POINTER_OWN);
|
271
|
+
__CODE
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
265
275
|
# Integer <> wxItemKind type mappings
|
266
276
|
|
267
277
|
map 'wxItemKind' => 'Integer' do
|