Merge branch 'gsoc2017-php7-classes-via-c-api'

This commit is contained in:
Olly Betts 2021-05-04 17:47:48 +12:00
commit 502e7185ce
128 changed files with 1571 additions and 2541 deletions

5
.gitignore vendored
View file

@ -184,11 +184,8 @@ Examples/perl5/*/*.pm
# PHP # PHP
Examples/test-suite/php/php_*.h Examples/test-suite/php/php_*.h
Examples/test-suite/php/*.php
!Examples/test-suite/php/*runme.php
!Examples/test-suite/php/skel.php
Examples/php/*/php_*.h Examples/php/*/php_*.h
Examples/php/*/example.php Examples/php/pragmas/example.php
# Python # Python
# Based on https://github.com/github/gitignore/blob/master/Python.gitignore # Based on https://github.com/github/gitignore/blob/master/Python.gitignore

View file

@ -139,22 +139,6 @@ matrix:
os: linux os: linux
env: SWIGLANG=perl5 env: SWIGLANG=perl5
dist: xenial dist: xenial
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.0
dist: xenial
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.1
dist: xenial
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.2
dist: xenial
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.3
dist: xenial
- compiler: gcc - compiler: gcc
os: linux os: linux
env: SWIGLANG=php VER=7.4 env: SWIGLANG=php VER=7.4
@ -163,6 +147,30 @@ matrix:
os: linux os: linux
env: SWIGLANG=php VER=8.0 env: SWIGLANG=php VER=8.0
dist: xenial dist: xenial
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.0 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11
dist: bionic
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.1 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11
dist: bionic
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.2 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11
dist: bionic
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.3 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11
dist: bionic
- compiler: gcc
os: linux
env: SWIGLANG=php VER=7.4 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11
dist: bionic
- compiler: gcc
os: linux
env: SWIGLANG=php VER=8.0 CONFIGOPTS=--enable-cpp11-testing CPPSTD=c++11
dist: bionic
- compiler: gcc - compiler: gcc
os: linux os: linux
env: SWIGLANG=python # 2.7 env: SWIGLANG=python # 2.7

View file

@ -7,6 +7,23 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress) Version 4.1.0 (in progress)
=========================== ===========================
2021-05-04: olly
[PHP] #1982 #1457 https://sourceforge.net/p/swig/bugs/1339/
SWIG now only use PHP's C API to implement its wrappers, and no
longer generates PHP code to define classes. The wrappers should
be almost entirely compatible with those generated before, but
faster and without some previously hard-to-fix bugs.
The main notable difference is SWIG no longer generates a .php
wrapper at all by default (only if %pragma(php) code=... or
%pragma(php) include=... are specified in the interface file).
This also means you need to load the module via extension=...
in php.ini, rather than letting the dl() in the generated
.php wrapper load it (but dl() has only worked for command-line
PHP for some years now).
*** POTENTIAL INCOMPATIBILITY ***
2021-04-30: olly 2021-04-30: olly
#1984 Remove support for $source and $target. #1984 Remove support for $source and $target.
These were officially deprecated in 2001, and attempts to use them have These were officially deprecated in 2001, and attempts to use them have

View file

@ -84,16 +84,21 @@ swig -php7 example.i
</pre></div> </pre></div>
<p> <p>
This will produce 3 files example_wrap.c, php_example.h and This will produce 2 files: example_wrap.c and php_example.h.
example.php. The first file, <tt>example_wrap.c</tt> contains all of The first file, <tt>example_wrap.c</tt> contains all of
the C code needed to build a PHP extension. The second file, the C code needed to build a PHP extension. The second file,
<tt>php_example.h</tt> contains the header information needed if <tt>php_example.h</tt> contains the header information needed if
you wish to statically link the extension into the php interpreter. you wish to statically link the extension into the php interpreter.
The third file, </p>
<tt>example.php</tt> can be included by PHP scripts. It attempts to
dynamically load the extension and contains extra php code specified <p>
in the interface file. If wrapping C++ code with PHP classes, it will If the interface file uses <tt>%pragma(php) include=</tt>... or
also contain PHP class wrappers. <tt>%pragma(php) code=</tt>... then SWIG will also generate a third file,
<tt>example.php</tt> to contain what these specify. In SWIG &lt; 4.1.0,
this third file was always generated as it defined the PHP classes, etc
(but this is now done via C code in <tt>example_wrap.c</tt>) and also
contained code to dynamically load the extension (but this used the
PHP <tt>dl()</tt> function, which isn't recommended nowadays).
</p> </p>
<p> <p>
@ -139,22 +144,30 @@ least work for Linux though):
<p> <p>
To test the extension from a PHP script, you first need to tell PHP to To test the extension from a PHP script, you first need to tell PHP to
load it. To do this, add a line like this to the <tt>[PHP]</tt> section of load it. Assuming you're using PHP 7.2 or higher, the recommended (and
<tt>php.ini</tt>: simplest!) way to do this is to copy it to PHP's default extension directory
and add a line like this to the <tt>[PHP]</tt> section of <tt>php.ini</tt>:
</p> </p>
<div class="code"><pre> <div class="code"><pre>
extension=/path/to/modulename.so extension=modulename
</pre></div> </pre></div>
<p> <p>
If the module is in PHP's default extension directory, you can omit the path. PHP &lt; 7.2 doesn't support loading by just the module name, so you need
to specify the filename of the module to be specified, which varies
between platforms. And for any PHP version, if the module is not in PHP's
default extension directory, you also need to specify the path, for example:
</p> </p>
<div class="code"><pre>
extension=/path/to/modulename.so
</pre></div>
<p> <p>
For some SAPIs (for example, the CLI SAPI) you can instead use the If you're using the PHP CLI SAPI it's possible (but not recommended) to use the
<a href="https://www.php.net/manual/en/function.dl.php">dl() function</a> to load <a href="https://www.php.net/manual/en/function.dl.php">dl() function</a> to
an extension at run time, by adding a line like this to the start of each load an extension at run time, by adding a line like this to the start of each
PHP script which uses your extension: PHP script which uses your extension:
</p> </p>
@ -163,23 +176,11 @@ PHP script which uses your extension:
</pre></div> </pre></div>
<p> <p>
But note that <tt>dl()</tt> isn't supported when running PHP through a But to do this portably you need to take into account that pathnames and the
webserver - you'll need to use <tt>extension</tt> in <tt>php.ini</tt> as filename extension vary by platform, and for security reasons PHP no longer
described above. supports <tt>dl()</tt> when running PHP through a webserver. Overall it's
</p> better to instead use <tt>extension</tt> in <tt>php.ini</tt> as described
above.
<p>
The PHP module which SWIG generates will also attempt to do the <tt>dl()</tt>
call for you if the extension isn't already loaded:
</p>
<div class="code"><pre>
include("example.php");
</pre></div>
<p>
This PHP module also defines the PHP classes for the wrapped API, so you'll
almost certainly want to include it anyway.
</p> </p>
<H2><a name="Php_nn2">32.2 Basic PHP interface</a></H2> <H2><a name="Php_nn2">32.2 Basic PHP interface</a></H2>
@ -219,24 +220,19 @@ you can access the constants in your PHP script like this,
</p> </p>
<div class="code"><pre> <div class="code"><pre>
include("example.php");
echo "PI = " . PI . "\n"; echo "PI = " . PI . "\n";
echo "E = " . E . "\n"; echo "E = " . E . "\n";
</pre> </pre>
</div> </div>
<p> <p>
There's one peculiarity of how constants work in PHP which it is useful There's one peculiarity of how constants work in PHP prior to PHP 8
to note (this is not specific to SWIG though) - if you try to use an undeclared which it is useful to note (this is not specific to SWIG though) - if you try
constant, PHP will emit a warning (or a notice in PHP 7.1 and earlier) and then to use an undeclared constant, PHP will emit a warning (or a notice in PHP 7.1
expand the constant to a string version of the constant's name. Unfortunately and earlier) and then expand the constant to a string version of the constant's
it is easy to miss the warning message if you're using PHP in a webserver as name. Unfortunately it is easy to miss the warning message if you're using PHP
it will probably end up in error.log or similar. Apparently this will throw in a webserver as it will probably end up in error.log or similar. PHP 8.0
an Error in a future version of PHP, but until then it's something to be made this an error.
aware of.
</p> </p>
<p> <p>
@ -256,8 +252,6 @@ accessed incorrectly in PHP,
<div class="code"> <div class="code">
<pre> <pre>
include("example.php");
if(EASY_TO_MISPEL) { if(EASY_TO_MISPEL) {
... ...
} else { } else {
@ -298,7 +292,6 @@ is accessed as follows:
</p> </p>
<div class="code"><pre> <div class="code"><pre>
include("example.php");
print seki_get(); print seki_get();
seki_set( seki_get() * 2); # The C variable is now 4. seki_set( seki_get() * 2); # The C variable is now 4.
print seki_get(); print seki_get();
@ -306,8 +299,10 @@ print seki_get();
<p> <p>
SWIG supports global variables of all C datatypes including pointers SWIG supports global variables of all C datatypes including pointers
and complex objects. Additional types can be supported by using the and complex objects. To support additional types, you just need to
<tt>varinit</tt> typemap. supply the standard <tt>in</tt> and <tt>out</tt> typemaps, which get
used because of the wrapping as <tt>_get()</tt> and <tt>_set()</tt>
functions.
</p> </p>
<p> <p>
@ -342,7 +337,6 @@ Will be accessed in PHP like this :
</p> </p>
<div class="code"><pre> <div class="code"><pre>
include("example.php");
$a = foo(2); $a = foo(2);
$b = bar(3.5, -1.5); $b = bar(3.5, -1.5);
$c = bar(3.5); # Use default argument for 2nd parameter $c = bar(3.5); # Use default argument for 2nd parameter
@ -467,8 +461,6 @@ This will result in the following usage in PHP:
<div class="code"><pre> <div class="code"><pre>
&lt;?php &lt;?php
include("example.php");
$in1=copy_intp(3); $in1=copy_intp(3);
$in2=copy_intp(5); $in2=copy_intp(5);
$result=new_intp(); $result=new_intp();
@ -500,8 +492,6 @@ This will result in the following usage in PHP:
<div class="code"><pre> <div class="code"><pre>
&lt;?php &lt;?php
include("example.php");
$in1 = 3; $in1 = 3;
$in2 = 5; $in2 = 5;
$result= add($in1, $in2); # Note using variables for the input is unnecessary. $result= add($in1, $in2); # Note using variables for the input is unnecessary.
@ -537,8 +527,6 @@ This will result in the following usage in PHP:
<div class="code"><pre> <div class="code"><pre>
&lt;?php &lt;?php
include("example.php");
$in1 = 3; $in1 = 3;
$in2 = 5; $in2 = 5;
$result = 0; $result = 0;
@ -602,7 +590,6 @@ Would be used in the following way from PHP:
<div class="code"><pre> <div class="code"><pre>
&lt;?php &lt;?php
require "vector.php";
$v = new Vector(); $v = new Vector();
$v-&gt;x = 3; $v-&gt;x = 3;
@ -717,8 +704,6 @@ would be accessed in PHP as,
</p> </p>
<div class="code"><pre> <div class="code"><pre>
include("example.php");
echo "There have now been " . Ko::threats() . " threats\n"; echo "There have now been " . Ko::threats() . " threats\n";
</pre></div> </pre></div>
@ -752,7 +737,6 @@ class Ko {
would be executed in PHP as, would be executed in PHP as,
<div class="code"><pre> <div class="code"><pre>
include("example.php");
Ko::threats(); Ko::threats();
</pre></div> </pre></div>
@ -779,9 +763,8 @@ If there are multiple interfaces, just list them separated by commas.
<p> <p>
To place PHP code in the generated "example.php" file one can use the You can get SWIG to generate an "example.php" file by specifying
<b>code</b> pragma. The code is inserted after loading the shared the code to put in it using the <b>code</b> pragma.
object.
</p> </p>
<div class="code"><pre> <div class="code"><pre>
@ -985,8 +968,6 @@ then at the PHP side you can define
<div class="targetlang"> <div class="targetlang">
<pre> <pre>
require("mymodule.php");
class MyFoo extends Foo { class MyFoo extends Foo {
function one() { function one() {
print "one from php\n"; print "one from php\n";
@ -1008,8 +989,8 @@ that derives from both the class in question and a special
<tt>Swig::Director</tt> class. These new classes, referred to as director <tt>Swig::Director</tt> class. These new classes, referred to as director
classes, can be loosely thought of as the C++ equivalent of the PHP classes, can be loosely thought of as the C++ equivalent of the PHP
proxy classes. The director classes store a pointer to their underlying proxy classes. The director classes store a pointer to their underlying
PHP object. Indeed, this is quite similar to the "_cPtr" and "thisown" PHP object. Indeed, this is quite similar to <tt>struct swig_object_wrapper</tt>
members of the PHP proxy classes. which is used to implement the PHP proxy classes.
</p> </p>
<p> <p>
@ -1064,12 +1045,12 @@ infinite loop.
<p> <p>
One more point needs to be made about the relationship between director One more point needs to be made about the relationship between director
classes and proxy classes. When a proxy class instance is created in classes and proxy classes. When a proxy class instance is created in
PHP, SWIG creates an instance of the original C++ class and assigns it PHP, SWIG creates an instance of the original C++ class and stores it
to <tt>-&gt;_cPtr</tt>. This is exactly what happens without directors in the <tt>struct swig_object_wrapper</tt>. This is true whether or not
and is true even if directors are enabled for the particular class in directors are enabled for the particular class in question. However
question. When a class <i>derived</i> from a proxy class is created, when a class <i>derived</i> from a proxy class is created, SWIG instead
however, SWIG then creates an instance of the corresponding C++ director creates an instance of the corresponding C++ director class.
class. The reason for this difference is that user-defined subclasses The reason for this difference is that user-defined subclasses
may override or extend methods of the original class, so the director may override or extend methods of the original class, so the director
class is needed to route calls to these methods correctly. For class is needed to route calls to these methods correctly. For
unmodified proxy classes, all methods are ultimately implemented in C++ unmodified proxy classes, all methods are ultimately implemented in C++
@ -1157,13 +1138,32 @@ should suffice in most cases:
<div class="code"> <div class="code">
<pre> <pre>
%feature("director:except") { %feature("director:except") {
if ($error == FAILURE) { #if SWIG_VERSION &gt;= 0x040100
if ($error != NULL)
#else
if ($error == FAILURE)
#endif
{
throw Swig::DirectorMethodException(); throw Swig::DirectorMethodException();
} }
} }
</pre> </pre>
</div> </div>
<p>
If you only need to support SWIG >= 4.1.0, you can just use the
<tt>($error != NULL)</tt> condition.
</p>
<p>
In SWIG 4.1.0, <tt>$error</tt> was changed in the SWIG/PHP director
implementation to make it work more like how it does for other languages.
Previously, <tt>$error</tt> didn't actually indicate an exception, but instead
was only set to <tt>FAILURE</tt> if there was a problem calling the PHP method.
Now <tt>$error</tt> indicates if the PHP method threw a PHP exception, and
directorout typemaps for PHP no longer need to be gated by <tt>if (EG(exception))</tt>.
</p>
<p> <p>
This code will check the PHP error state after each method call from a This code will check the PHP error state after each method call from a
director into PHP, and throw a C++ exception if an error occurred. This director into PHP, and throw a C++ exception if an error occurred. This

View file

@ -1053,6 +1053,7 @@ PHP = @PHP@
PHP_INCLUDE = @PHPINC@ PHP_INCLUDE = @PHPINC@
PHP_SO = @PHP_SO@ PHP_SO = @PHP_SO@
PHP_SCRIPT = $(SRCDIR)$(RUNME).php PHP_SCRIPT = $(SRCDIR)$(RUNME).php
PHP_EXTENSION = example$(PHP_SO)
# ------------------------------------------------------------------- # -------------------------------------------------------------------
# Build a PHP dynamically loadable module (C) # Build a PHP dynamically loadable module (C)
@ -1077,7 +1078,7 @@ php_cpp: $(SRCDIR_SRCS)
# ----------------------------------------------------------------- # -----------------------------------------------------------------
php_run: php_run:
$(RUNTOOL) $(PHP) -n -d extension_dir=. -d display_errors=stderr $(PHP_SCRIPT) $(RUNPIPE) $(RUNTOOL) $(PHP) -n -d extension_dir=. -d extension=$(PHP_EXTENSION) -d display_errors=stderr -r 'set_error_handler(function($$n,$$s,$$f,$$l){if($$f!==Null){print$$f;if($$l!==Null)print":$$l";print": ";}print"$$s\n";exit(1);});include($$argv[1]);' $(PHP_SCRIPT) $(RUNPIPE)
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# Version display # Version display

View file

@ -2,8 +2,6 @@
# This file illustrates the cross language polymorphism using directors. # This file illustrates the cross language polymorphism using directors.
require("example.php");
# Class, which overwrites Callback::run(). # Class, which overwrites Callback::run().
class PhpCallback extends Callback { class PhpCallback extends Callback {

View file

@ -2,8 +2,6 @@
# This example illustrates how member variables are wrapped. # This example illustrates how member variables are wrapped.
require("example.php");
# ----- Object creation ----- # ----- Object creation -----
print "Creating some objects:\n"; print "Creating some objects:\n";

View file

@ -1,7 +1,5 @@
<?php <?php
require "example.php";
print "ICONST = " . ICONST . " (should be 42)\n"; print "ICONST = " . ICONST . " (should be 42)\n";
print "FCONST = " . FCONST . " (should be 2.1828)\n"; print "FCONST = " . FCONST . " (should be 2.1828)\n";
print "CCONST = " . CCONST . " (should be 'x')\n"; print "CCONST = " . CCONST . " (should be 'x')\n";

View file

@ -1,7 +1,5 @@
<?php <?php
require "example.php";
# First create some objects using the pointer library. # First create some objects using the pointer library.
print "Testing the pointer library\n"; print "Testing the pointer library\n";

View file

@ -4,8 +4,6 @@
# created by SWIG. In this case, all of our C++ classes # created by SWIG. In this case, all of our C++ classes
# get converted into function calls. # get converted into function calls.
require("example.php");
# ----- Object creation ----- # ----- Object creation -----
print "Creating some objects:\n"; print "Creating some objects:\n";

View file

@ -1,7 +1,5 @@
<?php <?php
require "example.php";
# ----- Object creation ----- # ----- Object creation -----
# Print out the value of some enums # Print out the value of some enums

View file

@ -2,8 +2,6 @@
# This file illustrates the cross language polymorphism using directors. # This file illustrates the cross language polymorphism using directors.
require("example.php");
# CEO class, which overrides Employee::getPosition(). # CEO class, which overrides Employee::getPosition().
class CEO extends Manager { class CEO extends Manager {

View file

@ -1,7 +1,5 @@
<?php <?php
require "example.php";
$a = 37; $a = 37;
$b = 42; $b = 42;

View file

@ -4,8 +4,6 @@
# created by SWIG. In this case, all of our C++ classes # created by SWIG. In this case, all of our C++ classes
# get converted into function calls. # get converted into function calls.
include("example.php");
# ----- Object creation ----- # ----- Object creation -----
print "Creating some objects:\n"; print "Creating some objects:\n";

View file

@ -1,7 +1,5 @@
<?php <?php
require "example.php";
# First create some objects using the pointer library. # First create some objects using the pointer library.
print "Testing the pointer library\n"; print "Testing the pointer library\n";

View file

@ -4,8 +4,6 @@
# created by SWIG. In this case, all of our C++ classes # created by SWIG. In this case, all of our C++ classes
# get converted into function calls. # get converted into function calls.
include("example.php");
# ----- Object creation ----- # ----- Object creation -----
print "Creating some objects:\n"; print "Creating some objects:\n";

View file

@ -2,8 +2,6 @@
# This file illustrates the manipulation of C++ references in PHP. # This file illustrates the manipulation of C++ references in PHP.
require "example.php";
# ----- Object creation ----- # ----- Object creation -----
print "Creating some objects:\n"; print "Creating some objects:\n";

View file

@ -1,7 +1,5 @@
<?php <?php
require "example.php";
# Call our gcd() function # Call our gcd() function
$x = "42 aaa"; $x = "42 aaa";

View file

@ -1,13 +1,19 @@
#include "example.h" #include "example.h"
#include <stdio.h> #include <iostream>
int x = 42; int x = 42;
char *s = (char *)"Test"; std::string s = "Test";
void Sync::printer(void) { void Sync::printer() {
std::cout << "The value of global s is " << ::s << '\n';
printf("The value of global s is %s\n", s); std::cout << "The value of global x is " << ::x << '\n';
printf("The value of global x is %d\n", x); std::cout << "The value of class s is " << this->s << '\n';
printf("The value of class s is %s\n", s); std::cout << "The value of class x is " << this->x << '\n';
printf("The value of class x is %d\n", x); }
void Sync::all_change() {
::s = "global change";
++::x;
this->s = "local change";
++this->x;
} }

View file

@ -1,9 +1,14 @@
extern char *s; #include <string>
extern std::string s;
extern int x; extern int x;
class Sync { class Sync {
public: public:
int x; int x;
char *s; std::string s;
void printer(void); void printer();
void all_change();
Sync() : x(0) { }
}; };

View file

@ -1,5 +1,7 @@
%module example %module example
%include <std_string.i>
%{ %{
#include "example.h" #include "example.h"
%} %}

View file

@ -1,12 +1,29 @@
<? <?
// Load module and PHP classes. echo "PHP reading globals: string is '", s_get(), "' and value is ", x_get(), "\n";
include("example.php");
echo "Got new object\n"; $o = new Sync();
echo "Got string $s and value $x \n";
$s = new Sync();
echo "Got new object\n"; echo "Got new object\n";
$s->printer(); echo "PHP reading object: string is '", $o->s, "' and value is ", $o->x, "\n";
$o->printer();
example::s_set("global string");
example::x_set(42);
$o->s = "object string";
$o->x = 1234;
echo "PHP reading globals: string is '", example::s_get(), "' and int is ", example::x_get(), "\n";
echo "PHP reading object: string is '", $o->s, "' and int is ", $o->x, "\n";
$o->printer();
echo "Calling all_change() method\n";
$o->all_change();
echo "PHP reading globals: string is '", example::s_get(), "' and int is ", example::x_get(), "\n";
echo "PHP reading object: string is '", $o->s, "' and int is ", $o->x, "\n";
$o->printer();

View file

@ -1,8 +1,5 @@
<?php <?php
require "example.php";
$v = new Vector(); $v = new Vector();
$v->x = 1.0; $v->x = 1.0;
$v->y = 2.0; $v->y = 2.0;
@ -34,6 +31,6 @@
echo "\nNow I'm going to clean up the return result\n"; echo "\nNow I'm going to clean up the return result\n";
# free($r); unset($r);
echo "Good\n"; echo "Good\n";

View file

@ -1,6 +1,5 @@
<?php <?php
require "example.php";
echo "\nVariables (values printed from C)\n"; echo "\nVariables (values printed from C)\n";
print_vars(); print_vars();

View file

@ -26,17 +26,6 @@ UVW Bar::static_member_variable;
struct XYZ { struct XYZ {
}; };
// The operator& trick doesn't work for SWIG/PHP because the generated code
// takes the address of the variable in the code in the "vinit" section.
#ifdef SWIGPHP
%{
struct XYZ {
void foo() {}
private:
XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method
};
%}
#else
%{ %{
struct XYZ { struct XYZ {
void foo() {} void foo() {}
@ -45,7 +34,6 @@ private:
XYZ* operator&(); // prevent dereferencing used in normally generated get method XYZ* operator&(); // prevent dereferencing used in normally generated get method
}; };
%} %}
#endif
#if defined(SWIGUTL) #if defined(SWIGUTL)
%exception { %exception {
/* /*

View file

@ -18,22 +18,7 @@ namespace Swig {
%include "std_string.i" %include "std_string.i"
#ifdef SWIGPHP #if defined SWIGPHP || defined SWIGPYTHON
%feature("director:except") {
if ($error == FAILURE) {
Swig::DirectorMethodException::raise("$symname");
}
}
%exception {
try { $action }
catch (Swig::DirectorException &) { SWIG_fail; }
}
#endif
#ifdef SWIGPYTHON
%feature("director:except") { %feature("director:except") {
if ($error != NULL) { if ($error != NULL) {

View file

@ -11,13 +11,6 @@
%newobject *::create(); %newobject *::create();
#ifdef SWIGPHP
// TODO: Currently we do not track the dynamic type of returned objects
// in PHP, so we need the factory helper.
%include factory.i
%factory(Foo *Bar::create, Bar);
#endif
%rename(a) Bar::hello; %rename(a) Bar::hello;
%rename(s) Foo::p; %rename(s) Foo::p;
%rename(q) Foo::r; %rename(q) Foo::r;

View file

@ -17,11 +17,7 @@
%feature("director") Foo; %feature("director") Foo;
%feature("director:except") { %feature("director:except") {
#ifndef SWIGPHP
if ($error != NULL) { if ($error != NULL) {
#else
if ($error == FAILURE) {
#endif
throw Swig::DirectorMethodException(); throw Swig::DirectorMethodException();
} }
} }

View file

@ -33,4 +33,8 @@
b = "string b"; b = "string b";
x = 1234; x = 1234;
} }
int read_x() { return x; }
std::string read_b() { return b; }
%} %}

View file

@ -8,7 +8,7 @@
%import "import_nomodule.h" %import "import_nomodule.h"
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD) && !defined(SWIGPYTHON_BUILTIN) #if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD) && !defined(SWIGPYTHON_BUILTIN) && !defined(SWIGPHP)
/** /**
* The proxy class does not have Bar derived from Foo, yet an instance of Bar * The proxy class does not have Bar derived from Foo, yet an instance of Bar
@ -16,8 +16,8 @@
* language modules). * language modules).
* *
* This violation of the type system is not possible in Java, C# and D due to * This violation of the type system is not possible in Java, C# and D due to
* static type checking. It's also not (currently) possible in Ruby, but this may * static type checking. It's also not (currently) possible in PHP or Ruby, but
* be fixable (needs more investigation). * this may be fixable (needs more investigation).
*/ */
%newobject create_Foo; %newobject create_Foo;

View file

@ -71,9 +71,9 @@ missingtests: missingcpptests missingctests
# found, runs testcase.php, except for multicpptests. # found, runs testcase.php, except for multicpptests.
run_testcase = \ run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php_run; \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION=$(TARGETPREFIX)$*@PHP_SO@ PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php_run; \
elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL='$(RUNTOOL)' php_run; \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP_EXTENSION=$(TARGETPREFIX)$*@PHP_SO@ PHP_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL='$(RUNTOOL)' php_run; \
fi fi
# Clean: remove the generated .php file # Clean: remove the generated .php file

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "abstract_inherit_ok.php";
check::classes(array('Foo','Spam')); check::classes(array('Foo','Spam'));
$spam=new Spam(); $spam=new Spam();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "abstract_inherit.php";
check::classes(array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i')); check::classes(array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i'));
// This constructor attempt should fail as there isn't one // This constructor attempt should fail as there isn't one

View file

@ -1,10 +1,9 @@
<?php <?php
require "tests.php"; require "tests.php";
require "add_link.php";
// No new functions, except the flat functions // No new functions
check::functions(array('new_foo','foo_blah')); check::functions(array());
check::classes(array('Foo')); check::classes(array('Foo'));

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "argout.php";
check::functions(array('incp','incr','inctr','new_intp','copy_intp','delete_intp','intp_assign','intp_value','voidhandle','handle')); check::functions(array('incp','incr','inctr','new_intp','copy_intp','delete_intp','intp_assign','intp_value','voidhandle','handle'));
@ -22,16 +21,10 @@ check::equal(4,inctr($tr),"4==incr($tr)");
check::equal(5,intp_value($tr),"5==$tr"); check::equal(5,intp_value($tr),"5==$tr");
# Check the voidhandle call, first with null # Check the voidhandle call, first with null
unset($handle);
# FIXME: Call-time pass-by-reference has been deprecated for ages, and was
# removed in PHP 5.4. We need to rework
#voidhandle(&$handle);
#check::resource($handle,"_p_void",'$handle is not _p_void');
#$handledata=handle($handle);
#check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
$handle=NULL; $handle=NULL;
voidhandle($handle); voidhandle($handle);
check::isnull($handle,'$handle not null'); check::equal(get_class($handle),"SWIG\\_p_void",'$handle is not _p_void');
$handledata=handle($handle);
check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
check::done(); check::done();

View file

@ -1,13 +0,0 @@
<?php
require "tests.php";
require "arrayptr.php";
// No new functions
check::functions(array('foo'));
// No new classes
check::classes(array());
// now new vars
check::globals(array());
check::done();

View file

@ -1,11 +1,11 @@
<?php <?php
require "tests.php"; require "tests.php";
require "arrays_global.php";
check::functions(array('test_a','test_b','new_simplestruct','new_material')); check::functions(array('test_a','test_b'));
check::classes(array('arrays_global','SimpleStruct','Material')); check::classes(array('arrays_global','SimpleStruct','Material'));
check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','beginstring_fix44a','beginstring_fix44b','beginstring_fix44c','beginstring_fix44d','beginstring_fix44e','beginstring_fix44f','chitmat','hitmat_val','hitmat','simplestruct_double_field')); check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','BeginString_FIX44a','BeginString_FIX44b','BeginString_FIX44c','BeginString_FIX44d','BeginString_FIX44e','BeginString_FIX44f','chitMat','hitMat_val','hitMat'));
// The size of array_c is 2, but the last byte is \0, so we can only store a // The size of array_c is 2, but the last byte is \0, so we can only store a
// single byte string in it. // single byte string in it.
check::set("array_c","Z"); check::set("array_c","Z");

View file

@ -1,11 +1,11 @@
<?php <?php
require "tests.php"; require "tests.php";
require "arrays_global_twodim.php";
check::functions(array('fn_taking_arrays','get_2d_array','new_simplestruct','new_material')); check::functions(array('fn_taking_arrays','get_2d_array',));
check::classes(array('arrays_global_twodim','SimpleStruct','Material')); check::classes(array('arrays_global_twodim','SimpleStruct','Material'));
check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','chitmat','hitmat_val','hitmat','simplestruct_double_field')); check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','chitMat','hitMat_val','hitMat'));
$a1=array(10,11,12,13); $a1=array(10,11,12,13);
$a2=array(14,15,16,17); $a2=array(14,15,16,17);
$a=array($a1,$a2); $a=array($a1,$a2);

View file

@ -1,10 +1,10 @@
<?php <?php
require "tests.php"; require "tests.php";
require "arrays.php";
check::functions(array('fn_taking_arrays','newintpointer','setintfrompointer','getintfrompointer','array_pointer_func')); check::functions(array('fn_taking_arrays','newintpointer','setintfrompointer','getintfrompointer','array_pointer_func'));
check::classes(array('arrays','SimpleStruct','ArrayStruct','CartPoseData_t')); check::classes(array('arrays','SimpleStruct','ArrayStruct','CartPoseData_t'));
check::globals(array('simplestruct_double_field','arraystruct_array_c','arraystruct_array_sc','arraystruct_array_uc','arraystruct_array_s','arraystruct_array_us','arraystruct_array_i','arraystruct_array_ui','arraystruct_array_l','arraystruct_array_ul','arraystruct_array_ll','arraystruct_array_f','arraystruct_array_d','arraystruct_array_struct','arraystruct_array_structpointers','arraystruct_array_ipointers','arraystruct_array_enum','arraystruct_array_enumpointers','arraystruct_array_const_i','cartposedata_t_p')); check::globals(array());
$ss=new simplestruct(); $ss=new simplestruct();
check::classname('simplestruct',$ss); check::classname('simplestruct',$ss);

View file

@ -1,14 +1,13 @@
<?php <?php
require "tests.php"; require "tests.php";
require "arrays_scope.php";
// New functions // No new functions
check::functions(array('new_bar','bar_blah')); check::functions(array());
// New classes // New classes
check::classes(array('arrays_scope','Bar')); check::classes(array('arrays_scope','Bar'));
// New vars // No new globals
check::globals(array('bar_adata','bar_bdata','bar_cdata')); check::globals(array());
$bar=new bar(); $bar=new bar();

View file

@ -1,8 +1,10 @@
<?php <?php
require "tests.php"; require "tests.php";
require "callback.php";
// In 2.0.6 and earlier, the constant was misnamed. // In 2.0.6 and earlier, the constant was misnamed.
if (gettype(callback::FOO_I_Cb_Ptr) !== 'resource') die("callback::FOO_I_Cb_Ptr not a resource\n"); check::equal(gettype(callback::FOO_I_Cb_Ptr), 'object', "callback::FOO_I_Cb_Ptr not an object");
check::equal(get_class(callback::FOO_I_Cb_Ptr), 'SWIG\_p_f_int__int', "callback::FOO_I_Cb_Ptr not expected class");
check::done(); check::done();

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "casts.php";
// No new functions // No new functions
check::functions(array('new_a','a_hello','new_b')); check::functions(array());
// No new classes // New classes
check::classes(array('A','B')); check::classes(array('A','B'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
# Make sure $b inherits hello() from class A # Make sure $b inherits hello() from class A

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "char_strings.php";
$CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; $CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
$OTHERLAND_MSG_10 = "Little message from the safe world.10"; $OTHERLAND_MSG_10 = "Little message from the safe world.10";

View file

@ -1,9 +1,8 @@
<?php <?php
require "tests.php"; require "tests.php";
require "class_ignore.php";
check::functions(array('do_blah','new_bar','bar_blah','new_boo','boo_away','new_far','new_hoo')); check::functions(array('do_blah'));
check::classes(array('class_ignore','Bar','Boo','Far','Hoo')); check::classes(array('class_ignore','Bar','Boo','Far','Hoo'));
// No new vars // No new vars
check::globals(array()); check::globals(array());

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "conversion_namespace.php";
check::classes(array("Foo","Bar")); check::classes(array("Foo","Bar"));
$bar=new Bar; $bar=new Bar;

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "conversion_ns_template.php";
check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi")); check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi"));
// this is too hard, I'm not sure what to test for, // this is too hard, I'm not sure what to test for,

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "conversion.php";
check::classes(array("Foo","Bar")); check::classes(array("Foo","Bar"));
$bar=new Bar; $bar=new Bar;

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "cpp11_strongly_typed_enumerations.php";
function enumCheck($actual, $expected) { function enumCheck($actual, $expected) {
check::equal($actual, $expected, "Enum value mismatch"); check::equal($actual, $expected, "Enum value mismatch");

View file

@ -1,14 +1,13 @@
<?php <?php
require "tests.php"; require "tests.php";
require "cpp_basic.php";
// New functions // New functions
check::functions(array('foo_func1','foo_func2','foo___str__','foosubsub___str__','bar_test','bar_testfoo','get_func1_ptr','get_func2_ptr','test_func_ptr','fl_window_show')); check::functions(array('get_func1_ptr','get_func2_ptr','test_func_ptr'));
// New classes // New classes
check::classes(array('cpp_basic','Foo','FooSub','FooSubSub','Bar','Fl_Window')); check::classes(array('cpp_basic','Foo','FooSub','FooSubSub','Bar','Fl_Window'));
// New vars // No new vars
check::globals(array('foo_num','foo_func_ptr','bar_fptr','bar_fref','bar_fval','bar_cint','bar_global_fptr','bar_global_fref','bar_global_fval')); check::globals(array());
$f = new Foo(3); $f = new Foo(3);
$f->func_ptr = get_func1_ptr(); $f->func_ptr = get_func1_ptr();
@ -16,4 +15,12 @@ check::equal(test_func_ptr($f, 7), 2*7*3, "get_func1_ptr() didn't work");
$f->func_ptr = get_func2_ptr(); $f->func_ptr = get_func2_ptr();
check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work"); check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work");
// Test that custom properties work - standard PHP objects support them,
// so PHP developers will expect them to work for SWIG-wrapped objects too.
check::equal($f->custom_prop, NULL, "Test unset custom property");
$f->custom_prop = "test";
check::equal($f->custom_prop, "test", "Test custom property setting");
$f->custom_prop = 42;
check::equal($f->custom_prop, 42, "Test custom property setting");
check::done(); check::done();

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "cpp_static.php";
// New functions // New functions
check::functions(array('staticfunctiontest_static_func','staticfunctiontest_static_func_2','staticfunctiontest_static_func_3','is_python_builtin','staticmembertest_grab_int','staticbase_grab_statty_base','staticderived_grab_statty_derived')); check::functions(array('is_python_builtin'));
// New classes // New classes
check::classes(array('StaticMemberTest','StaticFunctionTest','cpp_static','StaticBase','StaticDerived')); check::classes(array('StaticMemberTest','StaticFunctionTest','cpp_static','StaticBase','StaticDerived'));
// New vars // No new vars
check::globals(array('staticmembertest_static_int','staticbase_statty','staticderived_statty')); check::globals(array());
check::done(); check::done();

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_abstract.php";
// No new functions // New functions
check::functions(array('foo_ping','foo_pong','example0_getxsize','example0_color','example0_get_color','example1_getxsize','example1_color','example1_get_color','example2_getxsize','example2_color','example2_get_color','example4_getxsize','example4_color','example4_get_color','example3_i_color','example3_i_get_color','g','a_f')); check::functions(array('g'));
// No new classes // New classes
check::classes(array('director_abstract','Foo','Example0','Example1','Example2','Example4','Example3_i','A')); check::classes(array('director_abstract','Foo','Example0','Example1','Example2','Example4','Example3_i','A'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class MyFoo extends Foo { class MyFoo extends Foo {

View file

@ -1,11 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_basic.php";
check::functions(array('foo_ping','foo_pong','foo_get_self','a_f','a_rg','a1_ff','myclass_method','myclass_vmethod','myclass_pmethod','myclass_cmethod','myclass_get_self','myclass_call_pmethod','myclasst_i_method','myclass_nonvirtual','myclass_nonoverride','myclass_call_nonvirtual','myclass_call_nonoverride','myclass_connect','constptrclass_getconstptr')); // No new functions
check::functions(array());
check::classes(array('Foo','A','A1','Bar','MyClass','MyClassT_i','ConstPtrClass')); check::classes(array('Foo','A','A1','Bar','MyClass','MyClassT_i','ConstPtrClass'));
check::globals(array('bar_x')); // No new vars
check::globals(array());
class PhpFoo extends Foo { class PhpFoo extends Foo {
function ping() { function ping() {

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_classic.php";
// No new functions // No new functions
check::functions(array('being_id','person_id','child_id','grandchild_id','caller_delcallback','caller_setcallback','caller_resetcallback','caller_call','caller_baseclass')); check::functions(array());
// No new classes // New classes
check::classes(array('Being','Person','Child','GrandChild','OrphanPerson','OrphanChild','Caller')); check::classes(array('Being','Person','Child','GrandChild','OrphanPerson','OrphanChild','Caller'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class TargetLangPerson extends Person { class TargetLangPerson extends Person {
@ -81,11 +80,7 @@ function mycheck($person, $expected) {
$ret = $baseclass->id(); $ret = $baseclass->id();
if ($debug) if ($debug)
print $ret . "\n"; print $ret . "\n";
# TODO: Currently we do not track the dynamic type of returned check::equal($ret, $expected, "#3 failed");
# objects, so in case it's possible that the dynamic type is not equal
# to the static type, we skip this check.
if (get_parent_class($person) === false)
check::equal($ret, $expected, "#3 failed");
$caller->resetCallback(); $caller->resetCallback();
if ($debug) if ($debug)

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_default.php";
// No new functions // No new functions
check::functions(array('foo_msg','foo_getmsg','bar_msg','bar_getmsg','defaultsbase_defaultargs','defaultsderived_defaultargs')); check::functions(array());
// No new classes // New classes
check::classes(array('Foo','Bar','DefaultsBase','DefaultsDerived')); check::classes(array('Foo','Bar','DefaultsBase','DefaultsDerived'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
$f = new Foo(); $f = new Foo();

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_detect.php";
// No new functions // No new functions
check::functions(array('foo_cloner','foo_get_value','foo_get_class','foo_just_do_it','bar_baseclass','bar_cloner','bar_get_value','bar_get_class','bar_just_do_it')); check::functions(array());
// No new classes // New classes
check::classes(array('A','Foo','Bar')); check::classes(array('A','Foo','Bar'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class MyBar extends Bar { class MyBar extends Bar {

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_enum.php";
// No new functions // No new functions
check::functions(array('foo_say_hello','foo_say_hi','foo_say_bye','foo_say_hi_ref','foo_ping','foo_ping_ref','foo_ping_member_enum','a_f','a2_f')); check::functions(array());
// No new classes // New classes
check::classes(array('director_enum','Foo','A','B','A2','B2')); check::classes(array('director_enum','Foo','A','B','A2','B2'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class MyFoo extends Foo { class MyFoo extends Foo {

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_exception.php";
// No new functions // New functions
check::functions(array('foo_ping','foo_pong','launder','bar_ping','bar_pong','returnalltypes_return_int','returnalltypes_return_double','returnalltypes_return_const_char_star','returnalltypes_return_std_string','returnalltypes_return_bar','returnalltypes_call_int','returnalltypes_call_double','returnalltypes_call_const_char_star','returnalltypes_call_std_string','returnalltypes_call_bar','is_python_builtin')); check::functions(array('launder','is_python_builtin'));
// No new classes // New classes
check::classes(array('director_exception','Foo','Exception1','Exception2','Base','Bar','ReturnAllTypes')); check::classes(array('director_exception','Foo','Exception1','Exception2','Base','Bar','ReturnAllTypes'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class MyException extends Exception { class MyException extends Exception {
@ -38,9 +37,7 @@ class MyFoo3 extends Foo {
# MyFoo.pong(). # MyFoo.pong().
$ok = 0; $ok = 0;
$a = new MyFoo(); $a = new MyFoo();
# TODO: Currently we do not track the dynamic type of returned $b = director_exception::launder($a);
# objects, so we skip the launder() call.
#$b = director_exception::launder($a);
$b = $a; $b = $a;
try { try {
$b->pong(); $b->pong();

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_extend.php";
// No new functions // No new functions
check::functions(array('spobject_getfoobar','spobject_dummy','spobject_exceptionmethod')); check::functions(array());
// No new classes // New classes
check::classes(array('SpObject')); check::classes(array('SpObject'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class MyObject extends SpObject{ class MyObject extends SpObject{

View file

@ -1,18 +1,22 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_finalizer.php";
// No new functions // New functions
check::functions(array('foo_orstatus','deletefoo','getstatus','launder','resetstatus')); check::functions(array('deleteFoo','getStatus','launder','resetStatus'));
// No new classes // New classes
check::classes(array('director_finalizer','Foo')); check::classes(array('director_finalizer','Foo'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class MyFoo extends Foo { class MyFoo extends Foo {
function __destruct() { function __destruct() {
$this->orStatus(2); # It's not safe to call methods on the C++ object from the PHP destructor
# if the object has been disowned, since the C++ object will already have
# been destroyed by the time the PHP destructor runs.
if ($this->thisown) {
$this->orStatus(2);
}
if (method_exists(get_parent_class(), "__destruct")) { if (method_exists(get_parent_class(), "__destruct")) {
parent::__destruct(); parent::__destruct();
} }
@ -41,19 +45,23 @@ resetStatus();
$a = new MyFoo(); $a = new MyFoo();
$a->thisown = 0; $a->thisown = 0;
check::equal(getStatus(), 0, "shadow release does not fire destructor of disowned object");
deleteFoo($a); deleteFoo($a);
unset($a); unset($a);
check::equal(getStatus(), 3, "getStatus() failed #4"); # getStatus() would ideally return 3 here.
check::equal(getStatus(), 1, "getStatus() failed #4");
resetStatus(); resetStatus();
$a = new MyFoo(); $a = new MyFoo();
$a->thisown = 0; $a->thisown = 0;
deleteFoo(launder($a)); $g = launder($a);
unset($a); unset($a);
deleteFoo($g);
check::equal(getStatus(), 3, "getStatus() failed #5"); # getStatus() would ideally return 3 here.
check::equal(getStatus(), 1, "getStatus() failed #5");
resetStatus(); resetStatus();

View file

@ -1,14 +1,13 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_frob.php";
// No new functions // No new functions
check::functions(array('alpha_abs_method','bravo_abs_method','charlie_abs_method','ops_opint','ops_opintstarstarconst','ops_opintamp','ops_opintstar','ops_opconstintintstar','prims_ull','prims_callull','corecallbacks_on3dengineredrawn','corecallbacks_on3dengineredrawn2')); check::functions(array());
// No new classes // New classes
check::classes(array('Alpha','Bravo','Charlie','Delta','Ops','Prims','corePoint3d','coreCallbacks_On3dEngineRedrawnData','coreCallbacksOn3dEngineRedrawnData','coreCallbacks')); check::classes(array('Alpha','Bravo','Charlie','Delta','Ops','Prims','corePoint3d','coreCallbacks_On3dEngineRedrawnData','coreCallbacksOn3dEngineRedrawnData','coreCallbacks'));
// now new vars // No new vars
check::globals(array('corecallbacks_on3dengineredrawndata__eye','corecallbacks_on3dengineredrawndata__at','corecallbackson3dengineredrawndata__eye','corecallbackson3dengineredrawndata__at')); check::globals(array());
$foo = new Bravo(); $foo = new Bravo();
$s = $foo->abs_method(); $s = $foo->abs_method();

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_nested.php";
// No new functions // No new functions
check::functions(array('foo_int_advance','foo_int_do_advance','bar_step','bar_do_advance','bar_do_step','foobar_int_get_value','foobar_int_get_name','foobar_int_name','foobar_int_get_self','foobar_int_do_advance','foobar_int_do_step')); check::functions(array());
// No new classes // New classes
check::classes(array('Foo_int','Bar','FooBar_int')); check::classes(array('Foo_int','Bar','FooBar_int'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class A extends FooBar_int { class A extends FooBar_int {
@ -60,10 +59,7 @@ class C extends FooBar_int {
} }
$cc = new C(); $cc = new C();
# TODO: Currently we do not track the dynamic type of returned $c = Foobar_int::get_self($cc);
# objects, so we skip the get_self() call.
#$c = Foobar_int::get_self($cc);
$c = $cc;
$c->advance(); $c->advance();
check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed"); check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed");

View file

@ -1,10 +1,8 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_overload.php";
check::functions(array('new_overloadedClass','new_overloadedPointers','new_overloadedGetSet','overloadedclass_method1','overloadedclass_method3','overloadedclass_method2','overloadedpointers_method','overloadedpointers_notover','overloadedgetset_rw'));
check::functions(array());
check::classes(array('OverloadedClass','OverloadedPointers','OverloadedGetSet')); check::classes(array('OverloadedClass','OverloadedPointers','OverloadedGetSet'));
check::globals(array()); check::globals(array());

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_pass_by_value.php";
$passByVal = null; $passByVal = null;

View file

@ -1,10 +1,9 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_profile.php";
// New functions // No new functions
check::functions(array('b_c_fn','b_vfi','b_fi','b_fj','b_fk','b_fl','b_get_self','b_vfs','b_fs')); check::functions(array());
// New classes // New classes
check::classes(array('A','B')); check::classes(array('A','B'));
// No new vars // No new vars

View file

@ -1,11 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_protected.php";
check::functions(array('foo_pong','foo_s','foo_q','foo_ping','foo_pang','foo_used','foo_cheer','bar_create','bar_callping','bar_callcheer','bar_cheer','bar_pong','bar_used','bar_ping','bar_pang','a_draw','b_draw')); // No new functions
check::functions(array());
check::classes(array('Foo','Bar','PrivateFoo','A','B','AA','BB')); check::classes(array('Foo','Bar','PrivateFoo','A','B','AA','BB'));
check::globals(array('bar_a')); // No new vars
check::globals(array());
class FooBar extends Bar { class FooBar extends Bar {
protected function ping() { protected function ping() {

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_stl.php";
// No new functions // No new functions
check::functions(array('foo_bar','foo_ping','foo_pong','foo_tping','foo_tpong','foo_pident','foo_vident','foo_vsecond','foo_tpident','foo_tvident','foo_tvsecond','foo_vidents','foo_tvidents')); check::functions(array());
// No new classes // New classes
check::classes(array('Foo')); check::classes(array('Foo'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
class MyFoo extends Foo { class MyFoo extends Foo {

View file

@ -1,14 +1,13 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_string.php";
// No new functions // No new functions
check::functions(array('a_get_first','a_call_get_first','a_string_length','a_process_text','a_call_process_func','stringvector_size','stringvector_is_empty','stringvector_clear','stringvector_push','stringvector_pop','stringvector_capacity','stringvector_reserve')); check::functions(array());
// No new classes // New classes
check::classes(array('A','StringVector')); check::classes(array('A','StringVector'));
// now new vars // No new vars
check::globals(array('a','a_call','a_m_strings','stringvector')); check::globals(array());
class B extends A { class B extends A {
function get_first() { function get_first() {

View file

@ -1,18 +1,17 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_thread.php";
# Fails in a ZTS-build of PHP5 - see: https://github.com/swig/swig/pull/155 # Fails in a ZTS-build of PHP5 - see: https://github.com/swig/swig/pull/155
# FIXME: Does this still fail in a threaded build of PHP7? # FIXME: Does this still fail in a threaded build of PHP7?
exit(0); exit(0);
// No new functions // New functions
check::functions(array('millisecondsleep','foo_stop','foo_run','foo_do_foo')); check::functions(array('millisecondsleep','foo_stop','foo_run','foo_do_foo'));
// No new classes // New classes
check::classes(array('director_thread','Foo')); check::classes(array('director_thread','Foo'));
// now new vars // No new vars
check::globals(array('foo_val')); check::globals(array());
class Derived extends Foo { class Derived extends Foo {
function do_foo() { function do_foo() {

View file

@ -1,14 +1,13 @@
<?php <?php
require "tests.php"; require "tests.php";
require "director_unroll.php";
// No new functions // No new functions
check::functions(array('foo_ping','foo_pong')); check::functions(array());
// No new classes // New classes
check::classes(array('Foo','Bar')); check::classes(array('Foo','Bar'));
// now new vars // No new vars
check::globals(array('bar')); check::globals(array());
class MyFoo extends Foo { class MyFoo extends Foo {
function ping() { function ping() {
@ -23,9 +22,7 @@ $b = new Bar();
$b->set($a); $b->set($a);
$c = $b->get(); $c = $b->get();
// FIXME: This doesn't work for checking that they wrap the same C++ object // FIXME: The python version checks that a.this == c.this, but we don't seem
// because the two objects have different PHP resources, and we can't easily // to have a way to check this with the PHP bindings we generate.
// look inside those resources to see which C++ objects they refer to.
//check::equal($a->_cPtr, $c->_cPtr, "_cPtr check failed");
check::done(); check::done();

View file

@ -1,14 +1,16 @@
<?php <?php
require "tests.php"; require "tests.php";
require "enum_scope_template.php";
check::functions(array("chops"));
check::classes(array("enum_scope_template", "TreeInt")); check::classes(array("enum_scope_template", "TreeInt"));
check::functions(array("chops","treeint_chops")); // No new vars
check::equal(0,TreeInt_Oak,"0==TreeInt_Oak"); check::globals(array());
check::equal(1,TreeInt_Fir,"1==TreeInt_Fir");
check::equal(2,TreeInt_Cedar,"2==TreeInt_Cedar"); check::equal(0,TreeInt::Oak,"0==TreeInt_Oak");
check::equal(TreeInt_Oak,chops(TreeInt_Oak),"TreeInt_Oak==chops(TreeInt_Oak)"); check::equal(1,TreeInt::Fir,"1==TreeInt_Fir");
check::equal(TreeInt_Fir,chops(TreeInt_Fir),"TreeInt_Fir==chops(TreeInt_Fir)"); check::equal(2,TreeInt::Cedar,"2==TreeInt_Cedar");
check::equal(TreeInt_Cedar,chops(TreeInt_Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)"); check::equal(TreeInt::Oak,chops(TreeInt::Oak),"TreeInt_Oak==chops(TreeInt_Oak)");
check::equal(TreeInt::Fir,chops(TreeInt::Fir),"TreeInt_Fir==chops(TreeInt_Fir)");
check::equal(TreeInt::Cedar,chops(TreeInt::Cedar),"TreeInt_Cedar==chops(TreeInt_Cedar)");
check::done(); check::done();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "evil_diamond_ns.php";
check::classes(array("evil_diamond_ns","foo","bar","baz","spam")); check::classes(array("evil_diamond_ns","foo","bar","baz","spam"));
check::functions("test"); check::functions("test");

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "evil_diamond_prop.php";
check::classes(array("evil_diamond_prop","foo","bar","baz","spam")); check::classes(array("evil_diamond_prop","foo","bar","baz","spam"));
check::functions("test"); check::functions("test");
@ -31,9 +30,7 @@ check::is_a($spam,"spam");
check::equal(1,$spam->_foo,"1==spam->_foo"); check::equal(1,$spam->_foo,"1==spam->_foo");
check::equal(2,$spam->_bar,"2==spam->_bar"); check::equal(2,$spam->_bar,"2==spam->_bar");
// multiple inheritance not supported in PHP // multiple inheritance not supported in PHP
set_error_handler(function () {return true;}, E_NOTICE|E_WARNING); // Don't complain that _baz is unknown.
check::equal(null,$spam->_baz,"null==spam->_baz"); check::equal(null,$spam->_baz,"null==spam->_baz");
restore_error_handler();
check::equal(4,$spam->_spam,"4==spam->_spam"); check::equal(4,$spam->_spam,"4==spam->_spam");
check::done(); check::done();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "evil_diamond.php";
check::classes(array("evil_diamond","foo","bar","baz","spam")); check::classes(array("evil_diamond","foo","bar","baz","spam"));
check::functions("test"); check::functions("test");

View file

@ -1,10 +1,9 @@
<? <?
require "tests.php"; require "tests.php";
require "exception_order.php";
check::functions(array('a_foo','a_bar','a_foobar','a_barfoo','is_python_builtin')); check::functions(array('is_python_builtin'));
check::classes(array('A','E1','E2','E3','exception_order','ET_i','ET_d')); check::classes(array('A','E1','E2','E3','exception_order','ET_i','ET_d'));
check::globals(array('efoovar','foovar','cfoovar','a_sfoovar','a_foovar','a_efoovar')); check::globals(array('efoovar','foovar','cfoovar'));
$a = new A(); $a = new A();
try { try {

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "extend_template_ns.php";
check::classes(array("extend_template_ns","Foo_One")); check::classes(array("extend_template_ns","Foo_One"));
$foo=new Foo_One(); $foo=new Foo_One();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "extend_template.php";
check::classes(array("Foo_0")); check::classes(array("Foo_0"));
$foo=new Foo_0(); $foo=new Foo_0();

View file

@ -0,0 +1,27 @@
<?php
require "tests.php";
check::functions(array('init','read_b','read_x'));
check::classes(array('A','global_vars'));
check::globals(array('b','a','ap','cap','ar','x','xp','c_member','vp','h','hp','hr'));
$an = new A();
check::classname('A', $an);
ap_set($an);
check::classname('A', ap_get());
check::equivalent(ap_get(), $an, "global var assignment");
x_set(17);
check::equal(x_get(), 17, "global var assignment");
check::equal(read_x(), 17, "PHP global var change visible in C++");
init();
check::equal(x_get(), 1234, "C++ global var change visible in PHP");
b_set('test');
check::equal(b_get(), 'test', "global var assignment");
check::equal(read_b(), 'test', "PHP global var change visible in C++");
init();
check::equal(b_get(), 'string b', "C++ global var change visible in PHP");
check::done();

View file

@ -1,11 +1,10 @@
<?php <?php
require "tests.php"; require "tests.php";
require "grouping.php";
check::functions(array("test1","test2","do_unary","negate")); check::functions(array("test1","test2","do_unary","negate"));
check::equal(5,test1(5),"5==test1(5)"); check::equal(5,test1(5),"5==test1(5)");
check::resource(test2(7),"_p_int","_p_int==test2(7)"); check::equal(get_class(test2(7)),"SWIG\\_p_int","test2(7) is _p_int");
check::globals(array('test3')); check::globals(array('test3'));
//check::equal(37,test3_get(),'37==test3_get()'); //check::equal(37,test3_get(),'37==test3_get()');

View file

@ -1,10 +1,9 @@
<?php <?php
require "tests.php"; require "tests.php";
require "ignore_parameter.php";
// New functions // New functions
check::functions(array('jaguar','lotus','tvr','ferrari','fiat','sportscars_daimler','sportscars_astonmartin','sportscars_bugatti','sportscars_lamborghini','sportscars_maseratti')); check::functions(array('jaguar','lotus','tvr','ferrari','fiat'));
// New classes // New classes
check::classes(array('ignore_parameter','SportsCars','MiniCooper','MorrisMinor','FordAnglia','AustinAllegro')); check::classes(array('ignore_parameter','SportsCars','MiniCooper','MorrisMinor','FordAnglia','AustinAllegro'));
// No new vars // No new vars

View file

@ -1,14 +1,16 @@
<?php <?php
require "tests.php";
require "import_nomodule.php";
// No new functions require "tests.php";
check::functions(array('create_foo','delete_foo','test1','is_python_builtin'));
// No new classes check::functions(array('is_python_builtin'));
check::classes(array('import_nomodule','Bar')); check::classes(array('import_nomodule'));
// now new vars // No new globals
check::globals(array()); check::globals(array());
// SWIGPHP doesn't currently support the "violation of the type system" which
// is tested by this testcase.
exit(0);
$f = import_nomodule::create_Foo(); $f = import_nomodule::create_Foo();
import_nomodule::test1($f,42); import_nomodule::test1($f,42);
import_nomodule::delete_Foo($f); import_nomodule::delete_Foo($f);

View file

@ -1,16 +1,16 @@
<?php <?php
require "tests.php"; require "tests.php";
require "li_carrays_cpp.php";
// Check functions. // Check functions.
check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','doublearray_getitem','doublearray_setitem','doublearray_cast','doublearray_frompointer','xyarray_getitem','xyarray_setitem','xyarray_cast','xyarray_frompointer','delete_abarray','abarray_getitem','abarray_setitem','shortarray_getitem','shortarray_setitem','shortarray_cast','shortarray_frompointer','sum_array')); check::functions(array('new_intArray','delete_intArray','intArray_getitem','intArray_setitem','new_ABArray','delete_ABArray','ABArray_getitem','ABArray_setitem','sum_array'));
// Check classes. // Check classes.
// NB An "li_carrays_cpp" class is created as a mock namespace. // NB An "li_carrays_cpp" class is created as a mock namespace.
check::classes(array('li_carrays_cpp','doubleArray','AB','XY','XYArray','shortArray')); check::classes(array('li_carrays_cpp','doubleArray','AB','XY','XYArray','shortArray'));
// Check global variables. // Check global variables.
check::globals(array('xy_x','xy_y','globalxyarray','ab_a','ab_b','globalabarray')); check::globals(array('globalXYArray','globalABArray'));
$d = new doubleArray(10); $d = new doubleArray(10);

View file

@ -1,16 +1,16 @@
<?php <?php
require "tests.php"; require "tests.php";
require "li_carrays.php";
// Check functions. // Check functions.
check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','doublearray_getitem','doublearray_setitem','doublearray_cast','doublearray_frompointer','xyarray_getitem','xyarray_setitem','xyarray_cast','xyarray_frompointer','delete_abarray','abarray_getitem','abarray_setitem','shortarray_getitem','shortarray_setitem','shortarray_cast','shortarray_frompointer','sum_array')); check::functions(array('new_intArray','delete_intArray','intArray_getitem','intArray_setitem','new_ABArray','delete_ABArray','ABArray_getitem','ABArray_setitem','sum_array'));
// Check classes. // Check classes.
// NB An "li_carrays" class is created as a mock namespace. // NB An "li_carrays" class is created as a mock namespace.
check::classes(array('li_carrays','doubleArray','AB','XY','XYArray','shortArray')); check::classes(array('li_carrays','doubleArray','AB','XY','XYArray','shortArray'));
// Check global variables. // Check global variables.
check::globals(array('xy_x','xy_y','globalxyarray','ab_a','ab_b','globalabarray')); check::globals(array('globalXYArray','globalABArray'));
$d = new doubleArray(10); $d = new doubleArray(10);

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "li_factory.php";
// No new functions // No new functions
check::functions(array('geometry_draw','geometry_create','geometry_clone_','point_draw','point_width','point_clone_','circle_draw','circle_radius','circle_clone_')); check::functions(array());
// No new classes // New classes
check::classes(array('Geometry','Point','Circle')); check::classes(array('Geometry','Point','Circle'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
$circle = Geometry::create(Geometry::CIRCLE); $circle = Geometry::create(Geometry::CIRCLE);

View file

@ -1,11 +1,34 @@
<?php <?php
require "tests.php"; require "tests.php";
require "li_std_string.php";
// Global variables # Checking expected use of %typemap(in) std::string {}
//$s="initial string"; li_std_string::test_value("Fee");
//check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
# Checking expected result of %typemap(out) std::string {}
check::equal(li_std_string::test_value("Fi"), "Fi", "Test 1");
# Checking expected use of %typemap(in) const std::string & {}
li_std_string::test_const_reference("Fo");
# Checking expected result of %typemap(out) const std::string& {}
check::equal(li_std_string::test_const_reference("Fum"), "Fum", "Test 3");
# Input and output typemaps for pointers and non-const references to
# std::string are *not* supported; the following tests confirm
# that none of these cases are slipping through.
$stringPtr = li_std_string::test_pointer_out();
li_std_string::test_pointer($stringPtr);
$stringPtr = li_std_string::test_const_pointer_out();
li_std_string::test_const_pointer($stringPtr);
$stringPtr = li_std_string::test_reference_out();
li_std_string::test_reference($stringPtr);
// Global variables // Global variables
$s = "initial string"; $s = "initial string";
@ -24,8 +47,7 @@ check::equal($myStructure->ConstMemberString, "const member string", "ConstMembe
check::equal(Structure::StaticMemberString2(), "static member string 2", "StaticMemberString2 test 1"); check::equal(Structure::StaticMemberString2(), "static member string 2", "StaticMemberString2 test 1");
Structure::StaticMemberString2($s); Structure::StaticMemberString2($s);
check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2"); check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2");
// below broken ? check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
// This used to give "Undefined variable: r" // This used to give "Undefined variable: r"
li_std_string::test_const_reference_returning_void("foo"); li_std_string::test_const_reference_returning_void("foo");

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "li_std_vector_member_var.php";
$t = new Test(); $t = new Test();

View file

@ -0,0 +1,59 @@
<?php
require "tests.php";
// Check functions.
check::functions(array('do_op','do_op_td','areapt','perimeterpt','perimeterpt_td','call1'));
// Check classes.
check::classes(array('member_pointer_const','Circle','Funktions','Shape','Square'));
// Check global variables.
check::globals(array('areavar','perimetervar','perimetervar_td'));
# Get the pointers
$area_pt = member_pointer_const::areapt();
$perim_pt = member_pointer_const::perimeterpt();
# Create some objects
$s = new Square(10);
# Do some calculations
check::equal(100.0, member_pointer_const::do_op($s, $area_pt), "Square area");
check::equal(40.0, member_pointer_const::do_op($s, $perim_pt), "Square perim");
$memberPtr = member_pointer_const::areavar_get();
$memberPtr = member_pointer_const::perimetervar_get();
# Try the variables
check::equal(100.0, member_pointer_const::do_op($s, member_pointer_const::areavar_get()), "Square area");
check::equal(40.0, member_pointer_const::do_op($s, member_pointer_const::perimetervar_get()), "Square perim");
# Modify one of the variables
member_pointer_const::areavar_set($perim_pt);
check::equal(40.0, member_pointer_const::do_op($s, member_pointer_const::areavar_get()), "Square perimeter");
# Try the constants
/*
$memberPtr = member_pointer_const::AREAPT;
$memberPtr = member_pointer_const::PERIMPT;
$memberPtr = member_pointer_const::NULLPT;
check::equal(100.0, member_pointer_const::do_op($s, member_pointer_const::AREAPT), "Square area");
check::equal(40.0, member_pointer_const::do_op($s, member_pointer_const::PERIMPT), "Square perim");
*/
# Typedefs
check::equal(40.0, member_pointer_const::do_op_td($s, $perim_pt), "Square perim");
/*
check::equal(3, member_pointer_const::call1(member_pointer_const::ADD_BY_VALUE, 1, 2), "Add by value");
check::equal(7, member_pointer_const::call2(member_pointer_const::ADD_BY_VALUE, 3, 4), "Add by pointer");
check::equal(11, member_pointer_const::call3(member_pointer_const::ADD_BY_VALUE, 5, 6), "Add by reference");
*/

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "multivalue.php";
// New functions // New functions
check::functions(array('divide_l','divide_v','divide_mv')); check::functions(array('divide_l','divide_v','divide_mv'));

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "newobject1.php";
// No new functions // No new functions
check::functions(array('foo_makefoo','foo_makemore','foo_foocount')); check::functions(array());
// No new classes // New classes
check::classes(array('Foo')); check::classes(array('Foo'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
$foo = Foo::makeFoo(); $foo = Foo::makeFoo();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "newobject3.php";
$factory = new factory(); $factory = new factory();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "overload_null.php";
$o = new Overload(); $o = new Overload();
$x = new X(); $x = new X();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "overload_polymorphic.php";
$t = new Derived(); $t = new Derived();

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "overload_rename.php";
// No new functions // No new functions
check::functions(array()); check::functions(array());
// No new classes // New classes
check::classes(array('Foo')); check::classes(array('Foo'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
$f = new Foo(1.0); $f = new Foo(1.0);

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "overload_return_type.php";
$b = new B; $b = new B;
check::equal($b->foo(1), 0, ""); check::equal($b->foo(1), 0, "");

View file

@ -1,9 +1,9 @@
<?php <?php
require "tests.php"; require "tests.php";
require "php_iterator.php";
check::functions(array('myiterator_rewind','myiterator_key','myiterator_current','myiterator_next','myiterator_valid')); // No new functions.
check::functions(array());
check::classes(array('MyIterator')); check::classes(array('MyIterator'));
// No new global variables. // No new global variables.
check::globals(array()); check::globals(array());

View file

@ -1,8 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "php_pragma.php";
check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)"); check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)");

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "pointer_reference.php";
$s = pointer_reference::get(); $s = pointer_reference::get();
check::equal($s->value, 10, "pointer_reference::get() failed"); check::equal($s->value, 10, "pointer_reference::get() failed");

View file

@ -1,13 +1,12 @@
<?php <?php
require "tests.php"; require "tests.php";
require "prefix.php";
// No new functions // No new functions
check::functions(array('foo_get_self')); check::functions(array());
// No new classes // New classes
check::classes(array('ProjectFoo')); check::classes(array('ProjectFoo'));
// now new vars // No new vars
check::globals(array()); check::globals(array());
$f = new ProjectFoo(); $f = new ProjectFoo();

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "preproc_constants_c.php";
// Same as preproc_constants.i testcase, but bool types are int instead // Same as preproc_constants.i testcase, but bool types are int instead
check::equal(gettype(preproc_constants_c::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type"); check::equal(gettype(preproc_constants_c::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type");

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "preproc_constants.php";
check::equal(gettype(preproc_constants::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type"); check::equal(gettype(preproc_constants::CONST_INT1), "integer", "preproc_constants.CONST_INT1 has unexpected type");
check::equal(gettype(preproc_constants::CONST_INT2), "integer", "preproc_constants.CONST_INT2 has unexpected type"); check::equal(gettype(preproc_constants::CONST_INT2), "integer", "preproc_constants.CONST_INT2 has unexpected type");

View file

@ -1,7 +1,6 @@
<?php <?php
require "tests.php"; require "tests.php";
require "primitive_ref.php";
# A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string. # A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
# The conversion to double can lose precision so this isn't an exact comparison. # The conversion to double can lose precision so this isn't an exact comparison.

Some files were not shown because too many files have changed in this diff Show more