… | |
… | |
4 | # to C++ classes for Perl. |
4 | # to C++ classes for Perl. |
5 | |
5 | |
6 | my $class = shift; |
6 | my $class = shift; |
7 | my $curclass = ""; |
7 | my $curclass = ""; |
8 | my (@scalar_member, @array_member); |
8 | my (@scalar_member, @array_member); |
|
|
9 | |
|
|
10 | # convert c member name to perl |
|
|
11 | sub c2perl($) { |
|
|
12 | local $_ = shift; |
|
|
13 | |
|
|
14 | s/^([^.]+)\.\1_/$1\_/g; # tcpi.tcpi_xxx => tcpi_xxx |
|
|
15 | |
|
|
16 | $_ |
|
|
17 | } |
9 | |
18 | |
10 | for my $file (@ARGV) { |
19 | for my $file (@ARGV) { |
11 | open my $fh, "<:utf8", $file |
20 | open my $fh, "<:utf8", $file |
12 | or die "$file: $!"; |
21 | or die "$file: $!"; |
13 | |
22 | |
… | |
… | |
59 | print "\tPROTOTYPE: \$;\$\n"; |
68 | print "\tPROTOTYPE: \$;\$\n"; |
60 | |
69 | |
61 | if (@scalar_member > 1) { |
70 | if (@scalar_member > 1) { |
62 | print "\tALIAS:\n"; |
71 | print "\tALIAS:\n"; |
63 | for (1 .. $#scalar_member) { |
72 | for (1 .. $#scalar_member) { |
64 | print "\t\t$scalar_member[$_][1]\t= $_\n"; |
73 | print "\t\t" . (c2perl $scalar_member[$_][1]) . "\t= $_\n"; |
65 | } |
74 | } |
66 | } |
75 | } |
67 | |
76 | |
68 | print "\tCODE:\n"; |
77 | print "\tCODE:\n"; |
69 | |
78 | |
… | |
… | |
96 | print "\tPROTOTYPE: \$;\$\n"; |
105 | print "\tPROTOTYPE: \$;\$\n"; |
97 | |
106 | |
98 | if (@array_member > 1) { |
107 | if (@array_member > 1) { |
99 | print "\tALIAS:\n"; |
108 | print "\tALIAS:\n"; |
100 | for (1 .. $#array_member) { |
109 | for (1 .. $#array_member) { |
101 | print "\t\t$array_member[$_][1]\t= $_\n"; |
110 | print "\t\t" . (c2perl $array_member[$_][1]) . "\t= $_\n"; |
102 | } |
111 | } |
103 | } |
112 | } |
104 | |
113 | |
105 | print "\tCODE:\n"; |
114 | print "\tCODE:\n"; |
106 | |
115 | |