// notify on property changes
if (is_gobject_property (prop) &&
- get_ccode_notify (prop) &&
+ prop.notify &&
(acc.writable || acc.construction)) {
var notify_call = new CCodeFunctionCall (new CCodeIdentifier ("g_object_notify"));
notify_call.add_argument (new CCodeCastExpression (new CCodeIdentifier ("self"), "GObject *"));
return get_ccode_attribute(m).sentinel;
}
- public static bool get_ccode_notify (Property prop) {
- return prop.get_attribute_bool ("CCode", "notify", true);
- }
-
- public static string get_ccode_nick (Property prop) {
- var nick = prop.get_attribute_string ("Description", "nick");
- if (nick == null) {
- nick = prop.name.replace ("_", "-");
- }
- return nick;
- }
-
- public static string get_ccode_blurb (Property prop) {
- var blurb = prop.get_attribute_string ("Description", "blurb");
- if (blurb == null) {
- blurb = prop.name.replace ("_", "-");
- }
- return blurb;
- }
-
public CCodeDeclaratorSuffix? get_ccode_declarator_suffix (DataType type) {
var array_type = type as ArrayType;
if (array_type != null) {
public override CCodeFunctionCall get_param_spec (Property prop) {
var cspec = new CCodeFunctionCall ();
cspec.add_argument (get_property_canonical_cconstant (prop));
- var nick = get_ccode_nick (prop);
- var blurb = get_ccode_blurb (prop);
- cspec.add_argument (new CCodeConstant ("\"%s\"".printf (nick)));
- cspec.add_argument (new CCodeConstant ("\"%s\"".printf (blurb)));
+ cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.nick)));
+ cspec.add_argument (new CCodeConstant ("\"%s\"".printf (prop.blurb)));
if (prop.property_type.data_type is Class || prop.property_type.data_type is Interface) {
gir/bug667751.test \
gir/bug742012.test \
annotations/deprecated.vala \
+ annotations/description.vala \
$(NULL)
check-TESTS: $(TESTS)
--- /dev/null
+class Foo : Object {
+ [Description (nick = "foo's nick", blurb = "foo's blurb")]
+ public int foo { get; set; }
+}
+
+void main () {
+ var foo = new Foo ();
+ (unowned ParamSpec)[] properties = foo.get_class ().list_properties ();
+ foreach (unowned ParamSpec p in properties) {
+ assert (p.get_name () == "foo");
+ assert (p.get_nick () == "foo's nick");
+ assert (p.get_blurb () == "foo's blurb");
+ }
+}
*/
public MemberBinding binding { get; set; default = MemberBinding.INSTANCE; }
+ /**
+ * The nick of this property
+ */
+ public string nick {
+ get {
+ if (_nick == null) {
+ _nick = get_attribute_string ("Description", "nick");
+ if (_nick == null) {
+ _nick = name.replace ("_", "-");
+ }
+ }
+ return _nick;
+ }
+ }
+
+ /**
+ * The blurb of this property
+ */
+ public string blurb {
+ get {
+ if (_blurb == null) {
+ _blurb = get_attribute_string ("Description", "blurb");
+ if (_blurb == null) {
+ _blurb = name.replace ("_", "-");
+ }
+ }
+ return _blurb;
+ }
+ }
+
+ /**
+ * Specifies whether this a property triggers a notify.
+ */
+ public bool notify {
+ get {
+ if (_notify == null) {
+ _notify = get_attribute_bool ("CCode", "notify", true);
+ }
+ return _notify;
+ }
+ }
+
/**
* Specifies the virtual or abstract property this property overrides.
* Reference must be weak as virtual properties set base_property to
private bool base_properties_valid;
PropertyAccessor? _get_accessor;
PropertyAccessor? _set_accessor;
+ private string? _nick;
+ private string? _blurb;
+ private bool? _notify;
/**
* Creates a new property.