Thank you for your email and for the pointers to the documents. I have been
actively using swig after the last four days to generate Common Lisp
(Clozure CL) wrappers for a large compiler project, including several
thousand C++ methods and several hundred C++ classes, and I am actually
quite impressed with it. I've only had to make a few additional small
adjustments to cffi.cxx in order to get things to build and test cleanly,
mostly in the department of handling numeric literals. So my impression is,
the CFFI swig interface may have not received alot of love lately, but it is
very useful (a huge time saver!) even if somewhat imperfect. I'd be happy
to add the test-suite and runtime tests to keep it going. I agree that
runtime tests are quite necessary, I find them hugely useful in development.
It's good to know the state things, and I concur with your idea that it is
reasonable to make structs-as-classes the default. So my plan is: I'll try
to develop 'simple' and 'class' examples along the guidelines that you
suggest. I may need to ping you once or twice for advice on how to integrate
them properly, but I don't foresee any big difficulties. I'll let you know
how it goes.
Jason E. Aten, Ph.D.
On Fri, Apr 1, 2011 at 2:42 PM, William S Fulton <wsf@...:
> On 30/03/11 15:50, Jason E. Aten wrote:
>> Dear SWIG developers,
>> I've added a small feature to the CFFI module. Since I'm not familiar
>> with the swig distribution makefile and test/example configuration
>> framework, nor with the policies for additions, I'd like to quickly
>> describe what's been done and ask for advice on how to proceed in order
>> to add it to the swig distribution.
>> Thank you.
>> Best regards,
>> Jason E. Aten, Ph.D.
>> Summary: -structs-as-classes addition to the CFFI module
>> scope: This addition effects only "swig -c++ -cffi example.i"
>> invocations, and is backwards compatible. Specically, the existing
>> "swig -c++ -cffi example.i" behavior is unchanged unless one
>> specifically invokes "swig -c++ -cffi -structs-as-classes example.i"
>> what it is: Starting from the most recent svn (as of this writing)
>> r12570, I added an option to one existing file, Source/Modules/cffi.cxx,
>> to add the feature. I added an Examples/ set of files to demonstrate its
>> why it was needed: The CFFI module previously treated C++ structs
>> differently from C++ classes. In particular, structs with methods (all
>> public classes) did not get method wrappers generated for them by SWIG.
>> This made it problematic to access methods defined within C++ structs.
>> feature added: The patch below adds an option to use the same method and
>> value wrapping that is used for classes, likewise for structs. This
>> results is the same nice CLOS (lisp) wrapper classes for C++ structs
>> that are already generated by SWIG for C++ classes.
>> what was done: a small modification to Source/Modules/cffi.cxx was made
>> to add an -structs-as-classes option to the -cffi module. This option is
>> optional, meaning that the change is fully backwards compatible with pre
>> swig 2.0.4 usage of -c++ -cffi invocations/
>> examples/tests included: I wrote a small example/test case and made a
>> cffi directory under Examples for it. It isn't hooked into the test
>> framework because I didn't know how to do that. Advice or pointers on
>> how (or whehter that's a good idea, given that most people probably
>> won't have a lisp installation) would be appreciated.
>> list of included files:
>> jaten@...$ tar cvf - Examples/cffi
>> Source/Modules/cffi.cxx | bzip2 > feature-addition-for-cffi.tar.bz2
> Hi Jason
> The cffi module hasn't been worked on for 4 years and I don't believe it
> was ever very good. It is one of the modules where the test-suite doesn't
> really work as far as I know so I won't put in any special effort to
> maintain it. If you'd like the patches included, I would first of all
> suggest you remove the -structs-as-classes option and make it the default
> because this module is in a half developed state, I don't think much
> attention should be paid to backwards compatibility. Classes and structs
> should be handled identically, so you're correcting something that should
> have been put in the first place.
> As SWIG has no runtime example anywherer for cffi, yours would be the
> first. This module is badly in need of runtime tests and the minimum
> required is a copy of the 'simple' and 'class' examples, so I suggest you
> turn your example into the 'simple' example. I don't really like to have
> different examples for each language module, unless testing a specific
> language module feature. There isn't a single runtime test and I don't
> accept many patches without a runtime test these days, so you'd need to add
> one in. The test-suite is documented quite well here:
> http://www.swig.org/Doc2.0/Extending.html#Extending_test_suite , but if
> you have any questions please ask. The top level Makefile is currently
> missing cffi test-suite and example support too, so that needs adding in too