From: Paul M. <p.e...@ru...> - 2006-09-06 08:15:48
|
Jason Stewart wrote: >Hey, > >Python has a 'package' option that can be specified as part of the >%module() directive. Try as I can, I can't find any documentation for >it - no examples in the test suite, etc. Seems that all it does is >import the current classes into the namespace given by the option... > > See section 29.11 of swig's python module docs. It's pretty short though Paul >There was a request for something similar on the list about two weeks >ago - how to break up a large module into smaller sub-modules but have >the namespaces work as if it was still a single large module. > >Well, after many years of frustration, the Xerces code is getting too >big to handle as a single module, so I am breaking it up into smaller >chunks - and it's working!!! > >But... > >There is a lot of legacy code out there using the old XML::Xerces >namespace. If I suddenly have a bunch of classes under >XML::Xerces::DOM - it will break a lot of code... So I want all the >sub-modules to put they're classes into the top-level XML::Xerces >namespace, not XML::Xerces::DOM or XML::Xerces::Handler, etc. > >Unfortunately there is no simple workaround like > > from XML.Xerces.DOM import *; > >I *can* copy over the Perl symbol tables: > > foreach $class (keys %XML::Xerces::DOM::) { > %XML::Xerces::$class = %XML::Xerces::DOM::$class; > } > >That succeeds in providing all the classes and class methods - but the >types will be different. Any test code that does this: > > $parser = XML::Xerces::XercesDOMParser->new(); > isa_ok($parser, 'XML::Xerces::XercesDOMParser'); > >will fail because $parser isa 'XML::Xerces::DOM::XercesDOMParser' >because all the type information is set in the C++ shadow class. > >This is *bad* because there is code that needs to check class info at >runtime - not much, but certainly *all* the regression tests. > >Proposal >== >To eliminate this, I wanted to add the 'package' option for Perl. If >specified, 'package' tells SWIG into what namespace all the classes >should be written. > >So for my example: > > %module(package="XML::Xerces") "DOM"; > >The module will be DOM.pm, but all the code will be in the XML::Xerces >namespace. > >Questions >== > >1) Is this how Python uses the 'package' option? > >2) Does this seem reasonable? > >Cheers, jas. > >------------------------------------------------------------------------- >Using Tomcat but need to do more? Need to support web services, security? >Get stuff done quickly with pre-integrated technology to make your job easier >Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >_______________________________________________ >Swig-devel mailing list >Swi...@li... >https://lists.sourceforge.net/lists/listinfo/swig-devel > > -- Paul Melis VR Specialist, Center for High-Performance Computing & Visualization, University of Groningen, The Netherlands T: +31 50 363 9298 E: p.e...@ru... W: http://www.rug.nl/rc/hpcv/index |