diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2016-10-13 09:39:47 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2016-10-18 11:07:29 +0200 |
commit | ad87c4eb227c438a3bcadda9ee9b87aacb77adae (patch) | |
tree | 2a8ea0c35676f2957634bf344ebde81827ff3db4 /ccode | |
parent | f1ddd5a6d201ccb90563e4b46fe500b72841d6f1 (diff) | |
download | vala-ad87c4eb227c438a3bcadda9ee9b87aacb77adae.tar.gz |
codegen: Support deprecating properties and their accessors
Use G_PARAM_DEPRECATED for properties and in addition their accessor
methods will be marked as deprecated.
Guard internal accessors calls with G_GNUC_BEGIN/END_IGNORED_DEPRECATIONS
to silence unavoidable warnings.
Based on patch by Simon Werbeck <simon.werbeck@gmail.com>
https://bugzilla.gnome.org/show_bug.cgi?id=732449
Diffstat (limited to 'ccode')
-rw-r--r-- | ccode/Makefile.am | 1 | ||||
-rw-r--r-- | ccode/valaccodeggnucsection.vala | 64 |
2 files changed, 65 insertions, 0 deletions
diff --git a/ccode/Makefile.am b/ccode/Makefile.am index fd3186a87..0402f6269 100644 --- a/ccode/Makefile.am +++ b/ccode/Makefile.am @@ -40,6 +40,7 @@ libvalaccode_la_VALASOURCES = \ valaccodefunction.vala \ valaccodefunctioncall.vala \ valaccodefunctiondeclarator.vala \ + valaccodeggnucsection.vala \ valaccodegotostatement.vala \ valaccodeidentifier.vala \ valaccodeifstatement.vala \ diff --git a/ccode/valaccodeggnucsection.vala b/ccode/valaccodeggnucsection.vala new file mode 100644 index 000000000..deb969ce2 --- /dev/null +++ b/ccode/valaccodeggnucsection.vala @@ -0,0 +1,64 @@ +/* valaccodeggnucsection.vala + * + * Copyright (C) 2016 Rico Tzschichholz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Rico Tzschichholz <ricotz@ubuntu.com> + */ + +using GLib; + +/** + * Represents a section that should be processed on condition. + */ +public class Vala.CCodeGGnucSection : CCodeFragment { + /** + * The expression + */ + public GGnucSectionType section_type { get; set; } + + public CCodeGGnucSection (GGnucSectionType t) { + section_type = t; + } + + public override void write (CCodeWriter writer) { + writer.write_string ("G_GNUC_BEGIN_"); + writer.write_string (section_type.to_string ()); + foreach (CCodeNode node in get_children ()) { + node.write_combined (writer); + } + writer.write_string ("G_GNUC_END_"); + writer.write_string (section_type.to_string ()); + writer.write_newline (); + } + + public override void write_declaration (CCodeWriter writer) { + } +} + +public enum Vala.GGnucSectionType { + IGNORE_DEPRECATIONS; + + public unowned string to_string () { + switch (this) { + case IGNORE_DEPRECATIONS: + return "IGNORE_DEPRECATIONS"; + default: + assert_not_reached (); + } + } +} |