Merge branch 'master' into octave

This commit is contained in:
Karl Wette 2018-05-17 14:08:29 +10:00 committed by GitHub
commit e66827be7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 1596 additions and 1149 deletions

View file

@ -162,6 +162,8 @@ CPP_TEST_CASES += \
cpp_nodefault \
cpp_static \
cpp_typedef \
cpp17_nested_namespaces \
cpp17_nspace_nested_namespaces \
curiously_recurring_template_pattern \
default_args \
default_arg_expressions \

View file

@ -0,0 +1,199 @@
%module cpp17_nested_namespaces
// Tests c++17 style nested namespaces
// Tests are designed so that code compiles with C++98 compilers
#define CPP17 1
%{
#if __cplusplus >= 201703L
#define CPP17 1
#endif
%}
%inline %{
// Tests with namespaces already defined using C++98 style (non-nested) namespaces
namespace A1 {
struct A1Struct {
void A1Method() {}
};
namespace B1 {
struct B1Struct {
void B1Method() {}
};
}
}
#if defined(CPP17)
namespace A1::B1 {
#else
namespace A1 {
namespace B1 {
#endif
A1Struct createA1Struct() { return ::A1::A1Struct(); }
B1Struct createB1Struct() { return ::A1::B1::B1Struct(); }
#if !defined(CPP17)
}
}
#else
}
#endif
namespace A1 {
namespace B1 {
namespace C1 {
struct C1Struct {
void C1Method() {}
};
}
}
}
#if defined(CPP17)
namespace A1::B1::C1 {
#else
namespace A1 {
namespace B1 {
namespace C1 {
#endif
C1Struct createC1Struct() { return ::A1::B1::C1::C1Struct(); }
#if !defined(CPP17)
}
}
}
#else
}
#endif
%}
%inline %{
// Tests with namespaces already defined using C++17 style (nested) namespaces
#if defined(CPP17)
namespace A2::B2 {
#else
namespace A2 {
namespace B2 {
#endif
struct B2Struct {
void B2Method() {}
};
#if !defined(CPP17)
}
}
#else
}
#endif
#if defined(CPP17)
namespace A2::B2 {
#else
namespace A2 {
namespace B2 {
#endif
B2Struct createB2Struct() { return ::A2::B2::B2Struct(); }
#if !defined(CPP17)
}
}
#else
}
#endif
#if defined(CPP17)
namespace A2::B2::C2 {
#else
namespace A2 {
namespace B2 {
namespace C2 {
#endif
struct C2Struct {
void C2Method() {}
};
#if !defined(CPP17)
}
}
}
#else
}
#endif
#if defined(CPP17)
namespace A2::B2::C2 {
#else
namespace A2 {
namespace B2 {
namespace C2 {
#endif
C2Struct createC2Struct() { return ::A2::B2::C2::C2Struct(); }
#if !defined(CPP17)
}
}
}
#else
}
#endif
%}
%inline %{
// Tests with namespaces already defined using C++17 style (nested) namespaces to 3 levels
#if defined(CPP17)
namespace A3::B3::C3 {
#else
namespace A3 {
namespace B3 {
namespace C3 {
#endif
struct C3Struct {
void C3Method() {}
};
#if !defined(CPP17)
}
}
}
#else
}
#endif
#if defined(CPP17)
namespace A3::B3::C3 {
#else
namespace A3 {
namespace B3 {
namespace C3 {
#endif
C3Struct createC3Struct() { return ::A3::B3::C3::C3Struct(); }
#if !defined(CPP17)
}
}
}
#else
}
#endif
#if defined(CPP17)
namespace A3::B3 {
#else
namespace A3 {
namespace B3 {
#endif
struct B3Struct {
void B3Method() {}
};
#if !defined(CPP17)
}
}
#else
}
#endif
#if defined(CPP17)
namespace A3::B3 {
#else
namespace A3 {
namespace B3 {
#endif
B3Struct createB3Struct() { return ::A3::B3::B3Struct(); }
#if !defined(CPP17)
}
}
#else
}
#endif
%}

View file

@ -0,0 +1,13 @@
%module cpp17_nspace_nested_namespaces
#if defined(SWIGJAVA)
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
#endif
// nspace feature only supported by these languages
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT)
%nspace;
#endif
%include "cpp17_nested_namespaces.i"

View file

@ -0,0 +1,25 @@
using System;
using cpp17_nested_namespacesNamespace;
public class cpp17_nested_namespaces_runme
{
static void Main()
{
new A1Struct().A1Method();
new B1Struct().B1Method();
new C1Struct().C1Method();
cpp17_nested_namespaces.createA1Struct().A1Method();
cpp17_nested_namespaces.createB1Struct().B1Method();
cpp17_nested_namespaces.createC1Struct().C1Method();
new B2Struct().B2Method();
new C2Struct().C2Method();
cpp17_nested_namespaces.createB2Struct().B2Method();
cpp17_nested_namespaces.createC2Struct().C2Method();
new B3Struct().B3Method();
new C3Struct().C3Method();
cpp17_nested_namespaces.createB3Struct().B3Method();
cpp17_nested_namespaces.createC3Struct().C3Method();
}
}

View file

