From 36b81e8cad251a516e39d3b665a49ba91a30c680 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Sat, 2 Feb 2008 12:21:04 +0000 Subject: [PATCH] support [Description (nick = "foo", blurb = "bar")] attribute, based on 2008-02-02 Juerg Billeter * vala/valaproperty.vala, gobject/valaccodegeneratorinterface.vala: support [Description (nick = "foo", blurb = "bar")] attribute, based on patch by Juan Carlos Girardi, fixes part of bug 437434 svn path=/trunk/; revision=948 --- ChangeLog | 6 ++++ gobject/valaccodegeneratorinterface.vala | 4 +-- vala/valaproperty.vala | 48 ++++++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7468d3d..52add52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-02-02 Jürg Billeter + + * vala/valaproperty.vala, gobject/valaccodegeneratorinterface.vala: + support [Description (nick = "foo", blurb = "bar")] attribute, + based on patch by Juan Carlos Girardi, fixes part of bug 437434 + 2008-02-01 Jürg Billeter * vala/parser.y, vala/valaproperty.vala, vala/valasemanticanalyzer.vala: diff --git a/gobject/valaccodegeneratorinterface.vala b/gobject/valaccodegeneratorinterface.vala index bb6c77f..87193f2 100644 --- a/gobject/valaccodegeneratorinterface.vala +++ b/gobject/valaccodegeneratorinterface.vala @@ -96,8 +96,8 @@ public class Vala.CCodeGenerator { private CCodeFunctionCall! get_param_spec (Property! prop) { var cspec = new CCodeFunctionCall (); cspec.add_argument (prop.get_canonical_cconstant ()); - cspec.add_argument (prop.get_canonical_cconstant ()); - cspec.add_argument (prop.get_canonical_cconstant ()); + cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.nick))); + cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb))); if ((prop.type_reference.data_type is Class && ((Class) prop.type_reference.data_type).is_subtype_of (gobject_type)) || prop.type_reference.data_type is Interface) { cspec.call = new CCodeIdentifier ("g_param_spec_object"); cspec.add_argument (new CCodeIdentifier (prop.type_reference.data_type.get_upper_case_cname ("TYPE_"))); diff --git a/vala/valaproperty.vala b/vala/valaproperty.vala index f3e22c8..e5cd95c 100644 --- a/vala/valaproperty.vala +++ b/vala/valaproperty.vala @@ -109,12 +109,39 @@ public class Vala.Property : Member, Lockable { * Specifies the abstract interface property this property implements. */ public Property base_interface_property { get; set; } - + + /** + * Nickname of this property. + */ + public string nick { + get { + if (_nick == null) { + _nick = get_canonical_name (); + } + } + set { _nick = value; } + } + + /** + * The long description of this property. + */ + public string blurb { + get { + if (_blurb == null) { + _blurb = get_canonical_name (); + } + } + set { _blurb = value; } + } + private bool lock_used = false; private DataType _data_type; private bool _instance = true; + private string? _nick; + private string? _blurb; + /** * Creates a new property. * @@ -167,7 +194,11 @@ public class Vala.Property : Member, Lockable { * @return string literal to be used in C code */ public CCodeConstant! get_canonical_cconstant () { - var str = new String ("\""); + return new CCodeConstant ("\"%s\"".printf (get_canonical_name ())); + } + + private string get_canonical_name () { + var str = new String (); string i = name; @@ -182,9 +213,7 @@ public class Vala.Property : Member, Lockable { i = i.next_char (); } - str.append_c ('"'); - - return new CCodeConstant (str.str); + return str.str; } /** @@ -196,7 +225,14 @@ public class Vala.Property : Member, Lockable { notify = true; } else if (a.name == "NoAccessorMethod") { no_accessor_method = true; - } + } else if (a.name == "Description") { + if (a.has_argument ("nick")) { + nick = a.get_string ("nick"); + } + if (a.has_argument ("blurb")) { + blurb = a.get_string ("blurb"); + } + } } } -- 2.7.4