Commit graph

431 commits

Author SHA1 Message Date
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
William S Fulton
b8feb85f0e Add Ruby std_array.i - std::array wrappers 2015-11-25 09:19:05 +00:00
William S Fulton
146252ff21 SWIG_Ruby_ConvertPtrAndOwn changes for smartptr feature
rb_obj_is_kind_of can no longer be used for type checking as the
smartptr feature type, eg shared_ptr<Derived> cannot be cast to
a smartptr of the base class, eg shared_ptr<Base>.
Previously Derived could be cast to Base as they were in an
inheritance chain and the call to rb_define_class_under() used
SWIGTYPE_p_Base->clientdata for all derived classes.
Now SWIG_TypeCheck is always used.
2015-09-25 22:58:00 +01:00
William S Fulton
fcb383b46b shared_ptr typemap error message fix for global variables
$argnum was not being expanded in the generated code
Correct to use the error message from the standard typemaps
2015-09-25 22:57:59 +01:00
William S Fulton
4677dbb796 Add Ruby shared_ptr typemaps 2015-09-25 22:57:53 +01:00
William S Fulton
3d1e20248f Ruby ownership refactor ready for smart pointers
ruby_owntype replaced with swig_ruby_owntype which contains a member own
for forthcoming smart pointer support.
2015-09-14 07:20:43 +01:00
William S Fulton
604b3d009c Ruby trackings bug fix support for 1.8
Issue #225
2015-09-13 20:09:50 +01:00
William S Fulton
e14b392596 Ruby trackings patch tidy up and add changes entry
Closes #225
2015-09-13 14:53:26 +01:00
Klaus Kämpf
0e725b5d9b Fix Ruby tracking code to use C hash
This is a patch to resolve SF bug 2034216 (Github issue #225)
The bug is that the tracking code uses a ruby hash and thus may
allocate objects (Bignum) while running the GC. This was tolerated in
1.8 but is invalid (raises an exception) in 1.9.
The patch uses a C hash (also used by ruby) instead.
2015-09-13 14:53:25 +01:00
Olly Betts
d1a8675ac4 Fix incorrect comments 2015-05-09 21:59:03 +12:00
Jason Turner
8339a2d441 Fix shared data problem on MacOS 10.9 with xcode 5.1
Move to construct on first use idiom for singleton definition,
which prevents problems with singletons between ruby swig modules
in an environment with multiple modules on MacOS 10.9 with xcode 5.1.

Before this fix, data was being shared between modules which caused
a crash on shutdown of the ruby interpreter if more than one
module was loaded at a time.
2014-06-04 14:11:18 -06:00
William S Fulton
3191473523 Fix compiler warnings in generated code when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type 2014-05-24 14:13:19 +01:00
Karl Wette
d5b765d388 Whitespace cleanup of all Makefiles*
- some of the %.clean rules in the test-suite Makefiles were using a single tab
  as an empty rule, dangerous! I've replaced these with the safer '@exit 0'.
2014-05-02 20:06:11 +02:00
William S Fulton
e897733b08 Fix missing fragments in Ruby wstring typemaps 2014-03-07 13:15:53 +00:00
Olly Betts
2f3bf144c6 Fix assorted comment and documentation typos 2014-02-23 17:15:22 +13:00
William S Fulton
0d9a8721f4 Move some header file includes into fragments for UTL languages 2014-02-21 19:02:14 +00:00
Olly Betts
b761131fec "if (strlen(msg))" -> "if (msg[0])" 2014-02-17 16:26:48 +13:00
William S Fulton
cc650e692e Director exceptions now derive from std::exception 2014-01-20 19:40:52 +00:00
William S Fulton
1a19451c1b Error out attempting to use directors without -c++
Remove redundant #ifdef __cplusplus markers in director.swg
2013-12-23 20:23:54 +00:00
William S Fulton
135a7cc558 Beautify director.swg files
Also some comment corrections for Perl
2013-12-23 19:50:41 +00:00
William S Fulton
1c5246ad66 Fix some gcc -Wall unused warnings in the Ruby wrappers
Fixes SF bug 1333.
2013-10-18 18:13:11 +01:00