bit more on javapackage typemap
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6842 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
66e8ff2c59
commit
100cb94359
1 changed files with 17 additions and 6 deletions
|
|
@ -4494,15 +4494,15 @@ For example:
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
Assume that the Foo class is part of the Java package <i>wombat.foo</i> but the above interface file is part of the Java package <i>wombat.example</i>.
|
Assume that the Foo class is part of the Java package <i>com.wombat.foo</i> but the above interface file is part of the Java package <i>com.wombat.example</i>.
|
||||||
Without the "javapackage" typemap, SWIG will assume that the Foo class belongs to <i>wombat.example</i> class.
|
Without the "javapackage" typemap, SWIG will assume that the Foo class belongs to <i>com.wombat.example</i> class.
|
||||||
The corrected interface file looks like:
|
The corrected interface file looks like:
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
// class Foo is handled in a different interface file:
|
// class Foo is handled in a different interface file:
|
||||||
%import "Foo.i"
|
%import "Foo.i"
|
||||||
%typemap("javapackage") Foo "wombat.foo";
|
%typemap("javapackage") Foo, Foo *, Foo & "com.wombat.foo";
|
||||||
%feature("director") Example;
|
%feature("director") Example;
|
||||||
|
|
||||||
%inline {
|
%inline {
|
||||||
|
|
@ -4518,7 +4518,10 @@ The corrected interface file looks like:
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Practically speaking, you should create a separate SWIG interface file, which is %import-ed into each SWIG interface file, when you have multiple Java packages:
|
SWIG looks up the package based on the <b>actual</b> type (plain Foo, Foo pointer and Foo reference), so it is important to associate all three types with the desired package.
|
||||||
|
Practically speaking, you should create a separate SWIG interface file, which is %import-ed into each SWIG interface file, when you have multiple Java packages.
|
||||||
|
Note the helper macros below, <code>OTHER_PACKAGE_SPEC</code> and <code>ANOTHER_PACKAGE_SPEC</code>, which reduce the amount of extra typing.
|
||||||
|
"<code>TYPE...</code>" is useful when passing templated types to the macro, since multiargument template types appear to the SWIG preprocessor as multiple macro arguments.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<blockquote>
|
<blockquote>
|
||||||
|
|
@ -4526,8 +4529,16 @@ Practically speaking, you should create a separate SWIG interface file, which is
|
||||||
%typemap("javapackage") SWIGTYPE, SWIGTYPE *, SWIGTYPE &
|
%typemap("javapackage") SWIGTYPE, SWIGTYPE *, SWIGTYPE &
|
||||||
"package.for.most.classes";
|
"package.for.most.classes";
|
||||||
|
|
||||||
%typemap("javapackage") Package_2_class_one "package.for.other.classes";
|
%define OTHER_PACKAGE_SPEC(TYPE...)
|
||||||
%typemap("javapackage") Package_3_class_two "package.for.another.set";
|
%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.other.classes";
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
%define ANOTHER_PACKAGE_SPEC(TYPE...)
|
||||||
|
%typemap("javapackage") TYPE, TYPE *, TYPE & "package.for.another.set";
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
OTHER_PACKAGE_SPEC(Package_2_class_one)
|
||||||
|
ANOTHER_PACKAGE_SPEC(Package_3_class_two)
|
||||||
/* etc */
|
/* etc */
|
||||||
</pre>
|
</pre>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue