csharp examples

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4433 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-03-04 22:49:38 +00:00
commit 511f4d42bf
12 changed files with 210 additions and 0 deletions

View file

@ -0,0 +1,14 @@
runme
*_wrap.c
*_wrap.cxx
*.iltmp
*.cs
*.dll
*.dsw
*.exp
*.lib
*.ncb
*.opt
*.plg
Release
Debug

View file

@ -0,0 +1,20 @@
TOP = ../..
SWIG = $(TOP)/../swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
SWIGOPT =
CSHARPSRCS = *.cs
CSHARPFLAGS= -o runme
all:: csharp
csharp::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
$(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
clean::
$(MAKE) -f $(TOP)/Makefile csharp_clean
check: all

View file

@ -0,0 +1,18 @@
/* File : example.c */
/* A global variable */
double Foo = 3.0;
/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
int g;
g = y;
while (x > 0) {
g = x;
x = y % x;
y = g;
}
return g;
}

View file

@ -0,0 +1,5 @@
/* File : example.i */
%module example
extern int gcd(int x, int y);
extern double Foo;

View file

@ -0,0 +1,23 @@
public class runme
{
static void Main()
{
// Call our gcd() function
int x = 42;
int y = 105;
int g = example.gcd(x,y);
Console.WriteLine("The gcd of " + x + " and " + y + " is " + g);
// Manipulate the Foo global variable
// Output its current value
Console.WriteLine("Foo = " + example.getFoo());
// Change its value
example.setFoo(3.1415926);
// See if the change took effect
Console.WriteLine("Foo = " + example.getFoo());
}
}