Commit graph

3,876 commits

Author SHA1 Message Date
William S Fulton
15a0681b11 Add note about wchar_t marshalling fix required for Windows 2019-07-25 18:57:10 +01:00
smithx
03f7745364 fix undesirable wstring encoding at return value marshalling for C# 2019-07-22 19:11:21 +01:00
smithx
8f6d97ab8c fix undesirable wstring encoding at return value marshalling for C# 2019-07-22 19:11:21 +01:00
William S Fulton
835c732506 Merge branch 'py3.8'
* py3.8:
  Use PyObject_GC_UnTrack in lieu of the old variant
2019-07-18 07:55:33 +01:00
Christian Kellner
db9822788e Use PyObject_GC_UnTrack in lieu of the old variant
The _PyObject_GC_UNTRACK[1] macro got deprecated in 3.6 and finally
removed in 3.8. Therefore use PyObject_GC_UnTrack instead.

[1] https://docs.python.org/3/c-api/gcsupport.html#c._PyObject_GC_UNTRACK
2019-07-17 11:15:17 +02:00
William S Fulton
53b425b638 Merge branch 'bugfix/616-csharp-bool-array'
* bugfix/616-csharp-bool-array:
  Add changes entry to fix C# bool[]
  Quieten failing bool[] testcase message
  Skip failing bool[] test cases when running under mono
  Change C# bool[] typemaps to marshall as 1-byte
2019-07-16 19:51:32 +01:00
Vadim Zeitlin
2be293a647 Fix std::vector<> Java typemaps for primitive types
For such types, the generated proxy class inherited from
java.util.AbstractSet<BoxedType<T>> (where BoxedType<T> is "Integer",
for example, when T is "int"), but defined an overloaded add() taking T,
instead of overriding the base class virtual add() taking BoxedType<T>,
resulting in an exception being thrown whenever add() was called during
run-time.

Extend Java unit test to bring it to parity with C# one added in the
previous commit.

See #1568.
2019-07-11 13:10:23 +02:00
Vadim Zeitlin
28c6140c56 Allow std::set<> C# typemaps to work for non-nullable types too
Notably make them work for primitive types, such as "int".

Doing this requires using "object" instead of the actual C# type of the
variable to store the current value in the iterator, as we don't
currently have a "csnullabletype" typemap that would expand to "T" for
nullable types and "T?" for the other ones. This is a bit ugly, but it
shouldn't matter much for the generated code and is already done in
std::vector<> typemaps.

Also add a simple unit test verifying the basic functionality for such
vectors.

Closes #1568.
2019-07-11 13:09:46 +02:00
Vadim Zeitlin
53d75dc133 Replace leftover string with the proper type in C# set typemap
This is just a mistake remaining from generalizing the old
string-specific typemap to any type.

Fix it now and update a unit test to test for sets of objects other than
strings.
2019-07-11 12:49:17 +02:00
Gareth Francis
58863bba59 Change C# bool[] typemaps to marshall as 1-byte
Default marshalling for bool[] now uses 1-byte entries in the array, to
ensure array contents is as expected in C++.

When running under mono csharp_lib_arrays_bool testcase will fail
due to an apparent bug in mono. Works correctly under Microsoft's
runtime. See https://github.com/mono/mono/issues/15592
2019-07-06 12:56:27 +01:00
William S Fulton
b655d3138b Remove the UnknownExceptionHandler director error handling class
Done in order to be C++17 compliant as it uses std::unexpected_handler
which was removed in C++17. This class was intended for director
exception handling but was never used by SWIG and was never documented.

Closes #1538
2019-06-27 07:40:49 +01:00
William S Fulton
5c1c69d140 Replace std::unexpected_handler with std::terminate_handler to be c++17 compliant
Closes #1538
2019-06-27 07:40:49 +01:00
Brad Kotsopoulos
55e835e0ae Java std::vector constructor performance improvement
Reserve before loop of push_back
Refactor li_std_vector testcase

This is a squash merge of #1552
2019-06-06 19:29:11 +01:00
Olly Betts
c864546b4a [Python] Fix implicit_conv tuple handling regression
Introduced in SWIG 4.0.0.  Fixes #1553, reported by Alexandre
Duret-Lutz.
2019-06-03 10:13:58 +12:00
Zackery Spytz
2f48bec666 Merge remote-tracking branch 'upstream/master' into OCaml-INPUT-OUTPUT-INOUT-primitives 2019-05-08 14:05:02 -06:00
William S Fulton
d67c133c4a Java/C# std::vector<bool> workarounds for clang
Workaround clang++ 9.1.0 error not knowing std::vector<bool>::const_reference
is actually typedef to bool:

  li_std_vector_wrap.cxx:1838:40: error: no matching constructor for initialization of 'std::vector<bool>::const_reference'

