Merged with recent changes from trunk.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@11187 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
da5ade3143
commit
8c74fa0f46
703 changed files with 21126 additions and 9266 deletions
24
Examples/php/simple/Makefile
Normal file
24
Examples/php/simple/Makefile
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
SRCS = example.c
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS =
|
||||
SWIGOPT =
|
||||
|
||||
all::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
php
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
|
||||
php_static
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile php_clean
|
||||
rm -f $(TARGET).php
|
||||
|
||||
check: all
|
||||
$(MAKE) -f $(TOP)/Makefile php_run
|
||||
23
Examples/php/simple/example.c
Normal file
23
Examples/php/simple/example.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* File : example.c */
|
||||
#include <stdio.h>
|
||||
|
||||
/* A global variable */
|
||||
double Foo = 3.0;
|
||||
|
||||
void print_Foo() {
|
||||
printf("In C, Foo = %f\n",Foo);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
10
Examples/php/simple/example.i
Normal file
10
Examples/php/simple/example.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%{
|
||||
extern double Foo;
|
||||
%}
|
||||
|
||||
extern double Foo;
|
||||
void print_Foo();
|
||||
int gcd(int x, int y);
|
||||
25
Examples/php/simple/runme.php
Executable file
25
Examples/php/simple/runme.php
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# Call our gcd() function
|
||||
|
||||
$x = "42 aaa";
|
||||
$y = 105;
|
||||
$g = gcd($x,$y);
|
||||
print "The gcd of $x and $y is $g\n";
|
||||
|
||||
# Manipulate the Foo global variable
|
||||
|
||||
# Output its current value
|
||||
print "Foo = " . Foo_get() . "\n";
|
||||
|
||||
# Change its value
|
||||
Foo_set(3.1415926);
|
||||
|
||||
# See if the change took effect ( this isn't a good example for php, see
|
||||
# manual for why. )
|
||||
print "Foo = " . Foo_get() . "\n";
|
||||
print_Foo();
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue