Re: [Vala] private fields vs bodyless properties
- From: "Juerg Billeter" <j bitron ch>
- To: "Yu Feng" <rainwoodman gmail com>
- Cc: vala-list <vala-list gnome org>
- Subject: Re: [Vala] private fields vs bodyless properties
- Date: Fri, 30 May 2008 10:46:32 +0200 (CEST)
On Fri, May 30, 2008 10:28, Yu Feng wrote:
On Fri, 2008-05-30 at 06:57 +0200, Jaap A. Haitsma wrote:
The reason for this is that the objects are gobjects and these are
created by a g_object_new call [1]. That function can only set
properties. So you need to have a property if you want to pass data to
your constructor
However the following code is perfectly fine;
MyObject * my_object_new(int my_value){
MyObject * myobject = g_object_new(TYPE_MY_OBJECT, NULL);
MyObjectPrivate * priv = MY_OBJECT_GET_PRIVATE(myobject);
priv->my_value = my_value;
}
(I think I am also using this when writing c programs)
We don't allow this as it will break subclassing, i.e. subclasses can't
assign anything to my_value, and it will also break bindings that call
g_object_new directly.
Juerg
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]