r14663 - gnucash/branches/swigify/src/business - The arguments that point to structs defined in the same module as the
warlord at MIT.EDU
Tue Aug 15 10:41:59 EDT 2006
Chris Shoemaker <c.shoemaker at cox.net> writes:
> On Mon, Aug 14, 2006 at 01:23:20PM -0400, Derek Atkins wrote:
>> Chris Shoemaker <chris at cvs.gnucash.org> writes:
>> > The arguments that point to structs defined in the same module as the
>> > function being wrapped are typed as taking a pointer to the "real" struct,
>> > not the "public" typedef'd name of the struct. If functions in other
>> > modules use the same pointer arguments, and SWIG isn't told about the
>> > typedef to the struct, then these wrappers will be typed with an
>> > incompatible generic pointer type with the public type name.
>> > This commit resolves this by 1) using SWIG's %import directive to see the
>> > typedef to the struct name, 2) associated -Imodule lines in Makefile.am,
>> > 3) using the mangled form of the real struct name anywhere we need a
>> > runtime type query. Got it?
>> So basically what you're saying is that with SWIG you can't use
>> the public typedef name? That seems... Wrong.
> I'm not 100% sure about this stuff, but I _think_ the wrappers have to
> use the same type name "inside" the module as "outside". By default,
> swig seems to resolve the typedef to the real structure type inside
> the module, therefore I guess we have to use that name outside as
> well. There might be some way to cause swig to use the public typedef
> name even inside the module, but I don't know how.
> Oh, wait a sec, I think maybe you can use a less-exact string for the
> type-query and it does a more exhaustive search, but using the precise
> name of the resolved struct type works faster.
> Feel free to test out better approaches.
Yeah, looking at the Typemaps doc it looks like it will go down to the
base type and work upwards through typedefs.. This is.. annoying..
but looks like it will work. So, yeah, it might be a bit slower but I
still think you should use the Typedef name in all places instead of
using the struct name.
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord at MIT.EDU PGP key available
More information about the gnucash-devel