Commit graph

401 commits

Author SHA1 Message Date
William S Fulton
e9e9531dc3 Merge branch 'tamuratak-fix_ruby_wstring'
* tamuratak-fix_ruby_wstring:
  [ruby] use %fragment to clarify the dependency of code.
  [ruby] should initialize static variables inside %init{}, in which it will not be        excuted concurrently by multiple threads.
  [ruby] * use static variable to avoid creating stirngs every time.        * fix possible overflow.
  [ruby] add std::wstring tests for string including a null terminator.
  [ruby] * rewrite SWIG_AsWCharPtrAndSize and SWIG_FromWCharPtrAndSize        * use UTF-32LE and UTF-16LE to avoid BOM        * add tests
  [ruby] use WCHAR_MAX to determine the encoding of std::wstring.
  [ruby] add a few tests for std::wstring
  [ruby] fix support for std::wstring.
2017-06-20 20:13:01 +01:00
William S Fulton
82969b0755 Fix warning in generated code - traits_asptr.
Visual Studio 2015 debug builds:
error C4703: potentially uninitialized local pointer variable 'p' used
2017-06-13 19:02:59 +01:00
William S Fulton
32855cfb69 Merge branch 'tamuratak-fix_ruby_unordered_set'
* tamuratak-fix_ruby_unordered_set:
  [ruby] add simple tests for std unordered containers.
  [ruby] clarify dependency of fragments for unordered_set containers.

 Conflicts:
	Examples/test-suite/ruby/Makefile.in
2017-04-24 20:44:12 +01:00
William S Fulton
ee44f9ba67 Merge branch 'tamuratak-fix_ruby_null_shared_ptr'
* tamuratak-fix_ruby_null_shared_ptr:
  [ruby] add a test.
  [ruby] use std::vector::back() method.
  [ruby] enable a test for null shared_ptr in containers.
  [ruby] add a test for null shared_ptr in containers.
  [ruby] treat null shared_ptr in std containers properly.

Conflicts:
	Examples/test-suite/ruby/Makefile.in
2017-04-24 19:50:59 +01:00
Takashi Tamura
43c3ca3767 [ruby] clarify dependency of fragments for unordered_set containers. 2017-04-22 16:35:25 +09:00
William S Fulton
71e5ff406f Merge branch 'tamuratak-fix_ruby_director_and_shared_ptr'
* tamuratak-fix_ruby_director_and_shared_ptr:
  Rename shared_ptr testcase
  [ruby] use boost/shared_ptr and boost_shared_ptr.i. not use auto.
  [ruby] delete unnecessary changes.
  [ruby] add %typemap(directorin) for shared_ptr.
  [ruby] enable a test, cpp11_shared_ptr_director.
  [ruby] add %typemap(directorin) and %typemap(directorout) for shared_ptr.
  [ruby] add %typemap(directorout) for shared_ptr.
  add a test for shared_ptr with director

Conflicts:
	CHANGES.current
2017-04-21 19:31:25 +01:00
Takashi Tamura
6672338cc0 [ruby] delete unnecessary changes. 2017-04-21 22:44:38 +09:00
William S Fulton
b4377488f7 Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj.
Closes #935
2017-04-20 18:51:45 +01:00
Takashi Tamura
0020fc97b0 [ruby] add %typemap(directorin) for shared_ptr. 2017-04-20 19:20:55 +09:00
Takashi Tamura
17b4e0c66e [ruby] add %typemap(directorin) and %typemap(directorout) for shared_ptr. 2017-04-20 19:20:11 +09:00
Takashi Tamura
b3c2b1c51c [ruby] add %typemap(directorout) for shared_ptr. 2017-04-20 19:20:11 +09:00
Takashi Tamura
661c3fc554 [ruby] treat null shared_ptr in std containers properly. 2017-04-20 18:53:47 +09:00
William S Fulton
c9d094e034 Merge branch 'tamuratak-shared_ptr_derived_2'
* tamuratak-shared_ptr_derived_2:
  Correct comment about const removal for shared_ptr
  Correct ordering of declarations in testcase
  Ruby shared_ptr on error code improvement in traits_as::as
  Add support for pointers to shared_ptr and null shared_ptr in Ruby containers
  Add shared_ptr non-overloaded upcast tests
  use forward declaration to treat the dependency of fragments
  [ruby] must not do a null check for VALUE.
  [ruby] add tests for shared_ptr of const Type.
  [ruby] For swig::from, use template specialization to convert shared_ptr<const T> to shared_ptr<T>.
  [ruby] edit comments [skip ci]
  [ruby] move template specialization to std_shared_ptr.i.
  [ruby] add tests for upcasting std::shared_ptr within std containers.
  [ruby] use template specialization for swig::asptr,asval functions on std:shared_ptr.
2017-04-20 07:50:20 +01:00
William S Fulton
660147043d Correct comment about const removal for shared_ptr 2017-04-20 07:49:03 +01:00
William S Fulton
1a6f8d1e4b Ruby shared_ptr on error code improvement in traits_as::as 2017-04-13 07:04:07 +01:00
William S Fulton
83a389d3fb Add support for pointers to shared_ptr and null shared_ptr in Ruby containers
Upcasting of pointers to shared_ptr would need some more fundamental
changes, but not done yet ... pointers to shared_ptr are not common.
2017-04-13 06:59:56 +01:00
Takashi Tamura
b32854bc59 use forward declaration to treat the dependency of fragments 2017-03-29 19:11:44 +09:00
Takashi Tamura
377d439964 Merge remote-tracking branch 'origin/shared_ptr_const_conv' into shared_ptr_derived_2 2017-03-29 18:16:01 +09:00
William S Fulton
382b3f0f8c Merge branch 'tamuratak-fix_typo_ruby_unordered_map'
* tamuratak-fix_typo_ruby_unordered_map:
  [ruby] add a test to make sure that std::multiset is including Enumerable.
  [ruyb] enable std::list test for Ruby.
  [ruby] make std::list include Enumerable.
  [ruby] make std::multiset and std::unordered_multiset include Enumerable. tests added.
  [ruby] make std::unordered_map include Enumerable.
2017-03-29 08:56:25 +01:00
Takashi Tamura
cb1f89cb68 [ruby] must not do a null check for VALUE. 2017-03-07 11:43:01 +09:00
Takashi Tamura
d0af6fd97d [ruby] must not do null check for VALUE obj, which can be 0x0 == Qfalse, a valid Ruby object. 2017-03-06 15:13:05 +09:00
Takashi Tamura
f96c2ad73d [ruby] For swig::from, use template specialization to convert shared_ptr<const T> to shared_ptr<T>. 2017-03-03 12:50:23 +09:00
Takashi Tamura
806f49bf58 [ruby] edit comments [skip ci] 2017-03-02 11:55:09 +09:00
Takashi Tamura
a784ace983 [ruby] move template specialization to std_shared_ptr.i. 2017-03-02 09:47:46 +09:00
Takashi Tamura
50e495c453 [ruby] use template specialization for swig::asptr,asval functions on std:shared_ptr. 2017-03-01 20:17:50 +09:00
Takashi Tamura
c88b9e8777 [ruby] make std::list include Enumerable. 2017-02-25 16:08:21 +09:00
Takashi Tamura
9f43082786 [ruby] make std::multiset and std::unordered_multiset include Enumerable. tests added. 2017-02-24 16:59:17 +09:00
Takashi Tamura
005e129287 [ruby] make std::unordered_map include Enumerable. 2017-02-24 16:59:17 +09:00
Takashi Tamura
4f31f5d0a3 [ruby] use %fragment to clarify the dependency of code. 2017-02-23 21:08:04 +09:00
Takashi Tamura
04a7c4f8b8 [ruby] should initialize static variables inside %init{}, in which it will not be
excuted concurrently by multiple threads.
2017-02-22 12:25:27 +09:00
Takashi Tamura
e7eece9bcd [ruby] * use static variable to avoid creating stirngs every time.
* fix possible overflow.
2017-02-21 21:25:14 +09:00
Takashi Tamura
89695255e6 [ruby] add std::wstring tests for string including a null terminator. 2017-02-20 17:49:17 +09:00
Takashi Tamura
4009da3588 [ruby] * rewrite SWIG_AsWCharPtrAndSize and SWIG_FromWCharPtrAndSize
* use UTF-32LE and UTF-16LE to avoid BOM
       * add tests
2017-02-20 17:00:52 +09:00
Takashi Tamura
5722d81a09 [ruby] use WCHAR_MAX to determine the encoding of std::wstring. 2017-02-19 15:57:34 +09:00
Takashi Tamura
bfe7204576 [ruby] add a few tests for std::wstring 2017-02-18 17:54:03 +09:00
Takashi Tamura
904bc2ad52 [ruby] fix support for std::wstring. 2017-02-18 16:27:23 +09:00
William S Fulton
50f556de39 Cosmetic changes in C++11 std_unordered support files 2017-02-10 19:26:02 +00:00
Takashi Tamura
d29a325b99 [ruby] support for std unordered containers. 2017-01-29 11:17:18 +09:00
Takashi Tamura
37af90a50e use equal_range instead of upper_bound.
unordered containers do not have the upper_bound method.
2017-01-29 11:11:55 +09:00
Anthony Heading
1871acd4bc Remove inheritance from std::unary_function and std::binary_function,
they are deprecated in C++11 and already removed in Visual C++ '15'
running with /std:c++latest

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3145.html
2016-12-29 00:56:46 -05:00
William S Fulton
364fa82499 Replicate Python memory leak fix in std::pair for Octave and Ruby
https://github.com/swig/swig/pull/851
2016-12-18 20:00:40 +00:00
William S Fulton
91aba9f719 UTL STL container descriptor checks
The vector of pointers (just fixed) were not working correctly because the
descriptors returned from swig::type_info() were sometimes returning
zero. Zero should only be used for void * as the subsequent call to
SWIG_ConvertPtr will blindly cast the pointer without checking
descriptor.

std::vector<void *> does not work and will require further changes:
specializing traits_info<void *> to return 0 and traits_asptr<void *>.
I tried this and traits_asptr<void> also needs to be added in which
seems odd and requires further investigation...

Lib/python/pystdcommon.swg:
  template <> struct traits_info<void *> {
    static swig_type_info *type_info() {
      static swig_type_info *info = 0;
    }
  };

Lib/std/std_common.i:
  template <>
  struct traits_asptr<void *> {
    static int asptr(PyObject *obj, void ***val) {
      void **p;
      swig_type_info *descriptor = 0;
      int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
      if (SWIG_IsOK(res)) {
	if (val) *val = p;
      }
      return res;
    }
  };

  // this is needed, but am not sure this is expected
  template <>
  struct traits_asptr<void> {
    static int asptr(PyObject *obj, void **val) {
      void **p;
      swig_type_info *descriptor = 0;
      int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
      if (SWIG_IsOK(res)) {
	if (val) *val = p;
      }
      return res;
    }
  };
2016-07-28 22:51:29 +01:00
William S Fulton
763827c2e1 Ruby opaque pointer handling regression fix
This bug was introduced in swig-3.0.8 in #146252 adding shared_ptr
support. An ObjectPreviouslyDeleted error was incorrectly thrown
when the pointer was used as a parameter after being set to zero
via a call to 'DATA_PTR(self) = 0'.

It isn't clear to me which approach is better in this corner case,
so I've gone for backwards compatibility and restored the old behaviour.

Closes #602
2016-05-24 19:09:17 +01:00
Alec Cooper
4e2fc7d115 Don't use long long if it isn't available
Adds preprocessor checks to avoid defining functions that use long long if it isn't available
Effects the following languages: javascript, octave, perl, python, r, ruby, tcl
2016-01-06 16:52:37 -05:00
William S Fulton
4f2dcfaeeb Fixes for Ruby and using -Wmissing-field-initializers 2015-12-19 16:21:22 +00:00
William S Fulton
6b4e57245d Fix STL wrappers to not generate <: digraphs.
For example std::vector<::X::Y> was sometimes generated, now
corrected to std::vector< ::X::Y >.
2015-12-12 14:05:46 +00:00
William S Fulton
93eb7eae0b Limited Python/Ruby support for boost::array
Hack to use the std::array support for boost::array.
Is limited as it currently exposes some 'using' bugs in SWIG.
For example, the type system fails to see that pointers to std::array
and pointers to boost::array are the same.

This approach saves having to maintain separate boost::array support.
The 'using' bug ought to be fixed, otherwise separate boost_array.i
files could be easily made from the std_array.i files.
2015-11-27 19:30:22 +00:00
William S Fulton
bb2523a003 Ruby STL container setting slices fixes
Setting an STL container wrapper slice better matches the way Ruby
arrays work. The behaviour is now the same as Ruby arrays. The only
exception is the default value used when expanding a container
cannot be nil as this is not a valid type/value for C++ container
elements.
2015-11-25 10:13:30 +00:00
William S Fulton
cd33aba427 Ruby STL container ranges and slices fixes.
Access via ranges and slices now behave identically to Ruby arrays.
The fixes are mostly for out of range indices and lengths.
- Zero length slice requests return an empty container instead of nil.
- Slices which request a length greater than the size of the container
  no longer chop off the last element.
- Ranges which used to return nil now return an empty array when the
  the start element is a valid index.
2015-11-25 09:19:13 +00:00
William S Fulton
fe09f05beb Ruby STL container negative indexing support improved
Using negative indexes to set values works the same as Ruby arrays, eg

%template(IntVector) std::vector<int>;

iv = IntVector.new([1,2,3,4])
iv[-4] = 9 # => [1,2,3,9]
iv[-5] = 9 # => IndexError
2015-11-25 09:19:13 +00:00