diff options
author | Ryan Lortie <desrt@desrt.ca> | 2009-02-16 22:17:18 +0000 |
---|---|---|
committer | Ryan Lortie <ryanl@src.gnome.org> | 2009-02-16 22:17:18 +0000 |
commit | 76af93cfca0cb9cf35c5a144dd59fcc75f80f8cf (patch) | |
tree | 6dd8a4c0cf2102081561985a30ea116563738fe4 /vala | |
parent | 7f0ef39fadb701499ee9a8d00a21b527c0ba0eb8 (diff) | |
download | vala-76af93cfca0cb9cf35c5a144dd59fcc75f80f8cf.tar.gz |
Add support for a 'use_const' CCode attribute and GIDL XML attribute that,
2009-02-17 Ryan Lortie <desrt@desrt.ca>
* gobject/valaccodebasemodule.vala:
* vala/valacodewriter.vala:
* vala/valastruct.vala:
* vapigen/valagidlparser.vala:
Add support for a 'use_const' CCode attribute and GIDL XML attribute
that, when set to false, causes Vala not to emit the 'const' modifier
on structure type input arguments. This is useful for structure types
that, by convention, are not used with const (eg: GtkTreeIter).
* vapi/packages/gtk+-2.0/gtk+-2.0.metadata:
* vapi/gtk+-2.0.vapi:
Add 'use_const' for GtkTreeIter to the gtk+-2.0 metadata. Regenerate
vapi.
svn path=/trunk/; revision=2446
Diffstat (limited to 'vala')
-rw-r--r-- | vala/valacodewriter.vala | 4 | ||||
-rw-r--r-- | vala/valastruct.vala | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index 457b13553..aef68650a 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -285,6 +285,10 @@ public class Vala.CodeWriter : CodeVisitor { write_string ("type_id = \"%s\", ".printf (st.get_type_id ())); } + if (!st.use_const) { + write_string ("use_const = false, "); + } + bool first = true; string cheaders = ""; foreach (string cheader in st.get_cheader_filenames ()) { diff --git a/vala/valastruct.vala b/vala/valastruct.vala index 6962b2938..4d13ac761 100644 --- a/vala/valastruct.vala +++ b/vala/valastruct.vala @@ -81,6 +81,12 @@ public class Vala.Struct : TypeSymbol { public Method default_construction_method { get; set; } /** + * Specifies if 'const' should be emitted for input parameters + * of this type. + */ + public bool use_const { get; set; default = true; } + + /** * Specifies whether this struct has a registered GType. */ public bool has_type_id { get; set; default = true; } @@ -392,6 +398,9 @@ public class Vala.Struct : TypeSymbol { if (a.has_argument ("destroy_function")) { set_destroy_function (a.get_string ("destroy_function")); } + if (a.has_argument ("use_const")) { + use_const = a.get_bool ("use_const"); + } } private void process_boolean_type_attribute (Attribute a) { @@ -720,3 +729,5 @@ public class Vala.Struct : TypeSymbol { return !error; } } + +// vim:sw=8 noet |