Re: [Vala] GScanner in glib.vapi busted (Re: Parsing with Vala)

On Tue, 2009-10-20 at 19:33 +0200, Xavier Bestel wrote:
On Sun, 2009-10-18 at 23:00 +0200, Xavier Bestel wrote:
Le dimanche 18 octobre 2009 à 19:26 +0100, Abderrahim Kitouni a écrit :
You might want to look at GScanner, I haven't used it myself, but it
seems to be exactly what you want.

That looks effectively exactely like I want.

Except the vapi file doesn't work.
Here are my changes:

--- /usr/share/vala/vapi/glib-2.0.vapi.orig     2009-10-20 19:22:51.000000000 +0200
+++ /usr/share/vala/vapi/glib-2.0.vapi  2009-10-20 19:29:03.000000000 +0200
@@ -2125,13 +2125,17 @@
                public TokenValue next_value;
                public uint next_line;
                public uint next_position;
-               public Scanner (ScannerConfig? config_templ);
+               public Scanner (ScannerConfig? config_templ = null);
                public void input_file (int input_fd);
                public void sync_file_offset ();
                public void input_text (string text, uint text_len);
                public TokenType peek_next_token ();
                public TokenType get_next_token ();
                public bool eof ();
+               public int cur_line ();
+               public int cur_position ();
+               public TokenType cur_token ();
+               public TokenValue cur_value ();
                public uint set_scope (uint scope_id);
                public void scope_add_symbol (uint scope_id, string symbol, void* value);
                public void scope_foreach_symbol (uint scope_id, HFunc func);

But even with that I still have a problem: TokenValue is a simple enum,
tagged with [SimpleType] in the vapi file, but Vala inserts a
(non-existing) g_token_value_destroy() and of course fails at link-time.

Could someone knowledgeable show me how to fix the vapi ?

So, I've added [CCode (destroy_function = "")] which makes it work, but
by pure luck: now the code generator inserts an "(&val)" into the code
(i.e. it tries to destroy the value with an empty function name).
That's ugly.

I think it comes from the fact that TokenValue is actually an union, but
Vala has no concept of union (even for foreign code) it it's declared as
a struct in the vapi, which it tries to destroy after use.

Is there some documentation about the code attributes somewhere ? I'd
like to fix it myself but I need some pointers.



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