summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/pidl/ndr.pm75
-rw-r--r--source4/build/pidl/odl.pm16
-rw-r--r--source4/build/pidl/util.pm47
-rw-r--r--source4/build/pidl/validator.pm178
4 files changed, 93 insertions, 223 deletions
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index 629d413db2..69e65c0697 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -216,7 +216,6 @@ sub is_surrounding_string($)
and $e->{PARENT}->{TYPE} ne "FUNCTION";
}
-
#####################################################################
# work out the correct alignment for a structure or union
sub find_largest_alignment($)
@@ -227,7 +226,7 @@ sub find_largest_alignment($)
for my $e (@{$s->{ELEMENTS}}) {
my $a = 1;
- if (Ndr::need_wire_pointer($e)) {
+ if ($e->{POINTERS}) {
$a = 4;
} else {
$a = align_type($e->{TYPE});
@@ -266,26 +265,6 @@ sub align_type
die("Unknown data type type $dt->{TYPE}");
}
-# determine if an element needs a reference pointer on the wire
-# in its NDR representation
-sub need_wire_pointer($)
-{
- my $e = shift;
-
- my $n = $e->{POINTERS};
- my $pt = pointer_type($e);
-
- # Top level "ref" pointers do not have a referrent identifier
- if ( defined($pt)
- and $pt eq "ref"
- and $e->{PARENT}->{TYPE} eq "FUNCTION")
- {
- $n--;
- }
-
- return $n;
-}
-
sub ParseElement($)
{
my $e = shift;
@@ -387,13 +366,6 @@ sub ParseBitmap($)
};
}
-sub ParseDeclare($$)
-{
- my $ndr = shift;
- my $d = shift;
-
-}
-
sub ParseTypedef($$)
{
my $ndr = shift;
@@ -458,14 +430,8 @@ sub ParseFunction($$$)
foreach my $x (@{$d->{ELEMENTS}}) {
my $e = ParseElement($x);
- if (util::has_property($x, "in")) {
- push (@{$e->{DIRECTION}}, "in");
- }
-
- if (util::has_property($x, "out")) {
- push (@{$e->{DIRECTION}}, "out");
- }
-
+ push (@{$e->{DIRECTION}}, "in") if (util::has_property($x, "in"));
+ push (@{$e->{DIRECTION}}, "out") if (util::has_property($x, "out"));
push (@elements, $e);
}
@@ -489,14 +455,8 @@ sub CheckPointerTypes($$)
my $default = shift;
foreach my $e (@{$s->{ELEMENTS}}) {
- if ($e->{POINTERS}) {
- if (not defined(Ndr::pointer_type($e))) {
- $e->{PROPERTIES}->{$default} = 1;
- }
-
- if (Ndr::pointer_type($e) eq "ptr") {
- print "Warning: ptr is not supported by pidl yet\n";
- }
+ if ($e->{POINTERS} and not defined(Ndr::pointer_type($e))) {
+ $e->{PROPERTIES}->{$default} = 1;
}
}
}
@@ -528,7 +488,7 @@ sub ParseInterface($)
}
if ($d->{TYPE} eq "DECLARE") {
- push (@declares, ParseDeclare($idl, $d));
+ push (@declares, $d);
}
if ($d->{TYPE} eq "FUNCTION") {
@@ -569,27 +529,7 @@ sub ParseInterface($)
# Convert a IDL tree to a NDR tree
# Gives a result tree describing all that's necessary for easily generating
-# NDR parsers
-# - list of interfaces
-# - list with functions
-# - list with in elements
-# - list with out elements
-# - list of typedefs
-# - list with structs
-# - alignment of structure
-# - list with elements
-# - list with unions
-# - alignment of union
-# - list with elements
-# - list with enums
-# - base type
-# - list with bitmaps
-# - base type
-# per element:
-# - alignment
-# - "level" table
-# properties are saved
-# pointer types explicitly specified
+# NDR parsers / generators
sub Parse($)
{
my $idl = shift;
@@ -644,5 +584,4 @@ sub ContainsDeferred($$)
return 0;
}
-
1;
diff --git a/source4/build/pidl/odl.pm b/source4/build/pidl/odl.pm
index 5ed508dc93..d40f8fbcca 100644
--- a/source4/build/pidl/odl.pm
+++ b/source4/build/pidl/odl.pm
@@ -6,6 +6,20 @@ package ODL;
use strict;
+#####################################################################
+# find an interface in an array of interfaces
+sub get_interface($$)
+{
+ my($if) = shift;
+ my($n) = shift;
+
+ foreach(@{$if}) {
+ if($_->{NAME} eq $n) { return $_; }
+ }
+
+ return 0;
+}
+
sub FunctionAddObjArgs($)
{
my $e = shift;
@@ -60,7 +74,7 @@ sub ODL2IDL($)
}
if ($x->{BASE}) {
- my $base = util::get_interface($odl, $x->{BASE});
+ my $base = get_interface($odl, $x->{BASE});
foreach my $fn (reverse @{$base->{DATA}}) {
next unless ($fn->{TYPE} eq "FUNCTION");
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index 537714adf3..c26ab2dd04 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -58,7 +58,6 @@ sub FlattenHash($)
return \%b;
}
-
#####################################################################
# traverse a perl data structure removing any empty arrays or
# hashes and any hash elements that map to undef
@@ -86,7 +85,6 @@ sub CleanData($)
return $v;
}
-
#####################################################################
# return the modification time of a file
sub FileModtime($)
@@ -95,7 +93,6 @@ sub FileModtime($)
return (stat($filename))[9];
}
-
#####################################################################
# read a file into a string
sub FileLoad($)
@@ -155,20 +152,6 @@ sub SaveStructure($$)
}
#####################################################################
-# find an interface in an array of interfaces
-sub get_interface($$)
-{
- my($if) = shift;
- my($n) = shift;
-
- foreach(@{$if}) {
- if($_->{NAME} eq $n) { return $_; }
- }
-
- return 0;
-}
-
-#####################################################################
# see if a pidl property list contains a given property
sub has_property($$)
{
@@ -201,17 +184,6 @@ sub property_matches($$$)
return undef;
}
-# determine if an element is a pass-by-reference structure
-sub is_ref_struct($)
-{
- my $e = shift;
- if (!is_scalar_type($e->{TYPE}) &&
- has_property($e, "ref")) {
- return 1;
- }
- return 0;
-}
-
# return 1 if the string is a C constant
sub is_constant($)
{
@@ -232,23 +204,4 @@ sub make_str($)
return "\"" . $str . "\"";
}
-###################################
-# find a sibling var in a structure
-sub find_sibling($$)
-{
- my($e) = shift;
- my($name) = shift;
- my($fn) = $e->{PARENT};
-
- if ($name =~ /\*(.*)/) {
- $name = $1;
- }
-
- for my $e2 (@{$fn->{ELEMENTS}}) {
- return $e2 if ($e2->{NAME} eq $name);
- }
-
- return undef;
-}
-
1;
diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm
index 3c7e1f51d0..ec4ad4503b 100644
--- a/source4/build/pidl/validator.pm
+++ b/source4/build/pidl/validator.pm
@@ -42,128 +42,93 @@ sub el_name($)
return $e->{NAME};
}
+###################################
+# find a sibling var in a structure
+sub find_sibling($$)
+{
+ my($e) = shift;
+ my($name) = shift;
+ my($fn) = $e->{PARENT};
+
+ if ($name =~ /\*(.*)/) {
+ $name = $1;
+ }
+
+ for my $e2 (@{$fn->{ELEMENTS}}) {
+ return $e2 if ($e2->{NAME} eq $name);
+ }
+
+ return undef;
+}
+
+
my %property_list = (
# interface
- "helpstring" => {INTERFACE => 1,
- FUNCTION => 1,
- },
- "version" => {INTERFACE => 1,
- },
- "uuid" => {INTERFACE => 1,
- },
- "endpoint" => {INTERFACE => 1,
- },
- "pointer_default" => {INTERFACE => 1,
- },
- "pointer_default_top" => {INTERFACE => 1,
- },
- "depends" => {INTERFACE => 1,
- },
- "authservice" => {INTERFACE => 1,
- },
+ "helpstring" => ["INTERFACE", "FUNCTION"],
+ "version" => ["INTERFACE"],
+ "uuid" => ["INTERFACE"],
+ "endpoint" => ["INTERFACE"],
+ "pointer_default" => ["INTERFACE"],
+ "pointer_default_top" => ["INTERFACE"],
+ "depends" => ["INTERFACE"],
+ "authservice" => ["INTERFACE"],
# dcom
- "object" => {INTERFACE => 1,
- },
- "local" => {INTERFACE => 1,
- FUNCTION => 1,
- },
- "iid_is" => {ELEMENT => 1,
- },
- "call_as" => {FUNCTION => 1,
- },
- "idempotent" => {FUNCTION => 1,
- },
+ "object" => ["INTERFACE"],
+ "local" => ["INTERFACE", "FUNCTION"],
+ "iid_is" => ["ELEMENT"],
+ "call_as" => ["FUNCTION"],
+ "idempotent" => ["FUNCTION"],
# function
- "noopnum" => {FUNCTION => 1,
- },
- "in" => {ELEMENT => 1,
- },
- "out" => {ELEMENT => 1,
- },
+ "noopnum" => ["FUNCTION"],
+ "in" => ["ELEMENT"],
+ "out" => ["ELEMENT"],
# pointer
- "ref" => {ELEMENT => 1,
- },
- "ptr" => {ELEMENT => 1,
- },
- "unique" => {ELEMENT => 1,
- },
- "relative" => {ELEMENT => 1,
- },
-
- # ndr_size
- "gensize" => {TYPEDEF => 1,
- },
- "value" => {ELEMENT => 1,
- },
- "flag" => {ELEMENT => 1,
- TYPEDEF => 1,
- },
+ "ref" => ["ELEMENT"],
+ "ptr" => ["ELEMENT"],
+ "unique" => ["ELEMENT"],
+ "relative" => ["ELEMENT"],
+
+ "gensize" => ["TYPEDEF"],
+ "value" => ["ELEMENT"],
+ "flag" => ["ELEMENT", "TYPEDEF"],
# generic
- "public" => {FUNCTION => 1,
- TYPEDEF => 1,
- },
- "nopush" => {FUNCTION => 1,
- TYPEDEF => 1,
- },
- "nopull" => {FUNCTION => 1,
- TYPEDEF => 1,
- },
- "noprint" => {FUNCTION => 1,
- TYPEDEF => 1,
- },
+ "public" => ["FUNCTION", "TYPEDEF"],
+ "nopush" => ["FUNCTION", "TYPEDEF"],
+ "nopull" => ["FUNCTION", "TYPEDEF"],
+ "noprint" => ["FUNCTION", "TYPEDEF"],
# union
- "switch_is" => {ELEMENT => 1,
- },
- "switch_type" => {ELEMENT => 1,
- TYPEDEF => 1,
- },
- "nodiscriminant" => {TYPEDEF => 1,
- },
- "case" => {ELEMENT => 1,
- },
- "default" => {ELEMENT => 1,
- },
+ "switch_is" => ["ELEMENT"],
+ "switch_type" => ["ELEMENT", "TYPEDEF"],
+ "nodiscriminant" => ["TYPEDEF"],
+ "case" => ["ELEMENT"],
+ "default" => ["ELEMENT"],
# subcontext
- "subcontext" => {ELEMENT => 1,
- },
- "subcontext_size" => {ELEMENT => 1,
- },
- "compression" => {ELEMENT => 1,
- },
- "obfuscation" => {ELEMENT => 1,
- },
+ "subcontext" => ["ELEMENT"],
+ "subcontext_size" => ["ELEMENT"],
+ "compression" => ["ELEMENT"],
+ "obfuscation" => ["ELEMENT"],
# enum
- "enum8bit" => {TYPEDEF => 1,
- },
- "enum16bit" => {TYPEDEF => 1,
- },
- "v1_enum" => {TYPEDEF => 1,
- },
+ "enum8bit" => ["TYPEDEF"],
+ "enum16bit" => ["TYPEDEF"],
+ "v1_enum" => ["TYPEDEF"],
# bitmap
- "bitmap8bit" => {TYPEDEF => 1,
- },
- "bitmap16bit" => {TYPEDEF => 1,
- },
- "bitmap32bit" => {TYPEDEF => 1,
- },
- "bitmap64bit" => {TYPEDEF => 1,
- },
+ "bitmap8bit" => ["TYPEDEF"],
+ "bitmap16bit" => ["TYPEDEF"],
+ "bitmap32bit" => ["TYPEDEF"],
+ "bitmap64bit" => ["TYPEDEF"],
# array
- "range" => {ELEMENT => 1,
- },
- "size_is" => {ELEMENT => 1,
- },
- "length_is" => {ELEMENT => 1,
- },
+ "range" => ["ELEMENT"],
+ "size_is" => ["ELEMENT"],
+ "length_is" => ["ELEMENT"],
);
#####################################################################
@@ -177,11 +142,10 @@ sub ValidProperties($$)
foreach my $key (keys %{$e->{PROPERTIES}}) {
fatal($e, el_name($e) . ": unknown property '$key'\n")
- if not defined($property_list{$key});
+ unless defined($property_list{$key});
- next if defined($property_list{$key}{ANY});
- fatal($e, el_name($e) . ": property '$key' not allowed on '$t'\n")
- if not defined($property_list{$key}{$t});
+ fatal($e, el_name($e) . ": property '$key' not allowed on '$t'\n")
+ unless grep($t, @{$property_list{$key}});
}
}
@@ -199,7 +163,7 @@ sub ValidElement($)
# Check whether switches are used correctly.
if (my $switch = util::has_property($e, "switch_is")) {
- my $e2 = util::find_sibling($e, $switch);
+ my $e2 = find_sibling($e, $switch);
my $type = typelist::getType($e->{TYPE});
if (defined($type) and $type->{DATA}->{TYPE} ne "UNION") {