Olly Betts wrote:
> On 2008-05-05, Paul Lowman <
paul_lowman@...> wrote:
>> That helped - it now compiles but unless I remove the %newobject line in
>> example.i no code appears in example.php for the factory method. Even
>> then - either way - I get -
>>
>> Fatal error: Call to a member function area() on a non-object in
>> /usr/src/swig-1.3.35/Examples/php4/shadow/runme.php4 on line 13
>>
>> This is the problem I cannot resolve - how do I get php to see the
>> returned resource as an instance of a class?
>
> It needs to be wrapped in the appropriate PHP class (using
> "new MyPHPClass($handle)" IIRC), which should happen automatically
> in the PHP wrapper for CircleFactory().
>
>> This apparently worked OK in php4 so what are the relevent changes?
>
> I guess you mean changes between PHP4 and PHP5 support?
>
> The two work in completely different ways. PHP4 constructs PHP objects
> using the C API. The functions used aren't present in PHP5 (hence the
> zend_property_reference() errors you saw), and the PHP APIs aren't
> well documented so we couldn't see how to fix this. So instead we
> took the approach used in SWIG/Python and wrap the C++ class as a
> set of flat functions which take a resource as the first argument, then
> create a PHP class wrapper which has the resource as a member variable
> and methods which call the flat functions.
>
> If you're able to see what needs fixing (in Source/Modules/php4.cxx
> I imagine) a patch would be great. Otherwise, file a bug and I'll take
> a look when I get a chance.
>
> Cheers,
> Olly
>
>
> -------------------------------------------------------------------------
> 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>
I don't see that code as a wrapper. This is what I see in example.php
abstract class example {
static function CircleFactory($r_) {
$r=CircleFactory($r_);
return is_resource($r) ? new Circle($r) : $r;
}
}
the .i files is -
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
/*%newobject CircleFactory;*/
%include "example.h"
If I uncomment the %newobject line then I get no reference to the circle
factory at all.
I assume I am not putting something in the .i file that needs to be there.
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