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);
61 foreach ($basedir, @$opt_incdirs) {
62 if (-f "$_/$idl_file") {
63 $idl_path = "$_/$idl_file";
68 error($x, "Unable to open include file `$idl_file'");
71 my $podl = Parse::Pidl::IDL::parse_file($idl_path, $opt_incdirs);
72 if (defined(@$podl)) {
73 require Parse::Pidl::Typelist;
75 Parse::Pidl::Typelist::LoadIdl($podl);
76 my $pidl = ODL2IDL($podl, $basedir, $opt_incdirs);
78 foreach my $y (@$pidl) {
79 if ($y->{TYPE} eq "INTERFACE") {
80 $interfaces->{$y->{NAME}} = $y;
84 error($x, "Failed to parse $idl_path");
89 if ($x->{TYPE} eq "INTERFACE") {
90 $interfaces->{$x->{NAME}} = $x;
91 # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
92 # and replace interfacepointers with MInterfacePointer
93 # for 'object' interfaces
94 if (has_property($x, "object")) {
95 foreach my $e (@{$x->{DATA}}) {
96 ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e);
97 ReplaceInterfacePointers($e);
103 my $base = $interfaces->{$x->{BASE}};
105 unless (defined($base)) {
106 error($x, "Undefined base interface `$x->{BASE}'");
108 foreach my $fn (reverse @{$base->{DATA}}) {
109 next unless ($fn->{TYPE} eq "FUNCTION");
110 push (@{$x->{INHERITED_FUNCTIONS}}, $fn);
119 PATHS => [ "\"orpc.idl\"" ],