From: Nitro <ni...@dr...> - 2007-10-16 09:14:38
|
Am 16.10.2007, 02:12 Uhr, schrieb Christopher Barker <Chr...@no...>: > David Piepgrass wrote: > >> I can think of a couple of possible changes to SWIG that would solve my >> enum problem, but if I'm the only one that needs to trim off enum >> prefixes then I really shouldn't bother you with them. > > Well, for what it's worth, this kind of thing come up when attempting to > write 'Pythonic" bindings. Python makes extensive use of namespaces, and > it sure feels stupid to be typing things like: > > import wx > > ... wx.wxWindow ... > > So, for that example, the wxPython bindings strip the "wx" off most of > the names. I don't know if Robin Dunn came up with any trickery for > enums, but you might want to see what he has done. > > Anyway having SWIG support this kind of name simplification out of the > box would be nice! Swig does support things like that. Personally I use a 2-phase parsing setup. The first stage uses -xml then I parse the output and strip off the prefixes, generate a Renames.i file and then parse again with that renames.i file included. Gives me the proper names for everything. The main downside is that this takes longer and my build system has a little problem with circular dependencies (this problem is related to the build tool really). There is also the fance %rename stuff with regexps that was already discussed here. All this won't do in this case, because of collision problems. As far as I know wxPython doesn't have those and that's why it works in their case. The OP's best bet is probably to use the xml processing part and take the namespace into account somehow. If everything fails he could maybe generate some C# code for the enums directly. -Matthias |