Commit graph

291 commits

Author SHA1 Message Date
William S Fulton
ed333b6b97 std::string throws typemaps
Go, Guile, Racket, Scilab: Add throws typemaps for std::string so that
thrown string exception messages can be seen.

Test all language for std::string throws typemaps
2022-09-19 09:09:29 +01:00
William S Fulton
4a29229bab Add catches_strings test to test throws char * typemap 2022-09-19 09:09:29 +01:00
William S Fulton
e97181ebc0 Add missing typecheck typemaps for std::auto_ptr and std::unique_ptr
To fix overloading when using these types.
2022-09-17 10:23:51 +01:00
William S Fulton
dad7c93ca0 Provide SWIGTYPE MOVE typemaps in swigmove.i
For implementing full move semantics when passing parameters by value.
Based on SWIGTYPE && and std::unique_ptr typemaps which implement move
semantics.

Added for all languages, but untested for: Go, Ocaml, R, Scilab (and
unlikely to be fully functional for same reasons as for std::unique_ptr
support).

Issue #999
2022-09-16 08:36:25 +01:00
William S Fulton
2212af3f4f rvalue reference outputs
Document rvalue reference outputs behaviour
Test rvalue reference outputs
2022-09-08 08:46:32 +01:00
William S Fulton
7934561874 Test/fixes to handle NULL pointer for unique_ptr/auto_ptr
Also add missing unique_ptr tests for Lua and Racket.
2022-08-31 19:42:55 +01:00
William S Fulton
e139a36511 SWIGTYPE && input typemaps now assume object has been moved
Replicated Java implementation.

Fully implemented for:
- C#
- D
- Guile
- Javascript (UTL)
- Lua
- MzScheme
- Octave (UTL)
- Perl (UTL)
- PHP
- Python (UTL)
- Ruby (UTL)
- Tcl (UTL)

PHP std::auto_ptr std::unique_ptr minor tweaks and testcase corrections
2022-08-31 19:40:14 +01:00
William S Fulton
63632f80fb Correct raw pointer handling test for virtual inheritance 2022-08-11 18:44:36 +01:00
William S Fulton
d4b1152d4b Add raw pointer handling test for virtual inheritance
This is a test added for D in previous commit, now expanded to all target languages.

Tidy up counting object instances.
2022-08-05 22:30:23 +01:00
William S Fulton
a741c7dbcf auto_ptr and unique_ptr test tweaks 2022-08-04 07:14:30 +01:00
Olly Betts
07f0b732ba Add machinery for C++14, C++17 and C++20 testing
Support running testcases conditional on the compiler supporting
a each language version, like we already handle C++11.

Currently no testcases are actually run in this way for these
newer language versions.
2022-07-26 15:28:51 +12:00
William S Fulton
1b63af0f2c std::unique_ptr std::auto_ptr tidyup
Add docs on additional support
Additional testing for invalid usage for parameter inputs
2022-07-19 20:23:06 +01:00
William S Fulton
db5e37a1d7 Add support for std::auto_ptr inputs
Ported from std::unique, behaviour is identical with regard to memory ownership/handling
2022-07-18 08:32:26 +01:00
William S Fulton
f99a2e6f64 Add Ruby support for std::unique_ptr inputs
Equivalent to Java/C#/Python implementations.
2022-07-17 15:20:25 +01:00
William S Fulton
299880e6a6 Add std::unique support
Simple copy of current auto_ptr support (just suppport for
functions returning std::unique_ptr).

Closes #1722
2022-07-02 16:17:18 +01:00
William S Fulton
d60724b636 Merge branch 'more_argcargv'
* more_argcargv:
  Document argc argv library
  argcargv.i cosmetic updates
  Typemaps for (int ARGC, char **ARGV) fixup
  Fix argcargv.i in Perl5, Tcl, PHP Add missing type map for type check. Add testing of argcargv.i for Perl5, Tcl, PHP and Ruby.
  Add Lua test for argcargv.i
  Add argcargv.i to more languages: Perl 5, Tcl, PHP
  Add argcargv.i to Lua
2022-05-15 19:42:25 +01:00
Erez Geva
b88fe498ca Fix argcargv.i in Perl5, Tcl, PHP
Add missing type map for type check.
Add testing of argcargv.i for Perl5, Tcl, PHP and Ruby.

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2022-05-11 01:10:12 +02:00
William S Fulton
f029beffe8 Ruby li_std_set test failure workaround
Prevent GC from collecting "hello" string in testcase
as workaround to prevent GC occasionally causing segfault.

Issue #2115
2022-05-06 08:11:29 +01:00
William S Fulton
5cc4591ae7 Consistent cpp11 testing in test-suite
Move HAVE_CXX11 into makefiles so that running test-suite
from top level directory or in the language's test-suite directory
is consistent. For example, running 'make check-java-test-suite'
behaves the same as 'cd Examples/test-suite/java && make check'.
2022-03-27 19:34:20 +01:00
Seth R Johnson
f4e2a4feee Fix warning and improve description of ignore_parameter test
See https://github.com/swig/swig/pull/2205#issuecomment-1052648190
2022-02-27 18:15:39 +13:00
Olly Betts
2e98189564 [Ruby] Fix remove of prefix from method name
The prefix is now only removed at the start.

