mirror of https://github.com/swig/swig
Enhance %nspace with %nspacemove for moving symbols into a different target language namespace
%nspacemove moves a class or enum into a different target language 'namespace'. This builds on top of %nspace and so is currently only implemented in C#, D, Java, Javascript and Lua. Javascript also supports %nspace for functions and variables in a namespace with a non-standard implementation; %nspacemove is not fully working yet for Javascript. Issue #2782
This commit is contained in:
parent
6f0442829f
commit
5035473e9b
|
@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.3.0 (in progress)
|
||||
===========================
|
||||
|
||||
2024-05-26: 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-04-12: pfusik
|
||||
[Javascript] #2869 Fix JavaScript _wrap_getCPtr on 64-bit Windows
|
||||
|
||||
|
|
|
@ -5,26 +5,26 @@ public class runme
|
|||
static void Main()
|
||||
{
|
||||
// constructors and destructors
|
||||
nspacemoveNamespace.Outer.Inner1.Color color1 = new nspacemoveNamespace.Outer.Inner1.Color();
|
||||
nspacemoveNamespace.Outer.Inner1.Color color = new nspacemoveNamespace.Outer.Inner1.Color(color1);
|
||||
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.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspacemoveNamespace.Outer.Inner1.Color created = nspacemoveNamespace.Outer.Inner1.Color.create();
|
||||
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.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspacemoveNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||
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.Outer.Inner1.Color.ColorEnumVal1;
|
||||
int val2 = nspacemoveNamespace.Outer.Inner1.Color.ColorEnumVal2;
|
||||
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");
|
||||
|
||||
|
@ -34,12 +34,12 @@ public class runme
|
|||
throw new ApplicationException("instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
nspacemoveNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspacemoveNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
|
||||
nspacemoveNamespace.Ooter.Extra.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspacemoveNamespace.Ooter.Extra.Inner1.Color.staticMemberVariable != 789)
|
||||
throw new ApplicationException("static member variable failed");
|
||||
if (nspacemoveNamespace.Outer.Inner1.Color.staticConstMemberVariable != 222)
|
||||
if (nspacemoveNamespace.Ooter.Extra.Inner1.Color.staticConstMemberVariable != 222)
|
||||
throw new ApplicationException("static const member variable failed");
|
||||
if (nspacemoveNamespace.Outer.Inner1.Color.staticConstEnumMemberVariable != nspacemoveNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||
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
|
||||
|
@ -49,18 +49,24 @@ public class runme
|
|||
throw new ApplicationException("global var failed");
|
||||
|
||||
// Same class different namespaces
|
||||
nspacemoveNamespace.Outer.Inner1.Color col1 = new nspacemoveNamespace.Outer.Inner1.Color();
|
||||
nspacemoveNamespace.Outer.Inner2.Color col2 = nspacemoveNamespace.Outer.Inner2.Color.create();
|
||||
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.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspacemoveNamespace.Outer.Inner1.Channel.Transmission1)
|
||||
nspacemoveNamespace.Euter.Extra.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspacemoveNamespace.Euter.Extra.Inner1.Channel.Transmission1)
|
||||
throw new ApplicationException("Transmission1 wrong");
|
||||
nspacemoveNamespace.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspacemoveNamespace.Outer.Inner2.Channel.Transmission2)
|
||||
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();
|
||||
|
|
|
@ -4,13 +4,15 @@ import std.exception;
|
|||
import nspacemove.nspacemove;
|
||||
static import nspacemove.NoNSpacePlease;
|
||||
static import nspacemove.Outer.namespce;
|
||||
static import nspacemove.Outer.Inner1.Channel;
|
||||
static import oi1c = nspacemove.Outer.Inner1.Color;
|
||||
static import nspacemove.Outer.Inner2.Channel;
|
||||
static import nspacemove.Outer.Inner2.Color;
|
||||
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
|
||||
|
@ -54,17 +56,23 @@ void main() {
|
|||
|
||||
// Same class different namespaces
|
||||
auto col1 = new oi1c.Color();
|
||||
auto col2 = nspacemove.Outer.Inner2.Color.Color.create();
|
||||
auto col2 = nspacemove.Outer.Snner2.Color.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// global enums
|
||||
auto outerChannel1 = someClass.GetInner1Channel();
|
||||
enforce(outerChannel1 == nspacemove.Outer.Inner1.Channel.Channel.Transmission1,
|
||||
enforce(outerChannel1 == nspacemove.Euter.Extra.Inner1.Channel.Channel.Transmission1,
|
||||
"Transmission1 wrong");
|
||||
auto outerChannel2 = someClass.GetInner2Channel();
|
||||
enforce(outerChannel2 == nspacemove.Outer.Inner2.Channel.Channel.Transmission2,
|
||||
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();
|
||||
|
|
|
@ -12,25 +12,25 @@ public class nspacemove_runme {
|
|||
|
||||
public static void main(String argv[]) {
|
||||
// constructors and destructors
|
||||
nspacemovePackage.Outer.Inner1.Color color1 = new nspacemovePackage.Outer.Inner1.Color();
|
||||
nspacemovePackage.Outer.Inner1.Color color = new nspacemovePackage.Outer.Inner1.Color(color1);
|
||||
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.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspacemovePackage.Outer.Inner1.Color created = nspacemovePackage.Outer.Inner1.Color.create();
|
||||
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.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspacemovePackage.Outer.Inner1.Color.Channel.Transmission)
|
||||
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.Outer.Inner1.Color.ColorEnumVal1;
|
||||
int val2 = nspacemovePackage.Outer.Inner1.Color.ColorEnumVal2;
|
||||
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");
|
||||
|
||||
|
@ -40,17 +40,17 @@ public class nspacemove_runme {
|
|||
throw new RuntimeException("instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
nspacemovePackage.Outer.Inner1.Color.setStaticMemberVariable(789);
|
||||
if (nspacemovePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789)
|
||||
nspacemovePackage.Ooter.Extra.Inner1.Color.setStaticMemberVariable(789);
|
||||
if (nspacemovePackage.Ooter.Extra.Inner1.Color.getStaticMemberVariable() != 789)
|
||||
throw new RuntimeException("static member variable failed");
|
||||
if (nspacemovePackage.Outer.Inner1.Color.staticConstMemberVariable != 222)
|
||||
if (nspacemovePackage.Ooter.Extra.Inner1.Color.staticConstMemberVariable != 222)
|
||||
throw new RuntimeException("static const member variable failed");
|
||||
if (nspacemovePackage.Outer.Inner1.Color.staticConstEnumMemberVariable != nspacemovePackage.Outer.Inner1.Color.Channel.Transmission)
|
||||
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.Outer.Inner1.Color col1 = new nspacemovePackage.Outer.Inner1.Color();
|
||||
nspacemovePackage.Outer.Inner2.Color col2 = nspacemovePackage.Outer.Inner2.Color.create();
|
||||
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
|
||||
|
@ -60,13 +60,19 @@ public class nspacemove_runme {
|
|||
throw new RuntimeException("global var failed");
|
||||
|
||||
// global enums
|
||||
nspacemovePackage.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspacemovePackage.Outer.Inner1.Channel.Transmission1)
|
||||
nspacemovePackage.Euter.Extra.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspacemovePackage.Euter.Extra.Inner1.Channel.Transmission1)
|
||||
throw new RuntimeException("Transmission1 wrong");
|
||||
nspacemovePackage.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspacemovePackage.Outer.Inner2.Channel.Transmission2)
|
||||
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();
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
var nspacemove = require("nspacemove");
|
||||
|
||||
var color1 = new nspacemove.Outer.Inner1.Color();
|
||||
var color = new nspacemove.Outer.Inner1.Color(color1);
|
||||
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.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
var created = nspacemove.Outer.Inner1.Color.create();
|
||||
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.Outer.Inner1.Color.Transmission) {
|
||||
if (channel != nspacemove.Ooter.Extra.Inner1.Color.Transmission) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
// class anonymous enums
|
||||
var val1 = nspacemove.Outer.Inner1.Color.ColorEnumVal1;
|
||||
var val2 = nspacemove.Outer.Inner1.Color.ColorEnumVal2;
|
||||
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.");
|
||||
}
|
||||
|
@ -30,22 +30,22 @@ if (color.instanceMemberVariable !== 123) {
|
|||
}
|
||||
|
||||
// static member variables
|
||||
nspacemove.Outer.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspacemove.Outer.Inner1.Color.staticMemberVariable !== 789) {
|
||||
nspacemove.Ooter.Extra.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspacemove.Ooter.Extra.Inner1.Color.staticMemberVariable !== 789) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
if (nspacemove.Outer.Inner1.Color.staticConstMemberVariable !== 222) {
|
||||
if (nspacemove.Ooter.Extra.Inner1.Color.staticConstMemberVariable !== 222) {
|
||||
throw new Error("Failed.");
|
||||
}
|
||||
|
||||
if (nspacemove.Outer.Inner1.Color.staticConstEnumMemberVariable !== nspacemove.Outer.Inner1.Color.Transmission) {
|
||||
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.Outer.Inner1.Color();
|
||||
var col2 = nspacemove.Outer.Inner2.Color.create();
|
||||
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);
|
||||
|
@ -56,15 +56,24 @@ if (nspacemove.Outer.Inner1.namespaceVar !== 111) {
|
|||
|
||||
// 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();
|
||||
|
|
|
@ -17,22 +17,22 @@ blue1.instanceMemberVariable = 4
|
|||
assert( blue1.instanceMemberVariable == 4 )
|
||||
|
||||
-- Constructors
|
||||
color1 = ns.Outer.Inner1.Color()
|
||||
color2 = ns.Outer.Inner1.Color.create()
|
||||
color = ns.Outer.Inner1.Color(color1)
|
||||
color3 = ns.Outer.Inner2.Color.create()
|
||||
color4 = ns.Outer.Inner2.Color.create()
|
||||
color5 = ns.Outer.Inner2.Color.create()
|
||||
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.GlobalClass()
|
||||
gc = ns.Additional.GlobalClass()
|
||||
|
||||
nnsp = ns.NoNSpacePlease()
|
||||
|
||||
-- Class methods
|
||||
color:colorInstanceMethod(20.0)
|
||||
ns.Outer.Inner1.Color.colorStaticMethod(30.0)
|
||||
ns.Ooter.Extra.Inner1.Color.colorStaticMethod(30.0)
|
||||
color3:colorInstanceMethod(40.0)
|
||||
ns.Outer.Inner2.Color.colorStaticMethod(50.0)
|
||||
ns.Outer.Snner2.Color.colorStaticMethod(50.0)
|
||||
color3:colors(color1, color2, color3, color4, color5)
|
||||
|
||||
gc:gmethod()
|
||||
|
@ -42,19 +42,19 @@ color.instanceMemberVariable = 5
|
|||
color1.instanceMemberVariable = 7
|
||||
assert( color.instanceMemberVariable == 5 )
|
||||
assert( color1.instanceMemberVariable == 7 )
|
||||
assert(ns.Outer.Inner1.Color.staticMemberVariable == 0 )
|
||||
assert(ns.Outer.Inner2.Color.staticMemberVariable == 0 )
|
||||
ns.Outer.Inner1.Color.staticMemberVariable = 9
|
||||
ns.Outer.Inner2.Color.staticMemberVariable = 11
|
||||
assert(ns.Outer.Inner1.Color.staticMemberVariable == 9)
|
||||
assert(ns.Outer.Inner2.Color.staticMemberVariable == 11)
|
||||
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.Outer.Inner1.Color.Specular == 0x20 )
|
||||
assert( ns.Outer.Inner2.Color.Specular == 0x40 )
|
||||
assert( ns.Outer.Inner1.Color.staticConstMemberVariable == 222 )
|
||||
assert( ns.Outer.Inner2.Color.staticConstMemberVariable == 333 )
|
||||
assert( ns.Outer.Inner1.Color.staticConstEnumMemberVariable ~= ns.Outer.Inner2.Color.staticConstEnumMemberVariable )
|
||||
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
|
||||
|
@ -63,17 +63,18 @@ assert( sc:GetInner1ColorChannel() ~= sc:GetInner2Channel() )
|
|||
assert( sc:GetInner1Channel() ~= sc:GetInner2Channel() )
|
||||
|
||||
-- Backward compatibility
|
||||
assert(ns.Outer.Inner1.Diffuse ~= nil)
|
||||
assert(ns.Euter.Extra.Inner1.Diffuse ~= nil)
|
||||
-- Enums within class within namespace shouldn't have backward compatible name. Same for static methods
|
||||
assert(ns.Outer.Inner1.Color_Diffuse == nil)
|
||||
assert(ns.Outer.Inner1.Color_colorStaticMethod == nil)
|
||||
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.Inner2.NoNSpacePlease_NoNspace == nil)
|
||||
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)
|
||||
|
|
|
@ -106,6 +106,9 @@ struct GlobalClass {
|
|||
void gmethod() {}
|
||||
};
|
||||
|
||||
enum GlobalEnum { aaa, bbb, ccc };
|
||||
void takeGlobalEnum(GlobalEnum) {}
|
||||
|
||||
void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {}
|
||||
%}
|
||||
|
||||
|
|
|
@ -2,5 +2,14 @@
|
|||
|
||||
// Testing %nspacemove which moves symbols into a different target language 'namespace'
|
||||
|
||||
// Currently this testcase is identical to the nspace testcase
|
||||
// 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"
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
#define %nspace %feature("nspace")
|
||||
#define %nonspace %feature("nspace","0")
|
||||
#define %clearnspace %feature("nspace","")
|
||||
#define %nspacemove(NAME) %feature("nspace", #NAME)
|
||||
|
||||
/* valuewrapper directives */
|
||||
#define %valuewrapper %feature("valuewrapper")
|
||||
|
|
|
@ -493,10 +493,21 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "tdname", tdname);
|
||||
}
|
||||
}
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
|
||||
String *oldnssymname = nssymname;
|
||||
String *nspace_feature = GetFlagAttr(n, "feature:nspace");
|
||||
String *nspace = Copy(nspace_feature);
|
||||
Replaceall(nspace, "::", ".");
|
||||
if (nspace) {
|
||||
if (Equal(nspace, "1")) {
|
||||
if (nssymname)
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
} else {
|
||||
Setattr(n, "sym:nspace", nspace);
|
||||
nssymname = nspace;
|
||||
}
|
||||
}
|
||||
|
||||
SwigType_new_scope(scopename);
|
||||
SwigType_attach_symtab(Getattr(n, "symtab"));
|
||||
|
||||
|
@ -533,6 +544,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,9 +844,18 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Setattr(n, "enumtype", enumtype);
|
||||
|
||||
if (nssymname) {
|
||||
if (GetFlag(n, "feature:nspace"))
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
String *oldnssymname = nssymname;
|
||||
String *nspace_feature = GetFlagAttr(n, "feature:nspace");
|
||||
String *nspace = Copy(nspace_feature);
|
||||
Replaceall(nspace, "::", ".");
|
||||
if (nspace) {
|
||||
if (Equal(nspace, "1")) {
|
||||
if (nssymname)
|
||||
Setattr(n, "sym:nspace", nssymname);
|
||||
} else {
|
||||
Setattr(n, "sym:nspace", nspace);
|
||||
nssymname = nspace;
|
||||
}
|
||||
}
|
||||
|
||||
// This block of code is for dealing with %ignore on an enum item where the target language
|
||||
|
@ -880,6 +902,8 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
|
||||
emit_children(n);
|
||||
|
||||
nssymname = oldnssymname;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue