]> Pileus Git - ~andy/gtk/blob - gdk/makegdkalias.pl
3b745e178011a882c55dc226835bb4b4f229a061
[~andy/gtk] / gdk / makegdkalias.pl
1 #!/usr/bin/perl -w
2
3 print <<EOF;
4 /* Generated by makegdkalias.pl */
5
6 #ifndef DISABLE_VISIBILITY
7
8 #include <glib.h>
9
10 #ifdef G_HAVE_GNUC_VISIBILITY
11
12 #ifdef  GDK_ENABLE_BROKEN
13 #define WAS_BROKEN
14 #endif
15 #define GDK_ENABLE_BROKEN
16
17 #ifdef  GDK_MULTIHEAD_SAFE
18 #define WAS_MULTIHEAD
19 #endif
20 #undef GDK_MULTIHEAD_SAVE
21
22 #ifdef  GDK_DISABLE_DEPRECATED
23 #define WAS_NO_DEPR
24 #endif
25 #undef  GDK_DISABLE_DEPRECATED
26
27 #ifdef  G_DISABLE_DEPRECATED
28 #define WAS_NO_G_DEPR
29 #endif
30 #undef  G_DISABLE_DEPRECATED
31
32 #include "gdk.h"
33
34 #ifdef GDK_WINDOWING_X11
35 #include "x11/gdkx.h"
36 #endif
37 #ifdef GDK_WINDOWING_WIN32
38 #include "win32/gdkwin32.h"
39 #endif
40 #ifdef GDK_WINDOWING_FB
41 #include "linux-fb/gdkfb.h"
42 #endif
43
44 EOF
45
46 my $in_comment = 0;
47 my $in_skipped_section = 0;
48
49 while (<>) {
50
51   # ignore empty lines
52   next if /^\s*$/;
53
54   # skip comments
55   if ($_ =~ /^\s*\/\*/)
56   {
57       $in_comment = 1;
58   }
59   
60   if ($in_comment)
61   {
62       if ($_ =~  /\*\/\s$/)
63       {
64           $in_comment = 0;
65       }
66       
67       next;
68   }
69
70   # handle ifdefs
71   if ($_ =~ /^\#endif/)
72   {
73       if (!$in_skipped_section)
74       {
75           print $_;
76       }
77
78       $in_skipped_section = 0;
79
80       next;
81   }
82
83   if ($_ =~ /^\#ifdef\s+INCLUDE_VARIABLES/)
84   {
85       $in_skipped_section = 1;
86   }
87
88   if ($in_skipped_section)
89   {
90       next;
91   }
92
93   if ($_ =~ /^\#ifdef\s+G/)
94   {
95       print $_;
96       
97       next;
98   }
99
100   chop;
101   my $str = $_;
102   my @words;
103   my $attributes = "";
104
105   @words = split(/ /, $str);
106   $str = shift(@words);
107   chomp($str);
108   my $alias = "IA__".$str;
109   
110   # Drop any Win32 specific .def file syntax,  but keep attributes
111   foreach $word (@words) {
112       $attributes = "$attributes $word" unless $word eq "PRIVATE";
113   }
114       
115   print <<EOF
116 extern __typeof ($str) $alias __attribute((visibility("hidden")))$attributes;
117 extern __typeof ($str) $str __attribute((alias("$alias"), visibility("default")));
118 \#define $str $alias
119
120 EOF
121 }
122
123 print <<EOF;
124
125 #ifndef WAS_BROKEN
126 #undef  GDK_ENABLE_BROKEN
127 #else
128 #undef  WAS_BROKEN
129 #endif
130
131 #ifdef  WAS_MULTIHEAD
132 #define GDK_MULTIHEAD_SAFE
133 #undef  WAS_MULTIHEAD
134 #endif
135
136 #ifdef  WAS_NO_DEPR
137 #define GDK_DISABLE_DEPRECATED
138 #undef  WAS_NO_DEPR
139 #endif
140
141 #ifdef  WAS_NO_G_DEPR
142 #define G_DISABLE_DEPRECATED
143 #undef  WAS_NO_G_DEPR
144 #endif
145
146 #endif /* G_HAVE_GNUC_VISIBILITY */
147
148 #endif /* DISABLE_VISIBILITY */
149 EOF
150