Re: [gdome]Re: reference counting again



On Fri, 14 Jun 2002, Chaoron wrote:
> That's the cause I think returning with a new reference in appendChild 
> like functions are unnecessary and make it hard to read and/or debug 
> the C code.

We don't have the freedom to decide that appendChild should return void
(or whatever) since libgdome is supposed to be a DOM implementation, and
the DOM recommendation specifies it like it is now implemented.

> For example GTK has reference counting, but object query 
> functions do not make another reference,

So you want to decide which DOM methods are "object query functions" and
which are not?

No, thank you, but please don't. I once read on this mailing list that
libgdome was created with the intention of creating bindings for other
languages easily. The fact that libgdome obeyes the DOM standard, and
that you can treat all returned DOM objects uniformly, is a great help, it
enables automatic binding creation.

> instead you should use 
> g_object_ref() on returned object if you really want to hold that 
> reference.

There is another problem here. Methods might create new objects that are
not referenced by other parts of the problem yet. Gtk has the "floating"
concept for these -- you don't need to ref or unref them, but you are
supposed to add them to a container if you don't.

> And it's very easy to automaticaly increase reference
> count in language bindings with gdome_n_ref(). This could be done by 
> modifying gdome_xml_n_mkref() to only create Gdome_xml_Node if it not 
> already exists. But it's just an idea, too many programs would be
> concerned.

If you are put off by all the explicit reference counting, then there are
2 options for you: either use libgdome with a smarter language than C (but
since this was proposed several times before, I deduce that you have to
write your program in C because of some reason), or decide that libgdome
is not the right tool for your needs.

I wonder why you want to use DOM in a C program anyway -- it does not even
look like DOM when you use it. Do you need something that libxml does not
provide? DOM is far from being the best possible XML API anyway.

Bye,
  Tobias






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]