File: nspace_runme.java

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (80 lines) | stat: -rw-r--r-- 3,768 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// 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 nspace_runme {

  static {
    try {
	System.loadLibrary("nspace");
    } 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
    nspacePackage.Outer.Inner1.Color color1 = new nspacePackage.Outer.Inner1.Color();
    nspacePackage.Outer.Inner1.Color color = new nspacePackage.Outer.Inner1.Color(color1);
    color1.delete();
    color1 = null;

    // class methods
    color.colorInstanceMethod(20.0);
    nspacePackage.Outer.Inner1.Color.colorStaticMethod(20.0);
    nspacePackage.Outer.Inner1.Color created = nspacePackage.Outer.Inner1.Color.create();

    // class enums
    nspacePackage.Outer.SomeClass someClass = new nspacePackage.Outer.SomeClass();
    nspacePackage.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
    if (channel != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
      throw new RuntimeException("Transmission wrong");

    // class anonymous enums
    int val1 = nspacePackage.Outer.Inner1.Color.ColorEnumVal1;
    int val2 = nspacePackage.Outer.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
    nspacePackage.Outer.Inner1.Color.setStaticMemberVariable(789);
    if (nspacePackage.Outer.Inner1.Color.getStaticMemberVariable() != 789)
      throw new RuntimeException("static member variable failed");
    if (nspacePackage.Outer.Inner1.Color.staticConstMemberVariable != 222)
      throw new RuntimeException("static const member variable failed");
    if (nspacePackage.Outer.Inner1.Color.staticConstEnumMemberVariable != nspacePackage.Outer.Inner1.Color.Channel.Transmission)
      throw new RuntimeException("static const enum member variable failed");

    // Same class different namespaces
    nspacePackage.Outer.Inner1.Color col1 = new nspacePackage.Outer.Inner1.Color();
    nspacePackage.Outer.Inner2.Color col2 = nspacePackage.Outer.Inner2.Color.create();
    col2.colors(col1, col1, col2, col2, col2);

    // check globals in a namespace don't get mangled with the nspacePackage option
    nspacePackage.nspace.namespaceFunction(color);
    nspacePackage.nspace.setNamespaceVar(111);
    if (nspacePackage.nspace.getNamespaceVar() != 111)
      throw new RuntimeException("global var failed");

    // global enums
    nspacePackage.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
    if (outerChannel1 != nspacePackage.Outer.Inner1.Channel.Transmission1)
      throw new RuntimeException("Transmission1 wrong");
    nspacePackage.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
    if (outerChannel2 != nspacePackage.Outer.Inner2.Channel.Transmission2)
      throw new RuntimeException("Transmission2 wrong");

    // turn feature off / ignoring
    nspacePackage.Outer.namespce ns = new nspacePackage.Outer.namespce();
    nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease();

    // Derived class
    nspacePackage.Outer.Inner3.Blue blue3 = new nspacePackage.Outer.Inner3.Blue();
    blue3.blueInstanceMethod();
    nspacePackage.Outer.Inner4.Blue blue4 = new nspacePackage.Outer.Inner4.Blue();
    blue4.blueInstanceMethod();
  }
}