Line data Source code
1 : /* valaccodeggnucsection.vala
2 : *
3 : * Copyright (C) 2016 Rico Tzschichholz
4 : *
5 : * This library is free software; you can redistribute it and/or
6 : * modify it under the terms of the GNU Lesser General Public
7 : * License as published by the Free Software Foundation; either
8 : * version 2.1 of the License, or (at your option) any later version.
9 :
10 : * This library is distributed in the hope that it will be useful,
11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : * Lesser General Public License for more details.
14 :
15 : * You should have received a copy of the GNU Lesser General Public
16 : * License along with this library; if not, write to the Free Software
17 : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 : *
19 : * Author:
20 : * Rico Tzschichholz <ricotz@ubuntu.com>
21 : */
22 :
23 : using GLib;
24 :
25 : /**
26 : * Represents a section that should be processed on condition.
27 : */
28 3 : public class Vala.CCodeGGnucSection : CCodeFragment {
29 : /**
30 : * The expression
31 : */
32 2 : public GGnucSectionType section_type { get; set; }
33 :
34 4 : public CCodeGGnucSection (GGnucSectionType t) {
35 2 : section_type = t;
36 : }
37 :
38 2 : public override void write (CCodeWriter writer) {
39 2 : writer.write_string ("G_GNUC_BEGIN_");
40 2 : writer.write_string (section_type.to_string ());
41 2 : writer.write_newline ();
42 6 : foreach (CCodeNode node in get_children ()) {
43 2 : node.write_combined (writer);
44 : }
45 2 : writer.write_string ("G_GNUC_END_");
46 2 : writer.write_string (section_type.to_string ());
47 2 : writer.write_newline ();
48 : }
49 :
50 2 : public override void write_declaration (CCodeWriter writer) {
51 : }
52 : }
53 :
54 : public enum Vala.GGnucSectionType {
55 : IGNORE_DEPRECATIONS;
56 :
57 : public unowned string to_string () {
58 4 : switch (this) {
59 : case IGNORE_DEPRECATIONS:
60 4 : return "IGNORE_DEPRECATIONS";
61 : default:
62 4 : assert_not_reached ();
63 : }
64 : }
65 : }
|