*** empty log message ***

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@50 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-01-12 03:21:25 +00:00
commit 63880a6e34
16 changed files with 517 additions and 0 deletions

View file

@ -0,0 +1,17 @@
TOP = ../..
SWIG = $(TOP)/../swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
clean::
rm -f *_wrap* *.o core *~ *.so *.pm myperl

View file

@ -0,0 +1 @@
Simple example from users manual.

View file

@ -0,0 +1,24 @@
/* Simple example from documentation */
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
/* Compute factorial of n */
int fact(int n) {
if (n <= 1) return 1;
else return n*fact(n-1);
}
/* Compute n mod m */
int my_mod(int n, int m) {
return (n % m);
}
char *get_time() {
long ltime;
time(&ltime);
return ctime(&ltime);
}

View file

@ -0,0 +1,11 @@
/* File : example.i */
%module example
%{
/* Put headers and other declarations here */
%}
extern double My_variable;
extern int fact(int);
%name(mod) extern int my_mod(int n, int m);
extern char *get_time();

View file

@ -0,0 +1,23 @@
#
# Perl5 script for testing simple example
use example;
package example;
print get_time();
print "My Variable = $My_variable","\n";
for ($i = 0; $i < 14; $i++) {
$n = fact($i);
print "$i factorial is $n\n";
}
for ($i = 1; $i < 250; $i++) {
for ($j = 1; $j < 250; $j++) {
$n = mod($i,$j);
$My_variable = $My_variable + $n;
}
}
print "My_variable = ", $My_variable, "\n";