1 # COM Header generation
2 # (C) 2005 Jelmer Vernooij <jelmer@samba.org>
4 package Parse::Pidl::Samba4::COM::Header;
6 use Parse::Pidl::Typelist qw(mapTypeName);
7 use Parse::Pidl::Util qw(has_property is_constant);
14 sub GetArgumentProtoList($)
19 foreach my $a (@{$f->{ELEMENTS}}) {
21 $res .= ", " . mapTypeName($a->{TYPE}) . " ";
23 my $l = $a->{POINTERS};
24 $l-- if (Parse::Pidl::Typelist::scalar_is_reference($a->{TYPE}));
25 foreach my $i (1..$l) {
29 if (defined $a->{ARRAY_LEN}[0] && !is_constant($a->{ARRAY_LEN}[0]) &&
34 if (defined $a->{ARRAY_LEN}[0] && is_constant($a->{ARRAY_LEN}[0])) {
35 $res .= "[$a->{ARRAY_LEN}[0]]";
42 sub GetArgumentList($)
47 foreach (@{$f->{ELEMENTS}}) { $res .= ", $_->{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" . mapTypeName($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#ifndef _$if->{NAME}_\n";
82 $res .= "#define _$if->{NAME}_\n";
84 $res .="\n\n/* $if->{NAME} */\n";
86 $res .="#define COM_" . uc($if->{NAME}) . "_UUID $if->{PROPERTIES}->{uuid}\n\n";
88 $res .="struct $if->{NAME}_vtable;\n\n";
90 $res .="struct $if->{NAME} {
92 struct com_context *ctx;
93 struct $if->{NAME}_vtable *vtable;
97 $res.=HeaderVTable($if);
99 foreach my $d (@{$if->{DATA}}) {
100 next if ($d->{TYPE} ne "FUNCTION");
102 $res .= "#define $if->{NAME}_$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . ") ";
104 $res .= "((interface)->vtable->$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . "))";
118 $res .= "#define CLSID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{uuid}\n";
119 if (has_property($c, "progid")) {
120 $res .= "#define PROGID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{progid}\n";
128 my ($idl,$ndr_header) = @_;
131 $res .= "#include \"librpc/gen_ndr/orpc.h\"\n" .
132 "#include \"$ndr_header\"\n\n";
136 if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) {
137 $res .="struct $_->{NAME};\n";
143 if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) {
144 $res.=ParseInterface($_);
147 if ($_->{TYPE} eq "COCLASS") {
148 $res.=ParseCoClass($_);