Add nspace feature for C# and add documentation on nspace

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11920 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-03-06 19:11:32 +00:00
commit b6b99bb148
9 changed files with 371 additions and 87 deletions

View file

@ -70,13 +70,13 @@ run_testcase = \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \
$*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \
`find $* -name "*.cs"`' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='*.cs' csharp_compile && cd .. ; \
CSHARPSRCS='`find . -name "*.cs"`' csharp_compile && cd .. ; \
fi
# Clean: remove testcase directories

View file

@ -0,0 +1,60 @@
using System;
public class runme
{
static void Main()
{
// constructors and destructors
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
nspaceNamespace.Outer.Inner1.Color color = new nspaceNamespace.Outer.Inner1.Color(color1);
color1.Dispose();
color1 = null;
// class methods
color.colorInstanceMethod(20.0);
nspaceNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
nspaceNamespace.Outer.Inner1.Color created = nspaceNamespace.Outer.Inner1.Color.create();
created.Dispose();
// class enums
nspaceNamespace.Outer.SomeClass someClass = new nspaceNamespace.Outer.SomeClass();
nspaceNamespace.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
throw new ApplicationException("Transmission wrong");
// static member variables
nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
throw new ApplicationException("static member variable failed");
// instance member variables
color.instanceMemberVariable = 123;
if (color.instanceMemberVariable != 123)
throw new ApplicationException("instance member variable failed");
// check globals in a namespace don't get mangled with the nspaceNamespace option
nspaceNamespace.nspace.namespaceFunction(color);
nspaceNamespace.nspace.namespaceVar = 111;
if (nspaceNamespace.nspace.namespaceVar != 111)
throw new ApplicationException("global var failed");
// Same class different namespaces
nspaceNamespace.Outer.Inner1.Color col1 = new nspaceNamespace.Outer.Inner1.Color();
nspaceNamespace.Outer.Inner2.Color col2 = nspaceNamespace.Outer.Inner2.Color.create();
col2.colors(col1, col1, col2, col2, col2);
// global enums
nspaceNamespace.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
if (outerChannel1 != nspaceNamespace.Outer.Inner1.Channel.Transmission1)
throw new ApplicationException("Transmission1 wrong");
nspaceNamespace.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
if (outerChannel2 != nspaceNamespace.Outer.Inner2.Channel.Transmission2)
throw new ApplicationException("Transmission2 wrong");
// turn feature off / ignoring
nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
ns.Dispose();
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
nons.Dispose();
}
}