Re: Introspection API

Havoc Pennington wrote:

On Sat, 2005-02-19 at 14:03 +0100, Christian M wrote:
Any particular reason why not xml is used as primary source

* xml -> header
* xml -> metadata compiler -> binary metadata

and use the header parsing program to migrate headers to xml?
Custom stuff could be defined in a separate header file.

XML is a crappy programming language. It's just a lot more convenient to
write code as code.
At the same time, C header files are missing a lot of the information you'd want to include in the metadata. You'll either end up with a lot of ugly comments in the header (for an extreme case, look at something like librpm's headers ...), or have the information separate from the definitions (which can result on them becoming out of date).

Having the C header files generated from a file written in some IDL that can represent all the metadata would mean that the C header only need include things relevant to C, and be fairly clean.

I agree that XML isn't the best language for writing function/method prototypes in, which is why I used the term IDL above (not necessarily referring to OMG IDL, though).
esp. since for a fully-introspectable gtk we'll probably need to declare
certain functions as C-only convenience functions and add similar
functions that are introspectable but annoying to use from C.

That brings up an interesting point: in this case you probably want to
tweak the lang bindings a bit, e.g. take one example we already have of
g_signal_emit vs. g_signal_emitv(), in the binding you probably want to
use emitv() to implement a method called emit()
There are two ways this could go here:

  1. the metadata for the "GObject::emit" method says that it should be
     implemented by calling g_signal_emitv(), and g_signal_emit() is a
     C convenience function (assuming that the metadata can describe a
     function like g_signal_emitv).
  2. or the metadata for "g_signal_emitv()" says it is the
     "GObject::emit" method, and "g_signal_emit()" says it should be
     ignored by language bindings.

Which is chosen depends on whether the information is seen as mapping C functions to an object oriented interface, or the reverse.


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