mirror of https://github.com/swig/swig
Merge branch 'nspacemove'
* nspacemove: Improved namespace validity checks for the nspace feature Add docs for %nspacemove Add nspacemove example for STL types Validate scopename in nspace feature Fix %nspace and %nspacemove for nested classes and enums in a class Enhance %nspace with %nspacemove for moving symbols into a different target language namespace nspacemove testcase Correct code in javascript testcase for jsc Conflicts: CHANGES.current
This commit is contained in:
commit
a3682dd3e5
|
@ -7,6 +7,43 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.3.0 (in progress)
|
||||
===========================
|
||||
|
||||
2024-05-31: wsfulton
|
||||
[C#, D, Java, Javascript, Lua] Fix %nspace and %nspacemove for nested
|
||||
classes and enums in a class. For example:
|
||||
|
||||
%nspace Space::OuterClass80;
|
||||
namespace Space {
|
||||
struct OuterClass80 {
|
||||
struct InnerClass80 {
|
||||
struct BottomClass80 {};
|
||||
};
|
||||
enum InnerEnum80 { ie80a, ie80b };
|
||||
};
|
||||
}
|
||||
|
||||
Previously the following were additionally required for some languages:
|
||||
|
||||
%nspace Space::OuterClass80::InnerClass80;
|
||||
%nspace Space::OuterClass80::InnerClass80::Bottom80;
|
||||
|
||||
Now the appropriate nspace setting is taken from the outer class.
|
||||
|
||||
A new warning has also been introduced to check and correct conflicting
|
||||
nspace usage, for example if the following is additionally added:
|
||||
|
||||
%nspacemove(AnotherSpace) Space::OuterClass80::InnerClass80;
|
||||
|
||||
The following warning appears as an inner class can't be moved outside
|
||||
of the outer class:
|
||||
|
||||
Warning 406: Ignoring nspace setting (AnotherSpace) for 'Space::OuterClass80::InnerClass80',
|
||||
Warning 406: as it conflicts with the nspace setting (Space) for outer class 'Space::OuterClass80'.
|
||||
|
||||
2024-05-31: wsfulton
|
||||
[C#, D, Java, Javascript, Lua] #2782 Enhance the nspace feature with
|
||||
%nspacemove for moving a class or enum into a differently named target
|
||||
language equivalent of a namespace.
|
||||
|
||||
2024-05-31: binaire10
|
||||
[Ruby] #2906 Fix SWIG wrappers for std::map and std::vector to
|
||||
work with Ruby's "select".
|
||||
|
@ -24,6 +61,7 @@ Version 4.3.0 (in progress)
|
|||
#2876 Report error if parser stack depth exceeded. Previously SWIG
|
||||
would quietly exit with status 0 in this situation.
|
||||
|
||||
|
||||
2024-04-12: pfusik
|
||||
[Javascript] #2869 Fix JavaScript _wrap_getCPtr on 64-bit Windows
|
||||
|
||||
|
|
|
@ -275,6 +275,11 @@
|
|||
<li><a href="SWIGPlus.html#SWIGPlus_namespaces">Namespaces</a>
|
||||
<ul>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nspace">The nspace feature for namespaces</a>
|
||||
<ul>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nspace_feature_flag">%nspace for mirroring namespace hierarchies</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nspacemove">%nspacemove for modifying namespace hierarchies</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_nspace_more">More about the nspace feature</a>
|
||||
</ul>
|
||||
</ul>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_renaming_templated_types_namespaces">Renaming templated types in namespaces</a>
|
||||
<li><a href="SWIGPlus.html#SWIGPlus_exception_specifications">Exception specifications</a>
|
||||
|
@ -401,6 +406,10 @@
|
|||
<li><a href="CPlusPlus20.html#CPlusPlus20_lambda_templates">Lambda templates</a>
|
||||
<li><a href="CPlusPlus20.html#CPlusPlus20_constexpr_destructors">Constexpr destructors</a>
|
||||
</ul>
|
||||
<li><a href="CPlusPlus20.html#CPlusPlus20_preprocessor_changes">Preprocessor changes</a>
|
||||
<ul>
|
||||
<li><a href="CPlusPlus20.html#CPlusPlus20_va_opt">__VA_OPT__()</a>
|
||||
</ul>
|
||||
<li><a href="CPlusPlus20.html#CPlusPlus20_standard_library_changes">Standard library changes</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -416,7 +425,7 @@
|
|||
<li><a href="Preprocessor.html#Preprocessor_condition_compilation">Conditional Compilation</a>
|
||||
<li><a href="Preprocessor.html#Preprocessor_nn5">Macro Expansion</a>
|
||||
<li><a href="Preprocessor.html#Preprocessor_nn6">SWIG Macros</a>
|
||||
<li><a href="Preprocessor.html#Preprocessor_nn7">C99 and GNU Extensions</a>
|
||||
<li><a href="Preprocessor.html#Preprocessor_nn7">Variadic Macros</a>
|
||||
<li><a href="Preprocessor.html#Preprocessor_delimiters">Preprocessing and delimiters</a>
|
||||
<ul>
|
||||
<li><a href="Preprocessor.html#Preprocessor_nn8">Preprocessing and %{ ... %} & " ... " delimiters</a>
|
||||
|
|
|
@ -425,7 +425,11 @@ struct A {
|
|||
<H3><a name="D_nspace">24.8.1 Extended namespace support (nspace)</a></H3>
|
||||
|
||||
|
||||
<p>By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, <em>free</em> variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.</p>
|
||||
<p>By default, SWIG flattens all C++ namespaces into a flattened D module hierarchy, but as for Java and C#, the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature is supported for D.
|
||||
If the feature is active, C++ namespaces are mapped to D packages/modules.
|
||||
This includes the <tt>nspace</tt> feature flag for mirroring the C++ namespaces into D namespaces as a scoped D module/package name.
|
||||
It also includes <tt>%nspacemove</tt> for transforming a C++ namespace into a completely different scoped D module/package name.
|
||||
Note, however, that like for the other languages, <em>free</em> variables and functions are not supported yet; currently, they are all available in the main proxy D module.</p>
|
||||
|
||||
|
||||
<H3><a name="D_native_pointer_support">24.8.2 Native pointer support</a></H3>
|
||||
|
|
|
@ -1929,7 +1929,7 @@ Each SWIG module can be placed into a separate package.
|
|||
<p>
|
||||
The default behaviour described above can be improved via the <a href="SWIGPlus.html#SWIGPlus_nspace">nspace feature</a>.
|
||||
Note that it only works for classes, structs, unions and enums declared within a named C++ namespace.
|
||||
When the nspace feature is used, the C++ namespaces are converted into Java packages of the same name.
|
||||
When the nspace feature is used (either the <tt>nspace</tt> feature flag or <tt>%nspacemove</tt>), the C++ namespaces are converted into Java packages of the same name.
|
||||
Proxy classes are thus declared within a package and this proxy makes numerous calls to the JNI intermediary class which is declared in the unnamed package by default.
|
||||
As Java does not support types declared in a named package accessing types declared in an unnamed package, the <tt>-package</tt> commandline option described earlier generally should be used to provide a parent package.
|
||||
So if SWIG is run using the <tt>-package com.myco</tt> option, a wrapped class, <tt>MyWorld::Material::Color</tt>, can then be accessed as <tt>com.myco.MyWorld.Material.Color</tt>.
|
||||
|
|
|
@ -1377,13 +1377,15 @@ add exception specification to functions or globally (respectively).
|
|||
|
||||
|
||||
<p>
|
||||
Since SWIG-3.0.0 C++ namespaces are supported via the %nspace feature.
|
||||
C++ namespaces are supported via the %nspace feature.
|
||||
</p>
|
||||
<p> Namespaces are mapped into Lua tables. Each of those tables contains names that were defined within appropriate namespace. Namespaces structure (a.k.a nested namespaces) is preserved. Consider the following C++ code:
|
||||
<p> Namespaces are mapped into Lua tables. Each of those tables contains names that were defined within an appropriate namespace. Namespace hierarchies (a.k.a nested namespaces) are preserved. Consider the following C++ code:
|
||||
</p>
|
||||
<div class="code"><pre>%module example
|
||||
%nspace MyWorld::Nested::Dweller;
|
||||
<div class="code"><pre>
|
||||
%module example
|
||||
|
||||
%nspace MyWorld::World;
|
||||
%nspace MyWorld::Nested::Dweller;
|
||||
|
||||
int module_function() { return 7; }
|
||||
int module_variable = 9;
|
||||
|
@ -1411,34 +1413,69 @@ Now, from Lua usage is as follows:
|
|||
|
||||
<div class="targetlang"><pre>
|
||||
> print(example.module_function())
|
||||
7
|
||||
7.0
|
||||
> print(example.module_variable)
|
||||
9
|
||||
9.0
|
||||
> print(example.MyWorld.World():create_world())
|
||||
17
|
||||
> print(example.MyWorld.World.world_max_count)
|
||||
9
|
||||
17.0
|
||||
> print(example.MyWorld.World().world_max_count)
|
||||
9.0
|
||||
> print(example.MyWorld.Nested.Dweller.MALE)
|
||||
0
|
||||
> print(example.MyWorld.Nested.Dweller.count())
|
||||
19
|
||||
>
|
||||
19.0
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
The hierarchies in Lua are the same as the C++ hierarchies when using <tt>%nspace</tt>,
|
||||
however, we could instead completely change these hierarchies with <tt>%nspacemove</tt>.
|
||||
Consider the code above with the two <tt>%nspace</tt> lines of code removed and replaced with the following:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
%nspacemove(DifferentWorld::SubSpace1::SubSpace2) MyWorld::World;
|
||||
%nspacemove(DifferentWorld) MyWorld::Nested::Dweller;
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
The Lua code uses the completely modified hierarchies:
|
||||
</p>
|
||||
|
||||
<div class="targetlang"><pre>
|
||||
> print(example.module_function())
|
||||
7.0
|
||||
> print(example.module_variable)
|
||||
9.0
|
||||
> print(example.DifferentWorld.SubSpace1.SubSpace2.World():create_world())
|
||||
17.0
|
||||
> print(example.DifferentWorld.SubSpace1.SubSpace2.World().world_max_count)
|
||||
9.0
|
||||
> print(example.DifferentWorld.Dweller.MALE)
|
||||
0
|
||||
> print(example.DifferentWorld.Dweller.count())
|
||||
19.0
|
||||
</pre></div>
|
||||
|
||||
<H4><a name="Lua_nn27">29.3.17.1 Compatibility Note </a></H4>
|
||||
|
||||
|
||||
<p>
|
||||
The nspace feature was first supported by the Lua module in SWIG-3.0.0
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If SWIG is running in a backwards compatible way, i.e. without the <tt>-no-old-metatable-bindings</tt> option, then additional old-style names are generated (notice the underscore):
|
||||
</p>
|
||||
<div class="targetlang"><pre>
|
||||
9
|
||||
> print(example.MyWorld.Nested.Dweller_MALE)
|
||||
0
|
||||
> print(example.MyWorld.Nested.Dweller_count())
|
||||
11
|
||||
>
|
||||
19.0
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
The ability to move symbols into different namespaces via <tt>%nspacemove</tt> was introduced in SWIG-4.3.0.
|
||||
</p>
|
||||
|
||||
<H4><a name="Lua_nn29">29.3.17.2 Names </a></H4>
|
||||
|
||||
|
|
|
@ -72,6 +72,11 @@
|
|||
<li><a href="#SWIGPlus_namespaces">Namespaces</a>
|
||||
<ul>
|
||||
<li><a href="#SWIGPlus_nspace">The nspace feature for namespaces</a>
|
||||
<ul>
|
||||
<li><a href="#SWIGPlus_nspace_feature_flag">%nspace for mirroring namespace hierarchies</a>
|
||||
<li><a href="#SWIGPlus_nspacemove">%nspacemove for modifying namespace hierarchies</a>
|
||||
<li><a href="#SWIGPlus_nspace_more">More about the nspace feature</a>
|
||||
</ul>
|
||||
</ul>
|
||||
<li><a href="#SWIGPlus_renaming_templated_types_namespaces">Renaming templated types in namespaces</a>
|
||||
<li><a href="#SWIGPlus_exception_specifications">Exception specifications</a>
|
||||
|
@ -4763,15 +4768,31 @@ More advanced handling of namespaces is discussed next.
|
|||
|
||||
|
||||
<p>
|
||||
Some target languages provide support for the <tt>nspace</tt> <a href="Customization.html#Customization_features">feature</a>.
|
||||
The feature can be applied to any class, struct, union or enum declared within a named namespace.
|
||||
The feature wraps the type within the target language specific concept of a namespace,
|
||||
for example, a Java package or C# namespace.
|
||||
Please see the language specific sections to see if the target language you are interested in supports the nspace feature.
|
||||
The <tt>nspace</tt> feature operates in two modes.
|
||||
Firstly, in a simple enable/disable mode to mirror the C++ namespaces into the target language specific concept of a C++ namespace.
|
||||
Secondly, a complex mode for modifying, renaming or moving the hierarchies of the language specific concept of a C++ namespace.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The feature is demonstrated below for C# using the following example:
|
||||
The types of symbols that the feature can be applied to are any class, struct, union or enum declared within a named namespace.
|
||||
This also includes templates of the aforementioned types.
|
||||
The feature wraps the type within the target language specific concept of a namespace,
|
||||
such as a Java package or C# namespace.
|
||||
Only some target languages provide support for the <tt>nspace</tt> feature.
|
||||
Please see the target language specific sections to see if the language you are interested in supports the nspace feature.
|
||||
</p>
|
||||
|
||||
<H4><a name="SWIGPlus_nspace_feature_flag">6.19.1.1 %nspace for mirroring namespace hierarchies</a></H4>
|
||||
|
||||
|
||||
<p>
|
||||
In this simple mode the <tt>nspace</tt> feature works as a <a href="Customization.html#Customization_feature_flags">feature flag</a> to enable or disable the feature for a given C++ symbol.
|
||||
As described earlier, all namespace are flattened by default, hence the <tt>nspace</tt> feature is disabled by default.
|
||||
When the feature is enabled, the C++ namespace hierarchies are mirrored into the target language concept of a namespace.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The feature flag is demonstrated below using the following example:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
|
@ -4795,7 +4816,7 @@ namespace MyWorld {
|
|||
</div>
|
||||
|
||||
<p>
|
||||
Without the <tt>nspace</tt> feature directives above or <tt>%rename</tt>, you would get the following warning resulting in just one of the <tt>Color</tt> classes being available for use from the target language:
|
||||
By default, without the above <tt>nspace</tt> feature flags (or an appropriate <tt>%rename</tt>), SWIG outputs the following warning resulting in just one of the <tt>Color</tt> classes being available for use from the target language:
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
|
@ -4806,14 +4827,24 @@ example.i:5: Error: Previous declaration of 'Color'
|
|||
</div>
|
||||
|
||||
<p>
|
||||
With the <tt>nspace</tt> feature the two <tt>Color</tt> classes are wrapped into the equivalent C# namespaces.
|
||||
Let's consider C# as the target language.
|
||||
With the two <tt>nspace</tt> feature flags, the two C# <tt>Color</tt> proxy classes are generated into the equivalent C# namespaces that mirror the C++ namespace hierarchies.
|
||||
A fully qualified constructor call of each these two types in C# is then:
|
||||
</p>
|
||||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
MyWorld.Material.Color materialColor = new MyWorld.Material.Color();
|
||||
MyWorld.Wrapping.Color wrappingColor = new MyWorld.Wrapping.Color();
|
||||
var materialColor = new MyWorld.Material.Color();
|
||||
var wrappingColor = new MyWorld.Wrapping.Color();
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Without the <tt>nspace</tt> feature flag, no namespaces are available in C# and the fully qualified constructor call of the type in C# would simply be:
|
||||
</p>
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
var materialColor = new Color();
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
@ -4837,9 +4868,186 @@ namespace MyWorld {
|
|||
</div>
|
||||
|
||||
<p>
|
||||
<b>Compatibility Note:</b> The nspace feature was first introduced in SWIG-2.0.0.
|
||||
<b>Compatibility Note:</b> The simple <tt>%nspace</tt> feature flag was first introduced in SWIG-2.0.0.
|
||||
</p>
|
||||
|
||||
<H4><a name="SWIGPlus_nspacemove">6.19.1.2 %nspacemove for modifying namespace hierarchies</a></H4>
|
||||
|
||||
|
||||
<p>
|
||||
The more complex mode for <tt>nspace</tt> provides the ability to move a type into a differently named target language equivalent of a namespace.
|
||||
This allows a fully flexible approach to mapping C++ namespaces into a target language equivalent of a namespace, such as:
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li> Renaming a namespace.</li>
|
||||
<li> Renaming any number of sub-namespaces of a namespace.</li>
|
||||
<li> Moving a type to a completely different namespace.</li>
|
||||
<li> Splitting many types in one namespace into multiple different namespaces.</li>
|
||||
<li> Adding nested sub-namespaces to a namespace.</li>
|
||||
<li> Removing nested sub-namespaces of namespace.</li>
|
||||
<li> Combinations of the above.</li>
|
||||
</ul>
|
||||
|
||||
<p>
|
||||
The <tt>nspace</tt> feature attaches to a C++ symbol and provides a target language namespace for that symbol to move to.
|
||||
The <tt>%nspacemove</tt> directive is a macro for the <tt>nspace</tt> feature as follows:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
#define %nspacemove(NAMESPACE) %feature("nspace", #NAMESPACE)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
where the target namespace is provided in <tt>NAMESPACE</tt> and is specified in valid C++ syntax, such as <tt>A::B::C</tt>.
|
||||
Internally, SWIG converts the C++ namespace into a target language equivalent,
|
||||
so this might for example, result in a C# namespace called <tt>A.B.C</tt> or a Java package named <tt>A.B.C</tt>.
|
||||
Note that the target namespace does not have to actually exist in any of the C++ code that SWIG parses; it could be entirely made-up.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Either the <tt>%nspacemove</tt> macro or the more verbose <tt>%feature</tt> syntax can be used. Please see the <a href="Customization.html#Customization_features">Features and the %feature directive</a> section for more details of SWIG features.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
An example follows:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
// Enable the nspace feature flag for all symbols
|
||||
%nspace;
|
||||
|
||||
// Override the nspace feature for a subset of symbols by moving them into different namespaces
|
||||
%nspacemove(A) A::B::C::Struct1;
|
||||
%feature("nspace", "A::B::X") A::B::C::Struct2;
|
||||
%nspacemove(A::B::C::D) A::B::C::Struct4;
|
||||
%nspacemove(Somewhere::Else) A::B::C::Struct5;
|
||||
|
||||
%inline %{
|
||||
namespace A {
|
||||
namespace B {
|
||||
namespace C {
|
||||
struct Struct1 {
|
||||
// ...
|
||||
};
|
||||
struct Struct2 {
|
||||
// ...
|
||||
};
|
||||
struct Struct3 {
|
||||
// ...
|
||||
};
|
||||
struct Struct4 {
|
||||
// ...
|
||||
};
|
||||
struct Struct5 {
|
||||
// ...
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
%}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The C# code below constructs each of the above classes.
|
||||
It shows the namespaces that the C# proxy classes have been moved into,
|
||||
noting though that <tt>Struct4</tt> merely exactly mirrors the C++ namespace hierarchy as it has the <tt>nspace</tt> feature flag attached to it.
|
||||
</p>
|
||||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
var s1 = new A.Struct1();
|
||||
var s2 = new A.B.X.Struct2();
|
||||
var s3 = new A.B.C.Struct3();
|
||||
var s4 = new A.B.C.D.Struct4();
|
||||
var s5 = new Somewhere.Else.Struct5();
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<H4><a name="SWIGPlus_nspace_more">6.19.1.3 More about the nspace feature</a></H4>
|
||||
|
||||
|
||||
<p>
|
||||
When the <tt>nspace</tt> feature is attached to a class or enum, all contained symbols (members) are also automatically moved into the target language namespace.
|
||||
Contained symbols include all enum values, static and non-static class members as well as nested classes.
|
||||
There is no need for additional <tt>nspace</tt> features to be specified for all the contained symbols.
|
||||
Below is an example showing this.
|
||||
It also shows the nspace feature working for templates.
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
// Easy way to move all the Structure template instantiations into a different namespace
|
||||
%nspacemove(A::Different::Space) Space::Structure;
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
template<typename T>
|
||||
struct Structure {
|
||||
static int Count;
|
||||
static void StaticMethod(T t) {
|
||||
// ...
|
||||
}
|
||||
struct NestedStruct {
|
||||
// ...
|
||||
};
|
||||
};
|
||||
template<typename T>
|
||||
int Structure<T>::Count = 0;
|
||||
}
|
||||
%}
|
||||
%template(StructureInt) Space::Structure<int>;
|
||||
%template(StructureString) Space::Structure<const char *>;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The C# code below shows the full C# namespace <tt>A.Different.Space</tt> being used as one would expect for all the contained symbols within a C# class.
|
||||
</p>
|
||||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
var s = new A.Different.Space.StructureInt();
|
||||
int count = A.Different.Space.StructureInt.Count;
|
||||
var n = new A.Different.Space.StructureInt.NestedStruct();
|
||||
A.Different.Space.StructureInt.StaticMethod(99);
|
||||
A.Different.Space.StructureString.StaticMethod("hi");
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Any attempt to give a different namespace value to a nested class or enum will issue a warning.
|
||||
For example, adding the following to the above in an attempt to move one of the instantiated nested classes into another namespace like this:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%nspacemove(Bad::Space) Space::Structure<int>::NestedStruct;
|
||||
... rest of example above ...
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
will result in the following warning:
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
<pre>
|
||||
Warning 406: Ignoring nspace setting (Bad::Space) for 'Space::Structure< int >::NestedStruct',
|
||||
Warning 406: as it conflicts with the nspace setting (A::Different::Space) for outer class 'Space::Structure< int >'.
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<b>Compatibility Note:</b> Modifying namespace hierarchies via <tt>%nspacemove</tt> was first introduced in SWIG-4.3.0.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<H2><a name="SWIGPlus_renaming_templated_types_namespaces">6.20 Renaming templated types in namespaces</a></H2>
|
||||
|
||||
|
||||
|
|
|
@ -478,6 +478,7 @@ example.i(4) : Syntax error in input(1).
|
|||
<li>403. Class 'name' might be abstract.
|
||||
<li>404. Duplicate template instantiation of '<em>type</em>' with name '<em>name</em>' ignored, previous instantiation of '<em>type</em>' with name '<em>name</em>'.
|
||||
<li>405. Method with rvalue ref-qualifier <em>name</em> ignored.
|
||||
<li>406. Ignoring nspace setting (<em>setting</em>) for '<em>type</em>', as it conflicts with the nspace setting (<em>setting</em>) for outer class '<em>type</em>'
|
||||
<li>450. Reserved
|
||||
<li>451. Setting const char * variable may leak memory.
|
||||
<li>452. Reserved
|
||||
|
|
|
@ -335,8 +335,6 @@ CPP_TEST_CASES += \
|
|||
namespace_typemap \
|
||||
namespace_union \
|
||||
namespace_virtual_method \
|
||||
nspace \
|
||||
nspace_extend \
|
||||
native_directive \
|
||||
naturalvar \
|
||||
naturalvar_more \
|
||||
|
@ -352,6 +350,11 @@ CPP_TEST_CASES += \
|
|||
nested_workaround \
|
||||
newobject1 \
|
||||
newobject3 \
|
||||
nspace \
|
||||
nspace_extend \
|
||||
nspacemove \
|
||||
nspacemove_nested \
|
||||
nspacemove_stl \
|
||||
null_pointer \
|
||||
numeric_bounds_checking \
|
||||
operator_overload \
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// outer classes
|
||||
nspacemove_nestedNamespace.Space.OuterClass1 oc1 = new nspacemove_nestedNamespace.Space.OuterClass1();
|
||||
nspacemove_nestedNamespace.Space.OuterClass2 oc2 = new nspacemove_nestedNamespace.Space.OuterClass2();
|
||||
nspacemove_nestedNamespace.NewSpace3.OuterClass3 oc3 = new nspacemove_nestedNamespace.NewSpace3.OuterClass3();
|
||||
nspacemove_nestedNamespace.NewSpace4.OuterClass4 oc4 = new nspacemove_nestedNamespace.NewSpace4.OuterClass4();
|
||||
nspacemove_nestedNamespace.OuterClass5 oc5 = new nspacemove_nestedNamespace.OuterClass5();
|
||||
nspacemove_nestedNamespace.OuterClass6 oc6 = new nspacemove_nestedNamespace.OuterClass6();
|
||||
nspacemove_nestedNamespace.OuterClass7 oc7 = new nspacemove_nestedNamespace.OuterClass7();
|
||||
|
||||
nspacemove_nestedNamespace.Space.OuterClass10 oc10 = new nspacemove_nestedNamespace.Space.OuterClass10();
|
||||
nspacemove_nestedNamespace.Space.OuterClass20 oc20 = new nspacemove_nestedNamespace.Space.OuterClass20();
|
||||
nspacemove_nestedNamespace.NewOkay30.OuterClass30 oc30 = new nspacemove_nestedNamespace.NewOkay30.OuterClass30();
|
||||
nspacemove_nestedNamespace.NewOkay40.OuterClass40 oc40 = new nspacemove_nestedNamespace.NewOkay40.OuterClass40();
|
||||
nspacemove_nestedNamespace.NewOkay50.OuterClass50 oc50 = new nspacemove_nestedNamespace.NewOkay50.OuterClass50();
|
||||
nspacemove_nestedNamespace.OuterClass60 oc60 = new nspacemove_nestedNamespace.OuterClass60();
|
||||
nspacemove_nestedNamespace.OuterClass70 oc70 = new nspacemove_nestedNamespace.OuterClass70();
|
||||
nspacemove_nestedNamespace.Space.OuterClass80 oc80 = new nspacemove_nestedNamespace.Space.OuterClass80();
|
||||
|
||||
// inner classes
|
||||
nspacemove_nestedNamespace.Space.OuterClass1.InnerClass1 ic1 = new nspacemove_nestedNamespace.Space.OuterClass1.InnerClass1();
|
||||
nspacemove_nestedNamespace.Space.OuterClass2.InnerClass2 ic2 = new nspacemove_nestedNamespace.Space.OuterClass2.InnerClass2();
|
||||
nspacemove_nestedNamespace.NewSpace3.OuterClass3.InnerClass3 ic3 = new nspacemove_nestedNamespace.NewSpace3.OuterClass3.InnerClass3();
|
||||
nspacemove_nestedNamespace.NewSpace4.OuterClass4.InnerClass4 ic4 = new nspacemove_nestedNamespace.NewSpace4.OuterClass4.InnerClass4();
|
||||
nspacemove_nestedNamespace.OuterClass5.InnerClass5 ic5 = new nspacemove_nestedNamespace.OuterClass5.InnerClass5();
|
||||
nspacemove_nestedNamespace.OuterClass6.InnerClass6 ic6 = new nspacemove_nestedNamespace.OuterClass6.InnerClass6();
|
||||
nspacemove_nestedNamespace.OuterClass7.InnerClass7 ic7 = new nspacemove_nestedNamespace.OuterClass7.InnerClass7();
|
||||
|
||||
nspacemove_nestedNamespace.Space.OuterClass10.InnerClass10 ic10 = new nspacemove_nestedNamespace.Space.OuterClass10.InnerClass10();
|
||||
nspacemove_nestedNamespace.Space.OuterClass20.InnerClass20 ic20 = new nspacemove_nestedNamespace.Space.OuterClass20.InnerClass20();
|
||||
nspacemove_nestedNamespace.NewOkay30.OuterClass30.InnerClass30 ic30 = new nspacemove_nestedNamespace.NewOkay30.OuterClass30.InnerClass30();
|
||||
nspacemove_nestedNamespace.NewOkay40.OuterClass40.InnerClass40 ic40 = new nspacemove_nestedNamespace.NewOkay40.OuterClass40.InnerClass40();
|
||||
nspacemove_nestedNamespace.NewOkay50.OuterClass50.InnerClass50 ic50 = new nspacemove_nestedNamespace.NewOkay50.OuterClass50.InnerClass50();
|
||||
nspacemove_nestedNamespace.OuterClass60.InnerClass60 ic60 = new nspacemove_nestedNamespace.OuterClass60.InnerClass60();
|
||||
nspacemove_nestedNamespace.OuterClass70.InnerClass70 ic70 = new nspacemove_nestedNamespace.OuterClass70.InnerClass70();
|
||||
nspacemove_nestedNamespace.Space.OuterClass80.InnerClass80 ic80 = new nspacemove_nestedNamespace.Space.OuterClass80.InnerClass80();
|
||||
|
||||
// inner enums
|
||||
oc1.take(nspacemove_nestedNamespace.Space.OuterClass1.InnerEnum1.ie1a, ic1);
|
||||
oc2.take(nspacemove_nestedNamespace.Space.OuterClass2.InnerEnum2.ie2a, ic2);
|
||||
oc3.take(nspacemove_nestedNamespace.NewSpace3.OuterClass3.InnerEnum3.ie3a, ic3);
|
||||
oc4.take(nspacemove_nestedNamespace.NewSpace4.OuterClass4.InnerEnum4.ie4a, ic4);
|
||||
oc5.take(nspacemove_nestedNamespace.OuterClass5.InnerEnum5.ie5a, ic5);
|
||||
oc6.take(nspacemove_nestedNamespace.OuterClass6.InnerEnum6.ie6a, ic6);
|
||||
oc7.take(nspacemove_nestedNamespace.OuterClass7.InnerEnum7.ie7a, ic7);
|
||||
|
||||
oc10.take(nspacemove_nestedNamespace.Space.OuterClass10.InnerEnum10.ie10a, ic10);
|
||||
oc20.take(nspacemove_nestedNamespace.Space.OuterClass20.InnerEnum20.ie20a, ic20);
|
||||
oc30.take(nspacemove_nestedNamespace.NewOkay30.OuterClass30.InnerEnum30.ie30a, ic30);
|
||||
oc40.take(nspacemove_nestedNamespace.NewOkay40.OuterClass40.InnerEnum40.ie40a, ic40);
|
||||
oc50.take(nspacemove_nestedNamespace.NewOkay50.OuterClass50.InnerEnum50.ie50a, ic50);
|
||||
oc60.take(nspacemove_nestedNamespace.OuterClass60.InnerEnum60.ie60a, ic60);
|
||||
oc70.take(nspacemove_nestedNamespace.OuterClass70.InnerEnum70.ie70a, ic70);
|
||||
oc80.take(nspacemove_nestedNamespace.Space.OuterClass80.InnerEnum80.ie80a, ic80);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// constructors and destructors
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color color1 = new nspacemoveNamespace.Ooter.Extra.Inner1.Color();
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color color = new nspacemoveNamespace.Ooter.Extra.Inner1.Color(color1);
|
||||
color1.Dispose();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color created = nspacemoveNamespace.Ooter.Extra.Inner1.Color.create();
|
||||
created.Dispose();
|
||||
|
||||
// class enums
|
||||
nspacemoveNamespace.Outer.SomeClass someClass = new nspacemoveNamespace.Outer.SomeClass();
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspacemoveNamespace.Ooter.Extra.Inner1.Color.Channel.Transmission)
|
||||
throw new ApplicationException("Transmission wrong");
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = nspacemoveNamespace.Ooter.Extra.Inner1.Color.ColorEnumVal1;
|
||||
int val2 = nspacemoveNamespace.Ooter.Extra.Inner1.Color.ColorEnumVal2;
|
||||
if (val1 != 0 || val2 != 0x22)
|
||||
throw new ApplicationException("ColorEnumVal wrong");
|
||||
|
||||
// instance member variables
|
||||
color.instanceMemberVariable = 123;
|
||||
if (color.instanceMemberVariable != 123)
|
||||
throw new ApplicationException("instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspacemoveNamespace.Ooter.Extra.Inner1.Color.staticMemberVariable != 789)
|
||||
throw new ApplicationException("static member variable failed");
|
||||
if (nspacemoveNamespace.Ooter.Extra.Inner1.Color.staticConstMemberVariable != 222)
|
||||
throw new ApplicationException("static const member variable failed");
|
||||
if (nspacemoveNamespace.Ooter.Extra.Inner1.Color.staticConstEnumMemberVariable != nspacemoveNamespace.Ooter.Extra.Inner1.Color.Channel.Transmission)
|
||||
throw new ApplicationException("static const enum member variable failed");
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspacemoveNamespace option
|
||||
nspacemoveNamespace.nspacemove.namespaceFunction(color);
|
||||
nspacemoveNamespace.nspacemove.namespaceVar = 111;
|
||||
if (nspacemoveNamespace.nspacemove.namespaceVar != 111)
|
||||
throw new ApplicationException("global var failed");
|
||||
|
||||
// Same class different namespaces
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color col1 = new nspacemoveNamespace.Ooter.Extra.Inner1.Color();
|
||||
nspacemoveNamespace.Outer.Snner2.Color col2 = nspacemoveNamespace.Outer.Snner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// global enums
|
||||
nspacemoveNamespace.Euter.Extra.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspacemoveNamespace.Euter.Extra.Inner1.Channel.Transmission1)
|
||||
throw new ApplicationException("Transmission1 wrong");
|
||||
nspacemoveNamespace.Outer.Enner2.Channel outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspacemoveNamespace.Outer.Enner2.Channel.Transmission2)
|
||||
throw new ApplicationException("Transmission2 wrong");
|
||||
|
||||
nspacemoveNamespace.nspacemove.takeGlobalEnum(nspacemoveNamespace.More.GlobalEnum.bbb);
|
||||
|
||||
// global class
|
||||
nspacemoveNamespace.Additional.GlobalClass gc = new nspacemoveNamespace.Additional.GlobalClass();
|
||||
gc.gmethod();
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspacemoveNamespace.Outer.namespce ns = new nspacemoveNamespace.Outer.namespce();
|
||||
ns.Dispose();
|
||||
nspacemoveNamespace.NoNSpacePlease nons = new nspacemoveNamespace.NoNSpacePlease();
|
||||
nons.Dispose();
|
||||
|
||||
// Derived class
|
||||
nspacemoveNamespace.Outer.Inner3.Blue blue3 = new nspacemoveNamespace.Outer.Inner3.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
nspacemoveNamespace.Outer.Inner4.Blue blue4 = new nspacemoveNamespace.Outer.Inner4.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
nspacemove_stlNamespace.CPlusPlus.Standard.Ints.VectorInt vi = new nspacemove_stlNamespace.CPlusPlus.Standard.Ints.VectorInt();
|
||||
nspacemove_stlNamespace.CPlusPlus.Standard.Strings.VectorString vs = new nspacemove_stlNamespace.CPlusPlus.Standard.Strings.VectorString();
|
||||
nspacemove_stlNamespace.CPlusPlus.Maps.MapIntInt mii = new nspacemove_stlNamespace.CPlusPlus.Maps.MapIntInt();
|
||||
nspacemove_stlNamespace.CPlusPlus.Maps.MapIntString mis = new nspacemove_stlNamespace.CPlusPlus.Maps.MapIntString();
|
||||
|
||||
nspacemove_stlNamespace.nspacemove_stl.test_vector_int(vi);
|
||||
nspacemove_stlNamespace.nspacemove_stl.test_vector_string(vs);
|
||||
nspacemove_stlNamespace.nspacemove_stl.test_map_int(mii);
|
||||
nspacemove_stlNamespace.nspacemove_stl.test_map_string(mis);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
module nspacemove_nested_runme;
|
||||
|
||||
import std.exception;
|
||||
import nspacemove_nested.nspacemove_nested;
|
||||
static import nspacemove_nested.Space.OuterClass1;
|
||||
static import nspacemove_nested.Space.OuterClass2;
|
||||
static import nspacemove_nested.NewSpace3.OuterClass3;
|
||||
static import nspacemove_nested.NewSpace4.OuterClass4;
|
||||
static import nspacemove_nested.OuterClass5;
|
||||
static import nspacemove_nested.OuterClass6;
|
||||
static import nspacemove_nested.OuterClass7;
|
||||
static import nspacemove_nested.Space.OuterClass10;
|
||||
static import nspacemove_nested.Space.OuterClass20;
|
||||
static import nspacemove_nested.NewOkay30.OuterClass30;
|
||||
static import nspacemove_nested.NewOkay40.OuterClass40;
|
||||
static import nspacemove_nested.NewOkay50.OuterClass50;
|
||||
static import nspacemove_nested.OuterClass60;
|
||||
static import nspacemove_nested.OuterClass70;
|
||||
static import nspacemove_nested.Space.OuterClass80;
|
||||
|
||||
void main() {
|
||||
// outer classes
|
||||
auto oc1 = new nspacemove_nested.Space.OuterClass1.OuterClass1();
|
||||
auto oc2 = new nspacemove_nested.Space.OuterClass2.OuterClass2();
|
||||
auto oc3 = new nspacemove_nested.NewSpace3.OuterClass3.OuterClass3();
|
||||
auto oc4 = new nspacemove_nested.NewSpace4.OuterClass4.OuterClass4();
|
||||
auto oc5 = new nspacemove_nested.OuterClass5.OuterClass5();
|
||||
auto oc6 = new nspacemove_nested.OuterClass6.OuterClass6();
|
||||
auto oc7 = new nspacemove_nested.OuterClass7.OuterClass7();
|
||||
|
||||
auto oc10 = new nspacemove_nested.Space.OuterClass10.OuterClass10();
|
||||
auto oc20 = new nspacemove_nested.Space.OuterClass20.OuterClass20();
|
||||
auto oc30 = new nspacemove_nested.NewOkay30.OuterClass30.OuterClass30();
|
||||
auto oc40 = new nspacemove_nested.NewOkay40.OuterClass40.OuterClass40();
|
||||
auto oc50 = new nspacemove_nested.NewOkay50.OuterClass50.OuterClass50();
|
||||
auto oc60 = new nspacemove_nested.OuterClass60.OuterClass60();
|
||||
auto oc70 = new nspacemove_nested.OuterClass70.OuterClass70();
|
||||
auto oc80 = new nspacemove_nested.Space.OuterClass80.OuterClass80();
|
||||
|
||||
// inner classes
|
||||
auto ic1 = new nspacemove_nested.Space.InnerClass1.InnerClass1();
|
||||
auto ic2 = new nspacemove_nested.Space.InnerClass2.InnerClass2();
|
||||
auto ic3 = new nspacemove_nested.NewSpace3.InnerClass3.InnerClass3();
|
||||
auto ic4 = new nspacemove_nested.NewSpace4.InnerClass4.InnerClass4();
|
||||
auto ic5 = new nspacemove_nested.InnerClass5.InnerClass5();
|
||||
auto ic6 = new nspacemove_nested.InnerClass6.InnerClass6();
|
||||
auto ic7 = new nspacemove_nested.InnerClass7.InnerClass7();
|
||||
|
||||
auto ic10 = new nspacemove_nested.Space.InnerClass10.InnerClass10();
|
||||
auto ic20 = new nspacemove_nested.Space.InnerClass20.InnerClass20();
|
||||
auto ic30 = new nspacemove_nested.NewOkay30.InnerClass30.InnerClass30();
|
||||
auto ic40 = new nspacemove_nested.NewOkay40.InnerClass40.InnerClass40();
|
||||
auto ic50 = new nspacemove_nested.NewOkay50.InnerClass50.InnerClass50();
|
||||
auto ic60 = new nspacemove_nested.InnerClass60.InnerClass60();
|
||||
auto ic70 = new nspacemove_nested.InnerClass70.InnerClass70();
|
||||
auto ic80 = new nspacemove_nested.Space.InnerClass80.InnerClass80();
|
||||
|
||||
// inner enums
|
||||
oc1.take(nspacemove_nested.Space.OuterClass1.OuterClass1.InnerEnum1.ie1a, ic1);
|
||||
oc2.take(nspacemove_nested.Space.OuterClass2.OuterClass2.InnerEnum2.ie2a, ic2);
|
||||
oc3.take(nspacemove_nested.NewSpace3.OuterClass3.OuterClass3.InnerEnum3.ie3a, ic3);
|
||||
oc4.take(nspacemove_nested.NewSpace4.OuterClass4.OuterClass4.InnerEnum4.ie4a, ic4);
|
||||
oc5.take(nspacemove_nested.OuterClass5.OuterClass5.InnerEnum5.ie5a, ic5);
|
||||
oc6.take(nspacemove_nested.OuterClass6.OuterClass6.InnerEnum6.ie6a, ic6);
|
||||
oc7.take(nspacemove_nested.OuterClass7.OuterClass7.InnerEnum7.ie7a, ic7);
|
||||
|
||||
oc10.take(nspacemove_nested.Space.OuterClass10.OuterClass10.InnerEnum10.ie10a, ic10);
|
||||
oc20.take(nspacemove_nested.Space.OuterClass20.OuterClass20.InnerEnum20.ie20a, ic20);
|
||||
oc30.take(nspacemove_nested.NewOkay30.OuterClass30.OuterClass30.InnerEnum30.ie30a, ic30);
|
||||
oc40.take(nspacemove_nested.NewOkay40.OuterClass40.OuterClass40.InnerEnum40.ie40a, ic40);
|
||||
oc50.take(nspacemove_nested.NewOkay50.OuterClass50.OuterClass50.InnerEnum50.ie50a, ic50);
|
||||
oc60.take(nspacemove_nested.OuterClass60.OuterClass60.InnerEnum60.ie60a, ic60);
|
||||
oc70.take(nspacemove_nested.OuterClass70.OuterClass70.InnerEnum70.ie70a, ic70);
|
||||
oc80.take(nspacemove_nested.Space.OuterClass80.OuterClass80.InnerEnum80.ie80a, ic80);
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
module nspacemove_runme;
|
||||
|
||||
import std.exception;
|
||||
import nspacemove.nspacemove;
|
||||
static import nspacemove.NoNSpacePlease;
|
||||
static import nspacemove.Outer.namespce;
|
||||
static import nspacemove.Euter.Extra.Inner1.Channel;
|
||||
static import oi1c = nspacemove.Ooter.Extra.Inner1.Color;
|
||||
static import nspacemove.Outer.Enner2.Channel;
|
||||
static import nspacemove.Outer.Snner2.Color;
|
||||
static import nspacemove.Outer.Inner3.Blue;
|
||||
static import nspacemove.Outer.Inner4.Blue;
|
||||
static import nspacemove.Outer.SomeClass;
|
||||
static import nspacemove.Additional.GlobalClass;
|
||||
static import nspacemove.More.GlobalEnum;
|
||||
|
||||
void main() {
|
||||
// constructors and destructors
|
||||
auto color1 = new oi1c.Color();
|
||||
auto color = new oi1c.Color(color1);
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
oi1c.Color.colorStaticMethod(20.0);
|
||||
auto created = oi1c.Color.create();
|
||||
|
||||
// class enums
|
||||
auto someClass = new nspacemove.Outer.SomeClass.SomeClass();
|
||||
auto channel = someClass.GetInner1ColorChannel();
|
||||
enforce(channel == oi1c.Color.Channel.Transmission,
|
||||
"Transmission wrong");
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = oi1c.Color.ColorEnumVal1;
|
||||
int val2 = oi1c.Color.ColorEnumVal2;
|
||||
enforce(val1 == 0 && val2 == 0x22, "ColorEnumVal wrong");
|
||||
|
||||
// instance member variables
|
||||
color.instanceMemberVariable = 123;
|
||||
enforce(color.instanceMemberVariable == 123,
|
||||
"instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
oi1c.Color.staticMemberVariable = 789;
|
||||
enforce(oi1c.Color.staticMemberVariable == 789,
|
||||
"static member variable failed");
|
||||
enforce(oi1c.Color.staticConstMemberVariable == 222,
|
||||
"static const member variable failed");
|
||||
enforce(oi1c.Color.staticConstEnumMemberVariable == oi1c.Color.Channel.Transmission,
|
||||
"static const enum member variable failed");
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspacemove option
|
||||
nspacemove.nspacemove.namespaceFunction(color);
|
||||
nspacemove.nspacemove.namespaceVar = 111;
|
||||
enforce(nspacemove.nspacemove.namespaceVar == 111, "global var failed");
|
||||
|
||||
// Same class different namespaces
|
||||
auto col1 = new oi1c.Color();
|
||||
auto col2 = nspacemove.Outer.Snner2.Color.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// global enums
|
||||
auto outerChannel1 = someClass.GetInner1Channel();
|
||||
enforce(outerChannel1 == nspacemove.Euter.Extra.Inner1.Channel.Channel.Transmission1,
|
||||
"Transmission1 wrong");
|
||||
auto outerChannel2 = someClass.GetInner2Channel();
|
||||
enforce(outerChannel2 == nspacemove.Outer.Enner2.Channel.Channel.Transmission2,
|
||||
"Transmission2 wrong");
|
||||
|
||||
takeGlobalEnum(nspacemove.More.GlobalEnum.GlobalEnum.bbb);
|
||||
|
||||
// global class
|
||||
auto gc = new nspacemove.Additional.GlobalClass.GlobalClass();
|
||||
gc.gmethod();
|
||||
|
||||
// turn feature off / ignoring
|
||||
auto ns = new nspacemove.Outer.namespce.namespce();
|
||||
auto nons = new nspacemove.NoNSpacePlease.NoNSpacePlease();
|
||||
|
||||
// Derived class
|
||||
auto blue3 = new nspacemove.Outer.Inner3.Blue.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
auto blue4 = new nspacemove.Outer.Inner4.Blue.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
module nspacemove_stl_runme;
|
||||
|
||||
import std.exception;
|
||||
import nspacemove_stl.nspacemove_stl;
|
||||
|
||||
void main() {
|
||||
auto vi = new nspacemove_stl.CPlusPlus.Standard.Ints.VectorInt.VectorInt();
|
||||
auto vs = new nspacemove_stl.CPlusPlus.Standard.Strings.VectorString.VectorString();
|
||||
auto mii = new nspacemove_stl.CPlusPlus.Maps.MapIntInt.MapIntInt();
|
||||
auto mis = new nspacemove_stl.CPlusPlus.Maps.MapIntString.MapIntString();
|
||||
|
||||
nspacemove_stl.nspacemove_stl.test_vector_int(vi);
|
||||
nspacemove_stl.nspacemove_stl.test_vector_string(vs);
|
||||
nspacemove_stl.nspacemove_stl.test_map_int(mii);
|
||||
nspacemove_stl.nspacemove_stl.test_map_string(mis);
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
%module xxx
|
||||
|
||||
// Test nspace warnings (based on Examples/test-suite/nspacemove_nested.i)
|
||||
|
||||
%feature("flatnested"); // must have in order to see nspace warnings when using Python as nested classes are otherwise simply ignored in Python
|
||||
|
||||
%nspace Space::OuterClass1;
|
||||
%nspacemove(Bad::Space1) Space::OuterClass1::InnerClass1;
|
||||
%nspacemove(Bad::Space1) Space::OuterClass1::InnerEnum1;
|
||||
|
||||
%nspace Space::OuterClass2;
|
||||
%nonspace Space::OuterClass2::InnerClass2;
|
||||
%nonspace Space::OuterClass2::InnerEnum2;
|
||||
|
||||
%nspacemove(NewSpace3) Space::OuterClass3;
|
||||
%nspacemove(Bad::Space3) Space::OuterClass3::InnerClass3;
|
||||
%nspacemove(Bad::Space3) Space::OuterClass3::InnerEnum3;
|
||||
|
||||
%nspacemove(NewSpace4::NewSubSpace4) Space::OuterClass4;
|
||||
%nonspace Space::OuterClass4::InnerClass4;
|
||||
%nonspace Space::OuterClass4::InnerEnum4;
|
||||
|
||||
%nspacemove(NewSpace5) Space::OuterClass5::InnerClass5;
|
||||
%nspacemove(NewSpace5) Space::OuterClass5::InnerEnum5;
|
||||
|
||||
%nonspace Space::OuterClass6;
|
||||
%nspace Space::OuterClass6::InnerClass6;
|
||||
%nspace Space::OuterClass6::InnerEnum6;
|
||||
|
||||
%nonspace Space::OuterClass7;
|
||||
%nspacemove(NewSpace7) Space::OuterClass7::InnerClass7;
|
||||
%nspacemove(NewSpace7) Space::OuterClass7::InnerEnum7;
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct OuterClass1 {
|
||||
struct InnerClass1 {
|
||||
struct BottomClass1 {};
|
||||
};
|
||||
enum InnerEnum1 { ie1a, ie1b };
|
||||
void take(InnerEnum1 e) {}
|
||||
};
|
||||
struct OuterClass2 {
|
||||
struct InnerClass2 {
|
||||
struct BottomClass2 {};
|
||||
};
|
||||
enum InnerEnum2 { ie2a, ie2b };
|
||||
void take(InnerEnum2 e) {}
|
||||
};
|
||||
struct OuterClass3 {
|
||||
struct InnerClass3 {
|
||||
struct BottomClass3 {};
|
||||
};
|
||||
enum InnerEnum3 { ie3a, ie3b };
|
||||
void take(InnerEnum3 e) {}
|
||||
};
|
||||
struct OuterClass4 {
|
||||
struct InnerClass4 {
|
||||
struct BottomClass4 {};
|
||||
};
|
||||
enum InnerEnum4 { ie4a, ie4b };
|
||||
void take(InnerEnum4 e) {}
|
||||
};
|
||||
struct OuterClass5 {
|
||||
struct InnerClass5 {
|
||||
struct BottomClass5 {};
|
||||
};
|
||||
enum InnerEnum5 { ie5a, ie5b };
|
||||
void take(InnerEnum5 e) {}
|
||||
};
|
||||
struct OuterClass6 {
|
||||
struct InnerClass6 {
|
||||
struct BottomClass6 {};
|
||||
};
|
||||
enum InnerEnum6 { ie6a, ie6b };
|
||||
void take(InnerEnum6 e) {}
|
||||
};
|
||||
struct OuterClass7 {
|
||||
struct InnerClass7 {
|
||||
struct BottomClass7 {};
|
||||
};
|
||||
enum InnerEnum7 { ie7a, ie7b };
|
||||
void take(InnerEnum7 e) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
// These should not warn
|
||||
%nspace Space::OuterClass10;
|
||||
%nspace Space::OuterClass10::InnerClass10;
|
||||
%nspace Space::OuterClass10::InnerEnum10;
|
||||
|
||||
%nspace Space::OuterClass20;
|
||||
%clearnspace Space::OuterClass20::InnerClass20;
|
||||
%clearnspace Space::OuterClass20::InnerEnum20;
|
||||
|
||||
%nspacemove(NewOkay30) Space::OuterClass30;
|
||||
%nspace Space::OuterClass30::InnerClass30;
|
||||
%nspace Space::OuterClass30::InnerEnum40;
|
||||
|
||||
%nspacemove(NewOkay40) Space::OuterClass40;
|
||||
%clearnspace Space::OuterClass40::InnerClass40;
|
||||
%clearnspace Space::OuterClass40::InnerEnum40;
|
||||
|
||||
%nspacemove(NewOkay50) Space::OuterClass50;
|
||||
|
||||
%nonspace Space::OuterClass60;
|
||||
%nonspace Space::OuterClass60::InnerClass60;
|
||||
%nonspace Space::OuterClass60::InnerEnum60;
|
||||
|
||||
%nonspace Space::OuterClass70;
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct OuterClass10 {
|
||||
struct InnerClass10 {
|
||||
struct BottomClass10 {};
|
||||
};
|
||||
enum InnerEnum10 { ie10a, ie10b };
|
||||
void take(InnerEnum10 e) {}
|
||||
};
|
||||
struct OuterClass20 {
|
||||
struct InnerClass20 {
|
||||
struct BottomClass20 {};
|
||||
};
|
||||
enum InnerEnum20 { ie20a, ie20b };
|
||||
void take(InnerEnum20 e) {}
|
||||
};
|
||||
struct OuterClass30 {
|
||||
struct InnerClass30 {
|
||||
struct BottomClass30 {};
|
||||
};
|
||||
enum InnerEnum30 { ie30a, ie30b };
|
||||
void take(InnerEnum30 e) {}
|
||||
};
|
||||
struct OuterClass40 {
|
||||
struct InnerClass40 {
|
||||
struct BottomClass40 {};
|
||||
};
|
||||
enum InnerEnum40 { ie40a, ie40b };
|
||||
void take(InnerEnum40 e) {}
|
||||
};
|
||||
struct OuterClass50 {
|
||||
struct InnerClass50 {
|
||||
struct BottomClass50 {};
|
||||
};
|
||||
enum InnerEnum50 { ie50a, ie50b };
|
||||
void take(InnerEnum50 e) {}
|
||||
};
|
||||
struct OuterClass60 {
|
||||
struct InnerClass60 {
|
||||
struct BottomClass60 {};
|
||||
};
|
||||
enum InnerEnum60 { ie60a, ie60b };
|
||||
void take(InnerEnum60 e) {}
|
||||
};
|
||||
struct OuterClass70 {
|
||||
struct InnerClass70 {
|
||||
struct BottomClass70 {};
|
||||
};
|
||||
enum InnerEnum70 { ie70a, ie70b };
|
||||
void take(InnerEnum70 e) {}
|
||||
};
|
||||
}
|
||||
%}
|
|
@ -0,0 +1,28 @@
|
|||
cpp_nspacemove.i:37: Warning 406: Ignoring nspace setting (Bad::Space1) for 'Space::OuterClass1::InnerClass1',
|
||||
cpp_nspacemove.i:36: Warning 406: as it conflicts with the nspace setting (Space) for outer class 'Space::OuterClass1'.
|
||||
cpp_nspacemove.i:40: Warning 406: Ignoring nspace setting (Bad::Space1) for 'Space::OuterClass1::InnerEnum1',
|
||||
cpp_nspacemove.i:36: Warning 406: as it conflicts with the nspace setting (Space) for outer class 'Space::OuterClass1'.
|
||||
cpp_nspacemove.i:44: Warning 406: Ignoring nspace setting (0) for 'Space::OuterClass2::InnerClass2',
|
||||
cpp_nspacemove.i:43: Warning 406: as it conflicts with the nspace setting (Space) for outer class 'Space::OuterClass2'.
|
||||
cpp_nspacemove.i:47: Warning 406: Ignoring nspace setting (0) for 'Space::OuterClass2::InnerEnum2',
|
||||
cpp_nspacemove.i:43: Warning 406: as it conflicts with the nspace setting (Space) for outer class 'Space::OuterClass2'.
|
||||
cpp_nspacemove.i:51: Warning 406: Ignoring nspace setting (Bad::Space3) for 'Space::OuterClass3::InnerClass3',
|
||||
cpp_nspacemove.i:50: Warning 406: as it conflicts with the nspace setting (NewSpace3) for outer class 'Space::OuterClass3'.
|
||||
cpp_nspacemove.i:54: Warning 406: Ignoring nspace setting (Bad::Space3) for 'Space::OuterClass3::InnerEnum3',
|
||||
cpp_nspacemove.i:50: Warning 406: as it conflicts with the nspace setting (NewSpace3) for outer class 'Space::OuterClass3'.
|
||||
cpp_nspacemove.i:58: Warning 406: Ignoring nspace setting (0) for 'Space::OuterClass4::InnerClass4',
|
||||
cpp_nspacemove.i:57: Warning 406: as it conflicts with the nspace setting (NewSpace4::NewSubSpace4) for outer class 'Space::OuterClass4'.
|
||||
cpp_nspacemove.i:61: Warning 406: Ignoring nspace setting (0) for 'Space::OuterClass4::InnerEnum4',
|
||||
cpp_nspacemove.i:57: Warning 406: as it conflicts with the nspace setting (NewSpace4::NewSubSpace4) for outer class 'Space::OuterClass4'.
|
||||
cpp_nspacemove.i:65: Warning 406: Ignoring nspace setting (NewSpace5) for 'Space::OuterClass5::InnerClass5',
|
||||
cpp_nspacemove.i:64: Warning 406: as it conflicts with the nspace setting () for outer class 'Space::OuterClass5'.
|
||||
cpp_nspacemove.i:68: Warning 406: Ignoring nspace setting (NewSpace5) for 'Space::OuterClass5::InnerEnum5',
|
||||
cpp_nspacemove.i:64: Warning 406: as it conflicts with the nspace setting () for outer class 'Space::OuterClass5'.
|
||||
cpp_nspacemove.i:72: Warning 406: Ignoring nspace setting (1) for 'Space::OuterClass6::InnerClass6',
|
||||
cpp_nspacemove.i:71: Warning 406: as it conflicts with the nspace setting () for outer class 'Space::OuterClass6'.
|
||||
cpp_nspacemove.i:75: Warning 406: Ignoring nspace setting (1) for 'Space::OuterClass6::InnerEnum6',
|
||||
cpp_nspacemove.i:71: Warning 406: as it conflicts with the nspace setting () for outer class 'Space::OuterClass6'.
|
||||
cpp_nspacemove.i:79: Warning 406: Ignoring nspace setting (NewSpace7) for 'Space::OuterClass7::InnerClass7',
|
||||
cpp_nspacemove.i:78: Warning 406: as it conflicts with the nspace setting () for outer class 'Space::OuterClass7'.
|
||||
cpp_nspacemove.i:82: Warning 406: Ignoring nspace setting (NewSpace7) for 'Space::OuterClass7::InnerEnum7',
|
||||
cpp_nspacemove.i:78: Warning 406: as it conflicts with the nspace setting () for outer class 'Space::OuterClass7'.
|
|
@ -0,0 +1,57 @@
|
|||
%module xxx
|
||||
|
||||
// Bad names for %nspacemove
|
||||
%nspacemove(2) AA::BB::Bad1;
|
||||
%nspacemove(1abc) AA::BB::Bad2;
|
||||
%nspacemove(abc.def) AA::BB::Bad3;
|
||||
%nspacemove(0gh::ij) AA::BB::Bad4;
|
||||
%nspacemove(kl::1mn) AA::BB::Bad5;
|
||||
%nspacemove(kl::mn<int>) AA::BB::Bad6;
|
||||
|
||||
// Good names for %nspacemove
|
||||
%nspacemove(_aaa::_bbb) AA::BB::Good1;
|
||||
%nspacemove(_ccc::_ddd::_eee) AA::BB::Good2;
|
||||
%nspacemove(_1ccc::_2ddd::_3eee) AA::BB::Good3;
|
||||
|
||||
namespace AA {
|
||||
namespace BB {
|
||||
struct Bad1 {};
|
||||
struct Bad2 {};
|
||||
struct Bad3 {};
|
||||
struct Bad4 {};
|
||||
struct Bad5 {};
|
||||
struct Bad6 {};
|
||||
|
||||
struct Good1 {};
|
||||
struct Good2 {};
|
||||
struct Good3 {};
|
||||
}
|
||||
}
|
||||
|
||||
// Good names (containing whitespace) for %nspacemove
|
||||
%nspacemove( Good :: Spaces ) AA::BB::Good4;
|
||||
%nspacemove( Good :: Spaces ) AA::BB::Good5;
|
||||
|
||||
// Bad names (single colons) for %nspacemove
|
||||
%nspacemove(:) AA::BB::Bad7;
|
||||
%nspacemove(X: :Y) AA::BB::Bad8;
|
||||
%nspacemove(X:Y) AA::BB::Bad9;
|
||||
|
||||
// Bad names (bad double colons) for %nspacemove
|
||||
%nspacemove(X::Y::) AA::BB::Bad10;
|
||||
%nspacemove(X:::Y) AA::BB::Bad11;
|
||||
%nspacemove(X::::Y) AA::BB::Bad12;
|
||||
|
||||
namespace AA {
|
||||
namespace BB {
|
||||
struct Good4 {};
|
||||
struct Good5 {};
|
||||
|
||||
struct Bad7 {};
|
||||
struct Bad8 {};
|
||||
struct Bad9 {};
|
||||
struct Bad10 {};
|
||||
struct Bad11 {};
|
||||
struct Bad12 {};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
cpp_nspacemove_bad.i:18: Error: '2' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:19: Error: '1abc' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:20: Error: 'abc.def' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:21: Error: '0gh::ij' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:22: Error: 'kl::1mn' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:23: Error: 'kl::mn<int>' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:50: Error: ':' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:51: Error: 'X: :Y' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:52: Error: 'X:Y' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:53: Error: 'X::Y::' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:54: Error: 'X:::Y' is not a valid identifier for nspace.
|
||||
cpp_nspacemove_bad.i:55: Error: 'X::::Y' is not a valid identifier for nspace.
|
|
@ -87,6 +87,9 @@ java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
|
|||
multiple_inheritance_nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace_extend.%: JAVA_PACKAGE = $*Package
|
||||
nspacemove.%: JAVA_PACKAGE = $*Package
|
||||
nspacemove_nested.%: JAVA_PACKAGE = $*Package
|
||||
nspacemove_stl.%: JAVA_PACKAGE = $*Package
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
public class nspacemove_nested_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("nspacemove_nested");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
// outer classes
|
||||
nspacemove_nestedPackage.Space.OuterClass1 oc1 = new nspacemove_nestedPackage.Space.OuterClass1();
|
||||
nspacemove_nestedPackage.Space.OuterClass2 oc2 = new nspacemove_nestedPackage.Space.OuterClass2();
|
||||
nspacemove_nestedPackage.NewSpace3.OuterClass3 oc3 = new nspacemove_nestedPackage.NewSpace3.OuterClass3();
|
||||
nspacemove_nestedPackage.NewSpace4.OuterClass4 oc4 = new nspacemove_nestedPackage.NewSpace4.OuterClass4();
|
||||
nspacemove_nestedPackage.OuterClass5 oc5 = new nspacemove_nestedPackage.OuterClass5();
|
||||
nspacemove_nestedPackage.OuterClass6 oc6 = new nspacemove_nestedPackage.OuterClass6();
|
||||
nspacemove_nestedPackage.OuterClass7 oc7 = new nspacemove_nestedPackage.OuterClass7();
|
||||
|
||||
nspacemove_nestedPackage.Space.OuterClass10 oc10 = new nspacemove_nestedPackage.Space.OuterClass10();
|
||||
nspacemove_nestedPackage.Space.OuterClass20 oc20 = new nspacemove_nestedPackage.Space.OuterClass20();
|
||||
nspacemove_nestedPackage.NewOkay30.OuterClass30 oc30 = new nspacemove_nestedPackage.NewOkay30.OuterClass30();
|
||||
nspacemove_nestedPackage.NewOkay40.OuterClass40 oc40 = new nspacemove_nestedPackage.NewOkay40.OuterClass40();
|
||||
nspacemove_nestedPackage.NewOkay50.OuterClass50 oc50 = new nspacemove_nestedPackage.NewOkay50.OuterClass50();
|
||||
nspacemove_nestedPackage.OuterClass60 oc60 = new nspacemove_nestedPackage.OuterClass60();
|
||||
nspacemove_nestedPackage.OuterClass70 oc70 = new nspacemove_nestedPackage.OuterClass70();
|
||||
nspacemove_nestedPackage.Space.OuterClass80 oc80 = new nspacemove_nestedPackage.Space.OuterClass80();
|
||||
|
||||
// inner classes
|
||||
nspacemove_nestedPackage.Space.OuterClass1.InnerClass1 ic1 = new nspacemove_nestedPackage.Space.OuterClass1.InnerClass1();
|
||||
nspacemove_nestedPackage.Space.OuterClass2.InnerClass2 ic2 = new nspacemove_nestedPackage.Space.OuterClass2.InnerClass2();
|
||||
nspacemove_nestedPackage.NewSpace3.OuterClass3.InnerClass3 ic3 = new nspacemove_nestedPackage.NewSpace3.OuterClass3.InnerClass3();
|
||||
nspacemove_nestedPackage.NewSpace4.OuterClass4.InnerClass4 ic4 = new nspacemove_nestedPackage.NewSpace4.OuterClass4.InnerClass4();
|
||||
nspacemove_nestedPackage.OuterClass5.InnerClass5 ic5 = new nspacemove_nestedPackage.OuterClass5.InnerClass5();
|
||||
nspacemove_nestedPackage.OuterClass6.InnerClass6 ic6 = new nspacemove_nestedPackage.OuterClass6.InnerClass6();
|
||||
nspacemove_nestedPackage.OuterClass7.InnerClass7 ic7 = new nspacemove_nestedPackage.OuterClass7.InnerClass7();
|
||||
|
||||
nspacemove_nestedPackage.Space.OuterClass10.InnerClass10 ic10 = new nspacemove_nestedPackage.Space.OuterClass10.InnerClass10();
|
||||
nspacemove_nestedPackage.Space.OuterClass20.InnerClass20 ic20 = new nspacemove_nestedPackage.Space.OuterClass20.InnerClass20();
|
||||
nspacemove_nestedPackage.NewOkay30.OuterClass30.InnerClass30 ic30 = new nspacemove_nestedPackage.NewOkay30.OuterClass30.InnerClass30();
|
||||
nspacemove_nestedPackage.NewOkay40.OuterClass40.InnerClass40 ic40 = new nspacemove_nestedPackage.NewOkay40.OuterClass40.InnerClass40();
|
||||
nspacemove_nestedPackage.NewOkay50.OuterClass50.InnerClass50 ic50 = new nspacemove_nestedPackage.NewOkay50.OuterClass50.InnerClass50();
|
||||
nspacemove_nestedPackage.OuterClass60.InnerClass60 ic60 = new nspacemove_nestedPackage.OuterClass60.InnerClass60();
|
||||
nspacemove_nestedPackage.OuterClass70.InnerClass70 ic70 = new nspacemove_nestedPackage.OuterClass70.InnerClass70();
|
||||
nspacemove_nestedPackage.Space.OuterClass80.InnerClass80 ic80 = new nspacemove_nestedPackage.Space.OuterClass80.InnerClass80();
|
||||
|
||||
// inner enums
|
||||
oc1.take(nspacemove_nestedPackage.Space.OuterClass1.InnerEnum1.ie1a, ic1);
|
||||
oc2.take(nspacemove_nestedPackage.Space.OuterClass2.InnerEnum2.ie2a, ic2);
|
||||
oc3.take(nspacemove_nestedPackage.NewSpace3.OuterClass3.InnerEnum3.ie3a, ic3);
|
||||
oc4.take(nspacemove_nestedPackage.NewSpace4.OuterClass4.InnerEnum4.ie4a, ic4);
|
||||
oc5.take(nspacemove_nestedPackage.OuterClass5.InnerEnum5.ie5a, ic5);
|
||||
oc6.take(nspacemove_nestedPackage.OuterClass6.InnerEnum6.ie6a, ic6);
|
||||
oc7.take(nspacemove_nestedPackage.OuterClass7.InnerEnum7.ie7a, ic7);
|
||||
|
||||
oc10.take(nspacemove_nestedPackage.Space.OuterClass10.InnerEnum10.ie10a, ic10);
|
||||
oc20.take(nspacemove_nestedPackage.Space.OuterClass20.InnerEnum20.ie20a, ic20);
|
||||
oc30.take(nspacemove_nestedPackage.NewOkay30.OuterClass30.InnerEnum30.ie30a, ic30);
|
||||
oc40.take(nspacemove_nestedPackage.NewOkay40.OuterClass40.InnerEnum40.ie40a, ic40);
|
||||
oc50.take(nspacemove_nestedPackage.NewOkay50.OuterClass50.InnerEnum50.ie50a, ic50);
|
||||
oc60.take(nspacemove_nestedPackage.OuterClass60.InnerEnum60.ie60a, ic60);
|
||||
oc70.take(nspacemove_nestedPackage.OuterClass70.InnerEnum70.ie70a, ic70);
|
||||
oc80.take(nspacemove_nestedPackage.Space.OuterClass80.InnerEnum80.ie80a, ic80);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
// This tests changes the package name from nspace to nspacePackage as javac can't seem to resolve classes and packages having the same name
|
||||
public class nspacemove_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("nspacemove");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
// constructors and destructors
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color color1 = new nspacemovePackage.Ooter.Extra.Inner1.Color();
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color color = new nspacemovePackage.Ooter.Extra.Inner1.Color(color1);
|
||||
color1.delete();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color created = nspacemovePackage.Ooter.Extra.Inner1.Color.create();
|
||||
|
||||
// class enums
|
||||
nspacemovePackage.Outer.SomeClass someClass = new nspacemovePackage.Outer.SomeClass();
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspacemovePackage.Ooter.Extra.Inner1.Color.Channel.Transmission)
|
||||
throw new RuntimeException("Transmission wrong");
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = nspacemovePackage.Ooter.Extra.Inner1.Color.ColorEnumVal1;
|
||||
int val2 = nspacemovePackage.Ooter.Extra.Inner1.Color.ColorEnumVal2;
|
||||
if (val1 != 0 || val2 != 0x22)
|
||||
throw new RuntimeException("ColorEnumVal wrong");
|
||||
|
||||
// instance member variables
|
||||
color.setInstanceMemberVariable(123);
|
||||
if (color.getInstanceMemberVariable() != 123)
|
||||
throw new RuntimeException("instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color.setStaticMemberVariable(789);
|
||||
if (nspacemovePackage.Ooter.Extra.Inner1.Color.getStaticMemberVariable() != 789)
|
||||
throw new RuntimeException("static member variable failed");
|
||||
if (nspacemovePackage.Ooter.Extra.Inner1.Color.staticConstMemberVariable != 222)
|
||||
throw new RuntimeException("static const member variable failed");
|
||||
if (nspacemovePackage.Ooter.Extra.Inner1.Color.staticConstEnumMemberVariable != nspacemovePackage.Ooter.Extra.Inner1.Color.Channel.Transmission)
|
||||
throw new RuntimeException("static const enum member variable failed");
|
||||
|
||||
// Same class different namespaces
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color col1 = new nspacemovePackage.Ooter.Extra.Inner1.Color();
|
||||
nspacemovePackage.Outer.Snner2.Color col2 = nspacemovePackage.Outer.Snner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspacemovePackage option
|
||||
nspacemovePackage.nspacemove.namespaceFunction(color);
|
||||
nspacemovePackage.nspacemove.setNamespaceVar(111);
|
||||
if (nspacemovePackage.nspacemove.getNamespaceVar() != 111)
|
||||
throw new RuntimeException("global var failed");
|
||||
|
||||
// global enums
|
||||
nspacemovePackage.Euter.Extra.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspacemovePackage.Euter.Extra.Inner1.Channel.Transmission1)
|
||||
throw new RuntimeException("Transmission1 wrong");
|
||||
nspacemovePackage.Outer.Enner2.Channel outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspacemovePackage.Outer.Enner2.Channel.Transmission2)
|
||||
throw new RuntimeException("Transmission2 wrong");
|
||||
|
||||
nspacemovePackage.nspacemove.takeGlobalEnum(nspacemovePackage.More.GlobalEnum.bbb);
|
||||
|
||||
// global class
|
||||
nspacemovePackage.Additional.GlobalClass gc = new nspacemovePackage.Additional.GlobalClass();
|
||||
gc.gmethod();
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspacemovePackage.Outer.namespce ns = new nspacemovePackage.Outer.namespce();
|
||||
nspacemovePackage.NoNSpacePlease nons = new nspacemovePackage.NoNSpacePlease();
|
||||
|
||||
// Derived class
|
||||
nspacemovePackage.Outer.Inner3.Blue blue3 = new nspacemovePackage.Outer.Inner3.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
nspacemovePackage.Outer.Inner4.Blue blue4 = new nspacemovePackage.Outer.Inner4.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
public class nspacemove_stl_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("nspacemove_stl");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
nspacemove_stlPackage.CPlusPlus.Standard.Ints.VectorInt vi = new nspacemove_stlPackage.CPlusPlus.Standard.Ints.VectorInt();
|
||||
nspacemove_stlPackage.CPlusPlus.Standard.Strings.VectorString vs = new nspacemove_stlPackage.CPlusPlus.Standard.Strings.VectorString();
|
||||
nspacemove_stlPackage.CPlusPlus.Maps.MapIntInt mii = new nspacemove_stlPackage.CPlusPlus.Maps.MapIntInt();
|
||||
nspacemove_stlPackage.CPlusPlus.Maps.MapIntString mis = new nspacemove_stlPackage.CPlusPlus.Maps.MapIntString();
|
||||
|
||||
nspacemove_stlPackage.nspacemove_stl.test_vector_int(vi);
|
||||
nspacemove_stlPackage.nspacemove_stl.test_vector_string(vs);
|
||||
nspacemove_stlPackage.nspacemove_stl.test_map_int(mii);
|
||||
nspacemove_stlPackage.nspacemove_stl.test_map_string(mis);
|
||||
}
|
||||
}
|
|
@ -3,16 +3,16 @@ var cpp17_nested_namespaces = require("cpp17_nested_namespaces");
|
|||
new cpp17_nested_namespaces.A1Struct().A1Method()
|
||||
new cpp17_nested_namespaces.B1Struct().B1Method()
|
||||
new cpp17_nested_namespaces.C1Struct().C1Method()
|
||||
new cpp17_nested_namespaces.createA1Struct().A1Method()
|
||||
new cpp17_nested_namespaces.createB1Struct().B1Method()
|
||||
new cpp17_nested_namespaces.createC1Struct().C1Method()
|
||||
cpp17_nested_namespaces.createA1Struct().A1Method()
|
||||
cpp17_nested_namespaces.createB1Struct().B1Method()
|
||||
cpp17_nested_namespaces.createC1Struct().C1Method()
|
||||
|
||||
new cpp17_nested_namespaces.B2Struct().B2Method()
|
||||
new cpp17_nested_namespaces.C2Struct().C2Method()
|
||||
new cpp17_nested_namespaces.createB2Struct().B2Method()
|
||||
new cpp17_nested_namespaces.createC2Struct().C2Method()
|
||||
cpp17_nested_namespaces.createB2Struct().B2Method()
|
||||
cpp17_nested_namespaces.createC2Struct().C2Method()
|
||||
|
||||
new cpp17_nested_namespaces.B3Struct().B3Method()
|
||||
new cpp17_nested_namespaces.C3Struct().C3Method()
|
||||
new cpp17_nested_namespaces.createB3Struct().B3Method()
|
||||
new cpp17_nested_namespaces.createC3Struct().C3Method()
|
||||
cpp17_nested_namespaces.createB3Struct().B3Method()
|
||||
cpp17_nested_namespaces.createC3Struct().C3Method()
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
var nspacemove_nested = require("nspacemove_nested");
|
||||
|
||||
// outer classes
|
||||
oc1 = new nspacemove_nested.Space.OuterClass1()
|
||||
oc2 = new nspacemove_nested.Space.OuterClass2()
|
||||
oc3 = new nspacemove_nested.NewSpace3.OuterClass3()
|
||||
oc4 = new nspacemove_nested.NewSpace4.OuterClass4()
|
||||
oc5 = new nspacemove_nested.OuterClass5()
|
||||
oc6 = new nspacemove_nested.OuterClass6()
|
||||
oc7 = new nspacemove_nested.OuterClass7()
|
||||
|
||||
oc10 = new nspacemove_nested.Space.OuterClass10()
|
||||
oc20 = new nspacemove_nested.Space.OuterClass20()
|
||||
oc30 = new nspacemove_nested.NewOkay30.OuterClass30()
|
||||
oc40 = new nspacemove_nested.NewOkay40.OuterClass40()
|
||||
oc50 = new nspacemove_nested.NewOkay50.OuterClass50()
|
||||
oc60 = new nspacemove_nested.OuterClass60()
|
||||
oc70 = new nspacemove_nested.OuterClass70()
|
||||
oc80 = new nspacemove_nested.Space.OuterClass80()
|
||||
|
||||
// inner classes
|
||||
ic1 = new nspacemove_nested.Space.InnerClass1()
|
||||
ic2 = new nspacemove_nested.Space.InnerClass2()
|
||||
ic3 = new nspacemove_nested.NewSpace3.InnerClass3()
|
||||
ic4 = new nspacemove_nested.NewSpace4.InnerClass4()
|
||||
ic5 = new nspacemove_nested.InnerClass5()
|
||||
ic6 = new nspacemove_nested.InnerClass6()
|
||||
ic7 = new nspacemove_nested.InnerClass7()
|
||||
|
||||
ic10 = new nspacemove_nested.Space.InnerClass10()
|
||||
ic20 = new nspacemove_nested.Space.InnerClass20()
|
||||
ic30 = new nspacemove_nested.NewOkay30.InnerClass30()
|
||||
ic40 = new nspacemove_nested.NewOkay40.InnerClass40()
|
||||
ic50 = new nspacemove_nested.NewOkay50.InnerClass50()
|
||||
ic60 = new nspacemove_nested.InnerClass60()
|
||||
ic70 = new nspacemove_nested.InnerClass70()
|
||||
ic80 = new nspacemove_nested.Space.InnerClass80()
|
||||
|
||||
// inner enums
|
||||
oc1.take(nspacemove_nested.Space.OuterClass1.ie1a, ic1)
|
||||
oc2.take(nspacemove_nested.Space.OuterClass2.ie2a, ic2)
|
||||
oc3.take(nspacemove_nested.NewSpace3.OuterClass3.ie3a, ic3)
|
||||
oc4.take(nspacemove_nested.NewSpace4.OuterClass4.ie4a, ic4)
|
||||
oc5.take(nspacemove_nested.OuterClass5.ie5a, ic5)
|
||||
oc6.take(nspacemove_nested.OuterClass6.ie6a, ic6)
|
||||
oc7.take(nspacemove_nested.OuterClass7.ie7a, ic7)
|
||||
|
||||
oc10.take(nspacemove_nested.Space.OuterClass10.ie10a, ic10)
|
||||
oc20.take(nspacemove_nested.Space.OuterClass20.ie20a, ic20)
|
||||
oc30.take(nspacemove_nested.NewOkay30.OuterClass30.ie30a, ic30)
|
||||
oc40.take(nspacemove_nested.NewOkay40.OuterClass40.ie40a, ic40)
|
||||
oc50.take(nspacemove_nested.NewOkay50.OuterClass50.ie50a, ic50)
|
||||
oc60.take(nspacemove_nested.OuterClass60.ie60a, ic60)
|
||||
oc70.take(nspacemove_nested.OuterClass70.ie70a, ic70)
|
||||
oc80.take(nspacemove_nested.Space.OuterClass80.ie80a, ic80)
|
|
@ -0,0 +1,85 @@
|
|||
var nspacemove = require("nspacemove");
|
||||
|
||||
var color1 = new nspacemove.Ooter.Extra.Inner1.Color();
|
||||
var color = new nspacemove.Ooter.Extra.Inner1.Color(color1);
|
||||
delete color1;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspacemove.Ooter.Extra.Inner1.Color.colorStaticMethod(20.0);
|
||||
var created = nspacemove.Ooter.Extra.Inner1.Color.create();
|
||||
|
||||
// class enums
|
||||
var someClass = new nspacemove.Outer.SomeClass();
|
||||
var channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspacemove.Ooter.Extra.Inner1.Color.Transmission) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
// class anonymous enums
|
||||
var val1 = nspacemove.Ooter.Extra.Inner1.Color.ColorEnumVal1;
|
||||
var val2 = nspacemove.Ooter.Extra.Inner1.Color.ColorEnumVal2;
|
||||
if (val1 !== 0 || val2 !== 0x22) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
// instance member variables
|
||||
color.instanceMemberVariable = 123;
|
||||
if (color.instanceMemberVariable !== 123) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
// static member variables
|
||||
nspacemove.Ooter.Extra.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspacemove.Ooter.Extra.Inner1.Color.staticMemberVariable !== 789) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
if (nspacemove.Ooter.Extra.Inner1.Color.staticConstMemberVariable !== 222) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
if (nspacemove.Ooter.Extra.Inner1.Color.staticConstEnumMemberVariable !== nspacemove.Ooter.Extra.Inner1.Color.Transmission) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
// Same class different namespaces
|
||||
var col1 = new nspacemove.Ooter.Extra.Inner1.Color();
|
||||
var col2 = nspacemove.Outer.Snner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
nspacemove.Outer.Inner1.namespaceFunction(color);
|
||||
nspacemove.Outer.Inner1.namespaceVar = 111;
|
||||
if (nspacemove.Outer.Inner1.namespaceVar !== 111) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
// global enums
|
||||
var outerChannel1 = someClass.GetInner1Channel();
|
||||
// TODO, broken:
|
||||
if (outerChannel1 != nspacemove.Outer.Inner1.Transmission1) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
var outerChannel2 = someClass.GetInner2Channel();
|
||||
// TODO, broken:
|
||||
if (outerChannel2 !== nspacemove.Outer.Inner2.Transmission2) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
// TODO, broken
|
||||
nspacemove.takeGlobalEnum(nspacemove.bbb);
|
||||
|
||||
// global class
|
||||
var gc = new nspacemove.Additional.GlobalClass();
|
||||
gc.gmethod();
|
||||
|
||||
// turn feature off / ignoring
|
||||
var ns = new nspacemove.Outer.namespce();
|
||||
var nons = new nspacemove.NoNSpacePlease();
|
||||
|
||||
// Derived class
|
||||
var blue3 = new nspacemove.Outer.Inner3.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
var blue4 = new nspacemove.Outer.Inner4.Blue();
|
||||
blue4.blueInstanceMethod();
|
|
@ -0,0 +1,11 @@
|
|||
var nspacemove_stl = require("nspacemove_stl");
|
||||
|
||||
vi = new nspacemove_stl.CPlusPlus.Standard.Ints.VectorInt()
|
||||
vs = new nspacemove_stl.CPlusPlus.Standard.Strings.VectorString()
|
||||
mii = new nspacemove_stl.CPlusPlus.Maps.MapIntInt()
|
||||
mis = new nspacemove_stl.CPlusPlus.Maps.MapIntString()
|
||||
|
||||
nspacemove_stl.test_vector_int(vi)
|
||||
nspacemove_stl.test_vector_string(vs)
|
||||
nspacemove_stl.test_map_int(mii)
|
||||
nspacemove_stl.test_map_string(mis)
|
|
@ -0,0 +1,61 @@
|
|||
require("import") -- the import fn
|
||||
import("nspacemove_nested") -- import lib
|
||||
|
||||
-- catch "undefined" global variables
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
-- outer classes
|
||||
oc1 = nspacemove_nested.Space.OuterClass1()
|
||||
oc2 = nspacemove_nested.Space.OuterClass2()
|
||||
oc3 = nspacemove_nested.NewSpace3.OuterClass3()
|
||||
oc4 = nspacemove_nested.NewSpace4.OuterClass4()
|
||||
oc5 = nspacemove_nested.OuterClass5()
|
||||
oc6 = nspacemove_nested.OuterClass6()
|
||||
oc7 = nspacemove_nested.OuterClass7()
|
||||
|
||||
oc10 = nspacemove_nested.Space.OuterClass10()
|
||||
oc20 = nspacemove_nested.Space.OuterClass20()
|
||||
oc30 = nspacemove_nested.NewOkay30.OuterClass30()
|
||||
oc40 = nspacemove_nested.NewOkay40.OuterClass40()
|
||||
oc50 = nspacemove_nested.NewOkay50.OuterClass50()
|
||||
oc60 = nspacemove_nested.OuterClass60()
|
||||
oc70 = nspacemove_nested.OuterClass70()
|
||||
oc80 = nspacemove_nested.Space.OuterClass80()
|
||||
|
||||
-- inner classes
|
||||
ic1 = nspacemove_nested.Space.InnerClass1()
|
||||
ic2 = nspacemove_nested.Space.InnerClass2()
|
||||
ic3 = nspacemove_nested.NewSpace3.InnerClass3()
|
||||
ic4 = nspacemove_nested.NewSpace4.InnerClass4()
|
||||
ic5 = nspacemove_nested.InnerClass5()
|
||||
ic6 = nspacemove_nested.InnerClass6()
|
||||
ic7 = nspacemove_nested.InnerClass7()
|
||||
|
||||
ic10 = nspacemove_nested.Space.InnerClass10()
|
||||
ic20 = nspacemove_nested.Space.InnerClass20()
|
||||
ic30 = nspacemove_nested.NewOkay30.InnerClass30()
|
||||
ic40 = nspacemove_nested.NewOkay40.InnerClass40()
|
||||
ic50 = nspacemove_nested.NewOkay50.InnerClass50()
|
||||
ic60 = nspacemove_nested.InnerClass60()
|
||||
ic70 = nspacemove_nested.InnerClass70()
|
||||
ic80 = nspacemove_nested.Space.InnerClass80()
|
||||
|
||||
-- inner enums
|
||||
oc1:take(nspacemove_nested.Space.OuterClass1.ie1a, ic1)
|
||||
oc2:take(nspacemove_nested.Space.OuterClass2.ie2a, ic2)
|
||||
oc3:take(nspacemove_nested.NewSpace3.OuterClass3.ie3a, ic3)
|
||||
oc4:take(nspacemove_nested.NewSpace4.OuterClass4.ie4a, ic4)
|
||||
oc5:take(nspacemove_nested.OuterClass5.ie5a, ic5)
|
||||
oc6:take(nspacemove_nested.OuterClass6.ie6a, ic6)
|
||||
oc7:take(nspacemove_nested.OuterClass7.ie7a, ic7)
|
||||
|
||||
oc10:take(nspacemove_nested.Space.OuterClass10.ie10a, ic10)
|
||||
oc20:take(nspacemove_nested.Space.OuterClass20.ie20a, ic20)
|
||||
oc30:take(nspacemove_nested.NewOkay30.OuterClass30.ie30a, ic30)
|
||||
oc40:take(nspacemove_nested.NewOkay40.OuterClass40.ie40a, ic40)
|
||||
oc50:take(nspacemove_nested.NewOkay50.OuterClass50.ie50a, ic50)
|
||||
oc60:take(nspacemove_nested.OuterClass60.ie60a, ic60)
|
||||
oc70:take(nspacemove_nested.OuterClass70.ie70a, ic70)
|
||||
oc80:take(nspacemove_nested.Space.OuterClass80.ie80a, ic80)
|
|
@ -0,0 +1,80 @@
|
|||
require("import") -- the import fn
|
||||
import("nspacemove") -- import lib
|
||||
|
||||
-- catch "undefined" global variables
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
ns = nspacemove
|
||||
|
||||
-- Inheritance
|
||||
blue1 = ns.Outer.Inner3.Blue()
|
||||
|
||||
-- blue1:blueInstanceMethod()
|
||||
blue1:colorInstanceMethod(60.0)
|
||||
blue1.instanceMemberVariable = 4
|
||||
assert( blue1.instanceMemberVariable == 4 )
|
||||
|
||||
-- Constructors
|
||||
color1 = ns.Ooter.Extra.Inner1.Color()
|
||||
color2 = ns.Ooter.Extra.Inner1.Color.create()
|
||||
color = ns.Ooter.Extra.Inner1.Color(color1)
|
||||
color3 = ns.Outer.Snner2.Color.create()
|
||||
color4 = ns.Outer.Snner2.Color.create()
|
||||
color5 = ns.Outer.Snner2.Color.create()
|
||||
mwp2 = ns.Outer.MyWorldPart2()
|
||||
gc = ns.Additional.GlobalClass()
|
||||
|
||||
nnsp = ns.NoNSpacePlease()
|
||||
|
||||
-- Class methods
|
||||
color:colorInstanceMethod(20.0)
|
||||
ns.Ooter.Extra.Inner1.Color.colorStaticMethod(30.0)
|
||||
color3:colorInstanceMethod(40.0)
|
||||
ns.Outer.Snner2.Color.colorStaticMethod(50.0)
|
||||
color3:colors(color1, color2, color3, color4, color5)
|
||||
|
||||
gc:gmethod()
|
||||
|
||||
-- Class variables
|
||||
color.instanceMemberVariable = 5
|
||||
color1.instanceMemberVariable = 7
|
||||
assert( color.instanceMemberVariable == 5 )
|
||||
assert( color1.instanceMemberVariable == 7 )
|
||||
assert(ns.Ooter.Extra.Inner1.Color.staticMemberVariable == 0 )
|
||||
assert(ns.Outer.Snner2.Color.staticMemberVariable == 0 )
|
||||
ns.Ooter.Extra.Inner1.Color.staticMemberVariable = 9
|
||||
ns.Outer.Snner2.Color.staticMemberVariable = 11
|
||||
assert(ns.Ooter.Extra.Inner1.Color.staticMemberVariable == 9)
|
||||
assert(ns.Outer.Snner2.Color.staticMemberVariable == 11)
|
||||
|
||||
-- Class constants
|
||||
assert( ns.Ooter.Extra.Inner1.Color.Specular == 0x20 )
|
||||
assert( ns.Outer.Snner2.Color.Specular == 0x40 )
|
||||
assert( ns.Ooter.Extra.Inner1.Color.staticConstMemberVariable == 222 )
|
||||
assert( ns.Outer.Snner2.Color.staticConstMemberVariable == 333 )
|
||||
assert( ns.Ooter.Extra.Inner1.Color.staticConstEnumMemberVariable ~= ns.Outer.Snner2.Color.staticConstEnumMemberVariable )
|
||||
|
||||
|
||||
-- Aggregation
|
||||
sc = ns.Outer.SomeClass()
|
||||
assert( sc:GetInner1ColorChannel() ~= sc:GetInner2Channel() )
|
||||
assert( sc:GetInner1Channel() ~= sc:GetInner2Channel() )
|
||||
|
||||
-- Backward compatibility
|
||||
assert(ns.Euter.Extra.Inner1.Diffuse ~= nil)
|
||||
-- Enums within class within namespace shouldn't have backward compatible name. Same for static methods
|
||||
assert(ns.Ooter.Extra.Inner1.Color_Diffuse == nil)
|
||||
assert(ns.Ooter.Extra.Inner1.Color_colorStaticMethod == nil)
|
||||
|
||||
-- Enums and static methods of class marked as %nonspace should have backward compatible name
|
||||
assert(ns.NoNSpacePlease_noNspaceStaticFunc() == 10)
|
||||
assert(ns.Outer.Enner2.NoNSpacePlease_NoNspace == nil)
|
||||
-- ReallyNoNSpaceEnum is wrapped into %nonspace and thus handled correctly.
|
||||
-- NoNSpaceEnum is not (although both of them are in %nonspace-wrapped class) and thus
|
||||
-- handled rather unexpectedly
|
||||
assert(ns.NoNSpacePlease_ReallyNoNspace1 == 1)
|
||||
assert(ns.NoNSpacePlease.ReallyNoNspace2 == 10)
|
||||
|
||||
ns.takeGlobalEnum(ns.More.bbb)
|
|
@ -0,0 +1,18 @@
|
|||
require("import") -- the import fn
|
||||
import("nspacemove_stl") -- import lib
|
||||
|
||||
-- catch "undefined" global variables
|
||||
local env = _ENV -- Lua 5.2
|
||||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
|
||||
vi = nspacemove_stl.CPlusPlus.Standard.Ints.VectorInt()
|
||||
vs = nspacemove_stl.CPlusPlus.Standard.Strings.VectorString()
|
||||
mii = nspacemove_stl.CPlusPlus.Maps.MapIntInt()
|
||||
mis = nspacemove_stl.CPlusPlus.Maps.MapIntString()
|
||||
|
||||
nspacemove_stl.test_vector_int(vi)
|
||||
nspacemove_stl.test_vector_string(vs)
|
||||
nspacemove_stl.test_map_int(mii)
|
||||
nspacemove_stl.test_map_string(mis)
|
|
@ -11,6 +11,7 @@ SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
|||
%nspace;
|
||||
%nonspace Outer::Inner2::NoNSpacePlease;
|
||||
%nonspace Outer::Inner2::NoNSpacePlease::ReallyNoNSpaceEnum;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Outer::Inner2::NoNSpacePlease;
|
||||
|
||||
%copyctor;
|
||||
%ignore Outer::Inner2::Color::Color();
|
||||
|
@ -52,8 +53,8 @@ namespace Outer {
|
|||
Color() : instanceMemberVariable(0) {}
|
||||
static Color* create() { return new Color(); }
|
||||
|
||||
enum Channel { Diffuse, Specular = 0x40, Transmission };
|
||||
enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3 };
|
||||
enum Channel { Diffuse, Specular = 0x40, Transmission, Channel4 };
|
||||
enum { ColorEnumVal1, ColorEnumVal2 = 0x33, ColorEnumVal3, ColorEnumVal4 };
|
||||
|
||||
int instanceMemberVariable;
|
||||
static int staticMemberVariable;
|
||||
|
@ -106,6 +107,9 @@ struct GlobalClass {
|
|||
void gmethod() {}
|
||||
};
|
||||
|
||||
enum GlobalEnum { aaa, bbb, ccc };
|
||||
void takeGlobalEnum(GlobalEnum) {}
|
||||
|
||||
void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {}
|
||||
%}
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
%module nspacemove
|
||||
|
||||
// Testing %nspacemove which moves symbols into a different target language 'namespace'
|
||||
|
||||
// move structs
|
||||
%nspacemove(Ooter::Extra::Inner1) Outer::Inner1::Color;
|
||||
%nspacemove(Outer::Snner2) Outer::Inner2::Color;
|
||||
%nspacemove(Additional) ::GlobalClass;
|
||||
|
||||
// move enum
|
||||
%nspacemove(Euter :: Extra :: Inner1) Outer::Inner1::Channel;
|
||||
%nspacemove(Outer:: Enner2) Outer::Inner2::Channel;
|
||||
%nspacemove(More) ::GlobalEnum;
|
||||
|
||||
%include "nspace.i"
|
|
@ -0,0 +1,201 @@
|
|||
%module nspacemove_nested
|
||||
|
||||
// Tests nested classes for badly configured %nspace, %nonspace, %nspacemove combinations
|
||||
// Based off Examples/test-suite/errors/swig_nspacemove.i
|
||||
|
||||
#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
|
||||
%feature ("flatnested");
|
||||
#endif
|
||||
|
||||
// These will warn, hence suppressed in this testcase
|
||||
|
||||
// Note that these could also be suppressed at the outer class level, eg:
|
||||
// %warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass1;
|
||||
// Or even at namespace level:
|
||||
// %warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space;
|
||||
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass1::InnerClass1;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass2::InnerClass2;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass3::InnerClass3;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass4::InnerClass4;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass5::InnerClass5;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass6::InnerClass6;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass7::InnerClass7;
|
||||
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass1::InnerEnum1;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass2::InnerEnum2;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass3::InnerEnum3;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass4::InnerEnum4;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass5::InnerEnum5;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass6::InnerEnum6;
|
||||
%warnfilter(SWIGWARN_TYPE_NSPACE_SETTING) Space::OuterClass7::InnerEnum7;
|
||||
|
||||
%nspace Space::OuterClass1;
|
||||
%nspacemove(BadSpace1) Space::OuterClass1::InnerClass1;
|
||||
%nspacemove(BadSpace1) Space::OuterClass1::InnerEnum1;
|
||||
|
||||
%nspace Space::OuterClass2;
|
||||
%nonspace Space::OuterClass2::InnerClass2;
|
||||
%nonspace Space::OuterClass2::InnerEnum2;
|
||||
|
||||
%nspacemove(NewSpace3) Space::OuterClass3;
|
||||
%nspacemove(BadSpace3) Space::OuterClass3::InnerClass3;
|
||||
%nspacemove(BadSpace3) Space::OuterClass3::InnerEnum3;
|
||||
|
||||
%nspacemove(NewSpace4) Space::OuterClass4;
|
||||
%nonspace Space::OuterClass4::InnerClass4;
|
||||
%nonspace Space::OuterClass4::InnerEnum4;
|
||||
|
||||
%nspacemove(NewSpace5) Space::OuterClass5::InnerClass5;
|
||||
%nspacemove(NewSpace5) Space::OuterClass5::InnerEnum5;
|
||||
|
||||
%nonspace Space::OuterClass6;
|
||||
%nspace Space::OuterClass6::InnerClass6;
|
||||
%nspace Space::OuterClass6::InnerEnum6;
|
||||
|
||||
%nonspace Space::OuterClass7;
|
||||
%nspacemove(NewSpace7) Space::OuterClass7::InnerClass7;
|
||||
%nspacemove(NewSpace7) Space::OuterClass7::InnerEnum7;
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct OuterClass1 {
|
||||
struct InnerClass1 {
|
||||
struct BottomClass1 {};
|
||||
};
|
||||
enum InnerEnum1 { ie1a, ie1b };
|
||||
void take(InnerEnum1 e, InnerClass1 c) {}
|
||||
};
|
||||
struct OuterClass2 {
|
||||
struct InnerClass2 {
|
||||
struct BottomClass2 {};
|
||||
};
|
||||
enum InnerEnum2 { ie2a, ie2b };
|
||||
void take(InnerEnum2 e, InnerClass2 c) {}
|
||||
};
|
||||
struct OuterClass3 {
|
||||
struct InnerClass3 {
|
||||
struct BottomClass3 {};
|
||||
};
|
||||
enum InnerEnum3 { ie3a, ie3b };
|
||||
void take(InnerEnum3 e, InnerClass3 c) {}
|
||||
};
|
||||
struct OuterClass4 {
|
||||
struct InnerClass4 {
|
||||
struct BottomClass4 {};
|
||||
};
|
||||
enum InnerEnum4 { ie4a, ie4b };
|
||||
void take(InnerEnum4 e, InnerClass4 c) {}
|
||||
};
|
||||
struct OuterClass5 {
|
||||
struct InnerClass5 {
|
||||
struct BottomClass5 {};
|
||||
};
|
||||
enum InnerEnum5 { ie5a, ie5b };
|
||||
void take(InnerEnum5 e, InnerClass5 c) {}
|
||||
};
|
||||
struct OuterClass6 {
|
||||
struct InnerClass6 {
|
||||
struct BottomClass6 {};
|
||||
};
|
||||
enum InnerEnum6 { ie6a, ie6b };
|
||||
void take(InnerEnum6 e, InnerClass6 c) {}
|
||||
};
|
||||
struct OuterClass7 {
|
||||
struct InnerClass7 {
|
||||
struct BottomClass7 {};
|
||||
};
|
||||
enum InnerEnum7 { ie7a, ie7b };
|
||||
void take(InnerEnum7 e, InnerClass7 c) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
// These should not warn
|
||||
%nspace Space::OuterClass10;
|
||||
%nspace Space::OuterClass10::InnerClass10;
|
||||
%nspace Space::OuterClass10::InnerEnum10;
|
||||
|
||||
%nspace Space::OuterClass20;
|
||||
%clearnspace Space::OuterClass20::InnerClass20;
|
||||
%clearnspace Space::OuterClass20::InnerEnum20;
|
||||
|
||||
%nspacemove(NewOkay30) Space::OuterClass30;
|
||||
%nspace Space::OuterClass30::InnerClass30;
|
||||
%nspace Space::OuterClass30::InnerEnum40;
|
||||
|
||||
%nspacemove(NewOkay40) Space::OuterClass40;
|
||||
%clearnspace Space::OuterClass40::InnerClass40;
|
||||
%clearnspace Space::OuterClass40::InnerEnum40;
|
||||
|
||||
%nspacemove(NewOkay50) Space::OuterClass50;
|
||||
|
||||
%nonspace Space::OuterClass60;
|
||||
%nonspace Space::OuterClass60::InnerClass60;
|
||||
%nonspace Space::OuterClass60::InnerEnum60;
|
||||
|
||||
%nonspace Space::OuterClass70;
|
||||
|
||||
%nspace Space::OuterClass80;
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct OuterClass10 {
|
||||
struct InnerClass10 {
|
||||
struct BottomClass10 {};
|
||||
};
|
||||
enum InnerEnum10 { ie10a, ie10b };
|
||||
void take(InnerEnum10 e, InnerClass10 c) {}
|
||||
};
|
||||
struct OuterClass20 {
|
||||
struct InnerClass20 {
|
||||
struct BottomClass20 {};
|
||||
};
|
||||
enum InnerEnum20 { ie20a, ie20b };
|
||||
void take(InnerEnum20 e, InnerClass20 c) {}
|
||||
};
|
||||
struct OuterClass30 {
|
||||
struct InnerClass30 {
|
||||
struct BottomClass30 {};
|
||||
};
|
||||
enum InnerEnum30 { ie30a, ie30b };
|
||||
void take(InnerEnum30 e, InnerClass30 c) {}
|
||||
};
|
||||
struct OuterClass40 {
|
||||
struct InnerClass40 {
|
||||
struct BottomClass40 {};
|
||||
};
|
||||
enum InnerEnum40 { ie40a, ie40b };
|
||||
void take(InnerEnum40 e, InnerClass40 c) {}
|
||||
};
|
||||
struct OuterClass50 {
|
||||
struct InnerClass50 {
|
||||
struct BottomClass50 {};
|
||||
};
|
||||
enum InnerEnum50 { ie50a, ie50b };
|
||||
void take(InnerEnum50 e, InnerClass50 c) {}
|
||||
};
|
||||
struct OuterClass60 {
|
||||
struct InnerClass60 {
|
||||
struct BottomClass60 {};
|
||||
};
|
||||
enum InnerEnum60 { ie60a, ie60b };
|
||||
void take(InnerEnum60 e, InnerClass60 c) {}
|
||||
};
|
||||
struct OuterClass70 {
|
||||
struct InnerClass70 {
|
||||
struct BottomClass70 {};
|
||||
};
|
||||
enum InnerEnum70 { ie70a, ie70b };
|
||||
void take(InnerEnum70 e, InnerClass70 c) {}
|
||||
};
|
||||
struct OuterClass80 {
|
||||
struct InnerClass80 {
|
||||
struct BottomClass80 {};
|
||||
};
|
||||
enum InnerEnum80 { ie80a, ie80b };
|
||||
void take(InnerEnum80 e, InnerClass80 c) {}
|
||||
};
|
||||
}
|
||||
%}
|
|
@ -0,0 +1,27 @@
|
|||
%module nspacemove_stl
|
||||
|
||||
#if defined(SWIGJAVA)
|
||||
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
|
||||
#endif
|
||||
|
||||
// %nspacemove needed before %include std_vector.i, std_map.i etc so that this nspace targetting the template is attached to the template node
|
||||
%nspacemove(CPlusPlus::Maps) std::map;
|
||||
|
||||
%include <stl.i>
|
||||
|
||||
// %nspacemove needed at least before instantiation of the templates
|
||||
%nspacemove(CPlusPlus::Standard::Ints) std::vector<int>;
|
||||
%nspacemove(CPlusPlus::Standard::Strings) std::vector<std::string>;
|
||||
|
||||
%template(VectorInt) std::vector<int>;
|
||||
%template(VectorString) std::vector<std::string>;
|
||||
|
||||
%template(MapIntInt) std::map<int, int>;
|
||||
%template(MapIntString) std::map<int, std::string>;
|
||||
|
||||
%inline %{
|
||||
void test_vector_int(std::vector<int> a) {}
|
||||
void test_vector_string(std::vector<std::string> a) {}
|
||||
void test_map_int(std::map<int, int> a) {}
|
||||
void test_map_string(std::map<int, std::string> a) {}
|
||||
%}
|
|
@ -156,7 +156,7 @@ template<class K, class T, class C = std::less< K> > class map {
|
|||
map(const map& other);
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%typemap(javaclassmodifiers) iterator "public class"
|
||||
%extend {
|
||||
std::map< K, T, C >::iterator getNextUnchecked() {
|
||||
std::map< K, T, C >::iterator copy = (*$self);
|
||||
|
|
|
@ -142,7 +142,7 @@ class set {
|
|||
public:
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%typemap(javaclassmodifiers) iterator "public class"
|
||||
%extend {
|
||||
void incrementUnchecked() {
|
||||
++(*$self);
|
||||
|
|
|
@ -156,7 +156,7 @@ template<class K, class T> class unordered_map {
|
|||
unordered_map(const unordered_map& other);
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%typemap(javaclassmodifiers) iterator "public class"
|
||||
%extend {
|
||||
std::unordered_map< K, T >::iterator getNextUnchecked() {
|
||||
std::unordered_map< K, T >::iterator copy = (*$self);
|
||||
|
|
|
@ -138,7 +138,7 @@ class unordered_set {
|
|||
public:
|
||||
|
||||
struct iterator {
|
||||
%typemap(javaclassmodifiers) iterator "protected class"
|
||||
%typemap(javaclassmodifiers) iterator "public class"
|
||||
%extend {
|
||||
void incrementUnchecked() {
|
||||
++(*$self);
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
#define %nspace %feature("nspace")
|
||||
#define %nonspace %feature("nspace","0")
|
||||
#define %clearnspace %feature("nspace","")
|
||||
#define %nspacemove(NAMESPACE) %feature("nspace", #NAMESPACE)
|
||||
|
||||
/* valuewrapper directives */
|
||||
#define %valuewrapper %feature("valuewrapper")
|
||||
|
|
|
@ -163,6 +163,7 @@
|
|||
#define WARN_TYPE_ABSTRACT 403
|
||||
#define WARN_TYPE_REDEFINED 404
|
||||
#define WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
|
||||
#define WARN_TYPE_NSPACE_SETTING 406
|
||||
|
||||
/* Unused since 4.1.0: #define WARN_TYPEMAP_SOURCETARGET 450 */
|
||||
#define WARN_TYPEMAP_CHARLEAK 451
|
||||
|
|
|
@ -341,6 +341,75 @@ class TypePass:private Dispatcher {
|
|||
Delete(allbases);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* nspace_setting()
|
||||
*
|
||||
* Configures "sym:nspace" on the node and returns an overridden
|
||||
* nspace value when %nspacemove is used.
|
||||
* outer should point to parent class.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
String *nspace_setting(Node *n, Node *outer) {
|
||||
String *nssymname_new = nssymname;
|
||||
String *feature_nspace = GetFlagAttr(n, "feature:nspace");
|
||||
String *nspace = Copy(feature_nspace);
|
||||
|
||||
// Check validity - single colons not allowed
|
||||
const char *c = Char(feature_nspace);
|
||||
int valid = 1;
|
||||
while(c && *c) {
|
||||
if (*(c++) == ':' && *(c++) != ':') {
|
||||
valid = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove whitespace
|
||||
Replaceall(nspace, " ", "");
|
||||
Replaceall(nspace, "\t", "");
|
||||
|
||||
valid = valid && (feature_nspace ? Equal(feature_nspace, "1") || Swig_scopename_isvalid(nspace) : 1);
|
||||
Replaceall(nspace, "::", ".");
|
||||
if (valid) {
|
||||
if (outer) {
|
||||
// Nested class or enum in a class
|
||||
String *outer_nspace = Getattr(outer, "sym:nspace");
|
||||
String *nspace_attribute = Getattr(n, "feature:nspace");
|
||||
bool warn = false;
|
||||
if (outer_nspace) {
|
||||
if (Equal(nspace_attribute, "0")) {
|
||||
warn = true;
|
||||
} else if (nspace && !(Equal(nspace, "1") || Equal(nspace, outer_nspace))) {
|
||||
warn = true;
|
||||
}
|
||||
} else if (nspace) {
|
||||
warn = true;
|
||||
}
|
||||
if (warn) {
|
||||
String *outer_nspace_feature = Copy(outer_nspace);
|
||||
Replaceall(outer_nspace_feature, ".", "::");
|
||||
Swig_warning(WARN_TYPE_NSPACE_SETTING, Getfile(n), Getline(n), "Ignoring nspace setting (%s) for '%s',\n", nspace_attribute, Swig_name_decl(n));
|
||||
Swig_warning(WARN_TYPE_NSPACE_SETTING, Getfile(outer), Getline(outer), "as it conflicts with the nspace setting (%s) for outer class '%s'.\n", outer_nspace_feature, Swig_name_decl(outer));
|
||||
}
|
||||
Setattr(n, "sym:nspace", outer_nspace);
|
||||
} else {
|
||||
if (nspace) {
|
||||
if (Equal(nspace, "1")) {
|
||||
if (nssymname)
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
} else {
|
||||
Setattr(n, "sym:nspace", nspace);
|
||||
nssymname_new = nspace;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Swig_error(Getfile(n), Getline(n), "'%s' is not a valid identifier for nspace.\n", feature_nspace);
|
||||
}
|
||||
Delete(nspace);
|
||||
return nssymname_new;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* top()
|
||||
* ------------------------------------------------------------ */
|
||||
|
@ -493,10 +562,10 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "tdname", tdname);
|
||||
}
|
||||
}
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
|
||||
String *oldnssymname = nssymname;
|
||||
nssymname = nspace_setting(n, Getattr(n, "nested:outer"));
|
||||
|
||||
SwigType_new_scope(scopename);
|
||||
SwigType_attach_symtab(Getattr(n, "symtab"));
|
||||
|
||||
|
@ -533,6 +602,8 @@ class TypePass:private Dispatcher {
|
|||
SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope"));
|
||||
}
|
||||
|
||||
nssymname = oldnssymname;
|
||||
|
||||
/* Normalize deferred types */
|
||||
{
|
||||
normal_node *nn = new normal_node();
|
||||
|
@ -831,10 +902,9 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Setattr(n, "enumtype", enumtype);
|
||||
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
}
|
||||
String *oldnssymname = nssymname;
|
||||
Node *parent = parentNode(n);
|
||||
nssymname = nspace_setting(n, parent && Equal(nodeType(parent), "class") ? parent : NULL);
|
||||
|
||||
// This block of code is for dealing with %ignore on an enum item where the target language
|
||||
// attempts to use the C enum value in the target language itself and expects the previous enum value
|
||||
|
@ -880,6 +950,8 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
|
||||
emit_children(n);
|
||||
|
||||
nssymname = oldnssymname;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -984,6 +984,28 @@ List *Swig_scopename_tolist(const String *s) {
|
|||
return scopes;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_isvalid()
|
||||
*
|
||||
* Checks that s is a valid scopename (C++ namespace scope)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_scopename_isvalid(const String *s) {
|
||||
List *scopes = Swig_scopename_tolist(s);
|
||||
int valid = 0;
|
||||
Iterator si;
|
||||
|
||||
for (si = First(scopes); si.item; si = Next(si)) {
|
||||
String *subscope = si.item;
|
||||
valid = subscope && Len(subscope) > 0;
|
||||
if (valid)
|
||||
valid = Swig_symbol_isvalid(subscope);
|
||||
if (!valid)
|
||||
break;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_scopename_check()
|
||||
*
|
||||
|
|
|
@ -252,6 +252,7 @@ extern "C" {
|
|||
extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
|
||||
extern SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab);
|
||||
extern int Swig_symbol_isvalid(const String *s);
|
||||
|
||||
/* --- Parameters and Parameter Lists --- */
|
||||
|
||||
|
@ -332,6 +333,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern String *Swig_scopename_suffix(const String *s);
|
||||
extern List *Swig_scopename_tolist(const String *s);
|
||||
extern int Swig_scopename_check(const String *s);
|
||||
extern int Swig_scopename_isvalid(const String *s);
|
||||
extern String *Swig_string_lower(String *s);
|
||||
extern String *Swig_string_upper(String *s);
|
||||
extern String *Swig_string_title(String *s);
|
||||
|
|
|
@ -2223,3 +2223,21 @@ SwigType *Swig_symbol_template_param_eval(const SwigType *p, Symtab *symtab) {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_isvalid()
|
||||
*
|
||||
* Checks that s is a valid C symbol
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_symbol_isvalid(const String *s) {
|
||||
int valid = 0;
|
||||
const char *c = Char(s);
|
||||
if (c) {
|
||||
valid = isalpha((int)*c) || (*c == '_');
|
||||
while (valid && *++c) {
|
||||
valid = isalnum((int)*c) || (*c == '_');
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue