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