From e90c93402bc916d85653c8f6340655184a6a5789 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 12 Feb 2005 23:03:26 +0000 Subject: r5362: Add pointer_default() support to pidl. pointer_default() is assumed to be "ptr" if not specified (just like midl). The validator will warn when "ptr" is used at the moment, because pidl only supports unique, ref and relative at the moment. (This used to be commit 31bed62a9a6f7830f523d509b67970648d40aaef) --- source4/build/pidl/ndr.pm | 85 ++++++++++++++++++++++++++++++++++------- source4/build/pidl/validator.pm | 6 +++ 2 files changed, 78 insertions(+), 13 deletions(-) (limited to 'source4/build') diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm index 345141285d..f910be623a 100644 --- a/source4/build/pidl/ndr.pm +++ b/source4/build/pidl/ndr.pm @@ -62,16 +62,34 @@ sub is_scalar_type($) return 0; } +sub pointer_type($) +{ + my $e = shift; + + return undef unless $e->{POINTERS}; + + return "ref" if (util::has_property($e, "ref")); + return "ptr" if (util::has_property($e, "ptr")); + return "unique" if (util::has_property($e, "unique")); + return "relative" if (util::has_property($e, "relative")); + + return undef; +} + # determine if an element needs a reference pointer on the wire # in its NDR representation sub need_wire_pointer($) { my $e = shift; - if ($e->{POINTERS} && - !util::has_property($e, "ref")) { - return $e->{POINTERS}; + my $pt; + + return 0 unless ($pt = pointer_type($e)); + + if ($pt ne "ref") { + return 1; + } else { + return 0; } - return undef; } # determine if an element is a pure scalar. pure scalars do not @@ -1828,15 +1846,6 @@ sub ParseInterface($) my($interface) = shift; my($data) = $interface->{DATA}; - foreach my $d (@{$data}) { - if ($d->{TYPE} eq "DECLARE") { - $typedefs{$d->{NAME}} = $d; - } - if ($d->{TYPE} eq "TYPEDEF") { - $typedefs{$d->{NAME}} = $d; - } - } - # Push functions foreach my $d (@{$data}) { ($d->{TYPE} eq "TYPEDEF") && @@ -1904,6 +1913,54 @@ sub RegistrationFunction($$) pidl "}\n\n"; } +sub CheckPointerTypes($$) +{ + my $s = shift; + my $default = shift; + + foreach my $e (@{$s->{ELEMENTS}}) { + if ($e->{POINTERS}) { + if (not defined(pointer_type($e))) { + $e->{PROPERTIES}->{$default} = 1; + } + + if (pointer_type($e) eq "ptr") { + print "Warning: ptr is not supported by pidl yet\n"; + } + } + } +} + +sub LoadInterface($) +{ + my $x = shift; + + if (not util::has_property($x, "pointer_default")) { + $x->{PROPERTIES}->{pointer_default} = "ptr"; + } + + foreach my $d (@{$x->{DATA}}) { + 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}); + } + } + if ($d->{TYPE} eq "FUNCTION") { + CheckPointerTypes($d, $x->{PROPERTIES}->{pointer_default}); + } + } +} + +sub Load($) +{ + my $idl = shift; + + foreach my $x (@{$idl}) { + LoadInterface($x); + } +} + ##################################################################### # parse a parsed IDL structure back into an IDL file sub Parse($$) @@ -1913,6 +1970,8 @@ sub Parse($$) my $h_filename = $filename; $res = ""; + Load($idl); + if ($h_filename =~ /(.*)\.c/) { $h_filename = "$1.h"; } diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm index d496a02309..73e05ed433 100644 --- a/source4/build/pidl/validator.pm +++ b/source4/build/pidl/validator.pm @@ -55,6 +55,7 @@ sub ValidElement($) if (!$e->{POINTERS} && ( util::has_property($e, "ptr") or util::has_property($e, "unique") or + util::has_property($e, "relative") or util::has_property($e, "ref"))) { fatal(el_name($e) . " : pointer properties on non-pointer element\n"); } @@ -137,6 +138,11 @@ sub ValidInterface($) my($interface) = shift; my($data) = $interface->{DATA}; + if (util::has_property($interface, "pointer_default") && + $interface->{PROPERTIES}->{pointer_default} eq "ptr") { + fatal "Full pointers are not supported yet\n"; + } + if (util::has_property($interface, "object")) { if(util::has_property($interface, "version") && $interface->{PROPERTIES}->{version} != 0) { -- cgit