cspec.call = new CCodeIdentifier ("g_param_spec_int");
cspec.add_argument (new CCodeConstant ("G_MININT"));
cspec.add_argument (new CCodeConstant ("G_MAXINT"));
- cspec.add_argument (new CCodeConstant ("0"));
+ if (prop.default_expression != null) {
+ cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+ } else {
+ cspec.add_argument (new CCodeConstant ("0"));
+ }
} else if (prop.type_reference.data_type == uint_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_uint");
cspec.add_argument (new CCodeConstant ("0"));
cspec.add_argument (new CCodeConstant ("G_MAXUINT"));
- cspec.add_argument (new CCodeConstant ("0U"));
+ if (prop.default_expression != null) {
+ cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+ } else {
+ cspec.add_argument (new CCodeConstant ("0U"));
+ }
} else if (prop.type_reference.data_type == long_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_long");
cspec.add_argument (new CCodeConstant ("G_MINLONG"));
cspec.add_argument (new CCodeConstant ("G_MAXLONG"));
- cspec.add_argument (new CCodeConstant ("0L"));
+ if (prop.default_expression != null) {
+ cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+ } else {
+ cspec.add_argument (new CCodeConstant ("0L"));
+ }
} else if (prop.type_reference.data_type == ulong_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_ulong");
cspec.add_argument (new CCodeConstant ("0"));
cspec.add_argument (new CCodeConstant ("G_MAXULONG"));
- cspec.add_argument (new CCodeConstant ("0UL"));
+ if (prop.default_expression != null) {
+ cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+ } else {
+ cspec.add_argument (new CCodeConstant ("0UL"));
+ }
} else if (prop.type_reference.data_type == bool_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_boolean");
- cspec.add_argument (new CCodeConstant ("FALSE"));
+ if (prop.default_expression != null) {
+ cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+ } else {
+ cspec.add_argument (new CCodeConstant ("FALSE"));
+ }
} else if (prop.type_reference.data_type == float_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_float");
cspec.add_argument (new CCodeConstant ("-G_MAXFLOAT"));
cspec.add_argument (new CCodeConstant ("G_MAXFLOAT"));
- cspec.add_argument (new CCodeConstant ("0.0F"));
+ if (prop.default_expression != null) {
+ cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+ } else {
+ cspec.add_argument (new CCodeConstant ("0.0F"));
+ }
} else if (prop.type_reference.data_type == double_type.data_type) {
cspec.call = new CCodeIdentifier ("g_param_spec_double");
cspec.add_argument (new CCodeConstant ("-G_MAXDOUBLE"));
cspec.add_argument (new CCodeConstant ("G_MAXDOUBLE"));
- cspec.add_argument (new CCodeConstant ("0.0"));
+ if (prop.default_expression != null) {
+ cspec.add_argument ((CCodeExpression) prop.default_expression.ccodenode);
+ } else {
+ cspec.add_argument (new CCodeConstant ("0.0"));
+ }
} else {
cspec.call = new CCodeIdentifier ("g_param_spec_pointer");
}
%type <property_accessor> get_accessor_declaration
%type <property_accessor> opt_set_accessor_declaration
%type <property_accessor> set_accessor_declaration
+%type <expression> opt_default_value
+%type <expression> default_value
%type <constant> constant_declaration
%type <field> field_declaration
%type <list> variable_declarators
;
property_declaration
- : comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_BRACE get_accessor_declaration opt_set_accessor_declaration CLOSE_BRACE
+ : comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_BRACE get_accessor_declaration opt_set_accessor_declaration opt_default_value CLOSE_BRACE
{
ValaSourceReference *src;
g_object_unref ($9);
}
+ if ($10 != NULL) {
+ vala_property_set_default_expression ($$, $10);
+ g_object_unref ($10);
+ }
+
if (($4 & VALA_MODIFIER_ABSTRACT) == VALA_MODIFIER_ABSTRACT) {
vala_property_set_is_abstract ($$, TRUE);
}
vala_property_set_instance ($$, FALSE);
}
}
- | comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_BRACE set_accessor_declaration opt_get_accessor_declaration CLOSE_BRACE
+ | comment opt_attributes opt_access_modifier opt_modifiers type identifier OPEN_BRACE set_accessor_declaration opt_get_accessor_declaration opt_default_value CLOSE_BRACE
{
ValaSourceReference *src;
g_object_unref ($9);
}
+ if ($10 != NULL) {
+ vala_property_set_default_expression ($$, $10);
+ g_object_unref ($10);
+ }
+
if (($4 & VALA_MODIFIER_ABSTRACT) == VALA_MODIFIER_ABSTRACT) {
vala_property_set_is_abstract ($$, TRUE);
}
}
;
+opt_default_value
+ : /* empty */
+ {
+ $$ = NULL;
+ }
+ | default_value
+ ;
+
+default_value
+ : DEFAULT OPEN_PARENS expression CLOSE_PARENS SEMICOLON
+ {
+ $$ = $3;
+ }
+ ;
+
signal_declaration
: comment opt_attributes opt_access_modifier SIGNAL type identifier OPEN_PARENS opt_formal_parameter_list CLOSE_PARENS SEMICOLON
{