csharp examples
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4433 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
73e647bc45
commit
511f4d42bf
12 changed files with 210 additions and 0 deletions
14
SWIG/Examples/csharp/simple/.cvsignore
Normal file
14
SWIG/Examples/csharp/simple/.cvsignore
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
runme
|
||||
*_wrap.c
|
||||
*_wrap.cxx
|
||||
*.iltmp
|
||||
*.cs
|
||||
*.dll
|
||||
*.dsw
|
||||
*.exp
|
||||
*.lib
|
||||
*.ncb
|
||||
*.opt
|
||||
*.plg
|
||||
Release
|
||||
Debug
|
||||
20
SWIG/Examples/csharp/simple/Makefile
Normal file
20
SWIG/Examples/csharp/simple/Makefile
Normal 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
|
||||
18
SWIG/Examples/csharp/simple/example.c
Normal file
18
SWIG/Examples/csharp/simple/example.c
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
5
SWIG/Examples/csharp/simple/example.i
Normal file
5
SWIG/Examples/csharp/simple/example.i
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
extern int gcd(int x, int y);
|
||||
extern double Foo;
|
||||
23
SWIG/Examples/csharp/simple/runme.cs
Normal file
23
SWIG/Examples/csharp/simple/runme.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue