[Vala] bugs




I have seen a glitch on the generated C code and a buggy example on the web.

This is the one provided by the signal example (which doesn't build)

   http://live.gnome.org/Vala/Signals

static gint maman_bar_main (int args_length1, char** args)
{
        MamanBar* bar;
        gint _tmp0;
        bar = g_new0 (MamanBar, 1);
        maman_bar_run (bar);
        return (_tmp0 = 0, (bar == NULL ? NULL : (bar = (maman_bar_free (bar), NULL))), _tmp0);
        (bar == NULL ? NULL : (bar = (maman_bar_free (bar), NULL))); /* <------ CODE AFTER RETURN??? ------ */
}

NOTE: I have created an account on the wiki and fixed the signal example.

The above lines are the steps on my 'investigation' to deduce why the example doesn't
build and how to fix it. It may be useful for someone :) 

$ valac signal.vala 
Compilation succeeded - 0 warning(s)

$ gcc $(pkg-config --cflags --libs gobject-2.0) -o signal signal.c
/tmp/cc2X8UsX.o: In function `maman_bar_run':
signal.c:(.text+0xda): undefined reference to `maman_foo_free'
/tmp/cc2X8UsX.o: In function `maman_bar_main':
signal.c:(.text+0x122): undefined reference to `maman_bar_free'
collect2: ld returned 1 exit status

The maman_{foo|bar}_free functions are not generated by Vala, so the linker can't find the
related symbols.

These methods are not generated because they does not exist Foo and Bar are two classes of
the Maman namespace and they does not implement the free methods.

In tests 018 and 024 there are two signal related examples and the way they fix this is by
make these classes inherit the Object class in this way:

   class Maman.Foo { ...
 into ->
   class Maman.Foo : Object { ...

The example in the wiki shou

I have tested the use of 'class Maman.Foo' vs 'namespace Maman; class Foo' and looks like
the C generated code is exactly the same. So I understand that both codes are equivalent.

Maybe that's new to me, because I'm a c# ignorant O:)

 
  --pancake



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