Implement functionwrapper
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11242 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f2c5fb59d6
commit
4aa72f9b01
16 changed files with 739 additions and 12 deletions
18
Examples/scilab/simple/example.c
Normal file
18
Examples/scilab/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;
|
||||
}
|
||||
|
||||
|
||||
7
Examples/scilab/simple/example.i
Normal file
7
Examples/scilab/simple/example.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%inline %{
|
||||
extern int gcd(int x, int y);
|
||||
extern double Foo;
|
||||
%}
|
||||
23
Examples/scilab/simple/runme.sci
Normal file
23
Examples/scilab/simple/runme.sci
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// builder the *.so
|
||||
exec builder.sce;
|
||||
|
||||
//loader the *.so
|
||||
exec loader.sce;
|
||||
|
||||
// Call our gcd() function
|
||||
x = 42;
|
||||
y = 105;
|
||||
g = gcd(x,y);
|
||||
printf("The gcd of %d and %d is %d\n",x,y,g);
|
||||
|
||||
//Manipulate the Foo global variable
|
||||
|
||||
// Output its current value
|
||||
Foo_get()
|
||||
|
||||
// Change its value
|
||||
Foo_set = 3.1415926
|
||||
|
||||
//See if the change took effect
|
||||
Foo_get
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue