Commit graph

272 commits

Author SHA1 Message Date
William S Fulton
a15bbbaee5 Java - unsigned long long marshalling improvements for negative numbers
Affects marshalling of negative numbers from Java to C only.
A cast to signed long long in the C layer will now result in the expected value.

Closes #623.
2016-03-31 18:56:32 +01:00
William S Fulton
8322686e84 Cosmetic java typemap cleanup 2016-03-31 18:56:32 +01:00
William S Fulton
870b814f5e Add C++11 std::array container support for Java 2016-03-14 20:46:56 +00:00
William S Fulton
dc4e0ab0f6 interface macro argument name tweaks 2016-03-11 19:47:08 +00:00
William S Fulton
e1dfad1a3b Change the name of the interface in %feature to be more portable
Use SwigInterface as a suffix to the class name when naming the
interface class instead of using a simple I as a prefix.
%feature_custom can be used to use I as a prefix if so desired.
2016-03-08 08:42:16 +00:00
William S Fulton
5cf20086a4 Rename feature_interface.i to swiginterface.i 2016-03-03 08:55:20 +00:00
William S Fulton
7f3f8fd76a Use rstrip instead of regex encoder in %feature_rename
The regex encoder is not always available in SWIG builds.
2016-03-03 08:55:10 +00:00
William S Fulton
3000824c94 Interface macros: %interface %interface_impl %interface_custom 2016-03-02 07:10:58 +00:00
William S Fulton
14d2341512 Add $interfacename family of special variable expansions
This is a simple expansion expanding to the name of the interface and is
not qualified like $javainterfacename and $csinterfacename.
Expansion within typemaps is much like $javainterfacename otherwise.
Note that expansion within the pure java code typemap,
'javainterfacecode' and similarly pure C# code typemap,
'csinterfacecode' works like $javaclassname/$csclassname and
$&interfacename should not be used, just $interfacename.
2016-02-29 21:18:42 +00:00
William S Fulton
c71dba5021 Interface name handling improvements and special variable changes
Support expansion of name attribute in: %feature("interface", name="%s")
%s expands to the proxy class name and all the usual %rename functions
can be used (regex, strip, camelcase etc) to derive the interface name
from the proxy class name.
Rename $interfacename family of special variables to $javainterfacename for Java
Rename $interfacename family of special variables to $csinterfacename for C#
This is to free up $interfacename for simple interface name expansion in forthcoming commit
2016-02-29 20:18:01 +00:00
William S Fulton
3b8f00f774 interface feature - SWIG_JAVABODY_PROXY does not need to be overridden 2016-02-26 18:17:20 +00:00
William S Fulton
50fec04759 Support namespaces and nspace with the interface feature for Java 2016-02-26 18:17:14 +00:00
William S Fulton
1737fc9b9b Add Java premature garbage collection prevention parameter (pgcpp) to interface feature
pgcpp was turned off but it is still needed for the interface feature
to prevent premature garbage collection of the proxy class being passed
into the C++ layer.
2016-02-24 08:30:10 +00:00
William S Fulton
e7bb3afa0c Create javainterfacecode and csinterfacecode typemaps
The interface feature is no longer hard coded and can
be controlled by a user via these new typemaps.
2016-02-23 07:30:00 +00:00
Vladimir Kalinin
5768d87deb director generation fixes
Conflicts:
	Lib/java/feature_interface.i
	Source/Modules/csharp.cxx
	Source/Modules/java.cxx
