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);
14 use vars
qw($VERSION);
17 sub FunctionAddObjArgs($)
21 unshift(@{$e->{ELEMENTS}}, {
24 'PROPERTIES' => { 'in' => '1' },
29 unshift(@{$e->{ELEMENTS}}, {
32 'PROPERTIES' => { 'out' => '1', 'ref' => '1' },
39 sub ReplaceInterfacePointers($)
42 foreach my $x (@{$e->{ELEMENTS}}) {
43 next unless (hasType($x->{TYPE}));
44 next unless getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE";
46 $x->{TYPE} = "MInterfacePointer";
50 # Add ORPC specific bits to an interface.
53 my ($odl, $basedir, $opt_incdirs) = (@_);
57 foreach my $x (@$odl) {
58 if ($x->{TYPE} eq "IMPORT") {
59 foreach my $idl_file (@{$x->{PATHS}}) {
60 $idl_file = unmake_str($idl_file);
62 foreach ($basedir, @$opt_incdirs) {
63 if (-f "$_/$idl_file") {
64 $idl_path = "$_/$idl_file";
69 error($x, "Unable to open include file `$idl_file'");
72 my $podl = Parse::Pidl::IDL::parse_file($idl_path, $opt_incdirs);
74 require Parse::Pidl::Typelist;
75 my $basename = basename($idl_path, ".idl");
77 Parse::Pidl::Typelist::LoadIdl($podl, $basename);
78 my $pidl = ODL2IDL($podl, $basedir, $opt_incdirs);
80 foreach my $y (@$pidl) {
81 if ($y->{TYPE} eq "INTERFACE") {
82 $interfaces->{$y->{NAME}} = $y;
86 error($x, "Failed to parse $idl_path");
91 if ($x->{TYPE} eq "INTERFACE") {
92 $interfaces->{$x->{NAME}} = $x;
93 # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
94 # and replace interfacepointers with MInterfacePointer
95 # for 'object' interfaces
96 if (has_property($x, "object")) {
97 foreach my $e (@{$x->{DATA}}) {
98 ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e);
99 ReplaceInterfacePointers($e);
105 my $base = $interfaces->{$x->{BASE}};
107 unless (defined($base)) {
108 error($x, "Undefined base interface `$x->{BASE}'");
110 foreach my $fn (reverse @{$base->{DATA}}) {
111 next unless ($fn->{TYPE} eq "FUNCTION");
112 push (@{$x->{INHERITED_FUNCTIONS}}, $fn);
121 PATHS => [ "\"orpc.idl\"" ],