vala r1497 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1497 - in trunk: . gobject vala
- Date: Fri, 30 May 2008 14:59:31 +0000 (UTC)
Author: juergbi
Date: Fri May 30 14:59:31 2008
New Revision: 1497
URL: http://svn.gnome.org/viewvc/vala?rev=1497&view=rev
Log:
2008-05-30 Juerg Billeter <j bitron ch>
* vala/valadynamicmethod.vala:
* vala/valadynamicproperty.vala:
* vala/valasymbol.vala:
* gobject/valaccodedynamicpropertybinding.vala:
Add support for dynamic properties of GObjects
Modified:
trunk/ChangeLog
trunk/gobject/valaccodedynamicpropertybinding.vala
trunk/vala/valadynamicmethod.vala
trunk/vala/valadynamicproperty.vala
trunk/vala/valasymbol.vala
Modified: trunk/gobject/valaccodedynamicpropertybinding.vala
==============================================================================
--- trunk/gobject/valaccodedynamicpropertybinding.vala (original)
+++ trunk/gobject/valaccodedynamicpropertybinding.vala Fri May 30 14:59:31 2008
@@ -53,7 +53,11 @@
func.add_parameter (new CCodeFormalParameter ("obj", dynamic_property.dynamic_type.get_cname ()));
var block = new CCodeBlock ();
- Report.error (node.source_reference, "dynamic properties are not supported for `%s'".printf (dynamic_property.dynamic_type.to_string ()));
+ if (dynamic_property.dynamic_type.data_type == codegen.gobject_type) {
+ generate_gobject_property_getter_wrapper (block);
+ } else {
+ Report.error (node.source_reference, "dynamic properties are not supported for `%s'".printf (dynamic_property.dynamic_type.to_string ()));
+ }
// append to C source file
codegen.source_type_member_declaration.append (func.copy ());
@@ -79,7 +83,11 @@
func.add_parameter (new CCodeFormalParameter ("value", node.property_type.get_cname ()));
var block = new CCodeBlock ();
- Report.error (node.source_reference, "dynamic properties are not supported for `%s'".printf (dynamic_property.dynamic_type.to_string ()));
+ if (dynamic_property.dynamic_type.data_type == codegen.gobject_type) {
+ generate_gobject_property_setter_wrapper (block);
+ } else {
+ Report.error (node.source_reference, "dynamic properties are not supported for `%s'".printf (dynamic_property.dynamic_type.to_string ()));
+ }
// append to C source file
codegen.source_type_member_declaration.append (func.copy ());
@@ -89,4 +97,30 @@
return getter_cname;
}
+
+ void generate_gobject_property_getter_wrapper (CCodeBlock block) {
+ var cdecl = new CCodeDeclaration (node.property_type.get_cname ());
+ cdecl.add_declarator (new CCodeVariableDeclarator ("result"));
+ block.add_statement (cdecl);
+
+ var call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_get"));
+ call.add_argument (new CCodeIdentifier ("obj"));
+ call.add_argument (node.get_canonical_cconstant ());
+ call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("result")));
+ call.add_argument (new CCodeConstant ("NULL"));
+
+ block.add_statement (new CCodeExpressionStatement (call));
+
+ block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("result")));
+ }
+
+ void generate_gobject_property_setter_wrapper (CCodeBlock block) {
+ var call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_set"));
+ call.add_argument (new CCodeIdentifier ("obj"));
+ call.add_argument (node.get_canonical_cconstant ());
+ call.add_argument (new CCodeIdentifier ("value"));
+ call.add_argument (new CCodeConstant ("NULL"));
+
+ block.add_statement (new CCodeExpressionStatement (call));
+ }
}
Modified: trunk/vala/valadynamicmethod.vala
==============================================================================
--- trunk/vala/valadynamicmethod.vala (original)
+++ trunk/vala/valadynamicmethod.vala Fri May 30 14:59:31 2008
@@ -42,7 +42,7 @@
}
public override Gee.List<string> get_cheader_filenames () {
- return new ReadOnlyList<string> ();
+ return new ArrayList<string> ();
}
public override string get_default_cname () {
Modified: trunk/vala/valadynamicproperty.vala
==============================================================================
--- trunk/vala/valadynamicproperty.vala (original)
+++ trunk/vala/valadynamicproperty.vala Fri May 30 14:59:31 2008
@@ -38,7 +38,7 @@
}
public override Gee.List<string> get_cheader_filenames () {
- return new ReadOnlyList<string> ();
+ return new ArrayList<string> ();
}
public override CodeBinding? create_code_binding (CodeGenerator codegen) {
Modified: trunk/vala/valasymbol.vala
==============================================================================
--- trunk/vala/valasymbol.vala (original)
+++ trunk/vala/valasymbol.vala Fri May 30 14:59:31 2008
@@ -192,7 +192,7 @@
* @return list of C header filenames for this symbol
*/
public virtual Gee.List<string> get_cheader_filenames () {
- return new ReadOnlyList<string> ();
+ return new ArrayList<string> ();
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]