Don't generate a .php wrapper file by default

It's now only generated if something to put in it is specified via:

%pragma(php) include=...

or

%pragma(php) code=...
This commit is contained in:
Olly Betts 2021-05-04 14:14:56 +12:00
commit 32283991c5
101 changed files with 46 additions and 176 deletions

5
.gitignore vendored
View file

@ -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

View file

@ -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 &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>
@ -178,15 +183,6 @@ better to instead use <tt>extension</tt> in <tt>php.ini</tt> as described
above.
</p>
<p>
SWIG also generates a PHP module which defines PHP classes for the wrapped
API, which you'll need to load, for example:
</p>
<div class="code"><pre>
include("example.php");
</pre></div>
<H2><a name="Php_nn2">32.2 Basic PHP interface</a></H2>
@ -224,12 +220,8 @@ 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>
@ -261,8 +253,6 @@ accessed incorrectly in PHP,
<div class="code">
<pre>
include("example.php");
if(EASY_TO_MISPEL) {
...
} else {
@ -303,7 +293,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();
@ -349,7 +338,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
@ -474,8 +462,6 @@ This will result in the following usage in PHP:
<div class="code"><pre>
&lt;?php
include("example.php");
$in1=copy_intp(3);
$in2=copy_intp(5);
$result=new_intp();
@ -507,8 +493,6 @@ This will result in the following usage in PHP:
<div class="code"><pre>
&lt;?php
include("example.php");
$in1 = 3;
$in2 = 5;
$result= add($in1, $in2); # Note using variables for the input is unnecessary.
@ -544,8 +528,6 @@ This will result in the following usage in PHP:
<div class="code"><pre>
&lt;?php
include("example.php");
$in1 = 3;
$in2 = 5;
$result = 0;
@ -609,7 +591,6 @@ Would be used in the following way from PHP:
<div class="code"><pre>
&lt;?php
require "vector.php";
$v = new Vector();
$v-&gt;x = 3;
@ -724,8 +705,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>
@ -759,7 +738,6 @@ class Ko {
would be executed in PHP as,
<div class="code"><pre>
include("example.php");
Ko::threats();
</pre></div>
@ -786,9 +764,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>
@ -992,8 +969,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";

View file

@ -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 {

View file

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

View file

@ -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";

View file

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

View file

@ -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";

View file

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

View file

@ -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 {

View file

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

View file

@ -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";

View file

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

View file

@ -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";

View file

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

View file

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

View file

@ -1,7 +1,5 @@
<?
include("example.php");
echo "PHP reading globals: string is '", s_get(), "' and value is ", x_get(), "\n";
$o = new Sync();

View file

@ -1,8 +1,5 @@
<?php
require "example.php";
$v = new Vector();
$v->x = 1.0;
$v->y = 2.0;

View file

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

View file

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

View file

@ -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

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "add_link.php";
// No new functions
check::functions(array());

View file

@ -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'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "arrays_global.php";
check::functions(array('test_a','test_b'));
check::classes(array('arrays_global','SimpleStruct','Material'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "arrays_global_twodim.php";
check::functions(array('fn_taking_arrays','get_2d_array',));
check::classes(array('arrays_global_twodim','SimpleStruct','Material'));

View file

@ -1,6 +1,6 @@
<?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'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "arrays_scope.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "callback.php";
// In 2.0.6 and earlier, the constant was misnamed.
check::equal(gettype(callback::FOO_I_Cb_Ptr), 'object', "callback::FOO_I_Cb_Ptr not an object");

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "casts.php";
// No new functions
check::functions(array());

View file

@ -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";

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "class_ignore.php";
check::functions(array('do_blah'));
check::classes(array('class_ignore','Bar','Boo','Far','Hoo'));

View file

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

View file

@ -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,

View file

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

View file

@ -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");

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "cpp_basic.php";
// New functions
check::functions(array('get_func1_ptr','get_func2_ptr','test_func_ptr'));

View file

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

View file

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

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_basic.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_classic.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_default.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_detect.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_enum.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_exception.php";
// New functions
check::functions(array('launder','is_python_builtin'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_extend.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_finalizer.php";
// New functions
check::functions(array('deletefoo','getstatus','launder','resetstatus'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_frob.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_nested.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_overload.php";
check::functions(array());
check::classes(array('OverloadedClass','OverloadedPointers','OverloadedGetSet'));

View file

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

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_profile.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_protected.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_stl.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_string.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?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?

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "director_unroll.php";
// No new functions
check::functions(array());

View file

@ -1,6 +1,5 @@
<?php
require "tests.php";
require "enum_scope_template.php";
check::functions(array("chops"));
check::classes(array("enum_scope_template", "TreeInt"));

View file

@ -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");

View file

@ -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");

View file

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

View file

@ -1,6 +1,5 @@
<?
require "tests.php";
require "exception_order.php";
check::functions(array('is_python_builtin'));
check::classes(array('A','E1','E2','E3','exception_order','ET_i','ET_d'));

View file

@ -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();

View file

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

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "global_vars.php";
check::functions(array('init','read_b','read_x'));
check::classes(array('A','global_vars'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "grouping.php";
check::functions(array("test1","test2","do_unary","negate"));
check::equal(5,test1(5),"5==test1(5)");

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "ignore_parameter.php";
// New functions
check::functions(array('jaguar','lotus','tvr','ferrari','fiat'));

View file

@ -1,6 +1,6 @@
<?php
require "tests.php";
require "import_nomodule.php";
check::functions(array('is_python_builtin'));
check::classes(array('import_nomodule'));

View file

@ -1,6 +1,6 @@
<?php
require "tests.php";
require "li_carrays_cpp.php";
// Check functions.
check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','new_abarray','delete_abarray','abarray_getitem','abarray_setitem','sum_array'));

View file

@ -1,6 +1,6 @@
<?php
require "tests.php";
require "li_carrays.php";
// Check functions.
check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','new_abarray','delete_abarray','abarray_getitem','abarray_setitem','sum_array'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "li_factory.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "li_std_string.php";
# Checking expected use of %typemap(in) std::string {}
li_std_string::test_value("Fee");

View file

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

View file

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

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "newobject1.php";
// No new functions
check::functions(array());

View file

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

View file

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

View file

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

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "overload_rename.php";
// No new functions
check::functions(array());

View file

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

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "php_iterator.php";
// No new functions.
check::functions(array());

View file

@ -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)");

View file

@ -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");

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "prefix.php";
// No new functions
check::functions(array());

View file

@ -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");

View file

@ -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");

View file

@ -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.

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "rename_scope.php";
check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket"));

View file

@ -2,7 +2,6 @@
// Sample test file
require "tests.php";
require "____.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "smart_pointer_rename.php";
check::classes(array("Foo","Bar"));
check::classmethods("foo",array("ftest1","ftest2","__set","__isset","__get","__construct"));

View file

@ -1,6 +1,5 @@
<?php
require("swig_exception.php");
require("tests.php");
$c = new Circle(10);

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "sym.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "template_arg_typename.php";
// No new functions
check::functions(array());

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "template_construct.php";
check::classes(array('Foo_int'));
$foo_int=new foo_int(3);

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "threads_exception.php";
// Check functions
check::functions(array('is_python_builtin'));

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "typedef_reference.php";
check::functions(array('somefunc','otherfunc','new_intp','copy_intp','delete_intp','intp_assign','intp_value'));
$int2=copy_intp(2);

View file

@ -1,7 +1,7 @@
<?php
require "tests.php";
require "typemap_ns_using.php";
if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");

View file

@ -1,7 +1,7 @@
<?php
require "tests.php";
require "using1.php";
if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");

View file

@ -1,7 +1,7 @@
<?php
require "tests.php";
require "using2.php";
if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "valuewrapper_base.php";
check::classes(array("valuewrapper_base","Base","Interface_BP"));
check::functions("make_interface_bp");

View file

@ -1,7 +1,6 @@
<?
require "tests.php";
require "virtual_vs_nonvirtual_base.php";
$fail = new SimpleClassFail();
$work = new SimpleClassWork();

View file

@ -1,7 +1,6 @@
<?php
require "tests.php";
require "wrapmacro.php";
check::functions(array('guint16_swap_le_be_constant', 'maximum'));

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