2016-02-12 07:09:17 +00:00
William S Fulton
abccc13a4a Merge branch 'interfaces' into interfaces2
* interfaces:
  Remove unnecessary interfaces for concrete classes
  cosmetic code formatting changes
  Correct interface name attributes that are internal
  interface macro changes to support templates
  Test non-virtual method in Derived classes
  interface tests for a most derived class inheriting the interfaces further up the chain
  Rename GetCPtr/getCPtr to SWIGInterfaceUpcast
  interface feature support for const ref pointers (used by the STL)
  Interface feature support for arrays
  More interface feature testing for return values
  interface feature support for passing by value
  interface feature support for references
  Multiple inheritance parameters as pointers testing
  Simplify multiple_inheritance_abstract Java runtime test
  Warning fixes
  Rename test functions in multiple_inheritance_abstract testcase
  Formatting fixes in generated code for interface feature
  Cosmetic spacing changes in test case
  interface feature typemap corrections to handle NULL pointers
  interface test added
  javadirectorin fix
  interface implementation visibility
  interface inheritance (2)
  interface inheritance (1)
  feature:interface ported to Java
  propagate non-abstract "interface" base methods (3)
  propagate non-abstract "interface" base methods (2)
  propagate non-abstract "interface" base methods (1)
  namespace support added GetCPtr now returns HandleRef "feature:interface:name" is now mandatory attribute
  interfaces (1)
  interfaces (1)

Conflicts:
	Source/Modules/csharp.cxx
	Source/Modules/java.cxx
2016-02-11 19:37:31 +00:00
William S Fulton
f82efac231 interface macro changes to support templates
The C++ type must be last in the argument list to support templates with
multiple arguments which are separated by commas.
Affects DECLARE_INTERFACE and DECLARE_INTERFACE_RENAME.
2016-02-09 07:02:42 +00:00
William S Fulton
72e5c221b6 Rename GetCPtr/getCPtr to SWIGInterfaceUpcast
This is then similarly named to other similar functions:
SWIGUpcast and SWIGSmartPtrUpcast
2016-02-08 20:49:46 +00:00
William S Fulton
e8907132cc interface feature support for const ref pointers (used by the STL)
Also interface feature return by value fixes
2016-02-07 13:58:47 +00:00
William S Fulton
5b86e2af13 Interface feature support for arrays 2016-02-06 20:15:48 +00:00
William S Fulton
a1f2d60535 interface feature support for passing by value
Also add in missing $owner for governing ownership when returning pointers and references
2016-02-06 20:15:40 +00:00
William S Fulton
3eec3e2ea5 interface feature support for references 2016-02-06 20:15:29 +00:00
William S Fulton
a7370b7bc0 Formatting fixes in generated code for interface feature 2016-02-06 16:34:24 +00:00
William S Fulton
abf39433e3 interface feature typemap corrections to handle NULL pointers 2016-02-05 19:28:29 +00:00
Vadim Zeitlin
a1bddd56eb Make (char*, size_t) typemap usable for strings of other types in Java.
Notably it now works for "unsigned char*" strings.

Add a test to check that it now works in Java and also showing that it already
worked for the other languages with support for this typemap.
2015-08-07 19:44:45 +02:00
William S Fulton
a1771cb8a0 Fix potential security exploit in generated Java classes 2015-08-02 11:22:46 +01:00
William S Fulton
cd04b372a4 Consistent memory intiailization between C and C++ in typemaps
Remove unnecessary initialization via calloc calls and replace with
malloc.
2015-07-30 20:20:38 +01:00
William S Fulton
c7da8bb06e Warning fixes in generated Java code for 64bit Visual C++ on Windows. 2015-07-03 20:59:24 +01:00
Olly Betts
e796ecaa23 Fix swapped parameters in memset call 2015-05-12 14:20:11 +12:00
William S Fulton
6c1630b152 Fix Java multi-argument typemaps (char *STRING, size_t LENGTH)
Now they can be applied to a wider range of types.
Closes #385.
2015-05-10 13:35:51 +01:00
William S Fulton
775afd3579 Refactor Java director swig_override array code
Remove code duplication: Use new Swig::BoolArray to replace multiple
instances of ZeroedBoolArray.

Refactors #403 and #413.
2015-05-10 11:40:42 +01:00
William S Fulton
ea1b6e8ed5 Memory leak in java directors when passing byte arrays (char*, size_t)
When passing a byte array from c++ to Java using the director feature, the generated jni code does not release a temporary byte array.