@ -0,0 +1,25 @@
using System;
using cpp17_nspace_nested_namespacesNamespace;
public class cpp17_nspace_nested_namespaces_runme
{
static void Main()
{
new cpp17_nspace_nested_namespacesNamespace.A1.A1Struct().A1Method();
new cpp17_nspace_nested_namespacesNamespace.A1.B1.B1Struct().B1Method();
new cpp17_nspace_nested_namespacesNamespace.A1.B1.C1.C1Struct().C1Method();
cpp17_nspace_nested_namespaces.createA1Struct().A1Method();
cpp17_nspace_nested_namespaces.createB1Struct().B1Method();
cpp17_nspace_nested_namespaces.createC1Struct().C1Method();
new cpp17_nspace_nested_namespacesNamespace.A2.B2.B2Struct().B2Method();
new cpp17_nspace_nested_namespacesNamespace.A2.B2.C2.C2Struct().C2Method();
cpp17_nspace_nested_namespaces.createB2Struct().B2Method();
cpp17_nspace_nested_namespaces.createC2Struct().C2Method();
new cpp17_nspace_nested_namespacesNamespace.A3.B3.B3Struct().B3Method();
new cpp17_nspace_nested_namespacesNamespace.A3.B3.C3.C3Struct().C3Method();
cpp17_nspace_nested_namespaces.createB3Struct().B3Method();
cpp17_nspace_nested_namespaces.createC3Struct().C3Method();
}
}

View file

@ -0,0 +1,34 @@
%module cpp_nested_namespace_alias
// C++17 nested namespaces
namespace A
{
namespace B
{
void ab1();
}
}
namespace A::B
{
void ab2();
}
namespace AAlias = A;
namespace AAlias::B
{
void ab3();
}
namespace A
{
namespace BAlias = B;
void ab4();
}
namespace A::BAlias
{
void ab5();
}
namespace ABAlias = A::B;
namespace ABAlias
{
void ab6();
}

View file

@ -0,0 +1,3 @@
cpp_nested_namespace_alias.i:18: Warning 308: Namespace alias 'AAlias' not allowed here. Assuming 'A'
cpp_nested_namespace_alias.i:27: Warning 308: Namespace alias 'BAlias' not allowed here. Assuming 'B'
cpp_nested_namespace_alias.i:32: Warning 308: Namespace alias 'ABAlias' not allowed here. Assuming 'B'

View file

@ -59,6 +59,7 @@ JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
SWIGOPT += $(JAVA_PACKAGEOPT)
# Custom tests - tests with additional commandline options
cpp17_nspace_nested_namespaces.%: JAVA_PACKAGE = $*Package
director_nspace.%: JAVA_PACKAGE = $*Package
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package

View file

@ -0,0 +1,32 @@
import cpp17_nested_namespaces.*;
public class cpp17_nested_namespaces_runme {
static {
try {
System.loadLibrary("cpp17_nested_namespaces");
} 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[]) {
new A1Struct().A1Method();
new B1Struct().B1Method();
new C1Struct().C1Method();
cpp17_nested_namespaces.createA1Struct().A1Method();
cpp17_nested_namespaces.createB1Struct().B1Method();
cpp17_nested_namespaces.createC1Struct().C1Method();
new B2Struct().B2Method();
new C2Struct().C2Method();
cpp17_nested_namespaces.createB2Struct().B2Method();
cpp17_nested_namespaces.createC2Struct().C2Method();
new B3Struct().B3Method();
new C3Struct().C3Method();
cpp17_nested_namespaces.createB3Struct().B3Method();
cpp17_nested_namespaces.createC3Struct().C3Method();
}
}

View file

@ -0,0 +1,30 @@
public class cpp17_nspace_nested_namespaces_runme {
static {
try {
System.loadLibrary("cpp17_nspace_nested_namespaces");
} 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[]) {
new cpp17_nspace_nested_namespacesPackage.A1.A1Struct().A1Method();
new cpp17_nspace_nested_namespacesPackage.A1.B1.B1Struct().B1Method();
new cpp17_nspace_nested_namespacesPackage.A1.B1.C1.C1Struct().C1Method();
cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createA1Struct().A1Method();
cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB1Struct().B1Method();
cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC1Struct().C1Method();
new cpp17_nspace_nested_namespacesPackage.A2.B2.B2Struct().B2Method();
new cpp17_nspace_nested_namespacesPackage.A2.B2.C2.C2Struct().C2Method();
cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB2Struct().B2Method();
cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC2Struct().C2Method();
new cpp17_nspace_nested_namespacesPackage.A3.B3.B3Struct().B3Method();
new cpp17_nspace_nested_namespacesPackage.A3.B3.C3.C3Struct().C3Method();
cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB3Struct().B3Method();
cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC3Struct().C3Method();
}
}

View file

@ -0,0 +1,18 @@
from cpp17_nested_namespaces import *
A1Struct().A1Method()
B1Struct().B1Method()
C1Struct().C1Method()
createA1Struct().A1Method()
createB1Struct().B1Method()
createC1Struct().C1Method()
B2Struct().B2Method()
C2Struct().C2Method()
createB2Struct().B2Method()
createC2Struct().C2Method()
B3Struct().B3Method()
C3Struct().C3Method()
createB3Struct().B3Method()
createC3Struct().C3Method()