Typo correction curtesy of Olly Betts.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7594 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
ada2b47e88
commit
71d989b3a9
1 changed files with 45 additions and 45 deletions
|
|
@ -27,7 +27,7 @@
|
|||
<li><a href="#Php_nn2_6">Structures and C++ classes</a>
|
||||
<ul>
|
||||
<li><a href="#Php_nn2_6_1">Using <tt>-noproxy</tt></a>
|
||||
<li><a href="#Php_nn2_6_2">Constructors and Destructers</a>
|
||||
<li><a href="#Php_nn2_6_2">Constructors and Destructors</a>
|
||||
<li><a href="#Php_nn2_6_3">Static Member Variables</a>
|
||||
<li><a href="#Php_nn2_6_4">Static Member Functions</a>
|
||||
</ul>
|
||||
|
|
@ -92,12 +92,12 @@ in the interface file.
|
|||
<p>
|
||||
Swig can generate PHP4 extensions from C++ libraries as well when
|
||||
given the <tt>-c++</tt> option. The support for C++ is discussed in
|
||||
more detail in a following section.
|
||||
more detail in <a href="#Php_nn2_6">section 24.2.6</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To finish building the extension, you have two choices. You can either build
|
||||
the extension as a seperate object file which will then have to be explicitly
|
||||
the extension as a separate shared object file which will then have to be explicitly
|
||||
loaded by each script. Or you can rebuild the entire php source tree and build
|
||||
the extension into the php executable/library so it will be available in every
|
||||
script. The first choice is the default, however it can be changed by passing
|
||||
|
|
@ -125,7 +125,7 @@ OS):
|
|||
<p>
|
||||
The <tt>-make</tt> command line argument to swig will generate an
|
||||
additional file Makefile. This Makefile can usually build the
|
||||
extension iteself (on unix platforms).
|
||||
extension itself (on unix platforms).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -165,8 +165,8 @@ libraries and header files for you.
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
If you depend on source files not generated by SWIG, before generated
|
||||
configure file, you may need to edit the <tt> Makefile.in</tt>
|
||||
If you depend on source files not generated by SWIG, before generating
|
||||
the configure file, you may need to edit the <tt>Makefile.in</tt>
|
||||
file. This contains the names of the source files to compile (just the
|
||||
wrapper file by default) and any additional libraries needed to be
|
||||
linked in. If there are extra C files to compile, you will need to add
|
||||
|
|
@ -187,11 +187,11 @@ Both the <tt>-make</tt> and <tt>-phpfull</tt> arguments accept
|
|||
additional optional arguments:
|
||||
</p>
|
||||
<ul>
|
||||
<li><tt>-withincs "<files>"</tt> Adds include files to the config.m4 file.
|
||||
<li><tt>-withlibs "<files>"</tt> Links the libraries into the shared object.
|
||||
<li><tt>-withc "<files>"</tt> Compiles and links the named C files into the shared object.
|
||||
<li><tt>-withcxx "<files>"</tt> Compiles and links the named C++ files into the shared object,
|
||||
<li><tt>-dlname "<name>"</tt> Changes the name of the generated shared object.
|
||||
<li><tt>-withincs "<files>"</tt> Adds include files to the config.m4 file.
|
||||
<li><tt>-withlibs "<files>"</tt> Links the libraries into the shared object.
|
||||
<li><tt>-withc "<files>"</tt> Compiles and links the named C files into the shared object.
|
||||
<li><tt>-withcxx "<files>"</tt> Compiles and links the named C++ files into the shared object,
|
||||
<li><tt>-dlname "<name>"</tt> Changes the name of the generated shared object.
|
||||
</ul>
|
||||
|
||||
<H3><a name="Php_nn1_2"></a>24.1.2 Building extensions into PHP</H3>
|
||||
|
|
@ -206,7 +206,7 @@ in each script.
|
|||
|
||||
<p>
|
||||
After running swig with the -phpfull switch, you will be left with a shockingly
|
||||
similiar set of files to the previous build process. However you will then need
|
||||
similar set of files to the previous build process. However you will then need
|
||||
to move these files to a subdirectory within the php source tree, this subdirectory you will need to create under the ext directory, with the name of the extension ( e.g mkdir php-4.0.6/ext/modulename .)
|
||||
</p>
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ and includes the extra command line arguments from the module you have added.
|
|||
Before running the generated configure file, you may need to edit the <tt>
|
||||
Makefile.in</tt>. This contains the names of the source files to compile (
|
||||
just the wrapper file by default) and any additional libraries needed to
|
||||
link in. If their are extra C files to compile you will need to add them
|
||||
link in. If there are extra C files to compile you will need to add them
|
||||
to the Makefile, or add the names of libraries if they are needed.
|
||||
In most cases <tt>Makefile.in</tt> will be complete, especially if you
|
||||
make use of <tt>-withlibs</tt> and <tt>-withincs</tt>
|
||||
|
|
@ -292,7 +292,7 @@ other symbols unless care is taken to <tt>%rename</tt> them.
|
|||
These work in much the same way as in C/C++, constants can be defined
|
||||
by using either the normal C pre-processor declarations, or the
|
||||
<tt>%constant</tt> SWIG directive. These will then be available from
|
||||
your PHP script as a PHP constant, (e.g. no dollar sign is needed to
|
||||
your PHP script as a PHP constant, (i.e. no dollar sign is needed to
|
||||
access them. ) For example, with a swig file like this,
|
||||
</p>
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ access them. ) For example, with a swig file like this,
|
|||
</div>
|
||||
|
||||
<p>
|
||||
you can access from in your php script like this,
|
||||
you can access the constants in your php script like this,
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -321,8 +321,8 @@ echo "E = " . E . "\n";
|
|||
|
||||
<p>
|
||||
There are two peculiarities with using constants in PHP4. The first is that
|
||||
if you try to use an undeclared constant, it will evaulate to a string
|
||||
set to the constants name. For example,
|
||||
if you try to use an undeclared constant, it will evaluate to a string
|
||||
set to the constant's name. For example,
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -351,7 +351,7 @@ if(EASY_TO_MISPEL) {
|
|||
|
||||
<p>
|
||||
will issue a warning about the undeclared constant, but will then
|
||||
evalute it and turn it into a string ('EASY_TO_MISPEL'), which
|
||||
evaluate it and turn it into a string ('EASY_TO_MISPEL'), which
|
||||
evaluates to true, rather than the value of the constant which would
|
||||
be false. This is a feature.
|
||||
</p>
|
||||
|
|
@ -399,7 +399,7 @@ also map to the same hash element 'test', but will not overwrite
|
|||
it. When called from the script, the TEST constant will again be
|
||||
mapped to the hash element 'test' so the constant will be
|
||||
retrieved. The case will then be checked, and will match up, so the
|
||||
value ('Hello') will be returned. When 'Test' is evaulated, it will
|
||||
value ('Hello') will be returned. When 'Test' is evaluated, it will
|
||||
also map to the same hash element 'test'. The same constant will be
|
||||
retrieved, this time though the case check will fail as 'Test' !=
|
||||
'TEST'. So PHP will assume that Test is a undeclared constant, and as
|
||||
|
|
@ -407,7 +407,7 @@ explained above, will return it as a string set to the constant name
|
|||
('Test'). Hence the script above will print 'Hello Test'. If they were
|
||||
declared non-case sensitive, the output would be 'Hello Hello', as
|
||||
both point to the same value, without the case test taking place. (
|
||||
Apologies, this paragraph needs rewritting to make some sense. )
|
||||
Apologies, this paragraph needs rewriting to make some sense. )
|
||||
</p>
|
||||
|
||||
<H3><a name="Php_nn2_2"></a>24.2.2 Global Variables</H3>
|
||||
|
|
@ -431,7 +431,7 @@ the use of automatically generated accessor functions.
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
is accessed as follow :
|
||||
is accessed as follows:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -498,10 +498,10 @@ $a = foo(2.0);
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
Functions are envoked using pass by value semantics like all of PHP.
|
||||
Functions are invoked using pass by value semantics like all of PHP.
|
||||
This means the conversion which automatically takes place when
|
||||
envoking a swig wrapped method does not change the native type of the
|
||||
arugment variable.
|
||||
invoking a swig wrapped method does not change the native type of the
|
||||
argument variable.
|
||||
</p>
|
||||
<div class="code"><pre>
|
||||
$s = "2 A string representing two";
|
||||
|
|
@ -536,7 +536,7 @@ void doit( double i );
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
it is questionable which to envoke when <tt>doit("2");</tt> is used in
|
||||
it is questionable which to invoke when <tt>doit("2");</tt> is used in
|
||||
PHP. The string <tt>"2"</tt> simultaneously represents the integer
|
||||
<tt>2</tt> and the double <tt>2.0</tt>.
|
||||
</p>
|
||||
|
|
@ -560,7 +560,7 @@ void doit( int i );
|
|||
</pre></div>
|
||||
|
||||
<p>
|
||||
Cause less confusion and <tt>doit("2");</tt> will envoke the function
|
||||
Cause less confusion and <tt>doit("2");</tt> will invoke the function
|
||||
taking the integer argument.
|
||||
</p>
|
||||
|
||||
|
|
@ -568,8 +568,8 @@ taking the integer argument.
|
|||
|
||||
|
||||
<p>
|
||||
Pointers to C/C++ objects <b>no longer</b> represented as character
|
||||
strings such as:<tt>_523d3f4_Circle_p</tt>, instead they are represented
|
||||
Pointers to C/C++ objects are <b>no longer</b> represented as character
|
||||
strings such as: <tt>_523d3f4_Circle_p</tt>, instead they are represented
|
||||
as PHP resources, rather like MySQL connection handles.
|
||||
</p>
|
||||
|
||||
|
|
@ -610,8 +610,8 @@ $result=new_intp();
|
|||
|
||||
add( $in1, $in2, $result );
|
||||
|
||||
echo "The sum " . intp_value($in1) . " + " . intp_value($in2) . " = " . inpt_value( $result) . "\n";
|
||||
?>
|
||||
echo "The sum " . intp_value($in1) . " + " . intp_value($in2) . " = " . intp_value( $result) . "\n";
|
||||
?>
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -643,11 +643,11 @@ $in2 = 5;
|
|||
$result= add($in1,$in2); # Note using variables for the input is unnecessary.
|
||||
|
||||
echo "The sum $in1 + $in2 = $result\n";
|
||||
?>
|
||||
?>
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
Because PHP has a native concept of reference, it may seem more natual
|
||||
Because PHP has a native concept of reference, it may seem more natural
|
||||
to the PHP developer to use references to pass pointers. To enable
|
||||
this, one needs to include <b>phppointers.i</b> which defines the
|
||||
named typemap REFERENCE.
|
||||
|
|
@ -676,7 +676,7 @@ $result = 0;
|
|||
add(&$in1,&$in2,&$result);
|
||||
|
||||
echo "The sum $in1 + $in2 = $result\n";
|
||||
?>
|
||||
?>
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
|
|
@ -691,7 +691,7 @@ may or may not be a good thing.
|
|||
|
||||
<p>
|
||||
We chose to allow passing NULL pointers into functions because that is
|
||||
sometimes required in C libraries.. A NULL pointer can be created in
|
||||
sometimes required in C libraries. A NULL pointer can be created in
|
||||
PHP in a number of ways: by using <tt>unset</tt> on an existing
|
||||
variable, or assigning <tt>NULL</tt> to a variable.
|
||||
</p>
|
||||
|
|
@ -734,25 +734,25 @@ Would be used in the following way:
|
|||
require "vector.php";
|
||||
|
||||
$v = new Vector();
|
||||
$v->x = 3;
|
||||
$v->y = 4;
|
||||
$v->z = 5;
|
||||
$v->x = 3;
|
||||
$v->y = 4;
|
||||
$v->z = 5;
|
||||
|
||||
echo "Magnitude of ($v->x,$v->y,$v->z) = " . $v->magnitude() . "\n";
|
||||
echo "Magnitude of ($v->x,$v->y,$v->z) = " . $v->magnitude() . "\n";
|
||||
|
||||
$v = NULL; # destructor called.
|
||||
|
||||
$c = new Complex();
|
||||
|
||||
$c->re = 0;
|
||||
$c->im = 0;
|
||||
$c->re = 0;
|
||||
$c->im = 0;
|
||||
|
||||
# $c destructor called when $c goes out of scope.
|
||||
?>
|
||||
?>
|
||||
</pre></div>
|
||||
|
||||
<p>
|
||||
Member variables and methods are accessed using the <tt>-></tt> operator.
|
||||
Member variables and methods are accessed using the <tt>-></tt> operator.
|
||||
</p>
|
||||
|
||||
<H4><a name="Php_nn2_6_1"></a>24.2.6.1 Using <tt>-noproxy</tt></H4>
|
||||
|
|
@ -761,7 +761,7 @@ Member variables and methods are accessed using the <tt>-></tt> operator.
|
|||
<p>
|
||||
The <tt>-noproxy</tt> option flattens the object structure and
|
||||
generates collections of named functions. The above example results
|
||||
in the follwoing PHP functions:
|
||||
in the following PHP functions:
|
||||
</p>
|
||||
|
||||
<div class="code"><pre>
|
||||
|
|
@ -780,7 +780,7 @@ Complex_im_set($obj,$d);
|
|||
Complex_im_get($obj);
|
||||
</pre></div>
|
||||
|
||||
<H4><a name="Php_nn2_6_2"></a>24.2.6.2 Constructors and Destructers</H4>
|
||||
<H4><a name="Php_nn2_6_2"></a>24.2.6.2 Constructors and Destructors</H4>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
@ -788,7 +788,7 @@ The constructor is called when <tt>new Object()</tt> (or
|
|||
<tt>new_Object()</tt> if using <tt>-noproxy</tt>) is used to create an
|
||||
instance of the object. If multiple constructors are defined for an
|
||||
object, function overloading will be used to determine which
|
||||
contructor to execute.
|
||||
constructor to execute.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue