« Return to Thread: swig and php

Re: swig and php

by Paul Lowman :: Rate this Message:

Reply to Author | View in Thread

Olly Betts wrote:

> On 2008-05-06, Paul Lowman <paul_lowman@...> wrote:
>> Olly Betts wrote:
>>> On 2008-05-05, Paul Lowman <paul_lowman@...> wrote:
>> 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;
>> }
>> }
>
> Well, it is wrapping the resource with the appropriate PHP class wrapper
> (Circle in this case).  I'm not sure that the is_resource() check is
> required in this case - I don't exactly remember why that's there.
>
> It does look like it might just call itself though.  Does this code
> work?
>
>> If I uncomment the %newobject line then I get no reference to the circle
>> factory at all.
>
> I guess that's the nub of the issue then.  I don't know quite how
> newobject works internally but it certainly shouldn't suppress the
> wrapper method entirely!
>
>> I assume I am not putting something in the .i file that needs to be there.
>
> No, I think it's probably a code generation bug in the PHP backend.
> Probably just an incorrect assumption on my part.
>
> I'm planning to switch the test suite over to testing PHP5 rather than
> PHP4 in the nearish future, and then I'll work through to fix any
> failing cases such as this one.  Patches are certainly welcome if
> you can figure out where the problem is (almost certainly somewhere
> in the (increasingly misnamed) Source/Modules/php4.cxx).
>
> 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
>
Olly

The code complains when it is run that a non object is being accessed -
so it would seem that php5 does not know about the class returned by the
factory method. Here is a snippet of code being used -

<?php

# This file illustrates the low-level C++ interface
# 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";
$c = CircleFactory(10);
print "    Created circle $c with area ". $c->area() ."\n";
..
..

It complains about $c->area ...

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

 « Return to Thread: swig and php