Re: [Vala] Looking for some general information on Vala's capabilities



Hi Quinn,

On Die, 2007-04-10 at 23:12 -0400, Quinn Storm wrote:
I recently decided to convert a project I am working on from weak polymorphism 
with structs and unions to full GObject, and I'm wondering...there are 
projects like Vala out there, and I don't know for sure if they'd be for 
me...specifically, I want to easily be able to do straight C and more complex 
things in the code, as I have to do some low-level X calls (for event 
forwarding to XEmbed clients).

If you are curious, gitweb can be browsed for the project at:
http://metascape.afraid.org:13666/link/gitweb/?p=bdock

I'd love to know if Vala could do what I want here, because I do like the 
straight C and gobject/gtk approach (at least better than QT/C++) but gobject 
is such a pain to write out by hand, and I would rather use the best tools 
available.

You can't use normal C code within a Vala source file but there are two
possibilities to use Vala in your project:

      * Write a Vala API file (binding) for the X libraries, so that you
        don't need to write C code at all. That's not very complicated
        usually but may be laborious if you need a large set of
        functions or structs. You can look at the files in the vapi
        folder of vala to see some examples.I'm not sure but it might be
        possible to generate VAPI files for xcb relatively easy as large
        parts of xcb are generated from protocol information files.
      * Only write the class structure and some unproblematic code parts
        in Vala and write the rest in C. If you don't specify a method
        body in a Vala source file, it just writes the declaration in a
        C header file, so you can write the implementation in a separate
        C file.

I'd recommend the first solution if that's possible for your project as
you wouldn't have to mix Vala and C code.

Don't hesitate to post further questions and comments, I'd like to make
integration with C code as smooth as possible.

Jürg




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