Commit graph

406 commits

Author SHA1 Message Date
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
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
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
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
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
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
d3ae85ee73 Cosmetic tweaks for C# std::set support 2019-03-12 22:47:11 +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
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
Zachary Hensley
d812a4291c Handle review comments 2019-02-22 10:55:20 -06:00
William S Fulton
6d8c1c47f3 Merge branch 'java9_finalize_warnings'
* java9_finalize_warnings:
  [Java] Suppress deprecation warning on finalize method
2019-02-21 13:46:59 -08:00
Zachary Hensley
1e571417b6 Updated java std_map to support Obj derivatives by importing original for use in class 2019-02-21 09:24:41 -06:00
William S Fulton
52063a732b Consistent parameter names for std::pair 2019-02-14 22:44:27 +00:00
William S Fulton
a6a50d60e1 Restore original std::map template parameters for Java 2019-02-14 21:41:08 +00:00
William S Fulton
6d27ead9c0 Add STL container copy constructors where missing
Also provide consistent copy constructor declarations.
2019-02-14 18:53:05 +00:00
William S Fulton
dc34c39c53 Cosmetic STL typedef changes 2019-02-14 08:16:16 +00:00
William S Fulton
40d7f4137e typedef declaration corrections for std::array 2019-02-14 07:38:49 +00:00
William S Fulton
440264e479 Add missing typedefs to std::list + typedef corrections
Numerous missing typedefs added.
std::list<T*>::const_reference and std::list<T*>::reference
specialization typedef fixes.
2019-02-14 07:31:21 +00:00
William S Fulton
e26f6bb4e2 Add missing typedefs to std::vector + typedef corrections
Tests for std::vector of pointers added which check
 std::vector<T*>::const_reference and std::vector<T*>::reference
usage which gave compilation errors in Python and Perl which had
specialized these vectors incorrectly.
2019-02-13 22:46:28 +00:00
William S Fulton
a47c2553f5 Add missing typedefs to std::pair 2019-02-13 22:46:28 +00:00
William S Fulton
9dd33e6367 Add missing typedefs to std::map 2019-02-13 22:46:27 +00:00
William S Fulton
6d0c495fd0 Add missing parameter names in STL container wrappers
Mostly in STL copy constructors.

Best to have parameter names as they make their way into the wrappers in
some target languages.
2019-02-13 22:45:47 +00:00
William S Fulton
68e86614ff Create a consistent stl.i library file
Same file now for all languages except R which is still missing std_map.i.
Recent Java changes adding in std_set.i removed.
2019-02-12 18:46:05 +00:00
William S Fulton
136e6cfe2b Merge branch 'bkotzz-add_set_map'
* bkotzz-add_set_map:
  Add missing typedefs to Java STL containers
  Combine duplicate unordered_set unordered_map testcases
  Nicer looking generated Java container code
  Replicate some cosmetic changes from std_map.i
  Legacy macros, protected iterator, typedefs
  Remove c++11 from stl.i
  Add to STL file as well
  Maps both working as java.util impls
  Mostly working for map
  Add set/unordered_set that extend AbstractSet
  Move unordered containers under cpp11_ prefix
  Add test cases to C++11 list
  Add unordered_{set|map} and set to Java
