> From: "mar...@saepia.net" <mar...@saepia.net> >Sent: Wednesday, 2 March 2016, 16:08 >Subject: Re: [Vala] How to properly define struct in manually written VAPI? > >thank you for suggestions. I'll try to implement them. > >But should I keep it as struct or rather compact class?
As a struct. A compact class in Vala is used to bind a set of function calls that operate on a struct, the struct being the instance data. For a compact class Vala will automatically generate the first parameter of the function call to be a struct of the right type to pass the instance data. > >Regarding json-glib: I intentionally try to avoid it. I was able to make >segfault even with a few simple attempts that should be tested in properly >written library, I don't need mapping for GObject properties, and I think I >encountered also some issues with big integers, I don't remember now. In my >use case more low level, better-tested library will a be better choice. json-glib is perfectly stable for the uses I'm putting it to. I remember it took a while to get used to the API. Here's an example that prints out a JSON array in JSON. The format is: { "script" : [] } It is in Genie, so meaningful whitespace and types are after identifiers: def print_script( script:Json.Node ) print "about to create JSON generator" var test = new Json.Generator test.set_pretty( true ) print "about to create root node" var root = new Json.Node( Json.NodeType.OBJECT ) print "about to create script object" var script_object = new Json.Object print "about to set script member" script_object.set_member( "script", script ) print "about to add script object to root node" root.set_object( script_object ) print "about to set root" test.set_root( root ) length:size_t print "about to print JSON" print test.to_data( out length ) Regards, Al _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list