Merge branch 'gsoc2017-php7-classes-via-c-api'
This commit is contained in:
commit
502e7185ce
128 changed files with 1571 additions and 2541 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -184,11 +184,8 @@ Examples/perl5/*/*.pm
|
|||
|
||||
# PHP
|
||||
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/*/example.php
|
||||
Examples/php/pragmas/example.php
|
||||
|
||||
# Python
|
||||
# Based on https://github.com/github/gitignore/blob/master/Python.gitignore
|
||||
|
|
|
|||
40
.travis.yml
40
.travis.yml
|
|
@ -139,22 +139,6 @@ matrix:
|
|||
os: linux
|
||||
env: SWIGLANG=perl5
|
||||
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
|
||||
os: linux
|
||||
env: SWIGLANG=php VER=7.4
|
||||
|
|
@ -163,6 +147,30 @@ matrix:
|
|||
os: linux
|
||||
env: SWIGLANG=php VER=8.0
|
||||
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
|
||||
os: linux
|
||||
env: SWIGLANG=python # 2.7
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
===========================
|
||||
|
||||
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
|
||||
#1984 Remove support for $source and $target.
|
||||
These were officially deprecated in 2001, and attempts to use them have
|
||||
|
|
|
|||
|
|
@ -84,16 +84,21 @@ swig -php7 example.i
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
This will produce 3 files example_wrap.c, php_example.h and
|
||||
example.php. The first file, <tt>example_wrap.c</tt> contains all of
|
||||
This will produce 2 files: example_wrap.c and php_example.h.
|
||||
The first file, <tt>example_wrap.c</tt> contains all of
|
||||
the C code needed to build a PHP extension. The second file,
|
||||
<tt>php_example.h</tt> contains the header information needed if
|
||||
you wish to statically link the extension into the php interpreter.
|
||||
The third file,
|
||||
<tt>example.php</tt> can be included by PHP scripts. It attempts to
|
||||
dynamically load the extension and contains extra php code specified
|
||||
in the interface file. If wrapping C++ code with PHP classes, it will
|
||||
also contain PHP class wrappers.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If the interface file uses <tt>%pragma(php) include=</tt>... or
|
||||
<tt>%pragma(php) code=</tt>... then SWIG will also generate a third file,
|
||||
<tt>example.php</tt> to contain what these specify. In SWIG < 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>
|
||||
|
|
@ -139,22 +144,30 @@ least work for Linux though):
|
|||
|
||||
<p>
|
||||
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
|
||||
<tt>php.ini</tt>:
|
||||
load it. Assuming you're using PHP 7.2 or higher, the recommended (and
|
||||
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>
|
||||
|
||||
<div class="code"><pre>
|
||||
extension=/path/to/modulename.so
|
||||
extension=modulename
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
If the module is in PHP's default extension directory, you can omit the path.
|
||||
PHP < 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>
|
||||
|
||||
<div class="code"><pre>
|
||||
extension=/path/to/modulename.so
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
For some SAPIs (for example, the CLI SAPI) you can instead use the
|
||||
<a href="https://www.php.net/manual/en/function.dl.php">dl() function</a> to load
|
||||
an extension at run time, by adding a line like this to the start of each
|
||||
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 an extension at run time, by adding a line like this to the start of each
|
||||
PHP script which uses your extension:
|
||||
</p>
|
||||
|
||||
|
|
@ -163,23 +176,11 @@ PHP script which uses your extension:
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
But note that <tt>dl()</tt> isn't supported when running PHP through a
|
||||
webserver - you'll need to use <tt>extension</tt> in <tt>php.ini</tt> as
|
||||
described above.
|
||||
</p>
|
||||
|
||||
<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.
|
||||
But to do this portably you need to take into account that pathnames and the
|
||||
filename extension vary by platform, and for security reasons PHP no longer
|
||||
supports <tt>dl()</tt> when running PHP through a webserver. Overall it's
|
||||
better to instead use <tt>extension</tt> in <tt>php.ini</tt> as described
|
||||
above.
|
||||
</p>
|
||||
|
||||
<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>
|
||||
|
||||
<div class="code"><pre>
|
||||
include("example.php");
|
||||
|
||||
echo "PI = " . PI . "\n";
|
||||
|
||||
echo "E = " . E . "\n";
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
There's one peculiarity of how constants work in PHP which it is useful
|
||||
to note (this is not specific to SWIG though) - if you try to use an undeclared
|
||||
constant, PHP will emit a warning (or a notice in PHP 7.1 and earlier) and then
|
||||
expand the constant to a string version of the constant's name. Unfortunately
|
||||
it is easy to miss the warning message if you're using PHP in a webserver as
|
||||
it will probably end up in error.log or similar. Apparently this will throw
|
||||
an Error in a future version of PHP, but until then it's something to be
|
||||
aware of.
|
||||
There's one peculiarity of how constants work in PHP prior to PHP 8
|
||||
which it is useful to note (this is not specific to SWIG though) - if you try
|
||||
to use an undeclared constant, PHP will emit a warning (or a notice in PHP 7.1
|
||||
and earlier) and then expand the constant to a string version of the constant's
|
||||
name. Unfortunately it is easy to miss the warning message if you're using PHP
|
||||
in a webserver as it will probably end up in error.log or similar. PHP 8.0
|
||||
made this an error.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -256,8 +252,6 @@ accessed incorrectly in PHP,
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
include("example.php");
|
||||
|
||||
if(EASY_TO_MISPEL) {
|
||||
...
|
||||
} else {
|
||||
|
|
@ -298,7 +292,6 @@ is accessed as follows:
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
include("example.php");
|
||||
print seki_get();
|
||||
seki_set( seki_get() * 2); # The C variable is now 4.
|
||||
print seki_get();
|
||||
|
|
@ -306,8 +299,10 @@ print seki_get();
|
|||
|
||||
<p>
|
||||
SWIG supports global variables of all C datatypes including pointers
|
||||
and complex objects. Additional types can be supported by using the
|
||||
<tt>varinit</tt> typemap.
|
||||
and complex objects. To support additional types, you just need to
|
||||
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>
|
||||
|
|
@ -342,7 +337,6 @@ Will be accessed in PHP like this :
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
include("example.php");
|
||||
$a = foo(2);
|
||||
$b = bar(3.5, -1.5);
|
||||
$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>
|
||||
<?php
|
||||
|
||||
include("example.php");
|
||||
|
||||
$in1=copy_intp(3);
|
||||
$in2=copy_intp(5);
|
||||
$result=new_intp();
|
||||
|
|
@ -500,8 +492,6 @@ This will result in the following usage in PHP:
|
|||
<div class="code"><pre>
|
||||
<?php
|
||||
|
||||
include("example.php");
|
||||
|
||||
$in1 = 3;
|
||||
$in2 = 5;
|
||||
$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>
|
||||
<?php
|
||||
|
||||
include("example.php");
|
||||
|
||||
$in1 = 3;
|
||||
$in2 = 5;
|
||||
$result = 0;
|
||||
|
|
@ -602,7 +590,6 @@ Would be used in the following way from PHP:
|
|||
|
||||
<div class="code"><pre>
|
||||
<?php
|
||||
require "vector.php";
|
||||
|
||||
$v = new Vector();
|
||||
$v->x = 3;
|
||||
|
|
@ -717,8 +704,6 @@ would be accessed in PHP as,
|
|||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
include("example.php");
|
||||
|
||||
echo "There have now been " . Ko::threats() . " threats\n";
|
||||
|
||||
</pre></div>
|
||||
|
|
@ -752,7 +737,6 @@ class Ko {
|
|||
|
||||
would be executed in PHP as,
|
||||
<div class="code"><pre>
|
||||
include("example.php");
|
||||
Ko::threats();
|
||||
</pre></div>
|
||||
|
||||
|
|
@ -779,9 +763,8 @@ If there are multiple interfaces, just list them separated by commas.
|
|||
|
||||
|
||||
<p>
|
||||
To place PHP code in the generated "example.php" file one can use the
|
||||
<b>code</b> pragma. The code is inserted after loading the shared
|
||||
object.
|
||||
You can get SWIG to generate an "example.php" file by specifying
|
||||
the code to put in it using the <b>code</b> pragma.
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -985,8 +968,6 @@ then at the PHP side you can define
|
|||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
require("mymodule.php");
|
||||
|
||||
class MyFoo extends Foo {
|
||||
function one() {
|
||||
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
|
||||
classes, can be loosely thought of as the C++ equivalent of the PHP
|
||||
proxy classes. The director classes store a pointer to their underlying
|
||||
PHP object. Indeed, this is quite similar to the "_cPtr" and "thisown"
|
||||
members of the PHP proxy classes.
|
||||
PHP object. Indeed, this is quite similar to <tt>struct swig_object_wrapper</tt>
|
||||
which is used to implement the PHP proxy classes.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -1064,12 +1045,12 @@ infinite loop.
|
|||
<p>
|
||||
One more point needs to be made about the relationship between director
|
||||
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
|
||||
to <tt>->_cPtr</tt>. This is exactly what happens without directors
|
||||
and is true even if directors are enabled for the particular class in
|
||||
question. When a class <i>derived</i> from a proxy class is created,
|
||||
however, SWIG then creates an instance of the corresponding C++ director
|
||||
class. The reason for this difference is that user-defined subclasses
|
||||
PHP, SWIG creates an instance of the original C++ class and stores it
|
||||
in the <tt>struct swig_object_wrapper</tt>. This is true whether or not
|
||||
directors are enabled for the particular class in question. However
|
||||
when a class <i>derived</i> from a proxy class is created, SWIG instead
|
||||
creates an instance of the corresponding C++ director class.
|
||||
The reason for this difference is that user-defined subclasses
|
||||
may override or extend methods of the original class, so the director
|
||||
class is needed to route calls to these methods correctly. For
|
||||
unmodified proxy classes, all methods are ultimately implemented in C++
|
||||
|
|
@ -1157,13 +1138,32 @@ should suffice in most cases:
|
|||
<div class="code">
|
||||
<pre>
|
||||
%feature("director:except") {
|
||||
if ($error == FAILURE) {
|
||||
#if SWIG_VERSION >= 0x040100
|
||||
if ($error != NULL)
|
||||
#else
|
||||
if ($error == FAILURE)
|
||||
#endif
|
||||
{
|
||||
throw Swig::DirectorMethodException();
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
</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>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1053,6 +1053,7 @@ PHP = @PHP@
|
|||
PHP_INCLUDE = @PHPINC@
|
||||
PHP_SO = @PHP_SO@
|
||||
PHP_SCRIPT = $(SRCDIR)$(RUNME).php
|
||||
PHP_EXTENSION = example$(PHP_SO)
|
||||
|
||||
# -------------------------------------------------------------------
|
||||
# Build a PHP dynamically loadable module (C)
|
||||
|
|
@ -1077,7 +1078,7 @@ php_cpp: $(SRCDIR_SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This file illustrates the cross language polymorphism using directors.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# Class, which overwrites Callback::run().
|
||||
|
||||
class PhpCallback extends Callback {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This example illustrates how member variables are wrapped.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
print "ICONST = " . ICONST . " (should be 42)\n";
|
||||
print "FCONST = " . FCONST . " (should be 2.1828)\n";
|
||||
print "CCONST = " . CCONST . " (should be 'x')\n";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# First create some objects using the pointer library.
|
||||
|
||||
print "Testing the pointer library\n";
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
# created by SWIG. In this case, all of our C++ classes
|
||||
# get converted into function calls.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
# Print out the value of some enums
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This file illustrates the cross language polymorphism using directors.
|
||||
|
||||
require("example.php");
|
||||
|
||||
# CEO class, which overrides Employee::getPosition().
|
||||
|
||||
class CEO extends Manager {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
$a = 37;
|
||||
$b = 42;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
# created by SWIG. In this case, all of our C++ classes
|
||||
# get converted into function calls.
|
||||
|
||||
include("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# First create some objects using the pointer library.
|
||||
|
||||
print "Testing the pointer library\n";
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
# created by SWIG. In this case, all of our C++ classes
|
||||
# get converted into function calls.
|
||||
|
||||
include("example.php");
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
# This file illustrates the manipulation of C++ references in PHP.
|
||||
|
||||
require "example.php";
|
||||
|
||||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
# Call our gcd() function
|
||||
|
||||
$x = "42 aaa";
|
||||
|
|
|
|||
|
|
@ -1,13 +1,19 @@
|
|||
#include "example.h"
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
int x = 42;
|
||||
char *s = (char *)"Test";
|
||||
std::string s = "Test";
|
||||
|
||||
void Sync::printer(void) {
|
||||
|
||||
printf("The value of global s is %s\n", s);
|
||||
printf("The value of global x is %d\n", x);
|
||||
printf("The value of class s is %s\n", s);
|
||||
printf("The value of class x is %d\n", x);
|
||||
void Sync::printer() {
|
||||
std::cout << "The value of global s is " << ::s << '\n';
|
||||
std::cout << "The value of global x is " << ::x << '\n';
|
||||
std::cout << "The value of class s is " << this->s << '\n';
|
||||
std::cout << "The value of class x is " << this->x << '\n';
|
||||
}
|
||||
|
||||
void Sync::all_change() {
|
||||
::s = "global change";
|
||||
++::x;
|
||||
this->s = "local change";
|
||||
++this->x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
extern char *s;
|
||||
#include <string>
|
||||
|
||||
extern std::string s;
|
||||
extern int x;
|
||||
|
||||
class Sync {
|
||||
public:
|
||||
int x;
|
||||
char *s;
|
||||
void printer(void);
|
||||
public:
|
||||
int x;
|
||||
std::string s;
|
||||
void printer();
|
||||
void all_change();
|
||||
|
||||
Sync() : x(0) { }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
%module example
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,29 @@
|
|||
<?
|
||||
|
||||
// Load module and PHP classes.
|
||||
include("example.php");
|
||||
echo "PHP reading globals: string is '", s_get(), "' and value is ", x_get(), "\n";
|
||||
|
||||
echo "Got new object\n";
|
||||
echo "Got string $s and value $x \n";
|
||||
|
||||
$s = new Sync();
|
||||
$o = new Sync();
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
|
||||
|
||||
$v = new Vector();
|
||||
$v->x = 1.0;
|
||||
$v->y = 2.0;
|
||||
|
|
@ -34,6 +31,6 @@
|
|||
|
||||
echo "\nNow I'm going to clean up the return result\n";
|
||||
|
||||
# free($r);
|
||||
unset($r);
|
||||
|
||||
echo "Good\n";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
require "example.php";
|
||||
echo "\nVariables (values printed from C)\n";
|
||||
|
||||
print_vars();
|
||||
|
|
|
|||
|
|
@ -26,17 +26,6 @@ UVW Bar::static_member_variable;
|
|||
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 {
|
||||
void foo() {}
|
||||
|
|
@ -45,7 +34,6 @@ private:
|
|||
XYZ* operator&(); // prevent dereferencing used in normally generated get method
|
||||
};
|
||||
%}
|
||||
#endif
|
||||
#if defined(SWIGUTL)
|
||||
%exception {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -18,22 +18,7 @@ namespace Swig {
|
|||
|
||||
%include "std_string.i"
|
||||
|
||||
#ifdef SWIGPHP
|
||||
|
||||
%feature("director:except") {
|
||||
if ($error == FAILURE) {
|
||||
Swig::DirectorMethodException::raise("$symname");
|
||||
}
|
||||
}
|
||||
|
||||
%exception {
|
||||
try { $action }
|
||||
catch (Swig::DirectorException &) { SWIG_fail; }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
#if defined SWIGPHP || defined SWIGPYTHON
|
||||
|
||||
%feature("director:except") {
|
||||
if ($error != NULL) {
|
||||
|
|
|
|||
|
|
@ -11,13 +11,6 @@
|
|||
|
||||
%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(s) Foo::p;
|
||||
%rename(q) Foo::r;
|
||||
|
|
|
|||
|
|
@ -17,11 +17,7 @@
|
|||
%feature("director") Foo;
|
||||
|
||||
%feature("director:except") {
|
||||
#ifndef SWIGPHP
|
||||
if ($error != NULL) {
|
||||
#else
|
||||
if ($error == FAILURE) {
|
||||
#endif
|
||||
throw Swig::DirectorMethodException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,8 @@
|
|||
b = "string b";
|
||||
x = 1234;
|
||||
}
|
||||
|
||||
int read_x() { return x; }
|
||||
|
||||
std::string read_b() { return b; }
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
%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
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
* language modules).
|
||||
*
|
||||
* 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
|
||||
* be fixable (needs more investigation).
|
||||
* static type checking. It's also not (currently) possible in PHP or Ruby, but
|
||||
* this may be fixable (needs more investigation).
|
||||
*/
|
||||
|
||||
%newobject create_Foo;
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ missingtests: missingcpptests missingctests
|
|||
# found, runs testcase.php, except for multicpptests.
|
||||
run_testcase = \
|
||||
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 \
|
||||
$(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
|
||||
|
||||
# Clean: remove the generated .php file
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "abstract_inherit_ok.php";
|
||||
|
||||
check::classes(array('Foo','Spam'));
|
||||
$spam=new Spam();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "abstract_inherit.php";
|
||||
|
||||
check::classes(array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i'));
|
||||
// This constructor attempt should fail as there isn't one
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "add_link.php";
|
||||
|
||||
// No new functions, except the flat functions
|
||||
check::functions(array('new_foo','foo_blah'));
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
|
||||
check::classes(array('Foo'));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?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'));
|
||||
|
||||
|
|
@ -22,16 +21,10 @@ check::equal(4,inctr($tr),"4==incr($tr)");
|
|||
check::equal(5,intp_value($tr),"5==$tr");
|
||||
|
||||
# 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;
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<?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::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
|
||||
// single byte string in it.
|
||||
check::set("array_c","Z");
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<?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::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);
|
||||
$a2=array(14,15,16,17);
|
||||
$a=array($a1,$a2);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "arrays.php";
|
||||
|
||||
check::functions(array('fn_taking_arrays','newintpointer','setintfrompointer','getintfrompointer','array_pointer_func'));
|
||||
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();
|
||||
check::classname('simplestruct',$ss);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "arrays_scope.php";
|
||||
|
||||
// New functions
|
||||
check::functions(array('new_bar','bar_blah'));
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('arrays_scope','Bar'));
|
||||
// New vars
|
||||
check::globals(array('bar_adata','bar_bdata','bar_cdata'));
|
||||
// No new globals
|
||||
check::globals(array());
|
||||
|
||||
$bar=new bar();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "callback.php";
|
||||
|
||||
// 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();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "casts.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('new_a','a_hello','new_b'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('A','B'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
# Make sure $b inherits hello() from class A
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "char_strings.php";
|
||||
|
||||
$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";
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
<?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'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "conversion_namespace.php";
|
||||
|
||||
check::classes(array("Foo","Bar"));
|
||||
$bar=new Bar;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "conversion_ns_template.php";
|
||||
|
||||
check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi"));
|
||||
// this is too hard, I'm not sure what to test for,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "conversion.php";
|
||||
|
||||
check::classes(array("Foo","Bar"));
|
||||
$bar=new Bar;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "cpp11_strongly_typed_enumerations.php";
|
||||
|
||||
function enumCheck($actual, $expected) {
|
||||
check::equal($actual, $expected, "Enum value mismatch");
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "cpp_basic.php";
|
||||
|
||||
// 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
|
||||
check::classes(array('cpp_basic','Foo','FooSub','FooSubSub','Bar','Fl_Window'));
|
||||
// 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'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$f = new Foo(3);
|
||||
$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();
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "cpp_static.php";
|
||||
|
||||
// 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
|
||||
check::classes(array('StaticMemberTest','StaticFunctionTest','cpp_static','StaticBase','StaticDerived'));
|
||||
// New vars
|
||||
check::globals(array('staticmembertest_static_int','staticbase_statty','staticderived_statty'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
check::done();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_abstract.php";
|
||||
|
||||
// No 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'));
|
||||
// No new classes
|
||||
// New functions
|
||||
check::functions(array('g'));
|
||||
// New classes
|
||||
check::classes(array('director_abstract','Foo','Example0','Example1','Example2','Example4','Example3_i','A'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyFoo extends Foo {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
<?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::globals(array('bar_x'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class PhpFoo extends Foo {
|
||||
function ping() {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_classic.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('being_id','person_id','child_id','grandchild_id','caller_delcallback','caller_setcallback','caller_resetcallback','caller_call','caller_baseclass'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Being','Person','Child','GrandChild','OrphanPerson','OrphanChild','Caller'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class TargetLangPerson extends Person {
|
||||
|
|
@ -81,11 +80,7 @@ function mycheck($person, $expected) {
|
|||
$ret = $baseclass->id();
|
||||
if ($debug)
|
||||
print $ret . "\n";
|
||||
# TODO: Currently we do not track the dynamic type of returned
|
||||
# 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");
|
||||
check::equal($ret, $expected, "#3 failed");
|
||||
|
||||
$caller->resetCallback();
|
||||
if ($debug)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_default.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('foo_msg','foo_getmsg','bar_msg','bar_getmsg','defaultsbase_defaultargs','defaultsderived_defaultargs'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Foo','Bar','DefaultsBase','DefaultsDerived'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$f = new Foo();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_detect.php";
|
||||
|
||||
// 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'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('A','Foo','Bar'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyBar extends Bar {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_enum.php";
|
||||
|
||||
// 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'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('director_enum','Foo','A','B','A2','B2'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyFoo extends Foo {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_exception.php";
|
||||
|
||||
// No 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'));
|
||||
// No new classes
|
||||
// New functions
|
||||
check::functions(array('launder','is_python_builtin'));
|
||||
// New classes
|
||||
check::classes(array('director_exception','Foo','Exception1','Exception2','Base','Bar','ReturnAllTypes'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyException extends Exception {
|
||||
|
|
@ -38,9 +37,7 @@ class MyFoo3 extends Foo {
|
|||
# MyFoo.pong().
|
||||
$ok = 0;
|
||||
$a = new MyFoo();
|
||||
# TODO: Currently we do not track the dynamic type of returned
|
||||
# objects, so we skip the launder() call.
|
||||
#$b = director_exception::launder($a);
|
||||
$b = director_exception::launder($a);
|
||||
$b = $a;
|
||||
try {
|
||||
$b->pong();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_extend.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('spobject_getfoobar','spobject_dummy','spobject_exceptionmethod'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('SpObject'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyObject extends SpObject{
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_finalizer.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('foo_orstatus','deletefoo','getstatus','launder','resetstatus'));
|
||||
// No new classes
|
||||
// New functions
|
||||
check::functions(array('deleteFoo','getStatus','launder','resetStatus'));
|
||||
// New classes
|
||||
check::classes(array('director_finalizer','Foo'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyFoo extends Foo {
|
||||
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")) {
|
||||
parent::__destruct();
|
||||
}
|
||||
|
|
@ -41,19 +45,23 @@ resetStatus();
|
|||
|
||||
$a = new MyFoo();
|
||||
$a->thisown = 0;
|
||||
check::equal(getStatus(), 0, "shadow release does not fire destructor of disowned object");
|
||||
|
||||
deleteFoo($a);
|
||||
unset($a);
|
||||
|
||||
check::equal(getStatus(), 3, "getStatus() failed #4");
|
||||
# getStatus() would ideally return 3 here.
|
||||
check::equal(getStatus(), 1, "getStatus() failed #4");
|
||||
|
||||
resetStatus();
|
||||
|
||||
$a = new MyFoo();
|
||||
$a->thisown = 0;
|
||||
deleteFoo(launder($a));
|
||||
$g = launder($a);
|
||||
unset($a);
|
||||
|
||||
check::equal(getStatus(), 3, "getStatus() failed #5");
|
||||
deleteFoo($g);
|
||||
# getStatus() would ideally return 3 here.
|
||||
check::equal(getStatus(), 1, "getStatus() failed #5");
|
||||
|
||||
resetStatus();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_frob.php";
|
||||
|
||||
// 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'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Alpha','Bravo','Charlie','Delta','Ops','Prims','corePoint3d','coreCallbacks_On3dEngineRedrawnData','coreCallbacksOn3dEngineRedrawnData','coreCallbacks'));
|
||||
// now new vars
|
||||
check::globals(array('corecallbacks_on3dengineredrawndata__eye','corecallbacks_on3dengineredrawndata__at','corecallbackson3dengineredrawndata__eye','corecallbackson3dengineredrawndata__at'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$foo = new Bravo();
|
||||
$s = $foo->abs_method();
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_nested.php";
|
||||
|
||||
// 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'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Foo_int','Bar','FooBar_int'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class A extends FooBar_int {
|
||||
|
|
@ -60,10 +59,7 @@ class C extends FooBar_int {
|
|||
}
|
||||
|
||||
$cc = new C();
|
||||
# TODO: Currently we do not track the dynamic type of returned
|
||||
# objects, so we skip the get_self() call.
|
||||
#$c = Foobar_int::get_self($cc);
|
||||
$c = $cc;
|
||||
$c = Foobar_int::get_self($cc);
|
||||
$c->advance();
|
||||
|
||||
check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed");
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
<?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::globals(array());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_pass_by_value.php";
|
||||
|
||||
$passByVal = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_profile.php";
|
||||
|
||||
// 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'));
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('A','B'));
|
||||
// No new vars
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
<?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::globals(array('bar_a'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class FooBar extends Bar {
|
||||
protected function ping() {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_stl.php";
|
||||
|
||||
// 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'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Foo'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyFoo extends Foo {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_string.php";
|
||||
|
||||
// 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'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('A','StringVector'));
|
||||
// now new vars
|
||||
check::globals(array('a','a_call','a_m_strings','stringvector'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class B extends A {
|
||||
function get_first() {
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_thread.php";
|
||||
|
||||
# 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?
|
||||
exit(0);
|
||||
|
||||
// No new functions
|
||||
// New functions
|
||||
check::functions(array('millisecondsleep','foo_stop','foo_run','foo_do_foo'));
|
||||
// No new classes
|
||||
// New classes
|
||||
check::classes(array('director_thread','Foo'));
|
||||
// now new vars
|
||||
check::globals(array('foo_val'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class Derived extends Foo {
|
||||
function do_foo() {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "director_unroll.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('foo_ping','foo_pong'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Foo','Bar'));
|
||||
// now new vars
|
||||
check::globals(array('bar'));
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
class MyFoo extends Foo {
|
||||
function ping() {
|
||||
|
|
@ -23,9 +22,7 @@ $b = new Bar();
|
|||
$b->set($a);
|
||||
$c = $b->get();
|
||||
|
||||
// FIXME: This doesn't work for checking that they wrap the same C++ object
|
||||
// because the two objects have different PHP resources, and we can't easily
|
||||
// look inside those resources to see which C++ objects they refer to.
|
||||
//check::equal($a->_cPtr, $c->_cPtr, "_cPtr check failed");
|
||||
// FIXME: The python version checks that a.this == c.this, but we don't seem
|
||||
// to have a way to check this with the PHP bindings we generate.
|
||||
|
||||
check::done();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
require "tests.php";
|
||||
require "enum_scope_template.php";
|
||||
|
||||
check::functions(array("chops"));
|
||||
check::classes(array("enum_scope_template", "TreeInt"));
|
||||
check::functions(array("chops","treeint_chops"));
|
||||
check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
|
||||
check::equal(1,TreeInt_Fir,"1==TreeInt_Fir");
|
||||
check::equal(2,TreeInt_Cedar,"2==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)");
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
check::equal(0,TreeInt::Oak,"0==TreeInt_Oak");
|
||||
check::equal(1,TreeInt::Fir,"1==TreeInt_Fir");
|
||||
check::equal(2,TreeInt::Cedar,"2==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();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "evil_diamond_ns.php";
|
||||
|
||||
check::classes(array("evil_diamond_ns","foo","bar","baz","spam"));
|
||||
check::functions("test");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "evil_diamond_prop.php";
|
||||
|
||||
check::classes(array("evil_diamond_prop","foo","bar","baz","spam"));
|
||||
check::functions("test");
|
||||
|
|
@ -31,9 +30,7 @@ check::is_a($spam,"spam");
|
|||
check::equal(1,$spam->_foo,"1==spam->_foo");
|
||||
check::equal(2,$spam->_bar,"2==spam->_bar");
|
||||
// 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");
|
||||
restore_error_handler();
|
||||
check::equal(4,$spam->_spam,"4==spam->_spam");
|
||||
|
||||
check::done();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "evil_diamond.php";
|
||||
|
||||
check::classes(array("evil_diamond","foo","bar","baz","spam"));
|
||||
check::functions("test");
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
<?
|
||||
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::globals(array('efoovar','foovar','cfoovar','a_sfoovar','a_foovar','a_efoovar'));
|
||||
check::globals(array('efoovar','foovar','cfoovar'));
|
||||
|
||||
$a = new A();
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "extend_template_ns.php";
|
||||
|
||||
check::classes(array("extend_template_ns","Foo_One"));
|
||||
$foo=new Foo_One();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "extend_template.php";
|
||||
|
||||
check::classes(array("Foo_0"));
|
||||
$foo=new Foo_0();
|
||||
|
|
|
|||
27
Examples/test-suite/php/global_vars_runme.php
Normal file
27
Examples/test-suite/php/global_vars_runme.php
Normal 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();
|
||||
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "grouping.php";
|
||||
|
||||
check::functions(array("test1","test2","do_unary","negate"));
|
||||
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::equal(37,test3_get(),'37==test3_get()');
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "ignore_parameter.php";
|
||||
|
||||
// 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
|
||||
check::classes(array('ignore_parameter','SportsCars','MiniCooper','MorrisMinor','FordAnglia','AustinAllegro'));
|
||||
// No new vars
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
require "tests.php";
|
||||
require "import_nomodule.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('create_foo','delete_foo','test1','is_python_builtin'));
|
||||
// No new classes
|
||||
check::classes(array('import_nomodule','Bar'));
|
||||
// now new vars
|
||||
require "tests.php";
|
||||
|
||||
check::functions(array('is_python_builtin'));
|
||||
check::classes(array('import_nomodule'));
|
||||
// No new globals
|
||||
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();
|
||||
import_nomodule::test1($f,42);
|
||||
import_nomodule::delete_Foo($f);
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "li_carrays_cpp.php";
|
||||
|
||||
// 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.
|
||||
// NB An "li_carrays_cpp" class is created as a mock namespace.
|
||||
check::classes(array('li_carrays_cpp','doubleArray','AB','XY','XYArray','shortArray'));
|
||||
|
||||
// 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "li_carrays.php";
|
||||
|
||||
// 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.
|
||||
// NB An "li_carrays" class is created as a mock namespace.
|
||||
check::classes(array('li_carrays','doubleArray','AB','XY','XYArray','shortArray'));
|
||||
|
||||
// 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "li_factory.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('geometry_draw','geometry_create','geometry_clone_','point_draw','point_width','point_clone_','circle_draw','circle_radius','circle_clone_'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Geometry','Point','Circle'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$circle = Geometry::create(Geometry::CIRCLE);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,34 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "li_std_string.php";
|
||||
|
||||
// Global variables
|
||||
//$s="initial string";
|
||||
//check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
|
||||
# Checking expected use of %typemap(in) std::string {}
|
||||
li_std_string::test_value("Fee");
|
||||
|
||||
# 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
|
||||
$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");
|
||||
Structure::StaticMemberString2($s);
|
||||
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"
|
||||
li_std_string::test_const_reference_returning_void("foo");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "li_std_vector_member_var.php";
|
||||
|
||||
$t = new Test();
|
||||
|
||||
|
|
|
|||
59
Examples/test-suite/php/member_pointer_const_runme.php
Normal file
59
Examples/test-suite/php/member_pointer_const_runme.php
Normal 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");
|
||||
*/
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "multivalue.php";
|
||||
|
||||
// New functions
|
||||
check::functions(array('divide_l','divide_v','divide_mv'));
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "newobject1.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('foo_makefoo','foo_makemore','foo_foocount'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('Foo'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$foo = Foo::makeFoo();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "newobject3.php";
|
||||
|
||||
$factory = new factory();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "overload_null.php";
|
||||
|
||||
$o = new Overload();
|
||||
$x = new X();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "overload_polymorphic.php";
|
||||
|
||||
$t = new Derived();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "overload_rename.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array());
|
||||
// No new classes
|
||||
// New classes
|
||||
check::classes(array('Foo'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$f = new Foo(1.0);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "overload_return_type.php";
|
||||
|
||||
$b = new B;
|
||||
check::equal($b->foo(1), 0, "");
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?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'));
|
||||
// No new global variables.
|
||||
check::globals(array());
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "php_pragma.php";
|
||||
|
||||
|
||||
check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==version(php_pragma)");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "pointer_reference.php";
|
||||
|
||||
$s = pointer_reference::get();
|
||||
check::equal($s->value, 10, "pointer_reference::get() failed");
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "prefix.php";
|
||||
|
||||
// No new functions
|
||||
check::functions(array('foo_get_self'));
|
||||
// No new classes
|
||||
check::functions(array());
|
||||
// New classes
|
||||
check::classes(array('ProjectFoo'));
|
||||
// now new vars
|
||||
// No new vars
|
||||
check::globals(array());
|
||||
|
||||
$f = new ProjectFoo();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require "tests.php";
|
||||
require "preproc_constants_c.php";
|
||||
|
||||
// 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");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?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_INT2), "integer", "preproc_constants.CONST_INT2 has unexpected type");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<?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.
|
||||
# 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
Loading…
Add table
Add a link
Reference in a new issue