Questions about GObjectification in GnuCash
Derek Atkins
warlord at MIT.EDU
Fri Jun 1 13:12:03 EDT 2007
Quoting David Hampton <david at dhampton.net>:
> On Fri, 2007-06-01 at 12:05 -0400, Derek Atkins wrote:
>
>> > Does any one know why QofInstance's functions use gpointer instead of
>> > QofInstance* ?
>>
>> Um, probably because they haven't been fixed, yet? Yes, they
>> should use QofInstance.
>
> The changes I committed were designed after functions like
> g_object_get/set/ref/unref that uses the gpointer style of argument
> passing. It made more sense to me, as using a QofInstance parameter
> would require casing on every single call to these functions cluttering
> up the code, and the casting does absolutely nothing at compile time
> except disable compiler checking, same as using a gpointer argument.
> The real checks to insure the argument is correct happen at runtime when
> the arguments are checked inside of the functions with a call to
> QOF_IS_INSTANCE().
True.. But if the API asked for a QofInstance* then:
a) users of the API would know what's expected
b) users of the API could use the QOF_INSTANCE() macros to cast
c) we can get a runtime cast failure in the caller instead of the callee
Not a huge deal, but seeing the failure in the caller might make it a
tiny bit easier to debug. And the self-documentation of the API taking
a QofInstance* might reduce potential mistakes.
>> > What about string based type system?
>>
>> EVENTUALLY we might want to change this, but again this is
>> something that doesn't have to change right away. Right now
>> there's a duplication here, there's the string type name and
>> the GObject type name/number. We would need to change the way
>> we define types in QOF before we could completely get rid of
>> the string types.
>
> I've looked at this, and its embedded quite deeply in the code. It can
> probably be removed, but it will be tedious work. I though the effort
> too much to do before the release of 2.2.
Yeah, it is embedded quite deeply. I conflated these pretty badly
in the original qof work years and years ago.
> David
-derek
--
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
mailing list