I'm not sure if its even possible to provide a namespace for global functions registered by PHP modules (regardless of whether they were created by SWIG or not).
But, it should still be possible to use the %nspace directive to assign a namespace to the generated *.php wrapper include file. Currently the %nspace directive seems to do nothing at all in PHP mode (is that correct?).
I can get most of the way with something like: %pragma(php) code="namespace qpid\messaging;"
But, PHP requires namespace statements to be the very first non-comment statement in any given PHP file, but the %pragma(php) code ends up being immediately after the "Try to load our extension if it's not already loaded" code block, causing the include of the wrapper *.php class file to fail.
It seems to me that "%nspace mynamespace" should result in "namespace mynamespace;" being added at the very beginning of the generated *.php class wrapper.
Also, if would be great if the %nspace directive would automatically translate :: and \ separators. For example, "%nspace ns1::n2::n3" should map to "ns1::ns2::ns3" for C#, and "ns1\ns2\ns3" for PHP, and vice versa. That would be great! :) Otherwise, we'd need different %nspace directives for different destination languages.
Log in to post a comment.