https://wiki.gnome.org/Projects/Vala/PropertiesSample

perhaps this is outdated?


On Mon, Jun 9, 2014 at 3:09 PM, Luca Bruno <[email protected]> wrote:

> Sorry, where did you read that in the documentation?
>
>
> On Mon, Jun 9, 2014 at 9:06 PM, Brian Grooman <[email protected]>
> wrote:
>
>> I just figured out the problem a few hours ago.
>>
>> The documentation recommends declaring properties in two parts, the value
>> and the getter/setter block.  so, for example:
>>
>> int _myvalue;
>>
>> public int myvalue{get; set;}
>>
>> The leading underscore on the int is there to prevent a naming conflict.
>>
>> I'm using vala to rewrite existing C code with gobjects.  I did not want
>> to rename the variables, so I instead put the underscore in front of the
>> getter/setter block, as so:
>>
>> int myvalue;
>>
>> public int _myvalue{get; set;}
>>
>> I guess valac didn't like that.  It would skip generating much of the
>> code.  Anyway, i found that you don't need to declare the variable at all:
>>
>> public int myvalue{get; set;}
>>
>> works just fine by itself.  A stupid mistake on my part.
>>
>>
>>
>> On Mon, Jun 9, 2014 at 2:49 PM, Luca Bruno <[email protected]> wrote:
>>
>>> Sorry I've read your post several times, but I don't understand what
>>> Vala generated code is missing. Can you please provide vala code and say
>>> what the generated C code is missing?
>>>
>>>
>>> On Fri, Jun 6, 2014 at 6:19 PM, Brian <[email protected]> wrote:
>>>
>>>> Hi all,
>>>> I've searched high and low for some information, but have been unable
>>>> to find
>>>> any on this particular situation.
>>>>
>>>> Hand coding GObjects in C allows for one get and one set function that
>>>> take
>>>> property id as an input. For example:
>>>>
>>>> object_set_property (GObject * object, guint property_id, Gvalue,
>>>> GParamSpec);
>>>>
>>>> And then a switch case statement inside the set function uses the
>>>> property_id
>>>> to decide which property to set. the property_id values are defined
>>>> with an
>>>> enum.
>>>>
>>>> When coding GObjects in vala, however, each property is given its own
>>>> get and
>>>> set function in the C code.  The funny thing is I still see a property
>>>> value
>>>> enum (that does not get filled out), as well as the generic get and set
>>>> functions with empty (default only) switch case statements.
>>>>
>>>> I already have gobject bindings that use the generic get/set functions.
>>>> I'd
>>>> rather not have to edit the vala-generated C code to use them.
>>>>
>>>> My question is, is there a way to get vala to automatically generate the
>>>> enums, and switch case statements? If not, is there a recommended
>>>> approach?
>>>>
>>>> I love the idea of not having to write all the GObject boilerplate and
>>>> writing
>>>> in vala rather than C. I really hope that I'm just missing something.
>>>> Any help
>>>> or ideas are much appreciated.
>>>>
>>>> Brian
>>>>
>>>> _______________________________________________
>>>> vala-list mailing list
>>>> [email protected]
>>>> https://mail.gnome.org/mailman/listinfo/vala-list
>>>>
>>>
>>>
>>>
>>> --
>>> www.debian.org - The Universal Operating System
>>>
>>
>>
>
>
> --
> www.debian.org - The Universal Operating System
>
_______________________________________________
vala-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to