2019-02-12 18:09:38 +00:00
William S Fulton
e83e14a15e Add missing typedefs to Java STL containers 2019-02-12 07:15:51 +00:00
William S Fulton
9849174d93 Nicer looking generated Java container code 2019-02-12 06:20:19 +00:00
William S Fulton
437037a3e6 Replicate some cosmetic changes from std_map.i
into std_set.i, std_unordered_map.i, std_unordered_set.i.
2019-02-12 06:20:10 +00:00
Brad Kotsopoulos
d06ffe1087 Legacy macros, protected iterator, typedefs 2019-02-04 22:23:13 -05:00
Brad Kotsopoulos
945bd7c808
Remove c++11 from stl.i 2018-12-27 11:47:16 -05:00
Brad Kotsopoulos
7e9f1a7972 Add to STL file as well 2018-12-27 01:15:18 -05:00
Brad Kotsopoulos
573ddb061e Maps both working as java.util impls 2018-12-27 01:11:54 -05:00
William S Fulton
5a388863fa director_thread test fixes for MacOS
Add extra debugging and correctly detect MacOS using __APPLE__ macro
2018-12-21 19:08:15 +00:00
William S Fulton
d835c69d65 Merge branch 'java-director-thread-name'
* java-director-thread-name:
  Add changes entry for setting Java thread name
  Increased Java thread name size.
  Java directors - more generic thread name setting
  Use prctl method to get thread names, which is available on all NDK versions
  Actually, pthread_getname_np is only available in recent versions of Android (API level >= 26).
  Set thread name when attaching to Android JVM in SWIG Java director
2018-12-20 21:23:29 +00:00
William S Fulton
f948a756bb Increased Java thread name size.
MacOS thread_info.h can handle thread names up to 64 characters.
See issue #1334.
2018-12-20 21:21:54 +00:00
Brad Kotsopoulos
e6d8675513 Mostly working for map 2018-12-04 01:08:47 -05:00
Brad Kotsopoulos
6ccc940a14 Add set/unordered_set that extend AbstractSet 2018-11-30 18:21:02 -05:00
Brad Kotsopoulos
0f18b430fb Add unordered_{set|map} and set to Java
Add test suite

Add to makefile

Revert set change

Fix java map test

Fix some of the tests

Fix unordered map test
2018-11-23 14:35:35 -05:00
William S Fulton
ca287ae13b Add support for non-default compare template argument in std::map wrappers 2018-10-09 19:44:00 +01:00
William S Fulton
8ddf24881a Merge branch 'vadz-java-map-comp'
* vadz-java-map-comp:
  Add support for std::map<> comparator template argument for Java

Conflicts:
	CHANGES.current
2018-10-09 07:09:06 +01:00
William S Fulton
3195c3e4da Java directors - more generic thread name setting
Activated if a user sets SWIG_JAVA_USE_THREAD_NAME.
Implementations provided for linux/android/macos/unix.
A user's implementation will be used if SWIG_JAVA_GET_THREAD_NAME is
defined. It must implement the function:
  namespace Swig {
    SWIGINTERN int GetThreadName(char *name, size_t len);
  }
2018-10-08 21:38:41 +01:00
Sam Hasinoff
989f4289c1 Use prctl method to get thread names, which is available on all NDK versions 2018-10-08 21:24:34 +01:00
Sam Hasinoff
8dd8634420 Actually, pthread_getname_np is only available in recent versions of Android (API level >= 26). 2018-10-08 21:24:34 +01:00
Sam Hasinoff
07268b8da6 Set thread name when attaching to Android JVM in SWIG Java director
Otherwise the native thread name gets clobbered with "Thread-XX", which
makes debugging hard. This issue seems to be specific to the Android JVM.
Someone proposed a similar fix to SWIG:
https://github.com/swig/swig/pull/831
but abandoned it.
2018-10-08 21:24:34 +01:00
William S Fulton
61d9dd40a0 Fix crash Java directors
Further crash fixes when using OUTPUT and INOUT typemaps in typemaps.i and
passing NULL pointers in C++ to director method overloaded and implemented
in Java.

Don't create the one element array in these directorin typemaps if the
input is a NULL pointer, that is, translate a NULL C++ pointer into a
null Java object.

Also add some missing JNI error checks in these typemaps.
2018-08-12 13:45:43 +01:00
Bryan Atwood
7eeffe698c Fix Java directorargout typemap crash when argument pointer is null 2018-08-10 17:12:34 -07:00
Vadim Zeitlin
369be6fac4 Add support for std::map<> comparator template argument for Java
Allow exporting maps using non-default comparison function, similar to
what was done for C# back in 9efaf954c7
2018-06-09 18:11:48 +02:00
luz.paz
6f69830321 follow-up typos 2018-05-17 10:26:00 -04:00