1 # COM Header generation
2 # (C) 2005 Jelmer Vernooij <jelmer@samba.org>
4 package Parse::Pidl::Samba::COM::Header;
6 use Parse::Pidl::Typelist;
7 use Parse::Pidl::Util qw(has_property);
11 sub GetArgumentProtoList($)
16 foreach my $a (@{$f->{ELEMENTS}}) {
18 $res .= ", " . Parse::Pidl::Typelist::mapType($a->{TYPE}) . " ";
20 my $l = $a->{POINTERS};
21 $l-- if (Parse::Pidl::Typelist::scalar_is_reference($a->{TYPE}));
22 foreach my $i (1..$l) {
26 if (defined $a->{ARRAY_LEN}[0] &&
27 !Parse::Pidl::Util::is_constant($a->{ARRAY_LEN}[0]) &&
32 if (defined $a->{ARRAY_LEN}[0] && Parse::Pidl::Util::is_constant($a->{ARRAY_LEN}[0])) {
33 $res .= "[$a->{ARRAY_LEN}[0]]";
40 sub GetArgumentList($)
45 foreach my $a (@{$f->{ELEMENTS}}) {
46 $res .= ", $a->{NAME}";
52 #####################################################################
53 # generate vtable structure for COM interface
56 my $interface = shift;
58 $res .= "#define " . uc($interface->{NAME}) . "_METHODS \\\n";
59 if (defined($interface->{BASE})) {
60 $res .= "\t" . uc($interface->{BASE} . "_METHODS") . "\\\n";
63 my $data = $interface->{DATA};
64 foreach my $d (@{$data}) {
65 $res .= "\t" . Parse::Pidl::Typelist::mapType($d->{RETURN_TYPE}) . " (*$d->{NAME}) (struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . GetArgumentProtoList($d) . ");\\\n" if ($d->{TYPE} eq "FUNCTION");
68 $res .= "struct $interface->{NAME}_vtable {\n";
69 $res .= "\tstruct GUID iid;\n";
70 $res .= "\t" . uc($interface->{NAME}) . "_METHODS\n";
81 $res .="\n\n/* $if->{NAME} */\n";
83 $res .="#define COM_" . uc($if->{NAME}) . "_UUID $if->{PROPERTIES}->{uuid}\n\n";
85 $res .="struct $if->{NAME}_vtable;\n\n";
87 $res .="struct $if->{NAME} {
88 struct com_context *ctx;
89 struct $if->{NAME}_vtable *vtable;
93 $res.=HeaderVTable($if);
95 foreach my $d (@{$if->{DATA}}) {
96 next if ($d->{TYPE} ne "FUNCTION");
98 $res .= "#define $if->{NAME}_$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . ") ";
100 $res .= "((interface)->vtable->$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . "))";
112 $res .= "#define CLSID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{uuid}\n";
113 if (has_property($c, "progid")) {
114 $res .= "#define PROGID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{progid}\n";
125 foreach my $x (@{$idl})
127 if ($x->{TYPE} eq "INTERFACE" && has_property($x, "object")) {
128 $res.=ParseInterface($x);
131 if ($x->{TYPE} eq "COCLASS") {
132 $res.=ParseCoClass($x);