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@12844 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6a74028e65
commit
6e56d87471
2 changed files with 35 additions and 1 deletions
|
|
@ -1656,6 +1656,40 @@ However, a call from C# to <tt>CSharpDefaults.DefaultMethod()</tt> will of cours
|
|||
should pass the call on to <tt>CSharpDefaults.DefaultMethod(int)</tt>using the C++ default value, as shown above.
|
||||
</p>
|
||||
|
||||
<H2><a name="CSharp_multiple_modules"></a>18.5 Multiples modules</H2>
|
||||
|
||||
<p>
|
||||
When using <a href="Modules.html">multiple modules</a> it is is possible to compile each SWIG generated wrapper
|
||||
into a different assembly.
|
||||
However, by default the generated code may not compile if
|
||||
generated classes in one assembly use generated classes in another assembly.
|
||||
The visibility of the
|
||||
<tt>getCPtr()</tt> and pointer constructor generated from the <tt>csbody</tt> typemaps needs changing.
|
||||
The default visibility is <tt>internal</tt> but it needs to be <tt>public</tt> for access from a different assembly.
|
||||
Just changing 'internal' to 'public' in the typemap achieves this.
|
||||
Two macros are available in <tt>csharp.swg</tt> to make this easier and using them is the preferred approach
|
||||
over simply copying the typemaps and modifying as this is forward compatible with any changes in
|
||||
the <tt>csbody</tt> typemap in future versions of SWIG.
|
||||
The macros are for the proxy and typewrapper classes and can respectively be used to
|
||||
to make the method and constructor public:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
SWIG_CSBODY_PROXY(public, public, SWIGTYPE)
|
||||
SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Alternatively, instead of exposing these as public, consider
|
||||
using the <tt>[assembly:InternalsVisibleTo("Name")]</tt> attribute available in the .NET framework when you
|
||||
know which assemblies these can be exposed to.
|
||||
Another approach would be to make these public, but also to hide them from intellisense by using
|
||||
the <tt>[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]</tt> attribute
|
||||
if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.
|
||||
</p>
|
||||
|
||||
<H2><a name="CSharp_typemap_examples"></a>18.7 C# Typemap examples</H2>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1186,7 +1186,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
|
||||
/* 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_PROXY(protected, protected, SWIGTYPE)
|
||||
SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE)
|
||||
|
||||
%typemap(javafinalize) SWIGTYPE %{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue