diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-02-12 21:43:08 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:09:46 -0500 |
commit | 51a6f7b227e131a7610b56cbf54d9128f35c7d66 (patch) | |
tree | e9b42123d342844bb5af822aa950019eab599f1b | |
parent | 67bc7ddbe9d42507f276381796f0be1ff01111d4 (diff) | |
download | samba-51a6f7b227e131a7610b56cbf54d9128f35c7d66.tar.gz samba-51a6f7b227e131a7610b56cbf54d9128f35c7d66.tar.bz2 samba-51a6f7b227e131a7610b56cbf54d9128f35c7d66.zip |
r5361: Rename some functions, add tests to validator.
(This used to be commit c9d7b88756039a3eb3024c886851e489c46ef67f)
-rw-r--r-- | source4/build/pidl/ndr.pm | 50 | ||||
-rw-r--r-- | source4/build/pidl/validator.pm | 11 | ||||
-rw-r--r-- | source4/librpc/idl/dcom.idl | 2 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 2 |
4 files changed, 40 insertions, 25 deletions
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm index 149d5f93b9..345141285d 100644 --- a/source4/build/pidl/ndr.pm +++ b/source4/build/pidl/ndr.pm @@ -199,7 +199,7 @@ sub find_sibling($$) #################################################################### # work out the name of a size_is() variable -sub find_size_var($$$) +sub ParseExpr($$$) { my($e) = shift; my($size) = shift; @@ -242,7 +242,7 @@ sub find_size_var($$$) } ##################################################################### -# check that a variable we get from find_size_var isn't a null pointer +# check that a variable we get from ParseExpr isn't a null pointer sub check_null_pointer($) { my $size = shift; @@ -253,7 +253,7 @@ sub check_null_pointer($) } ##################################################################### -# check that a variable we get from find_size_var isn't a null pointer +# check that a variable we get from ParseExpr isn't a null pointer # void return varient sub check_null_pointer_void($) { @@ -345,19 +345,23 @@ sub align_type my $dt = $typedefs{$e}->{DATA}; + return $dt->{ALIGN} if ($dt->{ALIGN}); + if ($dt->{TYPE} eq "STRUCT") { - return struct_alignment($dt); + $dt->{ALIGN} = struct_alignment($dt); } elsif($dt->{TYPE} eq "UNION") { - return struct_alignment($dt); + $dt->{ALIGN} = struct_alignment($dt); } elsif ($dt->{TYPE} eq "ENUM") { - return align_type(util::enum_type_fn(util::get_enum($e))); + $dt->{ALIGN} = align_type(util::enum_type_fn(util::get_enum($e))); } elsif ($dt->{TYPE} eq "BITMAP") { - return align_type(util::bitmap_type_fn(util::get_bitmap($e))); - } elsif ($dt->{TYPE} eq "SCALAR") { - return $dt->{ALIGN}; - } + $dt->{ALIGN} = align_type(util::bitmap_type_fn(util::get_bitmap($e))); + } - die("Internal pidl error. Typedef has unknown data type $dt->{TYPE}!"); + if (not defined($dt->{ALIGN})) { + die("Internal pidl error. Unable to determine alignment for data type $dt->{TYPE}!"); + } + + return $dt->{ALIGN}; } ##################################################################### @@ -368,7 +372,7 @@ sub ParseArrayPush($$$) my $var_prefix = shift; my $ndr_flags = shift; - my $size = find_size_var($e, util::array_size($e), $var_prefix); + my $size = ParseExpr($e, util::array_size($e), $var_prefix); if (defined $e->{CONFORMANT_SIZE}) { # the conformant size has already been pushed @@ -378,7 +382,7 @@ sub ParseArrayPush($$$) } if (my $length = util::has_property($e, "length_is")) { - $length = find_size_var($e, $length, $var_prefix); + $length = ParseExpr($e, $length, $var_prefix); pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));\n"; pidl "\t\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $length));\n"; $size = $length; @@ -397,11 +401,11 @@ sub ParseArrayPrint($$) { my $e = shift; my $var_prefix = shift; - my $size = find_size_var($e, util::array_size($e), $var_prefix); + my $size = ParseExpr($e, util::array_size($e), $var_prefix); my $length = util::has_property($e, "length_is"); if (defined $length) { - $size = find_size_var($e, $length, $var_prefix); + $size = ParseExpr($e, $length, $var_prefix); } if (is_scalar_type($e->{TYPE})) { @@ -420,7 +424,7 @@ sub CheckArraySizes($$) if (!defined $e->{CONFORMANT_SIZE} && util::has_property($e, "size_is")) { - my $size = find_size_var($e, util::array_size($e), $var_prefix); + my $size = ParseExpr($e, util::array_size($e), $var_prefix); pidl "\tif ($var_prefix$e->{NAME}) {\n"; check_null_pointer($size); pidl "\t\tNDR_CHECK(ndr_check_array_size(ndr, (void*)&$var_prefix$e->{NAME}, $size));\n"; @@ -428,7 +432,7 @@ sub CheckArraySizes($$) } if (my $length = util::has_property($e, "length_is")) { - $length = find_size_var($e, $length, $var_prefix); + $length = ParseExpr($e, $length, $var_prefix); pidl "\tif ($var_prefix$e->{NAME}) {\n"; check_null_pointer($length); pidl "\t\tNDR_CHECK(ndr_check_array_length(ndr, (void*)&$var_prefix$e->{NAME}, $length));\n"; @@ -445,7 +449,7 @@ sub ParseArrayPull($$$) my $var_prefix = shift; my $ndr_flags = shift; - my $size = find_size_var($e, util::array_size($e), $var_prefix); + my $size = ParseExpr($e, util::array_size($e), $var_prefix); my $alloc_size = $size; # if this is a conformant array then we use that size to allocate, and make sure @@ -571,7 +575,7 @@ sub ParseElementPullSwitch($$$$) my($var_prefix) = shift; my($ndr_flags) = shift; my $switch = shift; - my $switch_var = find_size_var($e, $switch, $var_prefix); + my $switch_var = ParseExpr($e, $switch, $var_prefix); my $cprefix = c_pull_prefix($e); @@ -624,7 +628,7 @@ sub ParseElementPushSwitch($$$$) my($var_prefix) = shift; my($ndr_flags) = shift; my $switch = shift; - my $switch_var = find_size_var($e, $switch, $var_prefix); + my $switch_var = ParseExpr($e, $switch, $var_prefix); my $cprefix = c_push_prefix($e); check_null_pointer($switch_var); @@ -655,7 +659,7 @@ sub ParseElementPrintSwitch($$$) my($e) = shift; my($var_prefix) = shift; my $switch = shift; - my $switch_var = find_size_var($e, $switch, $var_prefix); + my $switch_var = ParseExpr($e, $switch, $var_prefix); my $cprefix = c_push_prefix($e); check_null_pointer_void($switch_var); @@ -856,7 +860,7 @@ sub ParseStructPush($) # alignment) my $e = $struct->{ELEMENTS}[-1]; if (defined $e->{ARRAY_LEN} && $e->{ARRAY_LEN} eq "*") { - my $size = find_size_var($e, util::array_size($e), "r->"); + my $size = ParseExpr($e, util::array_size($e), "r->"); $e->{CONFORMANT_SIZE} = $size; check_null_pointer($size); pidl "\tNDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));\n"; @@ -1673,7 +1677,7 @@ sub AllocateRefVars($) } # its an array - my $size = find_size_var($e, $asize, "r->out."); + my $size = ParseExpr($e, $asize, "r->out."); check_null_pointer($size); pidl "\tNDR_ALLOC_N(ndr, r->out.$e->{NAME}, $size);\n"; if (util::has_property($e, "in")) { diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm index 818611ea46..d496a02309 100644 --- a/source4/build/pidl/validator.pm +++ b/source4/build/pidl/validator.pm @@ -47,6 +47,17 @@ sub ValidElement($) if ($e->{POINTERS} && $e->{ARRAY_LEN}) { fatal(el_name($e) . " : pidl cannot handle pointers to arrays. Use a substructure instead\n"); } + + if (util::has_property($e, "ptr")) { + fatal(el_name($e) . " : pidl does not support full NDR pointers yet\n"); + } + + if (!$e->{POINTERS} && ( + util::has_property($e, "ptr") or + util::has_property($e, "unique") or + util::has_property($e, "ref"))) { + fatal(el_name($e) . " : pointer properties on non-pointer element\n"); + } } ##################################################################### diff --git a/source4/librpc/idl/dcom.idl b/source4/librpc/idl/dcom.idl index 762b928252..ad2963c905 100644 --- a/source4/librpc/idl/dcom.idl +++ b/source4/librpc/idl/dcom.idl @@ -79,7 +79,7 @@ interface ObjectRpcBaseTypes uint32 size; /* Num extents. */ uint32 reserved; /* Must be zero. */ /*FIXME[size_is((size+1)&~1,), unique] ORPC_EXTENT **extent; extents */ - [size_is(size),unique] ORPC_EXTENT extent[]; + [size_is(size)] ORPC_EXTENT extent[]; } ORPC_EXTENT_ARRAY; diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 5f61a59a07..281980fb4c 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -106,7 +106,7 @@ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v) } /* - parse a pointer + parse a pointer referent identifier */ NTSTATUS ndr_pull_ptr(struct ndr_pull *ndr, uint32_t *v) { |