Workaround is use

  const value_type& getitem(int index) throw (std::out_of_range) { ...
  // bool specialization:
  bool getitem(int index) throw (std::out_of_range) { ...

instead of

  const_reference_type getitem(int index) throw (std::out_of_range) { ...

Although the following would be better, it would require a more
complicated implementation:

  const_reference_type getitem(int index) throw (std::out_of_range) { ...
  // bool specialization:
  bool getitem(int index) throw (std::out_of_range) { ...
2019-04-20 11:32:42 +01:00
William S Fulton
545ab8af08 Fix Visual Studio 2015 and later compilation errors due to snprintf macro definition.
Closes #1508
2019-04-19 11:33:02 +01:00
William S Fulton
f87182ad98 Improve backwards compatibility in C#/Java std::array wrappers
For users who have typemaps for the parameters in the setitem or set methods.
2019-04-19 11:06:24 +01:00
William S Fulton
592b97a8cd Improve backwards compatibility in D std::vector wrappers
For users who have typemaps for the parameters in the setElement method.
Correct definitions of const_reference to match the those in the
(C++11) standard.
2019-04-19 00:22:53 +01:00
William S Fulton
c79cf79085 Improve backwards compatibility in C# std::vector wrappers
For users who have typemaps for the parameters in the setitem method.
Correct definitions of const_reference to match the those in the
(C++11) standard.
2019-04-19 00:11:22 +01:00
William S Fulton
05c8c972cc Improve backwards compatibility in Java std::vector wrappers
For users who have typemaps for the parameters in the add and set methods
(now called doAdd and doSet).
Also for users who have typemaps for the get method - revert the return
type for get (now called doGet) back to the same return type as
std::vector::at. Correct definitions of const_reference to match the
those in the (C++11) standard.
2019-04-18 23:24:43 +01:00
William S Fulton
00528a1ef6 Fix C# wrappers FxCop warning CA2002 in SWIGPendingException
Fixes two warnings in each wrapper:

warning  : CA2002 : Microsoft.Reliability : 'examplePINVOKE.SWIGPendingException.Retrieve()' locks on a reference of type 'Type'. Replace this with a lock against an object with strong-identity.

warning  : CA2002 : Microsoft.Reliability : 'examplePINVOKE.SWIGPendingException.Set(Exception)' locks on a reference of type 'Type'. Replace this with a lock against an object with strong-identity.

Use lock statement advice not to use typeof for locks, see
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/lock-statement
2019-04-09 19:35:00 +01:00
William S Fulton
831fae3c69 Add the parameters typemap attribute to D and Java destructor wrapper typemaps
Added to the javadestruct, javadestruct_derived, ddispose, ddispose_derived
typemaps to mirror enhanced flexibility in the csdisposing and
csdisposing_derived (C#) typemaps. If provided the contents are generated
as the delete/dispose method's parameters declaration.
2019-04-08 19:20:50 +01:00
William S Fulton
06462acdf9 Fix C# CA1063 warning by implementing the recommended Dispose methods.
Previously just the Dispose() method was generated.
Now the Dispose() and Dispose(bool disposing) methods are generated.
Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived"
typemaps are being used. Details in #421 on Github. SWIG will error out if one of
the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example
error message:

  foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove
  it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the
  csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps.

Closes #421
2019-04-08 19:20:45 +01:00
William S Fulton
59030cb3d2 Replace void* with iterator* in C# std::list wrappers
Better to use the actual type rather than void* in the implementaton.
It also mean the %apply that was used in the implementation won't
inadvertently affect users other use of void* types.
2019-03-25 08:02:32 +00:00
William S Fulton
78051fdd33 C# std::list changes to support types that are not assignable
Assignable fixes are based on those used by C# std::vector where the
default wrappers work if there is no operator== available in the
template type. Enhanced wrappers are obtained via a macro:
 SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass)
 %template(ListKlass) std::list<SomeNamespace::Klass>;

Remove bool specialization (left over from the original std::vector
wrappers).
Add in missing typedefs.
2019-03-25 07:19:49 +00:00
Adrien JUND
e7f9316e60 C# - add std::list 2019-03-25 07:19:49 +00:00
William S Fulton
cfa7a4d4d0 Merge branch 'REnums2018'
* REnums2018:
  Fix R return by C++11 const ref enum classes
  Remove unused code in r.cxx
  extra doc on anonymous enums
  ENH:
  FIX: references to enums now functioning
  DOC: Extended documentation on enumeration support in R
  FIX: Corrected path to output from R tests
  Reformat comments in R module
  ENH: Run test for enum_thorough in R
  Code style changes post review
  ENH: R Module: Enumerations with values set by calls to C code, allowing arbitarily complex value expressions.
  Setting enum values with calls to the C code.
2019-03-18 18:03:20 +00:00
William S Fulton
39e3c3b9d7 Fix R return by C++11 const ref enum classes 2019-03-18 17:49:24 +00:00
mochizk
1e981dfc23 Fix node.js deprecated warnings >= v10.12.0 2019-03-13 23:09:57 +09:00
William S Fulton
d3ae85ee73 Cosmetic tweaks for C# std::set support 2019-03-12 22:47:11 +00:00
William S Fulton
51e75bacf7 Merge branch 'csharp-set'
* csharp-set:
  Fix header comment in C# std_set typemaps
  Implement set-theoretic methods in std::set C# typemaps
  Add std::set<> typemaps for C#
2019-03-12 22:30:15 +00:00
William S Fulton
f58a6dade3 Add missing hasher and key_type typedefs to C++11 STL containers 2019-03-12 21:59:03 +00:00
William S Fulton
f3e2ab9195 Include all template parameters for std_unordered_multiset and std_unordered_set 2019-03-12 21:47:45 +00:00
William S Fulton
4a25ddbb97 Correct unordered_set/unordered_multiset template Key parameter name 2019-03-12 20:21:19 +00:00
William S Fulton
404aa2c3db Merge branch 'std_unordered_map_args_fix'
* std_unordered_map_args_fix:
  Include all template parameters for std_unordered_multimap and std_unordered_map
  Include all template parameters for std_unordered_map macro
2019-03-12 20:03:48 +00:00
William S Fulton
30f59ffe22 Include all template parameters for std_unordered_multimap and std_unordered_map 2019-03-12 20:03:14 +00:00
Vadim Zeitlin
04c9a97787 Fix header comment in C# std_set typemaps
Mention that these typemaps require .NET 4 or greater.
2019-03-11 23:08:19 +01:00
Vadim Zeitlin
aaa12450c0 Implement set-theoretic methods in std::set C# typemaps
These implementations are not optimized, i.e. are done in a naive way in
C#, rather than using C++ functions more efficiently, but are better
than nothing.
2019-03-11 23:05:38 +01:00
Vadim Zeitlin
f0067b6bbf Add std::set<> typemaps for C#
Create new Lib/csharp/std_set.i based on the existing std_map.i and run
li_std_set unit test for C# as well.

Notice that the set operations defined by the base ISet<> interface are
not implemented yet.
2019-03-11 22:49:03 +01:00
Orion Poplawski
c38b7de6a1 Fix format-security error with octave 5.1 2019-03-10 11:47:27 -06:00
Richard Beare
43af20ab3b FIX: references to enums now functioning
There is some consolidation work to be done. The
core of the change is getRClassName2, which will
probably eventually replace getRClassName.

getRClassName seems to be in a funny state, with
a middle argument that is commented out and never
used.

My next step is to verify whether the new version
can replace it.
2019-03-08 21:56:36 +11:00
Richard Beare
e9b39797cc Setting enum values with calls to the C code. 2019-03-08 21:56:36 +11:00
John Wason
cfdf65eb34 Include all template parameters for std_unordered_map macro 2019-03-01 19:13:35 -05:00
William S Fulton
be491506a4 Java std::vector improvements for types that do not have a default constructor.
The std::vector wrappers have been changed to work by default for elements that are
not default insertable, i.e. have no default constructor. This has been achieved by
not wrapping:

  vector(size_type n);

Previously the above had to be ignored via %ignore.

If the above constructor is still required it can be added back in again via %extend:

  %extend std::vector {
    vector(size_type count) { return new std::vector< T >(count); }
  }

Alternatively, the following wrapped constructor could be used as it provides near-enough
equivalent functionality:

  vector(jint count, const value_type& value);

The equivalent change to std::list has also been made (std::list
wrappers were not in the previous release [3.0.12] though).
2019-03-01 18:01:14 +00:00
William S Fulton
613ff08150 Java: more replace Object with java.lang.Object 2019-02-23 16:39:21 +00:00
William S Fulton
a57326aa4f Merge branch 'zphensley42-master'
* zphensley42-master:
  Handle review comments
  Updated java std_map to support Obj derivatives by importing original for use in class
2019-02-23 16:30:04 +00:00
William S Fulton
7fc81f4f85 Merge branch 'gtbX-master'
* gtbX-master:
  Add comment for non-const version
  Don't write-back buffer into Java array when calling const-ptr c function
  Prevent writeback of a const char* array through a director when using the byte[] %typemap.
2019-02-23 16:28:07 +00:00
William S Fulton
a006091b0f Add in a definition for RTYPEDDATA_P for Ruby<1.9.3
This definition ensures the SWIG wrappers keep compiling in older versions
of Ruby given the previous change (which uses RTYPEDDATA_P and hence
requires Ruby 1.9.3). The definition of RTYPEDDATA_P is such that the
previous commit plus the definition should keep the behaviour the same
as before.
2019-02-22 19:55:55 +00:00
Takashi Tamura
ff9e9f9f98 [ruby] check whether object is of RTypedData using RTYPEDDATA_P. 2019-02-22 19:55:54 +00:00