The subject function takes a GncOwner as an argument, modifies it and
returns the result through the argument. It's not clear how to create a
Swig INOUT map for a non-primitive type. So, I wrote a wrapper to
return the result in a normal way and indicate an error with a NULL
return. The wrapper allocates the owner with gncOwnerNew() and returns
a Python object of type GncOwner.

However, I need an object of type Customer, Job,... based on the owner
type. So, on the Python side, I get the type from the instance and
create an object of the correct type such as Vendor via
Vendor(instance=instance). 

This works and I'm able to extract the vendor address and other data I
need.

It's not clear how to free the owner object allocated by the wrapper. A
call to gncOwnerFree fails in the IN typemap because the Swig pointer
type didn't match one of the 4 alternatives. I added a
SWIG_ConvertPtr() for GncOwner, but got the same "couldn't convert"
message. It's not clear how to inspect the Swig pointer type to see why
it's complaining.

This all seems overly complicated. Is there a better approach?

Also, any advice on how to not leak GncOwner.

Thanks,

Steve



_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to