line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Win32OLETypeLib.pm,v 1.2 2001/08/02 22:44:26 matt Exp $
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package XML::Generator::Win32OLETypeLib;
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
21445
|
use strict;
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
103
|
|
6
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION);
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
122
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$VERSION = '0.01';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Create an XML representation of a typelib
|
11
|
|
|
|
|
|
|
# - to eventually convert to WSDL.
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
5084
|
use Win32::OLE;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Win32::OLE::Const;
|
15
|
|
|
|
|
|
|
use Win32::OLE::TypeInfo;
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @Library;
|
18
|
|
|
|
|
|
|
sub libCLSID () {0}
|
19
|
|
|
|
|
|
|
sub libNAME () {1}
|
20
|
|
|
|
|
|
|
sub libMAJOR () {2}
|
21
|
|
|
|
|
|
|
sub libMINOR () {3}
|
22
|
|
|
|
|
|
|
sub libLANGUAGE () {4}
|
23
|
|
|
|
|
|
|
sub libFILENAME () {5}
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# list of all types
|
26
|
|
|
|
|
|
|
sub typeLIB () {0}
|
27
|
|
|
|
|
|
|
sub typeINFO () {1}
|
28
|
|
|
|
|
|
|
sub typeDOC () {2}
|
29
|
|
|
|
|
|
|
sub typeATTR () {3}
|
30
|
|
|
|
|
|
|
sub typeHIDDEN () {4}
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# list of all members
|
33
|
|
|
|
|
|
|
sub membTYPE () {0}
|
34
|
|
|
|
|
|
|
sub membDESC () {1}
|
35
|
|
|
|
|
|
|
sub membDOC () {2}
|
36
|
|
|
|
|
|
|
sub membICON () {3}
|
37
|
|
|
|
|
|
|
sub membREADONLY () {4}
|
38
|
|
|
|
|
|
|
sub membHIDDEN () {5}
|
39
|
|
|
|
|
|
|
sub membDETAILS () {6}
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# TYPEKIND sort order:
|
42
|
|
|
|
|
|
|
my @tkorder;
|
43
|
|
|
|
|
|
|
$tkorder[TKIND_COCLASS] = -4; # Treat COCLASS/DISPATCH the same for sorting
|
44
|
|
|
|
|
|
|
$tkorder[TKIND_DISPATCH] = -4;
|
45
|
|
|
|
|
|
|
$tkorder[TKIND_MODULE] = -3;
|
46
|
|
|
|
|
|
|
# $tkorder[TKIND_TYPE] = -2;
|
47
|
|
|
|
|
|
|
$tkorder[TKIND_ENUM] = -1;
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# MEMBERKIND sort order:
|
50
|
|
|
|
|
|
|
my %mkorder = (
|
51
|
|
|
|
|
|
|
Property => -4,
|
52
|
|
|
|
|
|
|
Method => -3,
|
53
|
|
|
|
|
|
|
Event => -2,
|
54
|
|
|
|
|
|
|
Const => -1,
|
55
|
|
|
|
|
|
|
);
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Icons - not actually used as icons here.
|
58
|
|
|
|
|
|
|
my @icon;
|
59
|
|
|
|
|
|
|
$icon[TKIND_COCLASS] = 'Class';
|
60
|
|
|
|
|
|
|
$icon[TKIND_DISPATCH] = 'Class';
|
61
|
|
|
|
|
|
|
$icon[TKIND_ENUM] = 'Enum';
|
62
|
|
|
|
|
|
|
$icon[TKIND_MODULE] = 'Module';
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my @vt;
|
65
|
|
|
|
|
|
|
$vt[VT_BOOL] = 'Boolean';
|
66
|
|
|
|
|
|
|
$vt[VT_BSTR] = 'String';
|
67
|
|
|
|
|
|
|
$vt[VT_DISPATCH] = 'Object';
|
68
|
|
|
|
|
|
|
$vt[VT_INT] = 'Long';
|
69
|
|
|
|
|
|
|
$vt[VT_I2] = 'Short';
|
70
|
|
|
|
|
|
|
$vt[VT_I4] = 'Long';
|
71
|
|
|
|
|
|
|
$vt[VT_R8] = 'Double';
|
72
|
|
|
|
|
|
|
$vt[VT_UNKNOWN] = 'Unknown';
|
73
|
|
|
|
|
|
|
$vt[VT_VARIANT] = 'Variant';
|
74
|
|
|
|
|
|
|
$vt[VT_VOID] = 'Void';
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
use vars qw/$ShowHidden $GroupByType/;
|
77
|
|
|
|
|
|
|
$ShowHidden = 0; # change to show hidden objects
|
78
|
|
|
|
|
|
|
$GroupByType = 0; # change to group by type
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub new {
|
81
|
|
|
|
|
|
|
my $class = shift;
|
82
|
|
|
|
|
|
|
die "No SAX handler passed" unless @_;
|
83
|
|
|
|
|
|
|
unshift @_, 'Handler' if @_ == 1;
|
84
|
|
|
|
|
|
|
my %params = @_;
|
85
|
|
|
|
|
|
|
return bless \%params, $class;
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub find_typelib {
|
89
|
|
|
|
|
|
|
my $self = shift;
|
90
|
|
|
|
|
|
|
my $match = shift;
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $doc_obj = {};
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$self->{Handler}->start_document( $doc_obj );
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$self->send_start("typelibs");
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my @matches = ();
|
99
|
|
|
|
|
|
|
Win32::OLE::Const->EnumTypeLibs(sub {
|
100
|
|
|
|
|
|
|
my ($clsid,$title,$version,$langid,$filename) = @_;
|
101
|
|
|
|
|
|
|
return unless $title =~ /\Q$match\E/;
|
102
|
|
|
|
|
|
|
return unless $version =~ /^([0-9a-fA-F]+)\.([0-9a-fA-F]+)$/;
|
103
|
|
|
|
|
|
|
my ($maj,$min) = (hex($1), hex($2));
|
104
|
|
|
|
|
|
|
push @matches, [$clsid,$title,$maj,$min,$langid,$filename];
|
105
|
|
|
|
|
|
|
});
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my %typelibs;
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
foreach my $lib (@matches) {
|
110
|
|
|
|
|
|
|
$self->send_start("typelib", 1);
|
111
|
|
|
|
|
|
|
$self->process_lib($lib);
|
112
|
|
|
|
|
|
|
$self->send_end("typelib", 1);
|
113
|
|
|
|
|
|
|
}
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$self->send_end("typelibs");
|
116
|
|
|
|
|
|
|
$self->{Handler}->end_document( $doc_obj );
|
117
|
|
|
|
|
|
|
}
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub process_lib {
|
120
|
|
|
|
|
|
|
my $self = shift;
|
121
|
|
|
|
|
|
|
my $lib = shift;
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Load new type library
|
124
|
|
|
|
|
|
|
my @def = @$lib[libNAME,libMAJOR,libMINOR,libLANGUAGE];
|
125
|
|
|
|
|
|
|
$def[0] = quotemeta $def[0];
|
126
|
|
|
|
|
|
|
my $tlib = Win32::OLE::Const->LoadRegTypeLib(@def);
|
127
|
|
|
|
|
|
|
if (Win32::OLE->LastError) {
|
128
|
|
|
|
|
|
|
die Win32::OLE->LastError;
|
129
|
|
|
|
|
|
|
}
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $tcount = $tlib->_GetTypeInfoCount;
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# Hide all interfaces mentioned in a COCLASS definition
|
134
|
|
|
|
|
|
|
my %hide;
|
135
|
|
|
|
|
|
|
for (0..$tcount-1) {
|
136
|
|
|
|
|
|
|
my $tinfo = $tlib->_GetTypeInfo($_);
|
137
|
|
|
|
|
|
|
++$hide{$tinfo->_GetImplTypeInfo($_)->_GetTypeAttr->{guid}}
|
138
|
|
|
|
|
|
|
foreach 0..$tinfo->_GetTypeAttr->{cImplTypes}-1;
|
139
|
|
|
|
|
|
|
}
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my @Type;
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
for (0..$tcount-1) {
|
144
|
|
|
|
|
|
|
my $tinfo = $tlib->_GetTypeInfo($_);
|
145
|
|
|
|
|
|
|
my $doc = $tinfo->_GetDocumentation;
|
146
|
|
|
|
|
|
|
my $attr = $tinfo->_GetTypeAttr;
|
147
|
|
|
|
|
|
|
my $tflags = $attr->{wTypeFlags};
|
148
|
|
|
|
|
|
|
next if $tflags & TYPEFLAG_FRESTRICTED;
|
149
|
|
|
|
|
|
|
next if $hide{$attr->{guid}};
|
150
|
|
|
|
|
|
|
next unless $icon[$attr->{typekind}];
|
151
|
|
|
|
|
|
|
my $hidden = $tflags & TYPEFLAG_FHIDDEN;
|
152
|
|
|
|
|
|
|
$hidden = 1 if $doc->{Name} =~ /^_/;
|
153
|
|
|
|
|
|
|
push @Type, [$tlib, $tinfo, $doc, $attr, $hidden];
|
154
|
|
|
|
|
|
|
}
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Make a sorted index of visible Types
|
157
|
|
|
|
|
|
|
my @Index = sort {
|
158
|
|
|
|
|
|
|
my ($_a,$_b) = @Type[$a,$b];
|
159
|
|
|
|
|
|
|
my $cmp = 0;
|
160
|
|
|
|
|
|
|
if ($GroupByType) {
|
161
|
|
|
|
|
|
|
my $ranka = $tkorder[$_a->[typeATTR]->{typekind}] || 0;
|
162
|
|
|
|
|
|
|
my $rankb = $tkorder[$_b->[typeATTR]->{typekind}] || 0;
|
163
|
|
|
|
|
|
|
$cmp = $ranka <=> $rankb;
|
164
|
|
|
|
|
|
|
}
|
165
|
|
|
|
|
|
|
$cmp || strcmp($_a->[typeDOC]->{Name}, $_b->[typeDOC]->{Name});
|
166
|
|
|
|
|
|
|
} grep {
|
167
|
|
|
|
|
|
|
$ShowHidden || !$Type[$_]->[typeHIDDEN]
|
168
|
|
|
|
|
|
|
} 0..@Type-1;
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# Create structure for available types
|
171
|
|
|
|
|
|
|
foreach (0..@Index-1) {
|
172
|
|
|
|
|
|
|
my $id = $Index[$_];
|
173
|
|
|
|
|
|
|
$self->send_start("type", 2);
|
174
|
|
|
|
|
|
|
# name:
|
175
|
|
|
|
|
|
|
$self->send_tag(name => $Type[$id]->[typeDOC]->{Name}, 3);
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# desc:
|
178
|
|
|
|
|
|
|
$self->send_tag(description => $Type[$id]->[typeDOC]->{DocString}, 3);
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
$self->send_start("members", 3);
|
181
|
|
|
|
|
|
|
$self->process_members($Type[$id]);
|
182
|
|
|
|
|
|
|
$self->send_end("members", 3);
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
$self->send_end("type", 2);
|
185
|
|
|
|
|
|
|
}
|
186
|
|
|
|
|
|
|
}
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub process_members {
|
189
|
|
|
|
|
|
|
my $self = shift;
|
190
|
|
|
|
|
|
|
my $type = shift;
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my @Members;
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
my $tkind = $type->[typeATTR]->{typekind};
|
195
|
|
|
|
|
|
|
if ($tkind == TKIND_COCLASS) {
|
196
|
|
|
|
|
|
|
my ($dispatch,$event);
|
197
|
|
|
|
|
|
|
my $tinfo = $type->[typeINFO];
|
198
|
|
|
|
|
|
|
for my $impltype (0 .. $type->[typeATTR]->{cImplTypes}-1) {
|
199
|
|
|
|
|
|
|
my $tflags = $tinfo->_GetImplTypeFlags($impltype);
|
200
|
|
|
|
|
|
|
next unless $tflags & IMPLTYPEFLAG_FDEFAULT;
|
201
|
|
|
|
|
|
|
($tflags & IMPLTYPEFLAG_FSOURCE ? $event : $dispatch) =
|
202
|
|
|
|
|
|
|
$tinfo->_GetImplTypeInfo($impltype);
|
203
|
|
|
|
|
|
|
}
|
204
|
|
|
|
|
|
|
addFunctions(\@Members, $dispatch);
|
205
|
|
|
|
|
|
|
addFunctions(\@Members, $event, 'Event');
|
206
|
|
|
|
|
|
|
}
|
207
|
|
|
|
|
|
|
else {
|
208
|
|
|
|
|
|
|
addFunctions(\@Members, $type->[typeINFO]);
|
209
|
|
|
|
|
|
|
addVariables(\@Members, $type->[typeINFO]);
|
210
|
|
|
|
|
|
|
}
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# Make a sorted index of visible Types
|
213
|
|
|
|
|
|
|
my @Index = sort {
|
214
|
|
|
|
|
|
|
my ($_a,$_b) = @Members[$a,$b];
|
215
|
|
|
|
|
|
|
my $cmp = 0;
|
216
|
|
|
|
|
|
|
if ($GroupByType) {
|
217
|
|
|
|
|
|
|
my $ranka = $mkorder{$_a->[membICON]} || 0;
|
218
|
|
|
|
|
|
|
my $rankb = $mkorder{$_b->[membICON]} || 0;
|
219
|
|
|
|
|
|
|
$cmp = $ranka <=> $rankb;
|
220
|
|
|
|
|
|
|
}
|
221
|
|
|
|
|
|
|
$cmp || strcmp($_a->[membDOC]->{Name}, $_b->[membDOC]->{Name});
|
222
|
|
|
|
|
|
|
} grep {
|
223
|
|
|
|
|
|
|
$ShowHidden || !$Members[$_]->[membHIDDEN]
|
224
|
|
|
|
|
|
|
} 0..@Members-1;
|
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my @results;
|
228
|
|
|
|
|
|
|
foreach my $index ( @Index ) {
|
229
|
|
|
|
|
|
|
$self->send_start("member", 4);
|
230
|
|
|
|
|
|
|
$self->getMemberInfo($Members[$index]);
|
231
|
|
|
|
|
|
|
$self->send_end("member", 4);
|
232
|
|
|
|
|
|
|
}
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
}
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub addFunctions {
|
237
|
|
|
|
|
|
|
my $Members = shift;
|
238
|
|
|
|
|
|
|
my ($tinfo, $event) = @_;
|
239
|
|
|
|
|
|
|
return unless defined $tinfo;
|
240
|
|
|
|
|
|
|
my $attr = $tinfo->_GetTypeAttr;
|
241
|
|
|
|
|
|
|
my %property;
|
242
|
|
|
|
|
|
|
for my $func (0 .. $attr->{cFuncs}-1) {
|
243
|
|
|
|
|
|
|
my $desc = $tinfo->_GetFuncDesc($func);
|
244
|
|
|
|
|
|
|
next if $desc->{wFuncFlags} & FUNCFLAG_FRESTRICTED;
|
245
|
|
|
|
|
|
|
my $doc = $tinfo->_GetDocumentation($desc->{memid});
|
246
|
|
|
|
|
|
|
my $name = $doc->{Name};
|
247
|
|
|
|
|
|
|
my $invkind = $desc->{invkind};
|
248
|
|
|
|
|
|
|
next if $event && $invkind != INVOKE_FUNC;
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
if ($invkind != INVOKE_FUNC && exists $property{$name}) {
|
251
|
|
|
|
|
|
|
if ($invkind & (INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF)) {
|
252
|
|
|
|
|
|
|
$Members->[$property{$name}]->[membREADONLY] = 0;
|
253
|
|
|
|
|
|
|
}
|
254
|
|
|
|
|
|
|
if ($invkind == INVOKE_PROPERTYGET) { # prefer GET syntax
|
255
|
|
|
|
|
|
|
$Members->[$property{$name}]->[membDESC] = $desc;
|
256
|
|
|
|
|
|
|
}
|
257
|
|
|
|
|
|
|
}
|
258
|
|
|
|
|
|
|
else {
|
259
|
|
|
|
|
|
|
$property{$name} = scalar @{ $Members } if $invkind != INVOKE_FUNC;
|
260
|
|
|
|
|
|
|
my $icon = $invkind == INVOKE_FUNC ? ($event||'Function') : 'Property';
|
261
|
|
|
|
|
|
|
my $readonly = $invkind == INVOKE_PROPERTYGET;
|
262
|
|
|
|
|
|
|
my $hidden = $desc->{wFuncFlags} & FUNCFLAG_FHIDDEN;
|
263
|
|
|
|
|
|
|
$hidden = 1 if $doc->{Name} =~ /^_/;
|
264
|
|
|
|
|
|
|
push @{ $Members }, [$tinfo, $desc, $doc, $icon, $readonly, $hidden];
|
265
|
|
|
|
|
|
|
}
|
266
|
|
|
|
|
|
|
}
|
267
|
|
|
|
|
|
|
}
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub addVariables {
|
270
|
|
|
|
|
|
|
my $Members = shift;
|
271
|
|
|
|
|
|
|
my ($tinfo) = @_;
|
272
|
|
|
|
|
|
|
return unless defined $tinfo;
|
273
|
|
|
|
|
|
|
my $attr = $tinfo->_GetTypeAttr;
|
274
|
|
|
|
|
|
|
for my $var (0 .. $attr->{cVars}-1) {
|
275
|
|
|
|
|
|
|
my $desc = $tinfo->_GetVarDesc($var);
|
276
|
|
|
|
|
|
|
next if $desc->{wVarFlags} & VARFLAG_FRESTRICTED;
|
277
|
|
|
|
|
|
|
my $doc = $tinfo->_GetDocumentation($desc->{memid});
|
278
|
|
|
|
|
|
|
push @{ $Members }, [$tinfo, $desc, $doc, 'Const'];
|
279
|
|
|
|
|
|
|
}
|
280
|
|
|
|
|
|
|
}
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub getMemberInfo {
|
283
|
|
|
|
|
|
|
my $self = shift;
|
284
|
|
|
|
|
|
|
my $member = shift;
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
my $doc = $member->[membDOC];
|
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
# method name
|
289
|
|
|
|
|
|
|
$self->send_tag(name => $doc->{Name}, 5);
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# method docs
|
292
|
|
|
|
|
|
|
$self->send_tag(documentation => $doc->{DocString}, 5);
|
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# method type
|
295
|
|
|
|
|
|
|
my $type = $member->[membICON];
|
296
|
|
|
|
|
|
|
$self->send_tag(type => $type, 5);
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
my $desc = $member->[membDESC];
|
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# Function declaration
|
301
|
|
|
|
|
|
|
if (exists $desc->{wFuncFlags}) {
|
302
|
|
|
|
|
|
|
my $tinfo = $member->[membTYPE];
|
303
|
|
|
|
|
|
|
# Parameter names
|
304
|
|
|
|
|
|
|
my $cParams = $desc->{cParams};
|
305
|
|
|
|
|
|
|
my $names = $tinfo->_GetNames($desc->{memid}, $cParams+1);
|
306
|
|
|
|
|
|
|
shift @$names;
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# Last arg of PROPERTYPUT is property type
|
309
|
|
|
|
|
|
|
my $retval = ElemDesc($desc->{elemdescFunc});
|
310
|
|
|
|
|
|
|
my $invkind = $desc->{invkind};
|
311
|
|
|
|
|
|
|
$retval = ElemDesc($desc->{rgelemdescParam}->[--$cParams])
|
312
|
|
|
|
|
|
|
if $invkind == INVOKE_PROPERTYPUT ||
|
313
|
|
|
|
|
|
|
$invkind == INVOKE_PROPERTYPUTREF;
|
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
# Decode function arguments
|
316
|
|
|
|
|
|
|
my $tag_sent;
|
317
|
|
|
|
|
|
|
for my $param (0 .. $cParams-1) {
|
318
|
|
|
|
|
|
|
if (!$tag_sent) {
|
319
|
|
|
|
|
|
|
$self->send_start("arguments", 5);
|
320
|
|
|
|
|
|
|
$tag_sent++;
|
321
|
|
|
|
|
|
|
}
|
322
|
|
|
|
|
|
|
my $elem = $desc->{rgelemdescParam}->[$param];
|
323
|
|
|
|
|
|
|
my $arg_tag = {
|
324
|
|
|
|
|
|
|
Name => "argument",
|
325
|
|
|
|
|
|
|
Attributes => { ($elem->{wParamFlags} & PARAMFLAG_FOPT ? (optional => "yes") : () )}
|
326
|
|
|
|
|
|
|
};
|
327
|
|
|
|
|
|
|
$self->{Handler}->characters({ Data => " " });
|
328
|
|
|
|
|
|
|
$self->{Handler}->start_element($arg_tag);
|
329
|
|
|
|
|
|
|
$self->new_line;
|
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
if (my $name = $names->[$param]) {
|
332
|
|
|
|
|
|
|
$self->send_tag(name => $name, 7);
|
333
|
|
|
|
|
|
|
}
|
334
|
|
|
|
|
|
|
$self->send_tag(type => ElemDesc($elem), 7);
|
335
|
|
|
|
|
|
|
if (defined $elem->{varDefaultValue}) {
|
336
|
|
|
|
|
|
|
my $default = $elem->{varDefaultValue};
|
337
|
|
|
|
|
|
|
# Lookup symbolic name in enum definition
|
338
|
|
|
|
|
|
|
my $tinfo = $elem->{vt}->[-1];
|
339
|
|
|
|
|
|
|
$default = getConstantName($tinfo, $default) if ref $tinfo;
|
340
|
|
|
|
|
|
|
$self->send_tag(default => $default, 7) if $default ne '0';
|
341
|
|
|
|
|
|
|
}
|
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
$self->{Handler}->characters({ Data => " " });
|
344
|
|
|
|
|
|
|
$self->{Handler}->end_element($arg_tag);
|
345
|
|
|
|
|
|
|
$self->new_line;
|
346
|
|
|
|
|
|
|
}
|
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
if ($tag_sent) {
|
349
|
|
|
|
|
|
|
$self->send_end("arguments", 5);
|
350
|
|
|
|
|
|
|
}
|
351
|
|
|
|
|
|
|
elsif ($type ne 'Property') {
|
352
|
|
|
|
|
|
|
$self->send_tag(arguments => "", 5);
|
353
|
|
|
|
|
|
|
}
|
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
# Return type
|
356
|
|
|
|
|
|
|
$self->send_tag(return_type => $retval, 5);
|
357
|
|
|
|
|
|
|
}
|
358
|
|
|
|
|
|
|
# Variable declaration
|
359
|
|
|
|
|
|
|
elsif (exists $desc->{wVarFlags}) {
|
360
|
|
|
|
|
|
|
my $value = $desc->{varValue};
|
361
|
|
|
|
|
|
|
if ($value =~ /^-?\d+$/) {
|
362
|
|
|
|
|
|
|
$self->send_tag(default => sprintf("0x%X", $value), 5);
|
363
|
|
|
|
|
|
|
}
|
364
|
|
|
|
|
|
|
else {
|
365
|
|
|
|
|
|
|
$self->send_tag(default => "\"$value\"", 5);
|
366
|
|
|
|
|
|
|
}
|
367
|
|
|
|
|
|
|
}
|
368
|
|
|
|
|
|
|
}
|
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
sub getConstantName {
|
371
|
|
|
|
|
|
|
my ($tinfo,$value) = @_;
|
372
|
|
|
|
|
|
|
# XXX only int constants supported right now
|
373
|
|
|
|
|
|
|
# ... everything else is treated as a string XXX
|
374
|
|
|
|
|
|
|
return qq("$value") unless $value =~ /^-?\d+$/;
|
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
my $attr = $tinfo->_GetTypeAttr;
|
377
|
|
|
|
|
|
|
for my $var (0 .. $attr->{cVars}-1) {
|
378
|
|
|
|
|
|
|
my $desc = $tinfo->_GetVarDesc($var);
|
379
|
|
|
|
|
|
|
next if $desc->{wVarFlags} & VARFLAG_FRESTRICTED;
|
380
|
|
|
|
|
|
|
return $tinfo->_GetDocumentation($desc->{memid})->{Name}
|
381
|
|
|
|
|
|
|
if $value == $desc->{varValue};
|
382
|
|
|
|
|
|
|
}
|
383
|
|
|
|
|
|
|
# sorry, not found (this is a typelib bug!)
|
384
|
|
|
|
|
|
|
return $value;
|
385
|
|
|
|
|
|
|
}
|
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
sub ElemDesc {
|
388
|
|
|
|
|
|
|
my $desc = shift;
|
389
|
|
|
|
|
|
|
my $vt = $desc->{vt}->[-1];
|
390
|
|
|
|
|
|
|
if (ref $vt) {
|
391
|
|
|
|
|
|
|
return $vt->_GetDocumentation(-1)->{Name};
|
392
|
|
|
|
|
|
|
}
|
393
|
|
|
|
|
|
|
return $vt[$vt] || $VT[$vt];
|
394
|
|
|
|
|
|
|
}
|
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
# String comparison
|
397
|
|
|
|
|
|
|
# =================
|
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
sub strcmp {
|
400
|
|
|
|
|
|
|
my ($x,$y) = @_;
|
401
|
|
|
|
|
|
|
# skip leading underscores and translate to lowercase
|
402
|
|
|
|
|
|
|
s/^_*(.*)/\l$1/ for $x, $y;
|
403
|
|
|
|
|
|
|
return $x cmp $y;
|
404
|
|
|
|
|
|
|
}
|
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
sub send_tag {
|
407
|
|
|
|
|
|
|
my $self = shift;
|
408
|
|
|
|
|
|
|
my ($name, $contents, $indent) = @_;
|
409
|
|
|
|
|
|
|
$self->{Handler}->characters({ Data => (" " x $indent) }) if $indent;
|
410
|
|
|
|
|
|
|
$self->{Handler}->start_element({ Name => $name, Attributes => {} });
|
411
|
|
|
|
|
|
|
$self->{Handler}->characters({ Data => $contents });
|
412
|
|
|
|
|
|
|
$self->{Handler}->end_element({ Name => $name, Attributes => {} });
|
413
|
|
|
|
|
|
|
$self->new_line;
|
414
|
|
|
|
|
|
|
}
|
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
sub send_start {
|
417
|
|
|
|
|
|
|
my $self = shift;
|
418
|
|
|
|
|
|
|
my ($name, $indent) = @_;
|
419
|
|
|
|
|
|
|
$self->{Handler}->characters({ Data => (" " x $indent) }) if $indent;
|
420
|
|
|
|
|
|
|
$self->{Handler}->start_element({ Name => $name, Attributes => {} });
|
421
|
|
|
|
|
|
|
$self->new_line;
|
422
|
|
|
|
|
|
|
}
|
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub send_end {
|
425
|
|
|
|
|
|
|
my $self = shift;
|
426
|
|
|
|
|
|
|
my ($name, $indent) = @_;
|
427
|
|
|
|
|
|
|
$self->{Handler}->characters({ Data => (" " x $indent) }) if $indent;
|
428
|
|
|
|
|
|
|
$self->{Handler}->end_element({ Name => $name, Attributes => {} });
|
429
|
|
|
|
|
|
|
$self->new_line;
|
430
|
|
|
|
|
|
|
}
|
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
sub new_line {
|
433
|
|
|
|
|
|
|
my $self = shift;
|
434
|
|
|
|
|
|
|
$self->{Handler}->characters({ Data => "\n" });
|
435
|
|
|
|
|
|
|
}
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
1;
|
438
|
|
|
|
|
|
|
__END__
|