From: Teruhiko K. <Ku...@ba...> - 2007-01-24 19:16:14
|
I have a C++ method that obtain an object as a pointer to it, which has this signature: bool Foo::GetBar(Bar *&barp); In C++, this is used as: Foo *foop =3D new Foo(); Bar *barp; if(foop->GetBar(barp)){ .... ;barp->someMethod()} I would like to use Swig so that I could do the same from PHP5, probably like: $foo =3D new Foo(); if($foo -> GetBar($bar)){ ... ;$bar->someMethod(); ...} To achive this, I wrote the Swig interface file as: %include phppointers.i %nodefaultctor Bar; class Bar { public: int someMethod(); } class Foo { public: bool GetBar(Bar *REF); } The generated wrapper files compiled and linked OK. But when I tried to use it PHP says: Fatal error: Call to a member function someMethod() on a non-object in /.../reftest-run.php on line 6 where the offending line is: $foo =3D new Foo(); // line 4 $foo->GetBar($bar); // line 5 echo "The value is " . $bar->someMethod();=20 In Swig manual section 27.2.5 talks about references but only about simple types. Is passing a reference to a class object supported by Swig for PHP5? -kuro =20 |