diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-02-13 12:38:56 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:09:48 -0500 |
commit | ff6e58a7c4da70880276aad482820b0d17be635b (patch) | |
tree | 7627c7bcd3c5ff08df8165ae4a00a0e930f35423 /source4/build | |
parent | ffa5c91d0fd63c789bb7d73cb91f50841fb4f503 (diff) | |
download | samba-ff6e58a7c4da70880276aad482820b0d17be635b.tar.gz samba-ff6e58a7c4da70880276aad482820b0d17be635b.tar.bz2 samba-ff6e58a7c4da70880276aad482820b0d17be635b.zip |
r5376: ORPC is NDR specific, so move it to ndr.pm.
Get rid of register_enum/register_bitmap, etc. (use list of
types in ndr.pm instead)
(This used to be commit efc2e41b8df3a0171cca57291929fb63760c1662)
Diffstat (limited to 'source4/build')
-rw-r--r-- | source4/build/pidl/header.pm | 49 | ||||
-rw-r--r-- | source4/build/pidl/idl.pm | 24 | ||||
-rw-r--r-- | source4/build/pidl/idl.yp | 24 | ||||
-rw-r--r-- | source4/build/pidl/ndr.pm | 50 | ||||
-rw-r--r-- | source4/build/pidl/util.pm | 38 |
5 files changed, 63 insertions, 122 deletions
diff --git a/source4/build/pidl/header.pm b/source4/build/pidl/header.pm index 33e7d56208..c49f60ce8b 100644 --- a/source4/build/pidl/header.pm +++ b/source4/build/pidl/header.pm @@ -103,8 +103,6 @@ sub HeaderEnum($$) my($enum) = shift; my($name) = shift; - util::register_enum($enum, $name); - pidl "\nenum $name {\n"; $tab_depth++; my $els = \@{$enum->{ELEMENTS}}; @@ -133,8 +131,6 @@ sub HeaderBitmap($$) my($bitmap) = shift; my($name) = shift; - util::register_bitmap($bitmap, $name); - pidl "\n/* bitmap $name */\n"; my $els = \@{$bitmap->{ELEMENTS}}; @@ -188,32 +184,27 @@ sub HeaderType($$$) HeaderUnion($data, $name); return; } + + my $dt = $NdrParser::typedefs{$e->{TYPE}}->{DATA}; + if ($data =~ "string") { pidl "const char *"; - } elsif (util::is_enum($e->{TYPE})) { - pidl "enum $data"; - } elsif (util::is_bitmap($e->{TYPE})) { - my $bitmap = util::get_bitmap($e->{TYPE}); - pidl util::bitmap_type_decl($bitmap); - } elsif (NdrParser::is_scalar_type($data)) { - pidl util::map_type($data); - } elsif (util::has_property($e, "switch_is")) { - pidl "union $data"; - } else { + } elsif (not defined($dt->{TYPE})) { pidl "struct $data"; - } -} - -##################################################################### -# parse a declare -sub HeaderDeclare($) -{ - my($declare) = shift; - - if ($declare->{DATA}->{TYPE} eq "ENUM") { - util::register_enum($declare, $declare->{NAME}); - } elsif ($declare->{DATA}->{TYPE} eq "BITMAP") { - util::register_bitmap($declare, $declare->{NAME}); + } else { + if ($dt->{TYPE} eq "ENUM") { + pidl "enum $data"; + } elsif ($dt->{TYPE} eq "BITMAP") { + pidl util::bitmap_type_decl($dt); + } elsif ($dt->{TYPE} eq "SCALAR") { + pidl util::map_type($data); + } elsif ($dt->{TYPE} eq "UNION") { + pidl "union $data"; + } elsif ($dt->{TYPE} eq "STRUCT") { + pidl "struct $data"; + } else { + print "Unknown data type type $dt->{TYPE}\n"; + } } } @@ -471,8 +462,6 @@ sub HeaderInterface($) foreach my $d (@{$data}) { ($d->{TYPE} eq "CONST") && HeaderConst($d); - ($d->{TYPE} eq "DECLARE") && - HeaderDeclare($d); ($d->{TYPE} eq "TYPEDEF") && HeaderTypedef($d); ($d->{TYPE} eq "TYPEDEF") && @@ -496,6 +485,8 @@ sub Parse($) my($idl) = shift; $tab_depth = 0; + NdrParser::Load($idl); + $res = ""; pidl "/* header auto-generated by pidl */\n\n"; foreach my $x (@{$idl}) { diff --git a/source4/build/pidl/idl.pm b/source4/build/pidl/idl.pm index b18215ed34..6ae7cb463f 100644 --- a/source4/build/pidl/idl.pm +++ b/source4/build/pidl/idl.pm @@ -2383,28 +2383,8 @@ sub parse_idl($$) my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); foreach my $x (@{$idl}) { - # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that - # for 'object' interfaces - if (util::has_property($x, "object")) { - foreach my $e (@{$x->{DATA}}) { - if($e->{TYPE} eq "FUNCTION") { - $e->{PROPERTIES}->{object} = 1; - unshift(@{$e->{ELEMENTS}}, - { 'NAME' => 'ORPCthis', - 'POINTERS' => 0, - 'PROPERTIES' => { 'in' => '1' }, - 'TYPE' => 'ORPCTHIS' - }); - unshift(@{$e->{ELEMENTS}}, - { 'NAME' => 'ORPCthat', - 'POINTERS' => 0, - 'PROPERTIES' => { 'out' => '1' }, - 'TYPE' => 'ORPCTHAT' - }); - } - } - } - + NdrParser::InterfaceORPC($x); + # Do the inheritance if (defined($x->{BASE}) and $x->{BASE} ne "") { my $parent = util::get_interface($idl, $x->{BASE}); diff --git a/source4/build/pidl/idl.yp b/source4/build/pidl/idl.yp index 4ee1703602..aff7f82f69 100644 --- a/source4/build/pidl/idl.yp +++ b/source4/build/pidl/idl.yp @@ -374,28 +374,8 @@ sub parse_idl($$) my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error ); foreach my $x (@{$idl}) { - # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that - # for 'object' interfaces - if (util::has_property($x, "object")) { - foreach my $e (@{$x->{DATA}}) { - if($e->{TYPE} eq "FUNCTION") { - $e->{PROPERTIES}->{object} = 1; - unshift(@{$e->{ELEMENTS}}, - { 'NAME' => 'ORPCthis', - 'POINTERS' => 0, - 'PROPERTIES' => { 'in' => '1' }, - 'TYPE' => 'ORPCTHIS' - }); - unshift(@{$e->{ELEMENTS}}, - { 'NAME' => 'ORPCthat', - 'POINTERS' => 0, - 'PROPERTIES' => { 'out' => '1' }, - 'TYPE' => 'ORPCTHAT' - }); - } - } - } - + NdrParser::InterfaceORPC($x); + # Do the inheritance if (defined($x->{BASE}) and $x->{BASE} ne "") { my $parent = util::get_interface($idl, $x->{BASE}); diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm index 6257fb360e..f3f40fb784 100644 --- a/source4/build/pidl/ndr.pm +++ b/source4/build/pidl/ndr.pm @@ -11,7 +11,7 @@ use strict; use needed; # list of known types -my %typedefs; +our %typedefs; my %type_alignments = ( @@ -55,9 +55,11 @@ sub is_scalar_type($) { my $type = shift; - return 1 if (defined($typedefs{$type}) and $typedefs{$type}->{DATA}->{TYPE} eq "SCALAR"); - return 1 if (util::is_enum($type)); - return 1 if (util::is_bitmap($type)); + if (my $dt = $typedefs{$type}->{DATA}->{TYPE}) { + return 1 if ($dt eq "SCALAR"); + return 1 if ($dt eq "ENUM"); + return 1 if ($dt eq "BITMAP"); + } return 0; } @@ -355,7 +357,7 @@ sub align_type { my $e = shift; - unless (defined($typedefs{$e})) { + unless (defined($typedefs{$e}) && defined($typedefs{$e}->{DATA}->{TYPE})) { # it must be an external type - all we can do is guess # print "Warning: assuming alignment of unknown type '$e' is 4\n"; return 4; @@ -370,9 +372,9 @@ sub align_type } elsif($dt->{TYPE} eq "UNION") { $dt->{ALIGN} = struct_alignment($dt); } elsif ($dt->{TYPE} eq "ENUM") { - $dt->{ALIGN} = align_type(util::enum_type_fn(util::get_enum($e))); + $dt->{ALIGN} = align_type(util::enum_type_fn($typedefs{$e}->{DATA})); } elsif ($dt->{TYPE} eq "BITMAP") { - $dt->{ALIGN} = align_type(util::bitmap_type_fn(util::get_bitmap($e))); + $dt->{ALIGN} = align_type(util::bitmap_type_fn($typedefs{$e}->{DATA})); } if (not defined($dt->{ALIGN})) { @@ -517,7 +519,6 @@ sub ParseArrayPull($$$) } } - ##################################################################### # parse scalars in a structure element sub ParseElementPushScalar($$$) @@ -606,9 +607,9 @@ sub ParseElementPullSwitch($$$$) my $e2 = find_sibling($e, $switch); my $type_decl = util::map_type($e2->{TYPE}); pidl "\tif (($ndr_flags) & NDR_SCALARS) {\n"; - if (util::is_enum($e2->{TYPE})) { + if ($typedefs{$e2->{TYPE}}->{DATA}->{TYPE} eq "ENUM") { $type_decl = util::enum_type_decl($e2); - } elsif (util::is_bitmap($e2->{TYPE})) { + } elsif ($typedefs{$e2->{TYPE}}->{DATA}->{TYPE} eq "BITMAP") { $type_decl = util::bitmap_type_decl($e2); } pidl "\t\t$type_decl _level;\n"; @@ -1942,7 +1943,7 @@ sub LoadInterface($) } foreach my $d (@{$x->{DATA}}) { - if ($d->{TYPE} eq "DECLARE" or $d->{TYPE} eq "TYPEDEF") { + if (($d->{TYPE} eq "DECLARE") or ($d->{TYPE} eq "TYPEDEF")) { $typedefs{$d->{NAME}} = $d; if ($d->{DATA}->{TYPE} eq "STRUCT" or $d->{DATA}->{TYPE} eq "UNION") { CheckPointerTypes($d->{DATA}, $x->{PROPERTIES}->{pointer_default}); @@ -1956,6 +1957,33 @@ sub LoadInterface($) } } +# Add ORPC specific bits to an interface. +sub InterfaceORPC($) +{ + my $x = shift; + # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that + # for 'object' interfaces + if (util::has_property($x, "object")) { + foreach my $e (@{$x->{DATA}}) { + if($e->{TYPE} eq "FUNCTION") { + $e->{PROPERTIES}->{object} = 1; + unshift(@{$e->{ELEMENTS}}, + { 'NAME' => 'ORPCthis', + 'POINTERS' => 0, + 'PROPERTIES' => { 'in' => '1' }, + 'TYPE' => 'ORPCTHIS' + }); + unshift(@{$e->{ELEMENTS}}, + { 'NAME' => 'ORPCthat', + 'POINTERS' => 0, + 'PROPERTIES' => { 'out' => '1' }, + 'TYPE' => 'ORPCTHAT' + }); + } + } + } +} + sub Load($) { my $idl = shift; diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm index 58d95eff39..02a7518ccf 100644 --- a/source4/build/pidl/util.pm +++ b/source4/build/pidl/util.pm @@ -202,25 +202,6 @@ sub property_matches($$$) my %enum_list; -sub register_enum($$) -{ - my $enum = shift; - my $name = shift; - $enum_list{$name} = $enum; -} - -sub is_enum($) -{ - my $name = shift; - return defined $enum_list{$name} -} - -sub get_enum($) -{ - my $name = shift; - return $enum_list{$name}; -} - sub enum_type_decl($) { my $enum = shift; @@ -240,25 +221,6 @@ sub enum_type_fn($) my %bitmap_list; -sub register_bitmap($$) -{ - my $bitmap = shift; - my $name = shift; - $bitmap_list{$name} = $bitmap; -} - -sub is_bitmap($) -{ - my $name = shift; - return defined $bitmap_list{$name}; -} - -sub get_bitmap($) -{ - my $name = shift; - return $bitmap_list{$name}; -} - sub bitmap_type_fn($) { my $bitmap = shift; |