Sha256: 05b683ab0e6cecfab9516437656f66b2d257a00064ccce9ebfd043434e7057a2
Contents?: true
Size: 1.51 KB
Versions: 9
Compression:
Stored size: 1.51 KB
Contents
### # wxRuby3 Common typemap definitions # Copyright (c) M.J.N. Corino, The Netherlands ### require_relative '../core/mapping' module WXRuby3 module Typemap # Typemaps which convert a wxArrayInt (array of integers) input # argument to a ruby output argument of the same sort. Used by methods # in (Check)ListBox and the global function get_multiple_choices (Functions.i) # to retrieve a list of selected items. module ArrayIntSelections include Typemap::Module define do map 'wxArrayInt& selections', 'wxArrayInt &checkedItems', as: 'Array<Integer>' do map_in ignore: true, temp: 'wxArrayInt tmp', code: '$1 = &tmp;' # ignore C defined return value entirely (also affects directorout) map_out ignore: ['int', 'unsigned int'] map_argout code: <<~__CODE $result = rb_ary_new(); for (size_t i = 0; i < $1->GetCount(); i++) { rb_ary_push($result,INT2NUM( $1->Item(i) ) ); } __CODE map_directorargout code: <<~__CODE c_result = 0; if (result != Qnil && TYPE(result) == T_ARRAY) { c_result = RARRAY_LEN(result); for (int i = 0, n = RARRAY_LEN(result); i < n ;i++) { int sel = NUM2INT(rb_ary_entry(result, i)); $1.Add(sel); } } __CODE end end # define end # ArrayIntSelections end # Typemap end # WXRuby3
Version data entries
9 entries across 9 versions & 1 rubygems