1 ##########################################
2 # Converts ODL stuctures to IDL structures
3 # (C) 2004-2005, 2008 Jelmer Vernooij <jelmer@samba.org>
5 package Parse::Pidl::ODL;
7 use Parse::Pidl qw(error);
9 use Parse::Pidl::Util qw(has_property unmake_str);
10 use Parse::Pidl::Typelist qw(hasType getType);
13 use vars qw($VERSION);
16 sub FunctionAddObjArgs($)
20 unshift(@{$e->{ELEMENTS}}, {
23 'PROPERTIES' => { 'in' => '1' },
28 unshift(@{$e->{ELEMENTS}}, {
31 'PROPERTIES' => { 'out' => '1', 'ref' => '1' },
38 sub ReplaceInterfacePointers($)
41 foreach my $x (@{$e->{ELEMENTS}}) {
42 next unless (hasType($x->{TYPE}));
43 next unless getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE";
45 $x->{TYPE} = "MInterfacePointer";
49 # Add ORPC specific bits to an interface.
52 my ($odl, $basedir, $opt_incdirs) = (@_);
56 foreach my $x (@$odl) {
57 if ($x->{TYPE} eq "IMPORT") {
58 foreach my $idl_file (@{$x->{PATHS}}) {
59 $idl_file = unmake_str($idl_file);
60 my $podl = Parse::Pidl::IDL::parse_file("$basedir/$idl_file", $opt_incdirs);
61 if (defined(@$podl)) {
62 require Parse::Pidl::Typelist;
64 Parse::Pidl::Typelist::LoadIdl($podl);
65 my $pidl = ODL2IDL($podl, $basedir, $opt_incdirs);
67 foreach my $y (@$pidl) {
68 if ($y->{TYPE} eq "INTERFACE") {
69 $interfaces->{$y->{NAME}} = $y;
73 error($x, "Failed to parse $idl_file");
78 if ($x->{TYPE} eq "INTERFACE") {
79 $interfaces->{$x->{NAME}} = $x;
80 # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
81 # and replace interfacepointers with MInterfacePointer
82 # for 'object' interfaces
83 if (has_property($x, "object")) {
84 foreach my $e (@{$x->{DATA}}) {
85 ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e);
86 ReplaceInterfacePointers($e);
92 my $base = $interfaces->{$x->{BASE}};
94 unless (defined($base)) {
95 error($x, "Undefined base interface `$x->{BASE}'");
97 foreach my $fn (reverse @{$base->{DATA}}) {
98 next unless ($fn->{TYPE} eq "FUNCTION");
99 push (@{$x->{INHERITED_FUNCTIONS}}, $fn);
108 PATHS => [ "\"orpc.idl\"" ],