Updated examples to function correctly with new php4 module. Added

some supplemental examples for cpointer, overloading and references using
proxies.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7391 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Kevin Ruland 2005-08-24 16:32:41 +00:00
commit 522ab32693
44 changed files with 506 additions and 131 deletions

View file

@ -1,4 +1,5 @@
#! /bin/sh -e
${SWIG:=swig} -php4 -phpfull -noproxy -withc example.c example.i
phpize && ./configure && make clean && make
${SWIG:=swig} -php4 -make -noproxy -withc example.c example.i
make
php -d extension_dir=. runme.php4

View file

@ -1,20 +1,12 @@
/* File : example.i */
%module example
%{
extern void add(int *, int *, int *);
extern void sub(int *, int *, int *);
extern int divide(int, int, int *);
%}
/* This example illustrates a couple of different techniques
for manipulating C pointers */
%include phppointers.i
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
%include cpointer.i
%pointer_functions(int, intp);
extern void add(double *x, double *y, double *result);
/* Next we'll use some typemaps */

View file

@ -6,28 +6,18 @@
print "Testing the pointer library\n";
$a = new_intp();
$b = new_intp();
$c = new_intp();
intp_assign($a,37);
intp_assign($b,42);
$a = 37.145;
$b = 42.555;
$c = ""; // $c must be defined and not null.
print " a = $a\n";
print " b = $b\n";
print " c = $c\n";
# Call the add() function wuth some pointers
add($a,$b,$c);
add(&$a,&$b,&$c);
# Now get the result
$r = intp_value($c);
print " 37 + 42 = $r\n";
# Clean up the pointers
delete_intp($a);
delete_intp($b);
delete_intp($c);
print " $a + $b = $c\n";
# Now try the typemap library
# This should be much easier. Now how it is no longer