[Vala] Hello and some questions!



Hi!

I'm Andrea, I found Vala few days ago and it looks very interesting. I'm
still in the process of learning it so forgive me for any *imprecision*
that I can write.
During my tests I manage to use a callback function, it works, but the C
compiler give me a warning (invalid cast or something similar). So I
tried to explicitly cast my function with the callback type and valac
(svn revision 137) gives me a segmentation fault *during* compilation. 
I reduced my program to this code snippet to isolate the problem:

using GLib;

namespace test
{
        public callback void ExampleCallback();

        public static void SetCallBack(ExampleCallback cb)
        {
        }

        public static void MyCallback()
        {
        }

        static int main(string[] args)
        {
                /* this cast cause a segmentation fault 
                   during compilation */
                SetCallBack((ExampleCallback) MyCallback);
                /* without the cast the compilation is OK
                        SetCallBack(MyCallback);
                */
                return 0;
        }
}

Second question. If I "wrap" this *interface* (taken from GStreamer
header) with this vala code:

        [CCode (cname="GstXOverlay", type_id="GST_X_OVERLAY")]  
        [ReferenceType()]
        /* 
         * Even if XOverlay is an interface, I must define it like a vala
struct
         */
        public struct XOverlay
        {
                [CCode (cname="gst_x_overlay_set_xwindow_id")]
                public void set_xwindow_id(ulong xwindow_id);
        }

Everythig compile fine, but if I try with the more appropriate keyword
"interface" (GstXOverlay is a GObject interface) the generated C code of
for this vala line:
        ((XOverlay)message.src).set_xwindow_id(test.anid);

will be something like:

gst_x_overlay_set_xwindow_id (GST_XOVERLAY(message->src), test->anid);

but GST_XOVERLAY(...) is not defined in gst.h, GST_X_OVERLAY(...) is!

Ok that's all for now.
Bye
Andrea

P.S.
Sorry for my english ;)




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