07f4bed2a030183c03d2f95f7d63fbb38d02a725
[roobuilder] / src / ccode / valaccode.vala
1 /* valaccode.vala
2  *
3  * Copyright (C) 2020  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 namespace Vala {
24         public unowned string GNUC_CONST;
25         public unowned string GNUC_DEPRECATED;
26         public unowned string GNUC_FORMAT;
27         public unowned string GNUC_INTERNAL;
28         public unowned string GNUC_NO_INLINE;
29         public unowned string GNUC_PRINTF;
30         public unowned string GNUC_SCANF;
31         public unowned string GNUC_UNUSED;
32
33         public static void ccode_init (Vala.Profile profile) {
34                 switch (profile) {
35                 case Vala.Profile.GOBJECT:
36                         GNUC_CONST = " G_GNUC_CONST ";
37                         GNUC_DEPRECATED = " G_GNUC_DEPRECATED ";
38                         GNUC_FORMAT = " G_GNUC_FORMAT(%d) ";
39                         GNUC_INTERNAL = " G_GNUC_INTERNAL ";
40                         GNUC_NO_INLINE = " G_GNUC_NO_INLINE ";
41                         GNUC_PRINTF = "  G_GNUC_PRINTF(%d,%d) ";
42                         GNUC_SCANF = " G_GNUC_SCANF(%d,%d) ";
43                         GNUC_UNUSED = " G_GNUC_UNUSED ";
44                         break;
45                 case Vala.Profile.POSIX:
46                         GNUC_CONST = " __attribute__((__const__)) ";
47                         GNUC_DEPRECATED = " __attribute__((__deprecated__)) ";
48                         GNUC_FORMAT = " __attribute__((__format_arg__ (arg_idx))) ";
49                         GNUC_INTERNAL = " __attribute__((visibility(\"hidden\"))) ";
50                         GNUC_NO_INLINE = " __attribute__((noinline)) ";
51                         GNUC_PRINTF = " __attribute__((__format__ (__printf__, %d, %d))) ";
52                         GNUC_SCANF = " __attribute__((__format__ (__scanf__, %d, %d))) ";
53                         GNUC_UNUSED = " __attribute__((__unused__)) ";
54                         break;
55                 default:
56                         assert_not_reached ();
57                 }
58         }
59 }