From: Josh C. <jc...@nc...> - 2009-08-25 23:53:37
|
On Tue, 25 Aug 2009, Angus McMorland wrote: > 2009/8/25 Josh Cherry <jc...@nc...>: >> You could use %extend to provide a Msg::SetData signature that takes a >> TEST_DATA. You could also use %extend to give TEST_DATA a method that >> returns its size, but the first approach would be more convenient for users. > > Thanks Josh, > > One issue I didn't make clear is that there are potentially hundreds > of different types of structures that we would want to feed into > SetData, with different contents, so any method would have to either > be able to handle them all generically, or automatically generatable > from the protocol's C++ header files. It sounds a bit like your > solution would be specific to TEST_DATA, or is there a way to make > this multi-purpose? It would, as you say, be specific to TEST_DATA. I don't know of a simple way to do this, e.g., a way to apply an %extend to every class. Macros could make your life easier, but I understand that you don't want to do this manually for hundreds of structures. One possibility is to write a script that uses SWIG's output to obtain a list of all classes in your module and generates the desired %extend's automatically. You could use xml output for this, or just use the generated .py file (essentially grep it for '^class ', throw away some matches, and extract the class names, or import it into Python and do some computations). I do something like this as part of the build process for my interface. Josh |