|
From: SourceForge.net <no...@so...> - 2009-08-17 08:50:27
|
Bugs item #2549217, was opened at 2009-01-30 14:16 Message generated for change (Comment added) made by olly You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2549217&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: php Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Barry Cohen (barrycohen) Assigned to: Olly Betts (olly) Summary: Cannot access struct object within struct Initial Comment: Using SWIG 1.3.37, it doesn't seem to be possible to get access to a non-primitive object declared within a struct/class. Consider the following: struct bar { int get4() { return 4; } }; struct foo { bar a; }; >From PHP, I would expect to be able to do: $myfoo = new foo(); printf($myfoo->{"a"}->get4() . "\n"); but the error is: PHP Fatal error: Call to a member function get4() on a non-object $myfoo->{"a"} returns a resource instead of an object. Perhaps this is a problem with my PHP syntax, but this process works as expected in Python and PHP. Is it possible to access the get4() function through foo? A complete example is attached. Thanks Barry ---------------------------------------------------------------------- >Comment By: Olly Betts (olly) Date: 2009-08-17 09:50 Message: Fixed in trunk r11619. I need to remove the attempts to print objects from your example (that won't work without defining a __toString() method), but then it passes with this change. ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2009-06-30 14:44 Message: Kevin's no longer active in SWIG so reassigning to myself. I don't know about $myfoo->{"a"}, but we document this should be usable as $myfoo->a and I bet that doesn't currently work as we don't check for a resource and wrap it in the __get() method we generate.gets wrapped. What's missing is the check for a resource and returning it wrapped in a PHP5 object, as happens for a method returning a class. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2549217&group_id=1645 |