Hi all
I have just joined the list as I am in the process of writing a machine
control application with a c++ frontend and a browser based GUI using
AJAX techniques. This requires me to interface c++ to php and swig
appears to be the correct approach (thus avoiding writing custom php
extensions ..).
My problem at the moment is that I am trying to access a pre-existing
structure in the c++ process by using a simple factory method that
returns a pointer to the structure. I see in the php4 examples that are
in the swig source tree an example called shadow. This appears to do
what I want. Unfortunately when I try to compile the code I get a bunch
of errors with example_wrap.cxx - a shortened list of which follows -
make[1]: Entering directory `/usr/src/swig-1.3.35/Examples/php4/shadow'
.../../../preinst-swig -php4 -cppext cxx -c++ example.i
g++ -c -fpic example.cxx example_wrap.cxx -I/usr/include/php
-I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend
-I/usr/include/php/ext -I/usr/include/php/ext/date/lib
example_wrap.cxx:981: error: 'zend_property_reference' was not declared
in this scope
example_wrap.cxx:981: error: 'property_reference' was not declared in
this scope
example_wrap.cxx:981: error: expected primary-expression before '*' token
example_wrap.cxx:981: error: 'value' was not declared in this scope
example_wrap.cxx:981: error: initializer expression list treated as
compound expression
example_wrap.cxx:982: error: 'zend_property_reference' was not declared
in this scope
example_wrap.cxx:982: error: 'property_reference' was not declared in
this scope
example_wrap.cxx:982: error: expected primary-expression before '*' token
example_wrap.cxx:982: error: 'value' was not declared in this scope
..
..
..
..
example_wrap.cxx:1705: error: 'value' was not declared in this scope
example_wrap.cxx: In function 'int zm_startup_example(int, int)':
example_wrap.cxx:2067: error: cannot convert 'pval' to '_zend_function*'
in assignment
example_wrap.cxx:2067: error: invalid conversion from 'int' to
'_zend_function*'
example_wrap.cxx:2071: error: cannot convert 'pval' to '_zend_function*'
in assignment
example_wrap.cxx:2071: error: invalid conversion from 'int' to
'_zend_function*'
example_wrap.cxx:2075: error: cannot convert 'pval' to '_zend_function*'
in assignment
example_wrap.cxx:2075: error: invalid conversion from 'int' to
'_zend_function*'
make[1]: *** [php4_cpp] Error 1
make[1]: Leaving directory `/usr/src/swig-1.3.35/Examples/php4/shadow'
make: *** [all] Error 2
All the other examples I have tried to compile work fine.
Unfortunately I am not gcc expert and I cannot track down the problem.
It seems that as the wrapper code is produced by swig then the problem
must lie there somewhere.
All this being said what I really need to do is access a c++ class /
structure via a pointer. I can see that php can get a resource in this
way but I could not see how to get php to use that resource to access
the fields and methods of the class/structure. It appears from the
shadow example that this can be achieved using the %newobject keyword.
Is this correct?
An further problem that I have noted is missing closing brackets in a
proxy class in php_example.php. Again it appears to be an issue with the
automatically generated code. It occurs in the proxy class for a
structure defined in the c++ header.
Any help or advice on these issues will be most appreciated.
Cheers
Paul Lowman
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user