diff --git a/rakelib/lib/core/mapping.rb b/rakelib/lib/core/mapping.rb index c2e9e618..357524ad 100644 --- a/rakelib/lib/core/mapping.rb +++ b/rakelib/lib/core/mapping.rb @@ -270,7 +270,7 @@ def initialize(map, temp: nil, code: nil, &block) end class ArgOut < Base - def initialize(map, as: nil, temp: nil, code: nil, &block) + def initialize(map, as: nil, by_ref: false, temp: nil, code: nil, &block) super(map, temp: nil, code: code) @as = {} if as @@ -278,10 +278,11 @@ def initialize(map, as: nil, temp: nil, code: nil, &block) elsif !map.types.empty? map.types.each_pair { |pset, type| @as[pset] = _get_mapped_type(type) } end + @by_ref = by_ref block.call(self) if block end - attr_reader :as + attr_reader :as, :by_ref def map_as(argdef) _map_args(argdef, @as) @@ -434,8 +435,8 @@ def map_freearg(temp: nil, code: nil, &block) @check = FreeArg.new(self, temp: temp, code: code, &block) end - def map_argout(as: nil, temp: nil, code: nil, &block) - @argout = ArgOut.new(self, as: as, temp: temp, code: code, &block) + def map_argout(as: nil, by_ref: false, temp: nil, code: nil, &block) + @argout = ArgOut.new(self, as: as, by_ref: by_ref, temp: temp, code: code, &block) end def map_directorin(temp: nil, code: nil, &block) @@ -541,7 +542,7 @@ def ignores_input? end def maps_input_as_output? - !!@argout + @argout && !@argout.by_ref end def ignores_output? diff --git a/rakelib/lib/director/graphics_context.rb b/rakelib/lib/director/graphics_context.rb index 2cc4f048..50bdbfc3 100644 --- a/rakelib/lib/director/graphics_context.rb +++ b/rakelib/lib/director/graphics_context.rb @@ -137,6 +137,18 @@ def setup } __CODE end + # for GetPartialTextExtents + spec.map 'wxArrayDouble &widths' => 'Array' do + map_in ignore: true, temp: 'wxArrayDouble tmp', code: '$1 = &tmp;' + + map_argout code: <<~__CODE + $result = rb_ary_new(); + for (size_t i = 0; i < $1->GetCount(); i++) + { + rb_ary_push($result,DBL2NUM( $1->Item(i) ) ); + } + __CODE + end # add convenience method providing efficient gc memory management spec.add_extend_code 'wxGraphicsContext', <<~__HEREDOC static VALUE draw_on(wxWindow* win) diff --git a/rakelib/lib/director/pgproperty.rb b/rakelib/lib/director/pgproperty.rb index d88a9b55..6b99dfb1 100644 --- a/rakelib/lib/director/pgproperty.rb +++ b/rakelib/lib/director/pgproperty.rb @@ -51,6 +51,35 @@ def setup return (*self)[idx]; } __HEREDOC + # for GetIndicesForStrings + spec.map 'wxArrayString *unmatched' => 'Array,nil' do + + map_in temp: 'wxArrayString tmp, VALUE rb_unmatched', code: <<~__CODE + rb_unmatched = $input; + if (!NIL_P(rb_unmatched)) + { + if (TYPE(rb_unmatched) == T_ARRAY) + { + $1 = &tmp; + } + else + { + SWIG_exception_fail(SWIG_TypeError, Ruby_Format_TypeError( "", "Array", "GetIndicesForStrings", $argnum, $input )); + } + } + __CODE + + map_argout by_ref: true, code: <<~__CODE + if (!NIL_P(rb_unmatched$argnum)) + { + for (size_t i = 0; i < $1->GetCount(); i++) + { + rb_ary_push(rb_unmatched$argnum,WXSTR_TO_RSTR( $1->Item(i) ) ); + } + } + __CODE + + end spec.disown 'wxPGProperty *prop', 'wxPGProperty *childProperty' # do not think this useful for wxRuby (Also; caused GC problems) spec.ignore 'wxPGProperty::GetCellRenderer' diff --git a/rakelib/lib/director/richtext_buffer.rb b/rakelib/lib/director/richtext_buffer.rb index a850bea2..ff3fcdf6 100644 --- a/rakelib/lib/director/richtext_buffer.rb +++ b/rakelib/lib/director/richtext_buffer.rb @@ -36,6 +36,35 @@ def setup %set_constant("$symname", rb_str_new2((const char *)wxString($value).utf8_str())); } __HEREDOC + # for GetExtWildcard + spec.map 'wxArrayInt* types' => 'Array,nil' do + + map_in temp: 'wxArrayInt tmp, VALUE rb_types', code: <<~__CODE + rb_types = $input; + if (!NIL_P(rb_types)) + { + if (TYPE(rb_types) == T_ARRAY) + { + $1 = &tmp; + } + else + { + SWIG_exception_fail(SWIG_TypeError, Ruby_Format_TypeError( "", "Array","wxRichTextBuffer::GetExtWildcard", $argnum, $input )); + } + } + __CODE + + map_argout by_ref: true, code: <<~__CODE + if (!NIL_P(rb_types$argnum)) + { + for (size_t i = 0; i < $1->GetCount(); i++) + { + rb_ary_push(rb_types$argnum,INT2NUM( $1->Item(i) ) ); + } + } + __CODE + + end spec.do_not_generate(:functions) super end