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

Re: [Vala] GMarkup broken in Vala 0.4.0?



Hi Matias,


It doesn't work if Test is a subclass of Object.


Yu
On Wed, 2008-10-22 at 10:27 -0200, Matías De la Puente wrote:
> Hi Yu
> 
> I patch the glib.vapi changing Markup delegates
> http://bugzilla.gnome.org/show_bug.cgi?id=553282 
> I done that to use "this" inside the method of the class.
> With this you can access the members and function of the class that
> aren't static.
> 
> here is a working example compiled with vala 0.4.0
> 
> public class Test 
> {
>     void start (MarkupParseContext context, string element_name,
> string[] attribute_names, string[] attribute_values)
>     {
>         print ("start " + element_name + "\n");
>     }
>     
>     void end (MarkupParseContext context, string element_name)
>     {
>         print ("end " + element_name + "\n");
>     }
>     
>     void text (MarkupParseContext context, string text, ulong
> text_len)
>     {
>         print ("text " + text + "\n");
>     }
>     
>     public Test ()
>     {
>         MarkupParser parser = {start, end, text, null, null };
>         MarkupParseContext context = new MarkupParseContext (parser,
> MarkupParseFlags.TREAT_CDATA_AS_TEXT, this, null);
>         
>         string xml_file;
>         FileUtils.get_contents ("test.xml", out xml_file);
>         context.parse (xml_file, xml_file.len ());
>     }
>     
>     public static void main (string[] args)
>     {
>         var test = new Test ();
>     }
> }
> 
> Matias



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