Fix inconsistencies in Java and C# getCPtr() and pointer constructor visibility - change to protected/internal from public. Add SWIG_JAVABODY_PROXY, SWIG_JAVABODY_TYPEWRAPPER and SWIG_CSBODY_PROXY, SWIG_CSBODY_TYPEWRAPPER for users to easily change when using multiple modules.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12843 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
959fdf2053
commit
6a74028e65
9 changed files with 168 additions and 77 deletions
|
|
@ -1,7 +1,17 @@
|
|||
// Users can provide their own SWIG_INTRUSIVE_PTR_TYPEMAPS or SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP macros before including this file to change the
|
||||
// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(protected, protected, CONST, TYPE)
|
||||
#endif
|
||||
#ifndef SWIG_INTRUSIVE_PTR_TYPEMAPS
|
||||
#define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...) SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE)
|
||||
#endif
|
||||
|
||||
|
||||
%include <intrusive_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
|
|
@ -256,12 +266,12 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
|
@ -271,13 +281,13 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
|
@ -314,7 +324,7 @@
|
|||
|
||||
%include <shared_ptr.i>
|
||||
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(CONST, TYPE...)
|
||||
%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
%naturalvar TYPE;
|
||||
%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
|
||||
|
|
@ -406,12 +416,12 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
|
@ -421,13 +431,13 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
// Users can provide their own SWIG_SHARED_PTR_TYPEMAPS macro before including this file to change the
|
||||
// visibility of the constructor and getCPtr method if desired to public if using multiple modules.
|
||||
#ifndef SWIG_SHARED_PTR_TYPEMAPS
|
||||
#define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...) SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(protected, protected, CONST, TYPE)
|
||||
#endif
|
||||
|
||||
%include <shared_ptr.i>
|
||||
|
||||
// Language specific macro implementing all the customisations for handling the smart pointer
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
|
||||
%define SWIG_SHARED_PTR_TYPEMAPS_IMPLEMENTATION(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, CONST, TYPE...)
|
||||
|
||||
// %naturalvar is as documented for member variables
|
||||
%naturalvar TYPE;
|
||||
|
|
@ -142,12 +148,12 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnBase;
|
||||
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
swigCMemOwnBase = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
|
@ -157,13 +163,13 @@
|
|||
private long swigCPtr;
|
||||
private boolean swigCMemOwnDerived;
|
||||
|
||||
public $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
super($imclassname.$javaclazznameSWIGSmartPtrUpcast(cPtr), true);
|
||||
swigCMemOwnDerived = cMemoryOwn;
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected static long getCPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1116,9 +1116,11 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
|
||||
/* javabody typemaps */
|
||||
|
||||
%define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPENAME...)
|
||||
%define SWIG_JAVABODY_METHODS(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...) SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE) %enddef // legacy name
|
||||
|
||||
%define SWIG_JAVABODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
|
||||
// Base proxy classes
|
||||
%typemap(javabody) TYPENAME %{
|
||||
%typemap(javabody) TYPE %{
|
||||
private long swigCPtr;
|
||||
protected boolean swigCMemOwn;
|
||||
|
||||
|
|
@ -1133,7 +1135,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
%typemap(javabody_derived) TYPENAME %{
|
||||
%typemap(javabody_derived) TYPE %{
|
||||
private long swigCPtr;
|
||||
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
|
||||
|
|
@ -1147,43 +1149,45 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%}
|
||||
%enddef
|
||||
|
||||
/* Set the default for SWIGTYPE: pointer constructor is protected,
|
||||
getCPtr is protected. Season to your own taste! */
|
||||
|
||||
SWIG_JAVABODY_METHODS(public, public, SWIGTYPE)
|
||||
|
||||
%define SWIG_JAVABODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
|
||||
// Typewrapper classes
|
||||
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
|
||||
%typemap(javabody) TYPE *, TYPE &, TYPE [] %{
|
||||
private long swigCPtr;
|
||||
|
||||
protected $javaclassname(long cPtr, boolean futureUse) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) {
|
||||
swigCPtr = cPtr;
|
||||
}
|
||||
|
||||
protected $javaclassname() {
|
||||
DEFAULTCTOR_VISIBILITY $javaclassname() {
|
||||
swigCPtr = 0;
|
||||
}
|
||||
|
||||
protected static long getCPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static long getCPtr($javaclassname obj) {
|
||||
return (obj == null) ? 0 : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(javabody) SWIGTYPE (CLASS::*) %{
|
||||
%typemap(javabody) TYPE (CLASS::*) %{
|
||||
private String swigCMemberPtr;
|
||||
|
||||
protected $javaclassname(String cMemberPtr, boolean futureUse) {
|
||||
PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, boolean futureUse) {
|
||||
swigCMemberPtr = cMemberPtr;
|
||||
}
|
||||
|
||||
protected $javaclassname() {
|
||||
DEFAULTCTOR_VISIBILITY $javaclassname() {
|
||||
swigCMemberPtr = null;
|
||||
}
|
||||
|
||||
protected static String getCMemberPtr($javaclassname obj) {
|
||||
CPTR_VISIBILITY static String getCMemberPtr($javaclassname obj) {
|
||||
return obj.swigCMemberPtr;
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
/* Set the default javabody typemaps to use protected visibility.
|
||||
Use the macros to change to public if using multiple modules. */
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE)
|
||||
|
||||
%typemap(javafinalize) SWIGTYPE %{
|
||||
protected void finalize() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue