b89778dee95f28b37193cd830a1c61886334bf85
[platform/upstream/glib.git] / glib / makegalias.pl
1 #!/usr/bin/perl -w
2
3 print <<EOF;
4 /* Generated by makegalias.pl */
5
6 #ifndef DISABLE_VISIBILITY
7
8 #include "glibconfig.h"
9
10 #ifdef G_HAVE_GNUC_VISIBILITY
11
12 #ifdef  G_DISABLE_DEPRECATED
13 #define WAS_NO_G_DEPR
14 #endif
15 #undef  G_DISABLE_DEPRECATED
16
17 #include "glib.h"
18
19 #include "gstdio.h"
20 #ifdef G_OS_WIN32
21 #include "gwin32.h"
22 #endif
23
24 EOF
25
26 my $in_comment = 0;
27 my $in_skipped_section = 0;
28
29 while (<>) {
30
31   # ignore empty lines
32   next if /^\s*$/;
33
34   # skip comments
35   if ($_ =~ /^\s*\/\*/)
36   {
37       $in_comment = 1;
38   }
39   
40   if ($in_comment)
41   {
42       if ($_ =~  /\*\/\s$/)
43       {
44           $in_comment = 0;
45       }
46       
47       next;
48   }
49
50   # handle ifdefs
51   if ($_ =~ /^\#endif/)
52   {
53       if (!$in_skipped_section)
54       {
55           print $_;
56       }
57
58       $in_skipped_section = 0;
59
60       next;
61   }
62
63   if ($_ =~ /^\#ifdef\s+(INCLUDE_VARIABLES|INCLUDE_INTERNAL_SYMBOLS)/)
64   {
65       $in_skipped_section = 1;
66   }
67
68   if ($in_skipped_section)
69   {
70       next;
71   }
72
73   if ($_ =~ /^\#ifdef\s+G/)
74   {
75       print $_;
76       
77       next;
78   }
79  
80   my $str = $_;
81   # Drop any Win32 specific .def file syntax
82   $str = (split (/ /, $str))[0];
83   chomp($str);
84   my $alias = "IA__".$str;
85   
86   print <<EOF
87 extern __typeof ($str) $alias __attribute((visibility("hidden")));
88 extern __typeof ($str) $str __attribute((alias("$alias"), visibility("default")));
89 \#define $str $alias
90
91 EOF
92 }
93
94 print <<EOF;
95
96 #ifdef  WAS_NO_G_DEPR
97 #define G_DISABLE_DEPRECATED
98 #undef  WAS_NO_G_DEPR
99 #endif
100
101 #endif /* G_HAVE_GNUC_VISIBILITY */
102
103 #endif /* DISABLE_VISIBILITY */
104 EOF
105
106