From 75104c732f1d03744798c4c23fdfb25f4dfd8f6e Mon Sep 17 00:00:00 2001
From: Kevin Ruland
Swig can generate PHP4 extensions from C++ libraries as well when
given the -c++ option. The support for C++ is discussed in
-more detail in a following section.
+more detail in section 24.2.6.
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):
The -make 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).
@@ -165,8 +165,8 @@ libraries and header files for you.
-If you depend on source files not generated by SWIG, before generated
-configure file, you may need to edit the Makefile.in
+If you depend on source files not generated by SWIG, before generating
+the configure file, you may need to edit the Makefile.in
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 -make and -phpfull arguments accept
additional optional arguments:
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 .)
@@ -92,12 +92,12 @@ in the interface file.
-
24.1.2 Building extensions into PHP
@@ -206,7 +206,7 @@ in each script.
-you can access from in your php script like this, +you can access the constants in your php script like this,
@@ -321,8 +321,8 @@ echo "E = " . E . "\n";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,
@@ -351,7 +351,7 @@ if(EASY_TO_MISPEL) {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.
@@ -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. )24.2.2 Global Variables
@@ -431,7 +431,7 @@ the use of automatically generated accessor functions.-is accessed as follow : +is accessed as follows:
@@ -498,10 +498,10 @@ $a = foo(2.0);-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.
$s = "2 A string representing two"; @@ -536,7 +536,7 @@ void doit( double i );-it is questionable which to envoke when doit("2"); is used in +it is questionable which to invoke when doit("2"); is used in PHP. The string "2" simultaneously represents the integer 2 and the double 2.0.
@@ -560,7 +560,7 @@ void doit( int i );
-Cause less confusion and doit("2"); will envoke the function +Cause less confusion and doit("2"); will invoke the function taking the integer argument.
@@ -568,8 +568,8 @@ taking the integer argument.-Pointers to C/C++ objects no longer represented as character -strings such as:_523d3f4_Circle_p, instead they are represented +Pointers to C/C++ objects are no longer represented as character +strings such as: _523d3f4_Circle_p, instead they are represented as PHP resources, rather like MySQL connection handles.
@@ -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"; +?>@@ -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"; -?> +?>
-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 phppointers.i which defines the named typemap REFERENCE. @@ -676,7 +676,7 @@ $result = 0; add(&$in1,&$in2,&$result); echo "The sum $in1 + $in2 = $result\n"; -?> +?>
@@ -691,7 +691,7 @@ may or may not be a good thing.
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 unset on an existing variable, or assigning NULL to a variable.
@@ -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. -?> +?>-Member variables and methods are accessed using the -> operator. +Member variables and methods are accessed using the -> operator.
The -noproxy 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:
@@ -780,7 +780,7 @@ Complex_im_set($obj,$d); Complex_im_get($obj);
@@ -788,7 +788,7 @@ The constructor is called when new Object() (or new_Object() if using -noproxy) 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.