If I use SWIG to port this C ++ function:
boost::shared_ptr<Client> Client::create() { return boost::shared_ptr<Client>(new Client()); }
And then name it in PHP:
$client = Client::create(); echo gettype($client);
The $client type is resource , not object , so I cannot call Client methods.
What are my options for wrapping this feature? I am creating a PHP shell for another C ++ library, so reworking the code so as not to use boost::shared_ptr is actually not an option.
This is the only solution I've come up with so far:
MyClient Client::createObject() { return *Client::create(); }
And calling it in PHP:
$client = Client::createObject(); echo gettype($client);
Now the type of $client is equal to object , and I can call it Client . Is this a smart decision? If not, what should I do?
source share