summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/build/pidl/TODO21
-rw-r--r--source4/build/pidl/ndr.pm2
-rw-r--r--source4/build/pidl/ndr_parser.pm72
-rw-r--r--source4/build/pidl/validator.pm1
4 files changed, 35 insertions, 61 deletions
diff --git a/source4/build/pidl/TODO b/source4/build/pidl/TODO
index d63fb4af7e..4969bf78b4 100644
--- a/source4/build/pidl/TODO
+++ b/source4/build/pidl/TODO
@@ -5,16 +5,23 @@
compilers.
Proposed extensions for pidl (to arrays):
[convert(t)] attribute for forcing conversions from CH_UCS2, etc to UTF8
- [noterm] attribute -> Indicating there is no terminating character
- [nullterm] attribute -> Indicating the string is null terminated
+ [noheader] attribute -> Indicating the string is not preceded
+
+Implement:
+ ndr.pm:
+ - represent a string as an array with length set to "STRING"
+ - [string] implies is_varying unless noheader is specified.
+ ndr_parser.pm:
+ - if [charset()] specified, use instead of the for loops (call ndr_pu{ll,sh}_charset()
+ - calculate length using helper function if [string] is specified
The various flags for strings would change as follows:
LIBNDR_FLAG_STR_ASCII -> [convert(CH_ASCII)]
-LIBNDR_FLAG_STR_LEN4 -> optionally [length_is()]
+LIBNDR_FLAG_STR_LEN4 -> [string]
LIBNDR_FLAG_STR_SIZE4 -> [size_is()] or if needed [conformant]
-LIBNDR_FLAG_STR_NOTERM -> [noterm]
-LIBNDR_FLAG_STR_NULLTERM -> [nullterm]
+LIBNDR_FLAG_STR_NOTERM -> array
+LIBNDR_FLAG_STR_NULLTERM -> [noheader]
LIBNDR_FLAG_STR_SIZE2 -> uint16 length; [string] char data[length]
LIBNDR_FLAG_STR_BYTESIZE -> uint16 length; [string] char data[length]
LIBNDR_FLAG_STR_FIXLEN32 -> [32]
@@ -25,3 +32,7 @@ LIBNDR_FLAG_STR_FIXLEN15 -> [15]
- True multiple dimension array / strings in arrays support (closely related to
things specified above)
+
+- compatibility mode for generating MIDL-readable data:
+ - strip out pidl-specific properties
+ - convert subcontext() to an array of chars.
diff --git a/source4/build/pidl/ndr.pm b/source4/build/pidl/ndr.pm
index b41d130011..c604d8fe48 100644
--- a/source4/build/pidl/ndr.pm
+++ b/source4/build/pidl/ndr.pm
@@ -79,7 +79,6 @@ sub GetElementLevelTable($)
IS_VARYING => "$is_varying",
IS_CONFORMANT => "$is_conformant",
IS_FIXED => (not $is_conformant and util::is_constant($size)),
- NO_METADATA => (not $is_conformant),
IS_INLINE => (not $is_conformant and not util::is_constant($size))
});
}
@@ -124,7 +123,6 @@ sub GetElementLevelTable($)
IS_VARYING => "$is_varying",
IS_CONFORMANT => 1,
IS_FIXED => 0,
- NO_METADATA => 0,
IS_INLINE => 0,
});
diff --git a/source4/build/pidl/ndr_parser.pm b/source4/build/pidl/ndr_parser.pm
index 7beefbf95d..5309d6fa36 100644
--- a/source4/build/pidl/ndr_parser.pm
+++ b/source4/build/pidl/ndr_parser.pm
@@ -239,23 +239,6 @@ sub GenerateFunctionOutEnv($)
}
#####################################################################
-# parse array preceding data - push side
-sub ParseArrayPushPreceding($$$$)
-{
- my $e = shift;
- my $l = shift;
- my $var_name = shift;
- my $env = shift;
-
- return if ($l->{NO_METADATA});
-
- my $size = ParseExpr($l->{SIZE_IS}, $env);
-
- # we need to emit the array size
- pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));";
-}
-
-#####################################################################
# parse the data of an array - push side
sub ParseArrayPushHeader($$$$$)
{
@@ -265,16 +248,15 @@ sub ParseArrayPushHeader($$$$$)
my $var_name = shift;
my $env = shift;
- if (!$l->{NO_METADATA}) {
+ if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}) {
$var_name = get_pointer_to($var_name);
}
my $size = ParseExpr($l->{SIZE_IS}, $env);
my $length = ParseExpr($l->{LENGTH_IS}, $env);
- # See whether the array size has been pushed yet
- if (!$l->{IS_SURROUNDING}) {
- ParseArrayPushPreceding($e, $l, $var_name, $env);
+ if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
+ pidl "NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, $size));";
}
if ($l->{IS_VARYING}) {
@@ -285,18 +267,6 @@ sub ParseArrayPushHeader($$$$$)
return $length;
}
-sub ParseArrayPullPreceding($$$)
-{
- my $e = shift;
- my $l = shift;
- my $var_name = shift;
-
- return if ($l->{NO_METADATA});
-
- # non fixed arrays encode the size just before the array
- pidl "NDR_CHECK(ndr_pull_array_size(ndr, " . get_pointer_to($var_name) . "));";
-}
-
#####################################################################
# parse an array - pull side
sub ParseArrayPullHeader($$$$$)
@@ -307,7 +277,7 @@ sub ParseArrayPullHeader($$$$$)
my $var_name = shift;
my $env = shift;
- unless ($l->{NO_METADATA}) {
+ if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}) {
$var_name = get_pointer_to($var_name);
}
@@ -322,8 +292,8 @@ sub ParseArrayPullHeader($$$$$)
# if this is a conformant array then we use that size to allocate, and make sure
# we allocate enough to pull the elements
- if (!$l->{IS_SURROUNDING}) {
- ParseArrayPullPreceding($e, $l, $var_name);
+ if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
+ pidl "NDR_CHECK(ndr_pull_array_size(ndr, " . get_pointer_to($var_name) . "));";
}
@@ -624,7 +594,7 @@ sub ParseElementPushLevel
my $length = ParseArrayPushHeader($e, $l, $ndr, $var_name, $env);
# Allow speedups for arrays of scalar types
if (is_scalar_array($e,$l)) {
- unless ($l->{NO_METADATA}) {
+ if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}) {
$var_name = get_pointer_to($var_name);
}
@@ -659,10 +629,10 @@ sub ParseElementPushLevel
$var_name = $var_name . "[$counter]";
- unless ($l->{NO_METADATA}) {
+ if ($l->{IS_VARYING} or $l->{IS_CONFORMANT}) {
$var_name = get_pointer_to($var_name);
}
-
+
if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) {
pidl "for ($counter = 0; $counter < $length; $counter++) {";
indent;
@@ -765,7 +735,7 @@ sub ParseElementPrint($$$)
my $length = ParseExpr($l->{LENGTH_IS}, $env);
if (is_scalar_array($e, $l)) {
- unless ($l->{NO_METADATA}){
+ if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}){
$var_name = get_pointer_to($var_name);
}
pidl "ndr_print_array_$e->{TYPE}(ndr, \"$e->{NAME}\", $var_name, $length);";
@@ -785,7 +755,7 @@ sub ParseElementPrint($$$)
$var_name = $var_name . "[$counter]";
- unless ($l->{NO_METADATA}){ $var_name = get_pointer_to($var_name); }
+ if ($l->{IS_VARYING} or $l->{IS_CONFORMANT}){ $var_name = get_pointer_to($var_name); }
} elsif ($l->{TYPE} eq "DATA") {
if (not typelist::is_scalar($l->{DATA_TYPE}) or typelist::scalar_is_reference($l->{DATA_TYPE})) {
@@ -945,7 +915,7 @@ sub ParseElementPullLevel
# Speed things up a little - special array pull functions
# for scalars
if (is_scalar_array($e, $l)) {
- unless ($l->{NO_METADATA}) {
+ if ($l->{IS_VARYING} or $l->{IS_CONFORMANT}) {
$var_name = get_pointer_to($var_name);
}
@@ -989,7 +959,7 @@ sub ParseElementPullLevel
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
$var_name = $var_name . "[$counter]";
- unless ($l->{NO_METADATA}) {
+ if ($l->{IS_VARYING} or $l->{IS_CONFORMANT}) {
$var_name = get_pointer_to($var_name);
}
@@ -1118,7 +1088,9 @@ sub ParseStructPush($$)
if (defined($e->{LEVELS}[0]) and
$e->{LEVELS}[0]->{TYPE} eq "ARRAY") {
- ParseArrayPushPreceding($e, $e->{LEVELS}[0], "r->$e->{NAME}", $env);
+ my $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env);
+
+ pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));";
} else {
pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, r->$e->{NAME})));";
}
@@ -1412,19 +1384,11 @@ sub ParseStructPull($$)
{
my($struct) = shift;
my $name = shift;
- my $conform_e;
return unless defined $struct->{ELEMENTS};
my $env = GenerateStructEnv($struct);
- # see if the structure contains a conformant array. If it
- # does, then it must be the last element of the structure, and
- # we need to pull the conformant length early, as it fits on
- # the wire before the structure (and even before the structure
- # alignment)
- $conform_e = $struct->{SURROUNDING_ELEMENT};
-
# declare any internal pointers we need
foreach my $e (@{$struct->{ELEMENTS}}) {
DeclarePtrVariables($e);
@@ -1439,8 +1403,8 @@ sub ParseStructPull($$)
pidl "if (ndr_flags & NDR_SCALARS) {";
indent;
- if (defined $conform_e) {
- ParseArrayPullPreceding($conform_e, $conform_e->{LEVELS}[0], "r->$conform_e->{NAME}");
+ if (defined $struct->{SURROUNDING_ELEMENT}) {
+ pidl "NDR_CHECK(ndr_pull_array_size(ndr, &r->$struct->{SURROUNDING_ELEMENT}->{NAME}));";
}
pidl "NDR_CHECK(ndr_pull_align(ndr, $struct->{ALIGN}));";
diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm
index ebe8115985..c4c74753b4 100644
--- a/source4/build/pidl/validator.pm
+++ b/source4/build/pidl/validator.pm
@@ -131,6 +131,7 @@ my %property_list = (
"range" => ["ELEMENT"],
"size_is" => ["ELEMENT"],
"string" => ["ELEMENT"],
+ "charset" => ["ELEMENT"],
"length_is" => ["ELEMENT"],
);