Fixes https://sourceforge.net/p/swig/bugs/1136/
2022-02-02 15:53:23 +13:00
William S Fulton
99954d6d4e Shorten testcase variable names for Scilab 6 to work 2021-11-15 22:45:56 +00:00
Vadim Zeitlin
f038fcb44d Do nothing in li_std_functors test when using Ruby 2.6
This test sporadically crashes when run in GitHub Actions environment,
so skip it for now when using the Ruby 2.6 version installed by rvm.
2021-10-01 04:26:15 +02:00
Thomas Reitmayr
505ffde655 Add justification for suppressing warnings in Ruby test case
In the same file removed a useless class for comparing versions.
2021-03-16 22:09:50 +01:00
Thomas Reitmayr
7963445048 Add and improve Ruby test cases in the context of nesting and namespaces
This is done in preparation for adding namespace support to the Ruby
part of SWIG. Some existing test cases were reorganized or duplicated
for flat/nonflat nesting. For some a Ruby test script was added.
Finally the ruby/Makefile.in was improved so that for test cases
without an explicit test script, the generated wrapper library will
be loaded by the Ruby interpreter to ensure loading works fine.
2020-12-16 22:30:46 +01:00
William S Fulton
71d4822860 Add Ruby test for wchar_t members in li_std_string testcase 2020-09-24 22:36:32 +01:00
William S Fulton
8041bfdf09 Ruby testcase fix
Reportedly failing. Failure can be replicated with 2.5.1 by increasing
number of loops.
Workaround is to disable GC.

Closes #1646
2020-06-07 17:59:21 +01:00
William S Fulton
a9731251a4 Disable GC checks for Ruby auto_ptr test 2020-01-31 22:45:46 +00:00
Vadim Zeitlin
7cc94808b6 Extend std::auto_ptr<> support to Ruby
This is trivial as exactly the same typemap as for Python can be used
for Ruby too, all the differenced are abstracted by the unified typemap
library.
2020-01-17 15:09:17 +01:00
William S Fulton
558f0ba485 Ruby globalmodule variables test enhancement
Check that the variables values are as expected in C++.
Note that the check_values global function is global in Ruby when
using -globalmodule.
2019-12-30 23:52:02 +00:00
Thomas Reitmayr
18a3ef3911 Fix code generated for Ruby global variables
This commit fixes swig#1653 by creating a Ruby virtual variable
for a C/c++ global variable when SWIG is invoked with the
-globalmodule option.
2019-10-27 21:41:03 +01:00
William S Fulton
86cb3a9532 Python STL container method overloading fix
Fix method overloading of methods that take STL containers of different types.
Due to some error handling that was not cleared during typehecking.
2019-08-06 19:36:14 +01:00
William S Fulton
a9a7b03ba6 Split testcases li_std_wstring.i and li_std_wstring_inherit.i
Not many languages have support for std_wstring.i, so disable testing
for these languages until added.
2019-07-22 19:05:21 +01:00
William S Fulton
5131096b80 li_std_wstring test rename to li_std_wstring_inherit
This testcase was only run in Ruby and Python and implements an
obscure feature where a C++ class inherits from a std::wstring.

The li_std_wstring test is left in place to be modified in next commit
for more regular wstring testing across all languages.
2019-07-18 19:49:50 +01:00
Takashi Tamura
ff9e9f9f98 [ruby] check whether object is of RTypedData using RTYPEDDATA_P. 2019-02-22 19:55:54 +00:00
William S Fulton
1f44997343 rename std::array testcase 2019-02-13 22:46:20 +00:00
William S Fulton
d14c97408d Fix overloading for non-pointers and NULL - Ruby 2018-12-29 14:15:51 +00:00
luz.paz
ed28e7cbe2 Misc. typo and whitespace fixes
Found via `codespell -q 3 -L "uint,bae,objext,cmo,goin,struc,ois,upto"`
whitespaces were unintentionally fixed due to my editors settings.

Rebased patch #1327
2018-09-19 20:29:14 +01:00
Joel Anderson
a1cea4f483 Fix ruby %alias directive for native c functions
Using the %alias directive on native C functions causes swig to segfault due to
a dereference of klass (which is NULL for native C functions) in the
defineAliases function of the Ruby module. This commit adds support for an alias
of native C functions for both separate module as well as global functions, as
well as three test cases for the %alias directive of the Ruby module.

Fixes:
mod.i
%module ruby_alias
%alias get_my_name "nickname,fullname";
%inline %{
const char *get_my_name(){
  return "Chester Tester";
}
%}
$ swig -ruby mod.i
Segmentation fault

Signed-off-by: Joel Anderson <joelanderson333@gmail.com>
2018-03-22 08:05:01 -04:00
William S Fulton
6470fe8c36 Director shared_ptr typemaps for scripting languages
Modify the Python and Ruby director shared_ptr typemaps to be language neutral.
Port the director modifications to other scripting languages that
have shared_ptr support - Octave, R and Scilab. Scilab shared_ptr
support is not fully working and needs work though.
2017-10-13 07:34:38 +01:00
Stephen Sinclair
bda750ee15 Add directorin typemap for Python and Ruby shared_ptr. 2017-09-27 11:22:30 -03:00
William S Fulton
ed4b84f4d3 Fix overloading of shared_ptr method overloading
Add 'equivalent' attribute to typecheck typemap.
Closes #1098.
2017-09-23 15:19:34 +01:00
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
241460eddc director_smartptr runtime tests enhancement
Add same changes from previous commit to additional languages
2017-05-23 21:36:24 +01:00
William S Fulton
db11e82896 Makefile cosmetics 2017-04-24 20:45:01 +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
70740c51d0 [ruby] add simple tests for std unordered containers. 2017-04-22 16:36:09 +09:00
William S Fulton
093cf8d60f Rename shared_ptr testcase 2017-04-21 19:28:08 +01:00
Takashi Tamura
0020fc97b0 [ruby] add %typemap(directorin) for shared_ptr. 2017-04-20 19:20:55 +09:00