diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/README | 3 | ||||
-rw-r--r-- | source4/build/pidl/ejs.pm (renamed from source4/build/pidl/esp.pm) | 19 | ||||
-rw-r--r-- | source4/build/pidl/ndr.pm | 54 | ||||
-rw-r--r-- | source4/build/pidl/ndr_client.pm | 3 | ||||
-rw-r--r-- | source4/build/pidl/ndr_header.pm | 28 | ||||
-rw-r--r-- | source4/build/pidl/ndr_parser.pm | 247 | ||||
-rwxr-xr-x | source4/build/pidl/pidl.pl | 101 |
7 files changed, 142 insertions, 313 deletions
diff --git a/source4/build/pidl/README b/source4/build/pidl/README index eac0674153..1214288724 100644 --- a/source4/build/pidl/README +++ b/source4/build/pidl/README @@ -18,12 +18,13 @@ dump.pm - Converts the parse tree back to an IDL file validator.pm - Validates the parse tree -- DCE/RPC+NDR -- +ndr.pm - Generates intermediate datastructures for use by NDR parses/generators ndr_client.pm - Generates client call functions in C using the NDR parser eth_parser.pm - Generates a parser for the ethereal network sniffer eth_header.pm - Generates a header for ethereal swig.pm - Generates SWIG interface files (.i) ndr_header.pm - Generates a header file with structures -ndr.pm - Generates pull/push functions for parsing NDR +ndr_parser.pm - Generates pull/push functions for parsing NDR server.pm - Generates server side implementation in C template.pm - Generates stubs in C for server implementation diff --git a/source4/build/pidl/esp.pm b/source4/build/pidl/ejs.pm index 8625544fda..4a106f6176 100644 --- a/source4/build/pidl/esp.pm +++ b/source4/build/pidl/ejs.pm @@ -1,9 +1,9 @@ ################################################### -# ESP function wrapper generator +# EJS function wrapper generator # Copyright jelmer@samba.org 2005 # released under the GNU GPL -package EspClient; +package EjsClient; use strict; use pidl::typelist; @@ -15,11 +15,11 @@ sub pidl ($) $res .= shift; } -sub ESPFunction($) +sub EJSFunction($) { my $d = shift; - pidl "static int esp_$d->{NAME}(struct EspRequest *ep, int argc, struct MprVar **argv)\n"; + pidl "static int ejs_$d->{NAME}(struct EspRequest *ep, int argc, struct MprVar **argv)\n"; pidl "{\n"; # FIXME @@ -30,7 +30,7 @@ sub ESPFunction($) ##################################################################### # parse the interface definitions -sub ESPInterface($) +sub EJSInterface($) { my($interface) = shift; my @fns = (); @@ -38,7 +38,7 @@ sub ESPInterface($) foreach my $d (@{$interface->{FUNCTIONS}}) { next if not defined($d->{OPNUM}); - ESPFunction($d); + EJSFunction($d); push (@fns, $d->{NAME}); } @@ -50,16 +50,15 @@ sub ESPInterface($) # parse a parsed IDL into a C header sub Parse($$) { - my($ndr) = shift; - my $hdr = shift; + my($ndr,$hdr) = @_; my @fns = (); $res = ""; pidl "#include \"$hdr\"\n\n"; - pidl "/* ESP wrapper functions auto-generated by pidl */\n\n"; + pidl "/* EJS wrapper functions auto-generated by pidl */\n\n"; foreach my $x (@{$ndr}) { if ($x->{TYPE} eq "INTERFACE") { - push (@fns, ESPInterface($x)); + push (@fns, EJSInterface($x)); } } diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm index c604d8fe48..09e1d2efc1 100644 --- a/source4/build/pidl/ndr.pm +++ b/source4/build/pidl/ndr.pm @@ -160,7 +160,7 @@ sub GetElementLevelTable($) DATA_TYPE => $e->{TYPE}, IS_DEFERRED => $is_deferred, CONTAINS_DEFERRED => can_contain_deferred($e), - IS_SURROUNDING => is_surrounding_string($e) + IS_SURROUNDING => 0 #FIXME }); my $i = 0; @@ -203,17 +203,6 @@ sub pointer_type($) return undef; } -sub is_surrounding_string($) -{ - my $e = shift; - - return 0; #FIXME - - return ($e->{TYPE} eq "string") and ($e->{POINTERS} == 0) - and util::property_matches($e, "flag", ".*LIBNDR_FLAG_STR_CONFORMANT.*") - and $e->{PARENT}->{TYPE} ne "FUNCTION"; -} - ##################################################################### # work out the correct alignment for a structure or union sub find_largest_alignment($) @@ -367,8 +356,7 @@ sub ParseBitmap($) sub ParseTypedef($$) { - my $ndr = shift; - my $d = shift; + my ($ndr,$d) = @_; my $data; if ($d->{DATA}->{TYPE} eq "STRUCT" or $d->{DATA}->{TYPE} eq "UNION") { @@ -379,17 +367,12 @@ sub ParseTypedef($$) $d->{DATA}->{PROPERTIES} = $d->{PROPERTIES}; } - if ($d->{DATA}->{TYPE} eq "STRUCT") { - $data = ParseStruct($d->{DATA}); - } elsif ($d->{DATA}->{TYPE} eq "UNION") { - $data = ParseUnion($d->{DATA}); - } elsif ($d->{DATA}->{TYPE} eq "ENUM") { - $data = ParseEnum($d->{DATA}); - } elsif ($d->{DATA}->{TYPE} eq "BITMAP") { - $data = ParseBitmap($d->{DATA}); - } else { - die("Unknown data type '$d->{DATA}->{TYPE}'"); - } + $data = { + STRUCT => \&ParseStruct, + UNION => \&ParseUnion, + ENUM => \&ParseEnum, + BITMAP => \&ParseBitmap + }->{$d->{DATA}->{TYPE}}->($d->{DATA}); $data->{ALIGN} = align_type($d->{NAME}); @@ -403,24 +386,19 @@ sub ParseTypedef($$) sub ParseConst($$) { - my $ndr = shift; - my $d = shift; + my ($ndr,$d) = @_; return $d; } sub ParseFunction($$$) { - my $ndr = shift; - my $d = shift; - my $opnum = shift; + my ($ndr,$d,$opnum) = @_; my @elements = (); my $rettype = undef; my $thisopnum = undef; - CheckPointerTypes($d, - $ndr->{PROPERTIES}->{pointer_default_top} - ); + CheckPointerTypes($d, $ndr->{PROPERTIES}->{pointer_default_top}); if (not defined($d->{PROPERTIES}{noopnum})) { $thisopnum = ${$opnum}; @@ -534,9 +512,7 @@ sub Parse($) my $idl = shift; my @ndr = (); - foreach my $x (@{$idl}) { - push @ndr, ParseInterface($x); - } + push(@ndr, ParseInterface($_)) foreach (@{$idl}); return \@ndr; } @@ -558,8 +534,7 @@ sub GetNextLevel($$) sub GetPrevLevel($$) { - my $e = shift; - my $fl = shift; + my ($e,$fl) = @_; my $prev = undef; foreach my $l (@{$e->{LEVELS}}) { @@ -572,8 +547,7 @@ sub GetPrevLevel($$) sub ContainsDeferred($$) { - my $e = shift; - my $l = shift; + my ($e,$l) = @_; do { return 1 if ($l->{IS_DEFERRED}); diff --git a/source4/build/pidl/ndr_client.pm b/source4/build/pidl/ndr_client.pm index eb7d73b991..44a5bde457 100644 --- a/source4/build/pidl/ndr_client.pm +++ b/source4/build/pidl/ndr_client.pm @@ -13,8 +13,7 @@ my($res); # parse a function sub ParseFunction($$) { - my $interface = shift; - my $fn = shift; + my ($interface, $fn) = @_; my $name = $fn->{NAME}; my $uname = uc $name; diff --git a/source4/build/pidl/ndr_header.pm b/source4/build/pidl/ndr_header.pm index e3e6022ded..1e5500400c 100644 --- a/source4/build/pidl/ndr_header.pm +++ b/source4/build/pidl/ndr_header.pm @@ -28,8 +28,7 @@ sub tabs() # parse a properties list sub HeaderProperties($$) { - my($props) = shift; - my($ignores) = shift; + my($props,$ignores) = @_; my $ret = ""; return; @@ -93,8 +92,7 @@ sub HeaderElement($) # parse a struct sub HeaderStruct($$) { - my($struct) = shift; - my($name) = shift; + my($struct,$name) = @_; pidl "\nstruct $name {\n"; $tab_depth++; my $el_count=0; @@ -116,8 +114,7 @@ sub HeaderStruct($$) # parse a enum sub HeaderEnum($$) { - my($enum) = shift; - my($name) = shift; + my($enum,$name) = @_; my $first = 1; if (not util::useUintEnums()) { @@ -164,8 +161,7 @@ sub HeaderEnum($$) # parse a bitmap sub HeaderBitmap($$) { - my($bitmap) = shift; - my($name) = shift; + my($bitmap,$name) = @_; pidl "\n/* bitmap $name */\n"; @@ -181,8 +177,7 @@ sub HeaderBitmap($$) # parse a union sub HeaderUnion($$) { - my($union) = shift; - my($name) = shift; + my($union,$name) = @_; my %done = (); if (defined $union->{PROPERTIES}) { @@ -206,9 +201,7 @@ sub HeaderUnion($$) # parse a type sub HeaderType($$$) { - my $e = shift; - my($data) = shift; - my($name) = shift; + my($e,$data,$name) = @_; if (ref($data) eq "HASH") { ($data->{TYPE} eq "ENUM") && HeaderEnum($data, $name); ($data->{TYPE} eq "BITMAP") && HeaderBitmap($data, $name); @@ -274,8 +267,7 @@ sub HeaderConst($) # parse a function sub HeaderFunctionInOut($$) { - my($fn) = shift; - my($prop) = shift; + my($fn,$prop) = @_; foreach my $e (@{$fn->{ELEMENTS}}) { if (util::has_property($e, $prop)) { @@ -288,8 +280,7 @@ sub HeaderFunctionInOut($$) # determine if we need an "in" or "out" section sub HeaderFunctionInOut_needed($$) { - my($fn) = shift; - my($prop) = shift; + my($fn,$prop) = @_; if ($prop eq "out" && $fn->{RETURN_TYPE}) { return 1; @@ -360,8 +351,7 @@ sub HeaderFunction($) # output prototypes for a IDL function sub HeaderFnProto($$) { - my $interface = shift; - my $fn = shift; + my ($interface,$fn) = @_; my $name = $fn->{NAME}; pidl "void ndr_print_$name(struct ndr_print *ndr, const char *name, int flags, struct $name *r);\n"; diff --git a/source4/build/pidl/ndr_parser.pm b/source4/build/pidl/ndr_parser.pm index 5309d6fa36..0af3cde311 100644 --- a/source4/build/pidl/ndr_parser.pm +++ b/source4/build/pidl/ndr_parser.pm @@ -22,8 +22,7 @@ sub get_typefamily($) sub append_prefix($$) { - my $e = shift; - my $var_name = shift; + my ($e, $var_name) = @_; my $pointers = 0; foreach my $l (@{$e->{LEVELS}}) { @@ -45,18 +44,9 @@ sub append_prefix($$) return $var_name; } -# see if a variable needs to be allocated by the NDR subsystem on pull -sub need_alloc($) -{ - my $e = shift; - - return 0; -} - sub is_scalar_array($$) { - my $e = shift; - my $l = shift; + my ($e,$l) = @_; return 0 if ($l->{TYPE} ne "ARRAY"); @@ -115,8 +105,7 @@ sub deindent() # work out the name of a size_is() variable sub ParseExpr($$) { - my($expr) = shift; - my $varlist = shift; + my($expr,$varlist) = @_; die("Undefined value in ParseExpr") if not defined($expr); @@ -242,11 +231,7 @@ sub GenerateFunctionOutEnv($) # parse the data of an array - push side sub ParseArrayPushHeader($$$$$) { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $var_name = shift; - my $env = shift; + my ($e,$l,$ndr,$var_name,$env) = @_; if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}) { $var_name = get_pointer_to($var_name); @@ -271,11 +256,7 @@ sub ParseArrayPushHeader($$$$$) # parse an array - pull side sub ParseArrayPullHeader($$$$$) { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $var_name = shift; - my $env = shift; + my ($e,$l,$ndr,$var_name,$env) = @_; if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}) { $var_name = get_pointer_to($var_name); @@ -333,8 +314,7 @@ sub ParseArrayPullHeader($$$$$) sub compression_alg($$) { - my $e = shift; - my $l = shift; + my ($e,$l) = @_; my $compression = $l->{COMPRESSION}; my ($alg, $clen, $dlen) = split(/ /, $compression); @@ -343,9 +323,7 @@ sub compression_alg($$) sub compression_clen($$$) { - my $e = shift; - my $l = shift; - my $env = shift; + my ($e,$l,$env) = @_; my $compression = $l->{COMPRESSION}; my ($alg, $clen, $dlen) = split(/ /, $compression); @@ -354,9 +332,7 @@ sub compression_clen($$$) sub compression_dlen($$$) { - my $e = shift; - my $l = shift; - my $env = shift; + my ($e,$l,$env) = @_; my $compression = $l->{COMPRESSION}; my ($alg, $clen, $dlen) = split(/ /, $compression); @@ -365,18 +341,16 @@ sub compression_dlen($$$) sub ParseCompressionPushStart($$$) { - my $e = shift; - my $l = shift; - my $subndr = shift; - my $comndr = $subndr."_compressed"; + my ($e,$l,$ndr) = @_; + my $comndr = "$ndr\_compressed"; pidl "{"; indent; pidl "struct ndr_push *$comndr;"; pidl ""; - pidl "$comndr = ndr_push_init_ctx($subndr);"; + pidl "$comndr = ndr_push_init_ctx($ndr);"; pidl "if (!$comndr) return NT_STATUS_NO_MEMORY;"; - pidl "$comndr->flags = $subndr->flags;"; + pidl "$comndr->flags = $ndr->flags;"; pidl ""; return $comndr; @@ -384,42 +358,35 @@ sub ParseCompressionPushStart($$$) sub ParseCompressionPushEnd($$$) { - my $e = shift; - my $l = shift; - my $subndr = shift; - my $comndr = $subndr."_compressed"; + my ($e,$l,$ndr) = @_; + my $comndr = "$ndr\_compressed"; my $alg = compression_alg($e, $l); - pidl "NDR_CHECK(ndr_push_compression($subndr, $comndr, $alg));"; + pidl "NDR_CHECK(ndr_push_compression($ndr, $comndr, $alg));"; deindent; pidl "}"; } sub ParseCompressionPullStart($$$$) { - my $e = shift; - my $l = shift; - my $subndr = shift; - my $env = shift; - my $comndr = $subndr."_compressed"; + my ($e,$l,$ndr,$env) = @_; + my $comndr = "$ndr\_compressed"; my $alg = compression_alg($e, $l); my $dlen = compression_dlen($e, $l, $env); pidl "{"; indent; pidl "struct ndr_pull *$comndr;"; - pidl "NDR_ALLOC($subndr, $comndr);"; - pidl "NDR_CHECK(ndr_pull_compression($subndr, $comndr, $alg, $dlen));"; + pidl "NDR_ALLOC($ndr, $comndr);"; + pidl "NDR_CHECK(ndr_pull_compression($ndr, $comndr, $alg, $dlen));"; return $comndr; } sub ParseCompressionPullEnd($$$) { - my $e = shift; - my $l = shift; - my $subndr = shift; - my $comndr = $subndr."_compressed"; + my ($e,$l,$ndr) = @_; + my $comndr = "$ndr\_compressed"; deindent; pidl "}"; @@ -427,8 +394,7 @@ sub ParseCompressionPullEnd($$$) sub ParseObfuscationPushStart($$) { - my $e = shift; - my $ndr = shift; + my ($e,$ndr) = @_; # nothing to do here @@ -437,8 +403,7 @@ sub ParseObfuscationPushStart($$) sub ParseObfuscationPushEnd($$) { - my $e = shift; - my $ndr = shift; + my ($e,$ndr) = @_; my $obfuscation = util::has_property($e, "obfuscation"); pidl "NDR_CHECK(ndr_push_obfuscation($ndr, $obfuscation));"; @@ -446,8 +411,7 @@ sub ParseObfuscationPushEnd($$) sub ParseObfuscationPullStart($$) { - my $e = shift; - my $ndr = shift; + my ($e,$ndr) = @_; my $obfuscation = util::has_property($e, "obfuscation"); pidl "NDR_CHECK(ndr_pull_obfuscation($ndr, $obfuscation));"; @@ -457,19 +421,14 @@ sub ParseObfuscationPullStart($$) sub ParseObfuscationPullEnd($$) { - my $e = shift; - my $ndr = shift; + my ($e,$ndr) = @_; # nothing to do here } sub ParseSubcontextPushStart($$$$$) { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $var_name = shift; - my $ndr_flags = shift; + my ($e,$l,$ndr,$var_name,$ndr_flags) = @_; my $retndr = "_ndr_$e->{NAME}"; pidl "{"; @@ -494,10 +453,7 @@ sub ParseSubcontextPushStart($$$$$) sub ParseSubcontextPushEnd($$$$) { - my $e = shift; - my $l = shift; - my $ndr_flags = shift; - my $env = shift; + my ($e,$l,$ndr_flags,$env) = @_; my $ndr = "_ndr_$e->{NAME}"; my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env); @@ -517,12 +473,7 @@ sub ParseSubcontextPushEnd($$$$) sub ParseSubcontextPullStart($$$$$$) { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $var_name = shift; - my $ndr_flags = shift; - my $env = shift; + my ($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_; my $retndr = "_ndr_$e->{NAME}"; my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env); @@ -545,9 +496,7 @@ sub ParseSubcontextPullStart($$$$$$) sub ParseSubcontextPullEnd($$$) { - my $e = shift; - my $l = shift; - my $env = shift; + my ($e,$l,$env) = @_; my $ndr = "_ndr_$e->{NAME}"; if (defined $l->{COMPRESSION}) { @@ -573,13 +522,7 @@ sub ParseSubcontextPullEnd($$$) sub ParseElementPushLevel { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $var_name = shift; - my $env = shift; - my $primitives = shift; - my $deferred = shift; + my ($e,$l,$ndr,$var_name,$env,$primitives,$deferred) = @_; my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); @@ -657,12 +600,7 @@ sub ParseElementPushLevel # parse scalars in a structure element sub ParseElementPush($$$$$$) { - my $e = shift; - my $ndr = shift; - my $var_prefix = shift; - my $env = shift; - my $primitives = shift; - my $deferred = shift; + my ($e,$ndr,$var_prefix,$env,$primitives,$deferred) = @_; my $subndr = undef; my $var_name = $var_prefix.$e->{NAME}; @@ -686,9 +624,7 @@ sub ParseElementPush($$$$$$) # parse a pointer in a struct element or function sub ParsePtrPush($$$) { - my $e = shift; - my $l = shift; - my $var_name = shift; + my ($e,$l,$var_name) = @_; if ($l->{POINTER_TYPE} eq "ref") { if ($l->{LEVEL} eq "EMBEDDED") { @@ -709,9 +645,7 @@ sub ParsePtrPush($$$) # print scalars in a structure element sub ParseElementPrint($$$) { - my($e) = shift; - my($var_name) = shift; - my $env = shift; + my($e,$var_name,$env) = @_; $var_name = append_prefix($e, $var_name); return if (util::has_property($e, "noprint")); @@ -791,31 +725,20 @@ sub ParseElementPrint($$$) # parse scalars in a structure element - pull size sub ParseSwitchPull($$$$$$) { - my($e) = shift; - my $l = shift; - my $ndr = shift; - my($var_name) = shift; - my($ndr_flags) = shift; - my $env = shift; + my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_; my $switch_var = ParseExpr($l->{SWITCH_IS}, $env); check_null_pointer($switch_var); $var_name = get_pointer_to($var_name); pidl "NDR_CHECK(ndr_pull_set_switch_value($ndr, $var_name, $switch_var));"; - } ##################################################################### # push switch element sub ParseSwitchPush($$$$$$) { - my($e) = shift; - my $l = shift; - my $ndr = shift; - my($var_name) = shift; - my($ndr_flags) = shift; - my $env = shift; + my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_; my $switch_var = ParseExpr($l->{SWITCH_IS}, $env); check_null_pointer($switch_var); @@ -825,11 +748,7 @@ sub ParseSwitchPush($$$$$$) sub ParseDataPull($$$$$) { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $var_name = shift; - my $ndr_flags = shift; + my ($e,$l,$ndr,$var_name,$ndr_flags) = @_; if (typelist::scalar_is_reference($l->{DATA_TYPE})) { $var_name = get_pointer_to($var_name); @@ -850,11 +769,7 @@ sub ParseDataPull($$$$$) sub ParseDataPush($$$$$) { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $var_name = shift; - my $ndr_flags = shift; + my ($e,$l,$ndr,$var_name,$ndr_flags) = @_; # strings are passed by value rather then reference if (not typelist::is_scalar($l->{DATA_TYPE}) or typelist::scalar_is_reference($l->{DATA_TYPE})) { @@ -866,9 +781,7 @@ sub ParseDataPush($$$$$) sub CalcNdrFlags($$$) { - my $l = shift; - my $primitives = shift; - my $deferred = shift; + my ($l,$primitives,$deferred) = @_; my $scalars = 0; my $buffers = 0; @@ -893,13 +806,7 @@ sub CalcNdrFlags($$$) sub ParseElementPullLevel { - my($e) = shift; - my $l = shift; - my $ndr = shift; - my($var_name) = shift; - my $env = shift; - my $primitives = shift; - my $deferred = shift; + my($e,$l,$ndr,$var_name,$env,$primitives,$deferred) = @_; my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred); @@ -987,12 +894,7 @@ sub ParseElementPullLevel # parse scalars in a structure element - pull size sub ParseElementPull($$$$$$) { - my($e) = shift; - my $ndr = shift; - my($var_prefix) = shift; - my $env = shift; - my $primitives = shift; - my $deferred = shift; + my($e,$ndr,$var_prefix,$env,$primitives,$deferred) = @_; my $var_name = $var_prefix.$e->{NAME}; @@ -1011,10 +913,7 @@ sub ParseElementPull($$$$$$) # parse a pointer in a struct element or function sub ParsePtrPull($$$$) { - my($e) = shift; - my $l = shift; - my $ndr = shift; - my($var_name) = shift; + my($e,$l,$ndr,$var_name) = @_; my $nl = Ndr::GetNextLevel($e, $l); my $next_is_array = ($nl->{TYPE} eq "ARRAY"); @@ -1061,8 +960,7 @@ sub ParsePtrPull($$$$) # parse a struct sub ParseStructPush($$) { - my($struct) = shift; - my $name = shift; + my($struct,$name) = @_; return unless defined($struct->{ELEMENTS}); @@ -1137,8 +1035,7 @@ sub ParseStructPush($$) # generate a push function for an enum sub ParseEnumPush($$) { - my($enum) = shift; - my $name = shift; + my($enum,$name) = @_; my($type_fn) = $enum->{BASE_TYPE}; start_flags($enum); @@ -1150,8 +1047,7 @@ sub ParseEnumPush($$) # generate a pull function for an enum sub ParseEnumPull($$) { - my($enum) = shift; - my $name = shift; + my($enum,$name) = @_; my($type_fn) = $enum->{BASE_TYPE}; my($type_v_decl) = typelist::mapType($type_fn); @@ -1167,8 +1063,7 @@ sub ParseEnumPull($$) # generate a print function for an enum sub ParseEnumPrint($$) { - my($enum) = shift; - my $name = shift; + my($enum,$name) = @_; pidl "const char *val = NULL;"; pidl ""; @@ -1226,8 +1121,7 @@ $typefamily{ENUM} = { # generate a push function for a bitmap sub ParseBitmapPush($$) { - my($bitmap) = shift; - my $name = shift; + my($bitmap,$name) = @_; my($type_fn) = $bitmap->{BASE_TYPE}; start_flags($bitmap); @@ -1241,8 +1135,7 @@ sub ParseBitmapPush($$) # generate a pull function for an bitmap sub ParseBitmapPull($$) { - my($bitmap) = shift; - my $name = shift; + my($bitmap,$name) = @_; my $type_fn = $bitmap->{BASE_TYPE}; my($type_decl) = typelist::mapType($bitmap->{BASE_TYPE}); @@ -1258,9 +1151,7 @@ sub ParseBitmapPull($$) # generate a print function for an bitmap sub ParseBitmapPrintElement($$$) { - my($e) = shift; - my($bitmap) = shift; - my($name) = shift; + my($e,$bitmap,$name) = @_; my($type_decl) = typelist::mapType($bitmap->{BASE_TYPE}); my($type_fn) = $bitmap->{BASE_TYPE}; my($flag); @@ -1278,8 +1169,7 @@ sub ParseBitmapPrintElement($$$) # generate a print function for an bitmap sub ParseBitmapPrint($$) { - my($bitmap) = shift; - my $name = shift; + my($bitmap,$name) = @_; my($type_decl) = typelist::mapType($bitmap->{TYPE}); my($type_fn) = $bitmap->{BASE_TYPE}; @@ -1330,8 +1220,7 @@ $typefamily{BITMAP} = { # generate a struct print function sub ParseStructPrint($$) { - my($struct) = shift; - my($name) = shift; + my($struct,$name) = @_; return unless defined $struct->{ELEMENTS}; @@ -1382,8 +1271,7 @@ sub DeclareArrayVariables($) # parse a struct - pull side sub ParseStructPull($$) { - my($struct) = shift; - my $name = shift; + my($struct,$name) = @_; return unless defined $struct->{ELEMENTS}; @@ -1506,8 +1394,7 @@ sub ParseUnionNdrSize($) # parse a union - push side sub ParseUnionPush($$) { - my $e = shift; - my $name = shift; + my ($e,$name) = @_; my $have_default = 0; # save the old relative_base_offset @@ -1593,9 +1480,8 @@ sub ParseUnionPush($$) # print a union sub ParseUnionPrint($$) { - my $e = shift; + my ($e,$name) = @_; my $have_default = 0; - my $name = shift; pidl "int level = ndr_print_get_switch_value(ndr, r);"; @@ -1635,8 +1521,7 @@ sub ParseUnionPrint($$) # parse a union - pull side sub ParseUnionPull($$) { - my $e = shift; - my $name = shift; + my ($e,$name) = @_; my $have_default = 0; my $switch_type = $e->{SWITCH_TYPE}; @@ -1953,11 +1838,7 @@ sub ParseFunctionPush($) sub AllocateArrayLevel($$$$$) { - my $e = shift; - my $l = shift; - my $ndr = shift; - my $env = shift; - my $size = shift; + my ($e,$l,$ndr,$env,$size) = @_; my $var = ParseExpr($e->{NAME}, $env); @@ -2162,8 +2043,7 @@ sub FunctionTable($) # parse the interface definitions sub ParseInterface($$) { - my($interface) = shift; - my $needed = shift; + my($interface,$needed) = @_; # Typedefs foreach my $d (@{$interface->{TYPEDEFS}}) { @@ -2194,8 +2074,7 @@ sub ParseInterface($$) sub RegistrationFunction($$) { - my $idl = shift; - my $filename = shift; + my ($idl,$filename) = @_; $filename =~ /.*\/ndr_(.*).c/; my $basename = $1; @@ -2226,8 +2105,7 @@ sub RegistrationFunction($$) # parse a parsed IDL structure back into an IDL file sub Parse($$) { - my($ndr) = shift; - my($filename) = shift; + my($ndr,$filename) = @_; $tabs = ""; my $h_filename = $filename; @@ -2260,8 +2138,7 @@ sub Parse($$) sub NeededFunction($$) { - my $fn = shift; - my $needed = shift; + my ($fn,$needed) = @_; $needed->{"pull_$fn->{NAME}"} = 1; $needed->{"push_$fn->{NAME}"} = 1; $needed->{"print_$fn->{NAME}"} = 1; @@ -2281,8 +2158,7 @@ sub NeededFunction($$) sub NeededTypedef($$) { - my $t = shift; - my $needed = shift; + my ($t,$needed) = @_; if (util::has_property($t, "public")) { $needed->{"pull_$t->{NAME}"} = not util::has_property($t, "nopull"); $needed->{"push_$t->{NAME}"} = not util::has_property($t, "nopush"); @@ -2316,8 +2192,7 @@ sub NeededTypedef($$) # work out what parse functions are needed sub NeededInterface($$) { - my ($interface) = shift; - my $needed = shift; + my ($interface,$needed) = @_; foreach my $d (@{$interface->{FUNCTIONS}}) { NeededFunction($d, $needed); } diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl index 169b5ea6c6..198a946625 100755 --- a/source4/build/pidl/pidl.pl +++ b/source4/build/pidl/pidl.pl @@ -31,7 +31,7 @@ use pidl::util; use pidl::template; use pidl::swig; use pidl::compat; -use pidl::esp; +use pidl::ejs; my($opt_help) = 0; my($opt_parse) = 0; @@ -40,19 +40,20 @@ my($opt_uint_enums) = 0; my($opt_diff) = 0; my($opt_header); my($opt_template) = 0; -my($opt_client) = 0; -my($opt_server) = 0; +my($opt_client); +my($opt_server); my($opt_parser); my($opt_eth_parser); my($opt_eth_header); -my($opt_keep) = 0; -my($opt_swig) = 0; -my($opt_dcom_proxy) = 0; -my($opt_com_header) = 0; -my($opt_esp); +my($opt_keep); +my($opt_swig); +my($opt_dcom_proxy); +my($opt_com_header); +my($opt_ejs); my($opt_odl) = 0; my($opt_quiet) = 0; my($opt_output); +my($opt_verbose) = 0; my($opt_warn_compat) = 0; my $idl_parser = new idl; @@ -74,20 +75,21 @@ Options: --uint-enums don't use C enums, instead use uint* types --header[=OUTFILE] create a C NDR header file --parser[=OUTFILE] create a C NDR parser - --esp[=OUTFILE] create esp wrapper file - --client create a C NDR client - --server create server boilerplate + --ejs[=OUTFILE] create ejs wrapper file + --client[=OUTFILE] create a C NDR client + --server[=OUTFILE] create server boilerplate --template print a template for a pipe - --eth-parser create an ethereal parser - --eth-header create an ethereal header file - --swig create swig wrapper file + --eth-parser[=OUTFILE]create an ethereal parser + --eth-header[=OUTFILE]create an ethereal header file + --swig[=OUTFILE] create swig wrapper file --diff run diff on the idl and dumped output - --keep keep the .pidl file + --keep[=OUTFILE] keep the .pidl file --odl accept ODL input - --dcom-proxy create DCOM proxy (implies --odl) - --com-header create header for COM interfaces (implies --odl) + --dcom-proxy[=OUTFILE]create DCOM proxy (implies --odl) + --com-header[=OUTFILE]create header for COM interfaces (implies --odl) --warn-compat warn about incompatibility with other compilers --quiet be quiet + --verbose be verbose \n"; exit(0); } @@ -100,20 +102,21 @@ GetOptions ( 'dump' => \$opt_dump, 'uint-enums' => \$opt_uint_enums, 'header:s' => \$opt_header, - 'server' => \$opt_server, + 'server:s' => \$opt_server, 'template' => \$opt_template, 'parser:s' => \$opt_parser, - 'client' => \$opt_client, + 'client:s' => \$opt_client, 'eth-parser:s' => \$opt_eth_parser, 'eth-header:s' => \$opt_eth_header, - 'esp:s' => \$opt_esp, + 'ejs:s' => \$opt_ejs, 'diff' => \$opt_diff, 'odl' => \$opt_odl, - 'keep' => \$opt_keep, - 'swig' => \$opt_swig, - 'dcom-proxy' => \$opt_dcom_proxy, - 'com-header' => \$opt_com_header, + 'keep:s' => \$opt_keep, + 'swig:s' => \$opt_swig, + 'dcom-proxy:s' => \$opt_dcom_proxy, + 'com-header:s' => \$opt_com_header, 'quiet' => \$opt_quiet, + 'verbose' => \$opt_verbose, 'warn-compat' => \$opt_warn_compat ); @@ -137,7 +140,7 @@ sub process_file($) $output = $opt_output . $basename; } - my($pidl_file) = util::ChangeExtension($output, ".pidl"); + my($pidl_file) = ($opt_keep or util::ChangeExtension($output, ".pidl")); unless ($opt_quiet) { print "Compiling $idl_file\n"; } @@ -146,7 +149,7 @@ sub process_file($) defined @$pidl || die "Failed to parse $idl_file"; typelist::LoadIdl($pidl); IdlValidator::Validate($pidl); - if ($opt_keep && !util::SaveStructure($pidl_file, $pidl)) { + if (defined($opt_keep) && !util::SaveStructure($pidl_file, $pidl)) { die "Failed to save $pidl_file\n"; } } else { @@ -169,10 +172,10 @@ sub process_file($) unlink($tempfile); } - if ($opt_com_header) { + if (defined($opt_com_header)) { my $res = COMHeader::Parse($pidl); if ($res) { - my $comh_filename = dirname($output) . "/com_$basename.h"; + my $comh_filename = ($opt_com_header or (dirname($output) . "/com_$basename.h")); util::FileSave($comh_filename, "#include \"librpc/gen_ndr/ndr_orpc.h\"\n" . "#include \"librpc/gen_ndr/ndr_$basename.h\"\n" . @@ -181,10 +184,10 @@ sub process_file($) $opt_odl = 1; } - if ($opt_dcom_proxy) { + if (defined($opt_dcom_proxy)) { my $res = DCOMProxy::Parse($pidl); if ($res) { - my ($client) = util::ChangeExtension($output, "_p.c"); + my ($client) = ($opt_dcom_proxy or util::ChangeExtension($output, "_p.c")); util::FileSave($client, "#include \"includes.h\"\n" . "#include \"librpc/gen_ndr/com_$basename.h\"\n" . @@ -201,7 +204,7 @@ sub process_file($) $pidl = ODL::ODL2IDL($pidl); } - if (defined($opt_header) or defined($opt_eth_parser) or defined($opt_eth_header) or $opt_client or $opt_server or defined($opt_parser) or defined($opt_esp)) { + if (defined($opt_header) or defined($opt_eth_parser) or defined($opt_eth_header) or defined($opt_client) or defined($opt_server) or defined($opt_parser) or defined($opt_ejs)) { $ndr = Ndr::Parse($pidl); # print util::MyDumper($ndr); } @@ -212,38 +215,33 @@ sub process_file($) $header = util::ChangeExtension($output, ".h"); } util::FileSave($header, NdrHeader::Parse($ndr)); - if ($opt_swig) { + if (defined($opt_swig)) { my($filename) = $output; $filename =~ s/\/ndr_/\//; - $filename = util::ChangeExtension($filename, ".i"); + $filename = ($opt_swig or util::ChangeExtension($filename, ".i")); IdlSwig::RewriteHeader($pidl, $header, $filename); } } - if (defined($opt_eth_header)) { - my($eparserhdr) = $opt_eth_header; - if ($eparserhdr eq "") { - $eparserhdr = dirname($output) . "/packet-dcerpc-$basename.h"; - } + my($eparserhdr) = ($opt_eth_header or (dirname($output) . "/packet-dcerpc-$basename.h")); util::FileSave($eparserhdr, EthHeader::Parse($ndr)); } my $h_filename = util::ChangeExtension($output, ".h"); - if ($opt_client) { - my ($client) = util::ChangeExtension($output, "_c.c"); + if (defined($opt_client)) { + my ($client) = ($opt_client or util::ChangeExtension($output, "_c.c")); util::FileSave($client, NdrClient::Parse($ndr,$h_filename)); } - if (defined($opt_esp)) { - my $esp = $opt_esp; - if ($esp eq "") { $esp = util::ChangeExtension($output, "_esp.c"); } - util::FileSave($esp, EspClient::Parse($ndr, $h_filename)); + if (defined($opt_ejs)) { + my $ejs = ($opt_ejs or util::ChangeExtension($output, "_ejs.c")); + util::FileSave($ejs, EjsClient::Parse($ndr, $h_filename)); } - if ($opt_server) { + if (defined($opt_server)) { my $dcom = ""; foreach my $x (@{$pidl}) { @@ -254,7 +252,7 @@ sub process_file($) } } - util::FileSave(util::ChangeExtension($output, "_s.c"), NdrServer::Parse($ndr,$h_filename)); + util::FileSave(($opt_server or util::ChangeExtension($output, "_s.c")), NdrServer::Parse($ndr,$h_filename)); if ($dcom ne "") { $dcom = " @@ -270,23 +268,16 @@ $dcom } if (defined($opt_parser)) { - my $parser = $opt_parser; - if ($parser eq "") { - $parser = util::ChangeExtension($output, ".c"); - } + my $parser = ($opt_parser or util::ChangeExtension($output, ".c")); util::FileSave($parser, NdrParser::Parse($ndr, $parser)); } if (defined($opt_eth_parser)) { - my($eparser) = $opt_eth_parser; - if ($eparser eq "") { - $eparser = dirname($output) . "/packet-dcerpc-$basename.c"; - } + my($eparser) = ($opt_eth_parser or dirname($output) . "/packet-dcerpc-$basename.c"); util::FileSave($eparser, EthParser::Parse($ndr, $basename, $eparser)); } - if ($opt_template) { print IdlTemplate::Parse($pidl); } |