1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
###################################################
# IDL Compatibility checker
# Copyright jelmer@samba.org 2005
# released under the GNU GPL
package Parse::Pidl::Compat;
use Parse::Pidl::Util qw(has_property);
use strict;
use vars qw($VERSION);
$VERSION = '0.01';
my %supported_properties = (
# interface
"helpstring" => ["INTERFACE", "FUNCTION"],
"version" => ["INTERFACE"],
"uuid" => ["INTERFACE"],
"endpoint" => ["INTERFACE"],
"pointer_default" => ["INTERFACE"],
# dcom
"object" => ["INTERFACE"],
"local" => ["INTERFACE", "FUNCTION"],
"iid_is" => ["ELEMENT"],
"call_as" => ["FUNCTION"],
"idempotent" => ["FUNCTION"],
# function
"in" => ["ELEMENT"],
"out" => ["ELEMENT"],
# pointer
"ref" => ["ELEMENT"],
"ptr" => ["ELEMENT"],
"unique" => ["ELEMENT"],
"ignore" => ["ELEMENT"],
"value" => ["ELEMENT"],
# generic
"public" => ["FUNCTION", "TYPEDEF"],
"nopush" => ["FUNCTION", "TYPEDEF"],
"nopull" => ["FUNCTION", "TYPEDEF"],
"noprint" => ["FUNCTION", "TYPEDEF"],
"noejs" => ["FUNCTION", "TYPEDEF"],
# union
"switch_is" => ["ELEMENT"],
"switch_type" => ["ELEMENT", "TYPEDEF"],
"case" => ["ELEMENT"],
"default" => ["ELEMENT"],
# subcontext
"subcontext" => ["ELEMENT"],
"subcontext_size" => ["ELEMENT"],
# enum
"enum16bit" => ["TYPEDEF"],
"v1_enum" => ["TYPEDEF"],
# bitmap
"bitmap8bit" => ["TYPEDEF"],
"bitmap16bit" => ["TYPEDEF"],
"bitmap32bit" => ["TYPEDEF"],
"bitmap64bit" => ["TYPEDEF"],
# array
"range" => ["ELEMENT"],
"size_is" => ["ELEMENT"],
"string" => ["ELEMENT"],
"noheader" => ["ELEMENT"],
"charset" => ["ELEMENT"],
"length_is" => ["ELEMENT"],
);
my($res);
sub warning($$)
{
my $l = shift;
my $m = shift;
print "$l->{FILE}:$l->{LINE}:Warning:$m\n";
}
sub error($$)
{
my ($l,$m) = @_;
print "$l->{FILE}:$l->{LINE}:$m\n";
}
sub CheckTypedef($)
{
my $td = shift;
if (has_property($td, "nodiscriminant")) {
error($td, "nodiscriminant property not supported");
}
if ($td->{TYPE} eq "BITMAP") {
warning($td, "converting bitmap to scalar");
#FIXME
}
if (has_property($td, "gensize")) {
warning($td, "ignoring gensize() property. ");
}
if (has_property($td, "enum8bit") and has_property($td, "enum16bit")) {
warning($td, "8 and 16 bit enums not supported, converting to scalar");
#FIXME
}
StripProperties($td);
}
sub CheckElement($)
{
my $e = shift;
if (has_property($e, "noheader")) {
error($e, "noheader property not supported");
return;
}
if (has_property($e, "subcontext")) {
warning($e, "converting subcontext to byte array");
#FIXME
}
if (has_property($e, "compression")) {
error($e, "compression() property not supported");
}
if (has_property($e, "obfuscation")) {
error($e, "obfuscation() property not supported");
}
if (has_property($e, "sptr")) {
error($e, "sptr() pointer property not supported");
}
if (has_property($e, "relative")) {
error($e, "relative() pointer property not supported");
}
if (has_property($td, "flag")) {
warning($e, "ignoring flag() property");
}
if (has_property($td, "value")) {
warning($e, "ignoring value() property");
}
StripProperties($e);
}
sub CheckFunction($)
{
my $fn = shift;
if (has_property($fn, "noopnum")) {
error($fn, "noopnum not converted. Opcodes will be out of sync.");
}
StripProperties($fn);
}
sub CheckInterface($)
{
my $if = shift;
if (has_property($if, "pointer_default_top") and
$if->{PROPERTIES}->{pointer_default_top} ne "ref") {
error($if, "pointer_default_top() is pidl-specific");
}
StripProperties($if);
foreach my $x (@{$if->{DATA}}) {
if ($x->{TYPE} eq "DECLARE") {
warning($if, "the declare keyword is pidl-specific");
next;
}
}
}
sub Check($)
{
my $pidl = shift;
my $nidl = [];
my $res = "";
foreach my $x (@{$pidl}) {
push (@$nidl, CheckInterface($x))
if ($x->{TYPE} eq "INTERFACE");
}
return $res;
}
1;
|