This is the typemap specified in Java.swg:

    %typemap(directorin, descriptor="[B") (char *STRING, size_t LENGTH) {
    jbyteArray jb = (jenv)->NewByteArray($2);
    (jenv)->SetByteArrayRegion(jb, 0, $2, (jbyte *)$1);
    $input = jb;
    }

    %typemap(directorargout) (char *STRING, size_t LENGTH)
    %{(jenv)->GetByteArrayRegion($input, 0, $2, (jbyte *)$1); %}

Notice that the call to NewByteArray doesn't contain a symmetric release logic as the SetByteArrayRegion/GetByteArrayRegion does.

Closes #386
2015-04-23 19:17:35 +01:00
William S Fulton
25b48b85ec Fix multiple definitions of 'ExceptionMatches' when using directors and multiple modules.
Java problem, closes #353 and closes #355.
2015-04-11 22:51:29 +01:00
Witold Wolski
70cccf38fd add @SuppressWarnings("unused") to constructors generated using SWIG_JAVABODY_TYPEWRAPPER macro 2015-02-04 10:12:37 +01:00
William S Fulton
0d34a0f0bf Merge branch 'pingany-director_local_jstring_leak'
* pingany-director_local_jstring_leak:
  Use more conventional naming for generated Java LocalRefGuard variables
  Make more use of LocalRefGuard in Java
  fixup! Patch of http://sourceforge.net/p/swig/mailman/message/29816385
  Patch of http://sourceforge.net/p/swig/mailman/message/29816385
2014-09-27 14:33:31 +01:00
William S Fulton
f4964f5fb3 Use more conventional naming for generated Java LocalRefGuard variables 2014-09-27 14:32:03 +01:00
William S Fulton
2f5bf397ae Make more use of LocalRefGuard in Java 2014-09-27 13:56:11 +01:00
Pingan Yi
f38f6371a3 fixup! Patch of http://sourceforge.net/p/swig/mailman/message/29816385 2014-08-13 16:14:57 +08:00
William S Fulton
1773726073 Doc/comment improvements in Java various.i 2014-08-04 19:22:02 +01:00
Yuval Kashtan
093fe2a556 Add support for java.nio.Buffer
including test-suite test case and documentation
2014-07-18 15:45:16 +03:00
Pingan Yi
b79646ce4c Patch of http://sourceforge.net/p/swig/mailman/message/29816385 2014-05-04 19:10:44 +08:00
William S Fulton
f01c84cd8b Java enums - remove redundant typemaps 2014-03-28 07:45:23 +00:00
Curtis Dunham
fe91d6449f Remove register storage class declarations
They're unnecessary, anacronistic, deprecated in modern
standards, generally ignored, useless, and (most importantly)
clang complains about them.
2014-02-19 11:58:27 -06:00
Marvin Greenberg
843aa7cd65 Work around differences in clang libc++ std::vector<bool>::const_reference
clang++ using -stdlib=libc++ defines const_reference as a class,
to map boolean vectors onto a bit set.  Because swig does
not "see" the type as "const &" it generates incorrect code for this case,
generating a declaration like:

  const_reference result;

When const_reference is a typedef to 'bool' as is the case with stdlibc++
this works.  When this is actually a constant reference, this is clearly
invalid since it is not initialized.  For libc++, this is a class
which cannot be default constructed, resulting in an error.  The fix
is to explicitly define the various accessor extensions as having a
bool return type for this specialization.
2014-02-04 16:00:12 -05: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
Vadim Zeitlin
ed28725a15 Add std_auto_ptr.i defining typemaps for returning std::auto_ptr<>.
These typemaps are currently defined for C#, Java and Python only and the
tests are provided only for these languages.

Also add a brief description of the new header to the documentation.
2013-12-03 23:45:20 +01:00
William S Fulton
e7a6be289e Rework the director.swg changes for director exception handling
- More robust implementation.
- Fix some bugs to give better exception messages when a user uses the
  director utility exception functions and classes.
- Replace unnecessarily shortened variable names for easier reading of
  code.
2013-11-07 22:51:35 +00:00
William S Fulton
fdc1772e38 Cosmetics/code style conformance in newly added Java director exception handling 2013-11-07 22:51:34 +00:00