summaryrefslogtreecommitdiff
path: root/source4/pidl/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-08-26 16:26:08 +1000
committerAndrew Bartlett <abartlet@samba.org>2008-08-26 16:26:08 +1000
commitf08786686c0bf2440e35ce29b8e0b1a2f116fe3a (patch)
treefd7ac6f7cd8528c550952731347f03397c70df77 /source4/pidl/lib
parentb5a3f45f645204bcc3d6caa47993b7839c8e4c99 (diff)
parent4eba234a7352094e1640e8ff9d80a20f8d4705a3 (diff)
downloadsamba-f08786686c0bf2440e35ce29b8e0b1a2f116fe3a.tar.gz
samba-f08786686c0bf2440e35ce29b8e0b1a2f116fe3a.tar.bz2
samba-f08786686c0bf2440e35ce29b8e0b1a2f116fe3a.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into pac-verify
(This used to be commit b706708210a05d6f10474a3cd2bbc550704d4356)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm75
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm506
2 files changed, 311 insertions, 270 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm
index 1e4504764a..10bd29715b 100644
--- a/source4/pidl/lib/Parse/Pidl/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/NDR.pm
@@ -287,6 +287,22 @@ sub GetElementLevelTable($$)
return $order;
}
+sub GetTypedefLevelTable($$$)
+{
+ my ($e, $data, $pointer_default) = @_;
+
+ my $order = [];
+
+ push (@$order, {
+ TYPE => "TYPEDEF"
+ });
+
+ my $i = 0;
+ foreach (@$order) { $_->{LEVEL_INDEX} = $i; $i+=1; }
+
+ return $order;
+}
+
#####################################################################
# see if a type contains any deferred data
sub can_contain_deferred($)
@@ -575,6 +591,7 @@ sub ParseTypedef($$)
NAME => $d->{NAME},
TYPE => $d->{TYPE},
PROPERTIES => $d->{PROPERTIES},
+ LEVELS => GetTypedefLevelTable($d, $data, $pointer_default),
DATA => $data,
ORIGINAL => $d
};
@@ -795,20 +812,21 @@ sub ContainsDeferred($$)
sub el_name($)
{
my $e = shift;
+ my $name = "<ANONYMOUS>";
- if ($e->{PARENT} && $e->{PARENT}->{NAME}) {
- return "$e->{PARENT}->{NAME}.$e->{NAME}";
- }
+ $name = $e->{NAME} if defined($e->{NAME});
- if ($e->{PARENT} && $e->{PARENT}->{PARENT}->{NAME}) {
- return "$e->{PARENT}->{PARENT}->{NAME}.$e->{NAME}";
+ if (defined($e->{PARENT}) and defined($e->{PARENT}->{NAME})) {
+ return "$e->{PARENT}->{NAME}.$name";
}
- if ($e->{PARENT}) {
- return "$e->{PARENT}->{NAME}.$e->{NAME}";
+ if (defined($e->{PARENT}) and
+ defined($e->{PARENT}->{PARENT}) and
+ defined($e->{PARENT}->{PARENT}->{NAME})) {
+ return "$e->{PARENT}->{PARENT}->{NAME}.$name";
}
- return $e->{NAME};
+ return $name;
}
###################################
@@ -858,25 +876,25 @@ my %property_list = (
"unique" => ["ELEMENT"],
"ignore" => ["ELEMENT"],
"relative" => ["ELEMENT"],
- "relative_base" => ["TYPEDEF"],
+ "relative_base" => ["TYPEDEF", "STRUCT", "UNION"],
- "gensize" => ["TYPEDEF"],
+ "gensize" => ["TYPEDEF", "STRUCT", "UNION"],
"value" => ["ELEMENT"],
- "flag" => ["ELEMENT", "TYPEDEF"],
+ "flag" => ["ELEMENT", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
# generic
- "public" => ["FUNCTION", "TYPEDEF"],
- "nopush" => ["FUNCTION", "TYPEDEF"],
- "nopull" => ["FUNCTION", "TYPEDEF"],
- "nosize" => ["FUNCTION", "TYPEDEF"],
- "noprint" => ["FUNCTION", "TYPEDEF"],
- "noejs" => ["FUNCTION", "TYPEDEF"],
+ "public" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
+ "nopush" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
+ "nopull" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
+ "nosize" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
+ "noprint" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP", "ELEMENT"],
+ "noejs" => ["FUNCTION", "TYPEDEF", "STRUCT", "UNION", "ENUM", "BITMAP"],
"todo" => ["FUNCTION"],
# union
"switch_is" => ["ELEMENT"],
- "switch_type" => ["ELEMENT", "TYPEDEF"],
- "nodiscriminant" => ["TYPEDEF"],
+ "switch_type" => ["ELEMENT", "UNION"],
+ "nodiscriminant" => ["UNION"],
"case" => ["ELEMENT"],
"default" => ["ELEMENT"],
@@ -889,15 +907,15 @@ my %property_list = (
"compression" => ["ELEMENT"],
# enum
- "enum8bit" => ["TYPEDEF"],
- "enum16bit" => ["TYPEDEF"],
- "v1_enum" => ["TYPEDEF"],
+ "enum8bit" => ["ENUM"],
+ "enum16bit" => ["ENUM"],
+ "v1_enum" => ["ENUM"],
# bitmap
- "bitmap8bit" => ["TYPEDEF"],
- "bitmap16bit" => ["TYPEDEF"],
- "bitmap32bit" => ["TYPEDEF"],
- "bitmap64bit" => ["TYPEDEF"],
+ "bitmap8bit" => ["BITMAP"],
+ "bitmap16bit" => ["BITMAP"],
+ "bitmap32bit" => ["BITMAP"],
+ "bitmap64bit" => ["BITMAP"],
# array
"range" => ["ELEMENT"],
@@ -921,7 +939,7 @@ sub ValidProperties($$)
unless defined($property_list{$key});
fatal($e, el_name($e) . ": property '$key' not allowed on '$t'")
- unless grep($t, @{$property_list{$key}});
+ unless grep(/^$t$/, @{$property_list{$key}});
}
}
@@ -1101,6 +1119,9 @@ sub ValidTypedef($)
$data->{PARENT} = $typedef;
+ $data->{FILE} = $typedef->{FILE} unless defined($data->{FILE});
+ $data->{LINE} = $typedef->{LINE} unless defined($data->{LINE});
+
ValidType($data) if (ref($data) eq "HASH");
}
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index a0de1f127a..745777d012 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -158,26 +158,26 @@ sub fn_declare($$$$)
###################################################################
# setup any special flags for an element or structure
-sub start_flags($$)
+sub start_flags($$$)
{
- my ($self, $e) = @_;
+ my ($self, $e, $ndr) = @_;
my $flags = has_property($e, "flag");
if (defined $flags) {
$self->pidl("{");
$self->indent;
- $self->pidl("uint32_t _flags_save_$e->{TYPE} = ndr->flags;");
- $self->pidl("ndr_set_flags(&ndr->flags, $flags);");
+ $self->pidl("uint32_t _flags_save_$e->{TYPE} = $ndr->flags;");
+ $self->pidl("ndr_set_flags(&$ndr->flags, $flags);");
}
}
###################################################################
# end any special flags for an element or structure
-sub end_flags($$)
+sub end_flags($$$)
{
- my ($self, $e) = @_;
+ my ($self, $e, $ndr) = @_;
my $flags = has_property($e, "flag");
if (defined $flags) {
- $self->pidl("ndr->flags = _flags_save_$e->{TYPE};");
+ $self->pidl("$ndr->flags = _flags_save_$e->{TYPE};");
$self->deindent;
$self->pidl("}");
}
@@ -331,12 +331,12 @@ sub ParseArrayPullHeader($$$$$$)
} else {
$length = $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
+ "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
check_fully_dereferenced($e, $env));
}
if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) {
- $self->pidl("NDR_CHECK(ndr_pull_array_size(ndr, " . get_pointer_to($var_name) . "));");
+ $self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, " . get_pointer_to($var_name) . "));");
}
if ($l->{IS_VARYING}) {
@@ -357,9 +357,9 @@ sub ParseArrayPullHeader($$$$$$)
$self->defer_indent;
my $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->defer(shift); },
- "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
+ "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
check_fully_dereferenced($e, $env));
- $self->defer("NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));");
+ $self->defer("NDR_CHECK(ndr_check_array_size($ndr, (void*)" . get_pointer_to($var_name) . ", $size));");
$self->defer_deindent;
$self->defer("}");
}
@@ -369,9 +369,9 @@ sub ParseArrayPullHeader($$$$$$)
$self->defer_indent;
my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->defer(shift); },
- "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for length_is()\");"),
+ "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for length_is()\");"),
check_fully_dereferenced($e, $env));
- $self->defer("NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));");
+ $self->defer("NDR_CHECK(ndr_check_array_length($ndr, (void*)" . get_pointer_to($var_name) . ", $length));");
$self->defer_deindent;
$self->defer("}");
}
@@ -543,7 +543,7 @@ sub ParseElementPushLevel
$self->ParseElementPushLevel($e, GetNextLevel($e, $l), $subndr, $var_name, $env, 1, 1);
$self->ParseSubcontextPushEnd($e, $l, $ndr, $env);
} elsif ($l->{TYPE} eq "POINTER") {
- $self->ParsePtrPush($e, $l, $var_name);
+ $self->ParsePtrPush($e, $l, $ndr, $var_name);
} elsif ($l->{TYPE} eq "ARRAY") {
my $length = $self->ParseArrayPushHeader($e, $l, $ndr, $var_name, $env);
@@ -561,6 +561,8 @@ sub ParseElementPushLevel
$self->ParseSwitchPush($e, $l, $ndr, $var_name, $env);
} elsif ($l->{TYPE} eq "DATA") {
$self->ParseDataPush($e, $l, $ndr, $var_name, $primitives, $deferred);
+ } elsif ($l->{TYPE} eq "TYPEDEF") {
+ $typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($self, $e->{DATA}, $ndr, $var_name);
}
}
@@ -569,7 +571,7 @@ sub ParseElementPushLevel
$self->pidl("if ($var_name) {");
$self->indent;
if ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("NDR_CHECK(ndr_push_relative_ptr2(ndr, $var_name));");
+ $self->pidl("NDR_CHECK(ndr_push_relative_ptr2($ndr, $var_name));");
}
}
$var_name = get_value_of($var_name);
@@ -629,7 +631,7 @@ sub ParseElementPush($$$$$$)
$var_name = append_prefix($e, $var_name);
- $self->start_flags($e);
+ $self->start_flags($e, $ndr);
if (defined(my $value = has_property($e, "value"))) {
$var_name = ParseExpr($value, $env, $e->{ORIGINAL});
@@ -637,7 +639,7 @@ sub ParseElementPush($$$$$$)
$self->ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred);
- $self->end_flags($e);
+ $self->end_flags($e, $ndr);
if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
$self->deindent;
@@ -647,25 +649,25 @@ sub ParseElementPush($$$$$$)
#####################################################################
# parse a pointer in a struct element or function
-sub ParsePtrPush($$$$)
+sub ParsePtrPush($$$$$)
{
- my ($self,$e,$l,$var_name) = @_;
+ my ($self,$e,$l,$ndr,$var_name) = @_;
if ($l->{POINTER_TYPE} eq "ref") {
$self->pidl("if ($var_name == NULL) {");
$self->indent;
- $self->pidl("return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
+ $self->pidl("return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL [ref] pointer\");");
$self->deindent;
$self->pidl("}");
if ($l->{LEVEL} eq "EMBEDDED") {
$self->pidl("NDR_CHECK(ndr_push_ref_ptr(ndr));");
}
} elsif ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("NDR_CHECK(ndr_push_relative_ptr1(ndr, $var_name));");
+ $self->pidl("NDR_CHECK(ndr_push_relative_ptr1($ndr, $var_name));");
} elsif ($l->{POINTER_TYPE} eq "unique") {
- $self->pidl("NDR_CHECK(ndr_push_unique_ptr(ndr, $var_name));");
+ $self->pidl("NDR_CHECK(ndr_push_unique_ptr($ndr, $var_name));");
} elsif ($l->{POINTER_TYPE} eq "full") {
- $self->pidl("NDR_CHECK(ndr_push_full_ptr(ndr, $var_name));");
+ $self->pidl("NDR_CHECK(ndr_push_full_ptr($ndr, $var_name));");
} else {
die("Unhandled pointer type $l->{POINTER_TYPE}");
}
@@ -702,45 +704,45 @@ sub need_pointer_to($$$)
return 0;
}
-sub ParseDataPrint($$$$)
+sub ParseDataPrint($$$$$)
{
- my ($self, $e, $l, $var_name) = @_;
-
+ my ($self, $e, $l, $ndr, $var_name) = @_;
+
if (not ref($l->{DATA_TYPE}) or defined($l->{DATA_TYPE}->{NAME})) {
if (need_pointer_to($e, $l, 1)) {
$var_name = get_pointer_to($var_name);
}
- $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."(ndr, \"$e->{NAME}\", $var_name);");
+ $self->pidl(TypeFunctionName("ndr_print", $l->{DATA_TYPE})."($ndr, \"$e->{NAME}\", $var_name);");
} else {
- $self->ParseTypePrint($l->{DATA_TYPE}, $var_name);
+ $self->ParseTypePrint($l->{DATA_TYPE}, $ndr, $var_name);
}
}
#####################################################################
# print scalars in a structure element
-sub ParseElementPrint($$$$)
+sub ParseElementPrint($$$$$)
{
- my($self, $e, $var_name, $env) = @_;
+ my($self, $e, $ndr, $var_name, $env) = @_;
return if (has_property($e, "noprint"));
if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
- $self->pidl("ndr_print_$e->{REPRESENTATION_TYPE}(ndr, \"$e->{NAME}\", $var_name);");
+ $self->pidl("ndr_print_$e->{REPRESENTATION_TYPE}($ndr, \"$e->{NAME}\", $var_name);");
return;
}
$var_name = append_prefix($e, $var_name);
if (defined(my $value = has_property($e, "value"))) {
- $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name";
+ $var_name = "($ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e->{ORIGINAL}) . ":$var_name";
}
foreach my $l (@{$e->{LEVELS}}) {
if ($l->{TYPE} eq "POINTER") {
- $self->pidl("ndr_print_ptr(ndr, \"$e->{NAME}\", $var_name);");
- $self->pidl("ndr->depth++;");
+ $self->pidl("ndr_print_ptr($ndr, \"$e->{NAME}\", $var_name);");
+ $self->pidl("$ndr->depth++;");
if ($l->{POINTER_TYPE} ne "ref") {
$self->pidl("if ($var_name) {");
$self->indent;
@@ -761,17 +763,17 @@ sub ParseElementPrint($$$$)
}
if (is_charset_array($e,$l)) {
- $self->pidl("ndr_print_string(ndr, \"$e->{NAME}\", $var_name);");
+ $self->pidl("ndr_print_string($ndr, \"$e->{NAME}\", $var_name);");
last;
} elsif (has_fast_array($e, $l)) {
my $nl = GetNextLevel($e, $l);
- $self->pidl("ndr_print_array_$nl->{DATA_TYPE}(ndr, \"$e->{NAME}\", $var_name, $length);");
+ $self->pidl("ndr_print_array_$nl->{DATA_TYPE}($ndr, \"$e->{NAME}\", $var_name, $length);");
last;
} else {
my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}";
- $self->pidl("ndr->print(ndr, \"\%s: ARRAY(\%d)\", \"$e->{NAME}\", (int)$length);");
- $self->pidl("ndr->depth++;");
+ $self->pidl("$ndr->print($ndr, \"\%s: ARRAY(\%d)\", \"$e->{NAME}\", (int)$length);");
+ $self->pidl("$ndr->depth++;");
$self->pidl("for ($counter=0;$counter<$length;$counter++) {");
$self->indent;
$self->pidl("char *idx_$l->{LEVEL_INDEX}=NULL;");
@@ -781,11 +783,11 @@ sub ParseElementPrint($$$$)
$var_name = get_array_element($var_name, $counter);
}
} elsif ($l->{TYPE} eq "DATA") {
- $self->ParseDataPrint($e, $l, $var_name);
+ $self->ParseDataPrint($e, $l, $ndr, $var_name);
} elsif ($l->{TYPE} eq "SWITCH") {
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return;"), check_fully_dereferenced($e, $env));
- $self->pidl("ndr_print_set_switch_value(ndr, " . get_pointer_to($var_name) . ", $switch_var);");
+ $self->pidl("ndr_print_set_switch_value($ndr, " . get_pointer_to($var_name) . ", $switch_var);");
}
}
@@ -795,7 +797,7 @@ sub ParseElementPrint($$$$)
$self->deindent;
$self->pidl("}");
}
- $self->pidl("ndr->depth--;");
+ $self->pidl("$ndr->depth--;");
} elsif (($l->{TYPE} eq "ARRAY")
and not is_charset_array($e,$l)
and not has_fast_array($e,$l)) {
@@ -804,7 +806,7 @@ sub ParseElementPrint($$$$)
$self->pidl("}");
$self->deindent;
$self->pidl("}");
- $self->pidl("ndr->depth--;");
+ $self->pidl("$ndr->depth--;");
}
}
}
@@ -816,7 +818,7 @@ sub ParseSwitchPull($$$$$$)
my($self,$e,$l,$ndr,$var_name,$env) = @_;
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"),
+ "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"),
check_fully_dereferenced($e, $env));
$var_name = get_pointer_to($var_name);
@@ -830,7 +832,7 @@ sub ParseSwitchPush($$$$$$)
my($self,$e,$l,$ndr,$var_name,$env) = @_;
my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"),
+ "return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"),
check_fully_dereferenced($e, $env));
$var_name = get_pointer_to($var_name);
@@ -861,7 +863,7 @@ sub ParseDataPull($$$$$$$)
$self->pidl("}");
}
} else {
- $self->ParseTypePull($l->{DATA_TYPE}, $var_name, $primitives, $deferred);
+ $self->ParseTypePull($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred);
}
}
@@ -880,7 +882,7 @@ sub ParseDataPush($$$$$$$)
$self->pidl("NDR_CHECK(".TypeFunctionName("ndr_push", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));");
} else {
- $self->ParseTypePush($l->{DATA_TYPE}, $var_name, $primitives, $deferred);
+ $self->ParseTypePush($l->{DATA_TYPE}, $ndr, $var_name, $primitives, $deferred);
}
}
@@ -936,9 +938,9 @@ sub ParseMemCtxPullFlags($$$$)
return $mem_flags;
}
-sub ParseMemCtxPullStart($$$$)
+sub ParseMemCtxPullStart($$$$$)
{
- my ($self, $e, $l, $ptr_name) = @_;
+ my ($self, $e, $l, $ndr, $ptr_name) = @_;
my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}";
my $mem_c_ctx = $ptr_name;
@@ -946,20 +948,20 @@ sub ParseMemCtxPullStart($$$$)
return unless defined($mem_c_flags);
- $self->pidl("$mem_r_ctx = NDR_PULL_GET_MEM_CTX(ndr);");
- $self->pidl("NDR_PULL_SET_MEM_CTX(ndr, $mem_c_ctx, $mem_c_flags);");
+ $self->pidl("$mem_r_ctx = NDR_PULL_GET_MEM_CTX($ndr);");
+ $self->pidl("NDR_PULL_SET_MEM_CTX($ndr, $mem_c_ctx, $mem_c_flags);");
}
-sub ParseMemCtxPullEnd($$$)
+sub ParseMemCtxPullEnd($$$$)
{
- my ($self, $e, $l) = @_;
+ my ($self, $e, $l, $ndr) = @_;
my $mem_r_ctx = "_mem_save_$e->{NAME}_$l->{LEVEL_INDEX}";
my $mem_r_flags = $self->ParseMemCtxPullFlags($e, $l);
return unless defined($mem_r_flags);
- $self->pidl("NDR_PULL_SET_MEM_CTX(ndr, $mem_r_ctx, $mem_r_flags);");
+ $self->pidl("NDR_PULL_SET_MEM_CTX($ndr, $mem_r_ctx, $mem_r_flags);");
}
sub CheckStringTerminator($$$$$)
@@ -1011,6 +1013,8 @@ sub ParseElementPullLevel
$self->ParseSwitchPull($e, $l, $ndr, $var_name, $env);
} elsif ($l->{TYPE} eq "DATA") {
$self->ParseDataPull($e, $l, $ndr, $var_name, $primitives, $deferred);
+ } elsif ($l->{TYPE} eq "TYPEDEF") {
+ $typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($self, $e->{DATA}, $ndr, $var_name);
}
}
@@ -1022,21 +1026,21 @@ sub ParseElementPullLevel
if ($l->{POINTER_TYPE} eq "relative") {
$self->pidl("uint32_t _relative_save_offset;");
- $self->pidl("_relative_save_offset = ndr->offset;");
- $self->pidl("NDR_CHECK(ndr_pull_relative_ptr2(ndr, $var_name));");
+ $self->pidl("_relative_save_offset = $ndr->offset;");
+ $self->pidl("NDR_CHECK(ndr_pull_relative_ptr2($ndr, $var_name));");
}
}
- $self->ParseMemCtxPullStart($e, $l, $var_name);
+ $self->ParseMemCtxPullStart($e, $l, $ndr, $var_name);
$var_name = get_value_of($var_name);
$self->ParseElementPullLevel($e, GetNextLevel($e,$l), $ndr, $var_name, $env, 1, 1);
- $self->ParseMemCtxPullEnd($e,$l);
+ $self->ParseMemCtxPullEnd($e, $l, $ndr);
if ($l->{POINTER_TYPE} ne "ref") {
if ($l->{POINTER_TYPE} eq "relative") {
- $self->pidl("ndr->offset = _relative_save_offset;");
+ $self->pidl("$ndr->offset = _relative_save_offset;");
}
$self->deindent;
$self->pidl("}");
@@ -1049,7 +1053,7 @@ sub ParseElementPullLevel
$var_name = get_array_element($var_name, $counter);
- $self->ParseMemCtxPullStart($e, $l, $array_name);
+ $self->ParseMemCtxPullStart($e, $l, $ndr, $array_name);
if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) {
my $nl = GetNextLevel($e,$l);
@@ -1073,7 +1077,7 @@ sub ParseElementPullLevel
$self->pidl("}");
}
- $self->ParseMemCtxPullEnd($e, $l);
+ $self->ParseMemCtxPullEnd($e, $l, $ndr);
} elsif ($l->{TYPE} eq "SWITCH") {
$self->ParseElementPullLevel($e, GetNextLevel($e,$l), $ndr, $var_name, $env, $primitives, $deferred);
@@ -1103,11 +1107,11 @@ sub ParseElementPull($$$$$$)
$var_name = append_prefix($e, $var_name);
- $self->start_flags($e);
+ $self->start_flags($e, $ndr);
$self->ParseElementPullLevel($e,$e->{LEVELS}[0],$ndr,$var_name,$env,$primitives,$deferred);
- $self->end_flags($e);
+ $self->end_flags($e, $ndr);
# Representation type is different from transmit_as
if ($e->{REPRESENTATION_TYPE} ne $e->{TYPE}) {
@@ -1131,7 +1135,7 @@ sub ParsePtrPull($$$$$)
if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") {
if (!$next_is_array and !$next_is_string) {
- $self->pidl("if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {");
+ $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {");
$self->pidl("\tNDR_PULL_ALLOC($ndr, $var_name);");
$self->pidl("}");
}
@@ -1172,9 +1176,9 @@ sub ParsePtrPull($$$$$)
$self->pidl("}");
}
-sub ParseStructPushPrimitives($$$$)
+sub ParseStructPushPrimitives($$$$$)
{
- my ($self, $struct, $varname, $env) = @_;
+ my ($self, $struct, $ndr, $varname, $env) = @_;
# see if the structure contains a conformant array. If it
# does, then it must be the last element of the structure, and
@@ -1198,39 +1202,39 @@ sub ParseStructPushPrimitives($$$$)
$size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL});
}
- $self->pidl("NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));");
+ $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, $size));");
} else {
- $self->pidl("NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_string_array_size(ndr, $varname->$e->{NAME})));");
+ $self->pidl("NDR_CHECK(ndr_push_uint32($ndr, NDR_SCALARS, ndr_string_array_size($ndr, $varname->$e->{NAME})));");
}
}
- $self->pidl("NDR_CHECK(ndr_push_align(ndr, $struct->{ALIGN}));");
+ $self->pidl("NDR_CHECK(ndr_push_align($ndr, $struct->{ALIGN}));");
if (defined($struct->{PROPERTIES}{relative_base})) {
# set the current offset as base for relative pointers
# and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, $varname, ndr->offset));");
+ $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
}
- $self->ParseElementPush($_, "ndr", $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
+ $self->ParseElementPush($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
}
-sub ParseStructPushDeferred($$$)
+sub ParseStructPushDeferred($$$$)
{
- my ($self, $struct, $varname, $env) = @_;
+ my ($self, $struct, $ndr, $varname, $env) = @_;
if (defined($struct->{PROPERTIES}{relative_base})) {
# retrieve the current offset as base for relative pointers
# based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, $varname));");
+ $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2($ndr, $varname));");
}
- $self->ParseElementPush($_, "ndr", $env, 0, 1) foreach (@{$struct->{ELEMENTS}});
+ $self->ParseElementPush($_, $ndr, $env, 0, 1) foreach (@{$struct->{ELEMENTS}});
}
#####################################################################
# parse a struct
-sub ParseStructPush($$$)
+sub ParseStructPush($$$$)
{
- my ($self, $struct, $varname) = @_;
+ my ($self, $struct, $ndr, $varname) = @_;
return unless defined($struct->{ELEMENTS});
@@ -1240,61 +1244,61 @@ sub ParseStructPush($$$)
$self->DeclareArrayVariables($_) foreach (@{$struct->{ELEMENTS}});
- $self->start_flags($struct);
+ $self->start_flags($struct, $ndr);
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
$self->indent;
- $self->ParseStructPushPrimitives($struct, $varname, $env);
+ $self->ParseStructPushPrimitives($struct, $ndr, $varname, $env);
$self->deindent;
$self->pidl("}");
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
- $self->ParseStructPushDeferred($struct, $varname, $env);
+ $self->ParseStructPushDeferred($struct, $ndr, $varname, $env);
$self->deindent;
$self->pidl("}");
- $self->end_flags($struct);
+ $self->end_flags($struct, $ndr);
}
#####################################################################
# generate a push function for an enum
-sub ParseEnumPush($$$)
+sub ParseEnumPush($$$$)
{
- my($self,$enum,$varname) = @_;
+ my($self,$enum,$ndr,$varname) = @_;
my($type_fn) = $enum->{BASE_TYPE};
- $self->start_flags($enum);
- $self->pidl("NDR_CHECK(ndr_push_$type_fn(ndr, NDR_SCALARS, $varname));");
- $self->end_flags($enum);
+ $self->start_flags($enum, $ndr);
+ $self->pidl("NDR_CHECK(ndr_push_$type_fn($ndr, NDR_SCALARS, $varname));");
+ $self->end_flags($enum, $ndr);
}
#####################################################################
# generate a pull function for an enum
-sub ParseEnumPull($$$)
+sub ParseEnumPull($$$$)
{
- my($self,$enum,$varname) = @_;
+ my($self,$enum,$ndr,$varname) = @_;
my($type_fn) = $enum->{BASE_TYPE};
my($type_v_decl) = mapTypeName($type_fn);
$self->pidl("$type_v_decl v;");
- $self->start_flags($enum);
- $self->pidl("NDR_CHECK(ndr_pull_$type_fn(ndr, NDR_SCALARS, &v));");
+ $self->start_flags($enum, $ndr);
+ $self->pidl("NDR_CHECK(ndr_pull_$type_fn($ndr, NDR_SCALARS, &v));");
$self->pidl("*$varname = v;");
- $self->end_flags($enum);
+ $self->end_flags($enum, $ndr);
}
#####################################################################
# generate a print function for an enum
-sub ParseEnumPrint($$$$)
+sub ParseEnumPrint($$$$$)
{
- my($self,$enum,$name,$varname) = @_;
+ my($self,$enum,$ndr,$name,$varname) = @_;
$self->pidl("const char *val = NULL;");
$self->pidl("");
- $self->start_flags($enum);
+ $self->start_flags($enum, $ndr);
$self->pidl("switch ($varname) {");
$self->indent;
@@ -1311,9 +1315,9 @@ sub ParseEnumPrint($$$$)
$self->deindent;
$self->pidl("}");
- $self->pidl("ndr_print_enum(ndr, name, \"$enum->{TYPE}\", val, $varname);");
+ $self->pidl("ndr_print_enum($ndr, name, \"$enum->{TYPE}\", val, $varname);");
- $self->end_flags($enum);
+ $self->end_flags($enum, $ndr);
}
sub DeclEnum($$$$)
@@ -1332,39 +1336,39 @@ $typefamily{ENUM} = {
#####################################################################
# generate a push function for a bitmap
-sub ParseBitmapPush($$$)
+sub ParseBitmapPush($$$$)
{
- my($self,$bitmap,$varname) = @_;
+ my($self,$bitmap,$ndr,$varname) = @_;
my($type_fn) = $bitmap->{BASE_TYPE};
- $self->start_flags($bitmap);
+ $self->start_flags($bitmap, $ndr);
- $self->pidl("NDR_CHECK(ndr_push_$type_fn(ndr, NDR_SCALARS, $varname));");
+ $self->pidl("NDR_CHECK(ndr_push_$type_fn($ndr, NDR_SCALARS, $varname));");
- $self->end_flags($bitmap);
+ $self->end_flags($bitmap, $ndr);
}
#####################################################################
# generate a pull function for an bitmap
-sub ParseBitmapPull($$$)
+sub ParseBitmapPull($$$$)
{
- my($self,$bitmap,$varname) = @_;
+ my($self,$bitmap,$ndr,$varname) = @_;
my $type_fn = $bitmap->{BASE_TYPE};
my($type_decl) = mapTypeName($bitmap->{BASE_TYPE});
$self->pidl("$type_decl v;");
- $self->start_flags($bitmap);
- $self->pidl("NDR_CHECK(ndr_pull_$type_fn(ndr, NDR_SCALARS, &v));");
+ $self->start_flags($bitmap, $ndr);
+ $self->pidl("NDR_CHECK(ndr_pull_$type_fn($ndr, NDR_SCALARS, &v));");
$self->pidl("*$varname = v;");
- $self->end_flags($bitmap);
+ $self->end_flags($bitmap, $ndr);
}
#####################################################################
# generate a print function for an bitmap
-sub ParseBitmapPrintElement($$$$$)
+sub ParseBitmapPrintElement($$$$$$)
{
- my($self,$e,$bitmap,$name,$varname) = @_;
+ my($self,$e,$bitmap,$ndr,$name,$varname) = @_;
my($type_decl) = mapTypeName($bitmap->{BASE_TYPE});
my($type_fn) = $bitmap->{BASE_TYPE};
my($flag);
@@ -1375,28 +1379,28 @@ sub ParseBitmapPrintElement($$$$$)
die "Bitmap: \"$name\" invalid Flag: \"$e\"";
}
- $self->pidl("ndr_print_bitmap_flag(ndr, sizeof($type_decl), \"$flag\", $flag, $varname);");
+ $self->pidl("ndr_print_bitmap_flag($ndr, sizeof($type_decl), \"$flag\", $flag, $varname);");
}
#####################################################################
# generate a print function for an bitmap
-sub ParseBitmapPrint($$$$)
+sub ParseBitmapPrint($$$$$)
{
- my($self,$bitmap,$name,$varname) = @_;
+ my($self,$bitmap,$ndr,$name,$varname) = @_;
my($type_decl) = mapTypeName($bitmap->{TYPE});
my($type_fn) = $bitmap->{BASE_TYPE};
- $self->start_flags($bitmap);
+ $self->start_flags($bitmap, $ndr);
- $self->pidl("ndr_print_$type_fn(ndr, name, $varname);");
+ $self->pidl("ndr_print_$type_fn($ndr, name, $varname);");
- $self->pidl("ndr->depth++;");
+ $self->pidl("$ndr->depth++;");
foreach my $e (@{$bitmap->{ELEMENTS}}) {
- $self->ParseBitmapPrintElement($e, $bitmap, $name, $varname);
+ $self->ParseBitmapPrintElement($e, $bitmap, $ndr, $name, $varname);
}
- $self->pidl("ndr->depth--;");
+ $self->pidl("$ndr->depth--;");
- $self->end_flags($bitmap);
+ $self->end_flags($bitmap, $ndr);
}
sub DeclBitmap($$$$)
@@ -1415,9 +1419,9 @@ $typefamily{BITMAP} = {
#####################################################################
# generate a struct print function
-sub ParseStructPrint($$$$)
+sub ParseStructPrint($$$$$)
{
- my($self,$struct,$name,$varname) = @_;
+ my($self,$struct,$ndr,$name,$varname) = @_;
return unless defined $struct->{ELEMENTS};
@@ -1425,17 +1429,17 @@ sub ParseStructPrint($$$$)
$self->DeclareArrayVariables($_) foreach (@{$struct->{ELEMENTS}});
- $self->pidl("ndr_print_struct(ndr, name, \"$name\");");
+ $self->pidl("ndr_print_struct($ndr, name, \"$name\");");
- $self->start_flags($struct);
+ $self->start_flags($struct, $ndr);
- $self->pidl("ndr->depth++;");
+ $self->pidl("$ndr->depth++;");
- $self->ParseElementPrint($_, $env->{$_->{NAME}}, $env)
+ $self->ParseElementPrint($_, $ndr, $env->{$_->{NAME}}, $env)
foreach (@{$struct->{ELEMENTS}});
- $self->pidl("ndr->depth--;");
+ $self->pidl("$ndr->depth--;");
- $self->end_flags($struct);
+ $self->end_flags($struct, $ndr);
}
sub DeclarePtrVariables($$)
@@ -1474,38 +1478,38 @@ sub DeclareMemCtxVariables($$)
}
}
-sub ParseStructPullPrimitives($$$$)
+sub ParseStructPullPrimitives($$$$$)
{
- my($self,$struct,$varname,$env) = @_;
+ my($self,$struct,$ndr,$varname,$env) = @_;
if (defined $struct->{SURROUNDING_ELEMENT}) {
- $self->pidl("NDR_CHECK(ndr_pull_array_size(ndr, &$varname->$struct->{SURROUNDING_ELEMENT}->{NAME}));");
+ $self->pidl("NDR_CHECK(ndr_pull_array_size($ndr, &$varname->$struct->{SURROUNDING_ELEMENT}->{NAME}));");
}
- $self->pidl("NDR_CHECK(ndr_pull_align(ndr, $struct->{ALIGN}));");
+ $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $struct->{ALIGN}));");
if (defined($struct->{PROPERTIES}{relative_base})) {
# set the current offset as base for relative pointers
# and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, $varname, ndr->offset));");
+ $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
}
- $self->ParseElementPull($_, "ndr", $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
+ $self->ParseElementPull($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
$self->add_deferred();
}
-sub ParseStructPullDeferred($$$$)
+sub ParseStructPullDeferred($$$$$)
{
- my ($self,$struct,$varname,$env) = @_;
+ my ($self,$struct,$ndr,$varname,$env) = @_;
if (defined($struct->{PROPERTIES}{relative_base})) {
# retrieve the current offset as base for relative pointers
# based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, $varname));");
+ $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2($ndr, $varname));");
}
foreach my $e (@{$struct->{ELEMENTS}}) {
- $self->ParseElementPull($e, "ndr", $env, 0, 1);
+ $self->ParseElementPull($e, $ndr, $env, 0, 1);
}
$self->add_deferred();
@@ -1513,9 +1517,9 @@ sub ParseStructPullDeferred($$$$)
#####################################################################
# parse a struct - pull side
-sub ParseStructPull($$$)
+sub ParseStructPull($$$$)
{
- my($self,$struct,$varname) = @_;
+ my($self,$struct,$ndr,$varname) = @_;
return unless defined $struct->{ELEMENTS};
@@ -1526,22 +1530,22 @@ sub ParseStructPull($$$)
$self->DeclareMemCtxVariables($e);
}
- $self->start_flags($struct);
+ $self->start_flags($struct, $ndr);
my $env = GenerateStructEnv($struct, $varname);
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
$self->indent;
- $self->ParseStructPullPrimitives($struct,$varname,$env);
+ $self->ParseStructPullPrimitives($struct,$ndr,$varname,$env);
$self->deindent;
$self->pidl("}");
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
- $self->ParseStructPullDeferred($struct,$varname,$env);
+ $self->ParseStructPullDeferred($struct,$ndr,$varname,$env);
$self->deindent;
$self->pidl("}");
- $self->end_flags($struct);
+ $self->end_flags($struct, $ndr);
}
#####################################################################
@@ -1592,16 +1596,16 @@ sub ParseUnionNdrSize($$$)
$self->pidl("return ndr_size_union($varname, flags, level, (ndr_push_flags_fn_t)ndr_push_$name);");
}
-sub ParseUnionPushPrimitives($$$)
+sub ParseUnionPushPrimitives($$$$)
{
- my ($self, $e, $varname) = @_;
+ my ($self, $e, $ndr ,$varname) = @_;
my $have_default = 0;
- $self->pidl("int level = ndr_push_get_switch_value(ndr, $varname);");
+ $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);");
if (defined($e->{SWITCH_TYPE})) {
- $self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}(ndr, NDR_SCALARS, level));");
+ $self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}($ndr, NDR_SCALARS, level));");
}
$self->pidl("switch (level) {");
@@ -1615,13 +1619,13 @@ sub ParseUnionPushPrimitives($$$)
if ($el->{TYPE} ne "EMPTY") {
$self->indent;
if (defined($e->{PROPERTIES}{relative_base})) {
- $self->pidl("NDR_CHECK(ndr_push_align(ndr, $el->{ALIGN}));");
+ $self->pidl("NDR_CHECK(ndr_push_align($ndr, $el->{ALIGN}));");
# set the current offset as base for relative pointers
# and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1(ndr, $varname, ndr->offset));");
+ $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
}
$self->DeclareArrayVariables($el);
- $self->ParseElementPush($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
+ $self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
$self->deindent;
}
$self->pidl("break; }");
@@ -1629,23 +1633,23 @@ sub ParseUnionPushPrimitives($$$)
}
if (! $have_default) {
$self->pidl("default:");
- $self->pidl("\treturn ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+ $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
}
$self->deindent;
$self->pidl("}");
}
-sub ParseUnionPushDeferred($$$)
+sub ParseUnionPushDeferred($$$$)
{
- my ($self,$e,$varname) = @_;
+ my ($self,$e,$ndr,$varname) = @_;
my $have_default = 0;
- $self->pidl("int level = ndr_push_get_switch_value(ndr, $varname);");
+ $self->pidl("int level = ndr_push_get_switch_value($ndr, $varname);");
if (defined($e->{PROPERTIES}{relative_base})) {
# retrieve the current offset as base for relative pointers
# based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2(ndr, $varname));");
+ $self->pidl("NDR_CHECK(ndr_push_setup_relative_base_offset2($ndr, $varname));");
}
$self->pidl("switch (level) {");
$self->indent;
@@ -1657,7 +1661,7 @@ sub ParseUnionPushDeferred($$$)
$self->pidl("$el->{CASE}:");
if ($el->{TYPE} ne "EMPTY") {
$self->indent;
- $self->ParseElementPush($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1);
+ $self->ParseElementPush($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1);
$self->deindent;
}
$self->pidl("break;");
@@ -1665,7 +1669,7 @@ sub ParseUnionPushDeferred($$$)
}
if (! $have_default) {
$self->pidl("default:");
- $self->pidl("\treturn ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+ $self->pidl("\treturn ndr_push_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
}
$self->deindent;
$self->pidl("}");
@@ -1673,31 +1677,31 @@ sub ParseUnionPushDeferred($$$)
#####################################################################
# parse a union - push side
-sub ParseUnionPush($$$)
+sub ParseUnionPush($$$$)
{
- my ($self,$e,$varname) = @_;
+ my ($self,$e,$ndr,$varname) = @_;
my $have_default = 0;
- $self->start_flags($e);
+ $self->start_flags($e, $ndr);
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
$self->indent;
- $self->ParseUnionPushPrimitives($e, $varname);
+ $self->ParseUnionPushPrimitives($e, $ndr, $varname);
$self->deindent;
$self->pidl("}");
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
- $self->ParseUnionPushDeferred($e, $varname);
+ $self->ParseUnionPushDeferred($e, $ndr, $varname);
$self->deindent;
$self->pidl("}");
- $self->end_flags($e);
+ $self->end_flags($e, $ndr);
}
#####################################################################
# print a union
-sub ParseUnionPrint($$$$)
+sub ParseUnionPrint($$$$$)
{
- my ($self,$e,$name,$varname) = @_;
+ my ($self,$e,$ndr,$name,$varname) = @_;
my $have_default = 0;
$self->pidl("int level;");
@@ -1705,11 +1709,11 @@ sub ParseUnionPrint($$$$)
$self->DeclareArrayVariables($el);
}
- $self->start_flags($e);
+ $self->start_flags($e, $ndr);
- $self->pidl("level = ndr_print_get_switch_value(ndr, $varname);");
+ $self->pidl("level = ndr_print_get_switch_value($ndr, $varname);");
- $self->pidl("ndr_print_union(ndr, name, level, \"$name\");");
+ $self->pidl("ndr_print_union($ndr, name, level, \"$name\");");
$self->pidl("switch (level) {");
$self->indent;
@@ -1720,7 +1724,7 @@ sub ParseUnionPrint($$$$)
$self->pidl("$el->{CASE}:");
if ($el->{TYPE} ne "EMPTY") {
$self->indent;
- $self->ParseElementPrint($el, "$varname->$el->{NAME}", {});
+ $self->ParseElementPrint($el, $ndr, "$varname->$el->{NAME}", {});
$self->deindent;
}
$self->pidl("break;");
@@ -1728,23 +1732,23 @@ sub ParseUnionPrint($$$$)
}
if (! $have_default) {
$self->pidl("default:");
- $self->pidl("\tndr_print_bad_level(ndr, name, level);");
+ $self->pidl("\tndr_print_bad_level($ndr, name, level);");
}
$self->deindent;
$self->pidl("}");
- $self->end_flags($e);
+ $self->end_flags($e, $ndr);
}
-sub ParseUnionPullPrimitives($$$$)
+sub ParseUnionPullPrimitives($$$$$)
{
- my ($self,$e,$varname,$switch_type) = @_;
+ my ($self,$e,$ndr,$varname,$switch_type) = @_;
my $have_default = 0;
if (defined($switch_type)) {
- $self->pidl("NDR_CHECK(ndr_pull_$switch_type(ndr, NDR_SCALARS, &_level));");
+ $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));");
$self->pidl("if (_level != level) {");
- $self->pidl("\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname\", _level);");
+ $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u for $varname\", _level);");
$self->pidl("}");
}
@@ -1761,12 +1765,12 @@ sub ParseUnionPullPrimitives($$$$)
$self->DeclarePtrVariables($el);
$self->DeclareArrayVariables($el);
if (defined($e->{PROPERTIES}{relative_base})) {
- $self->pidl("NDR_CHECK(ndr_pull_align(ndr, $el->{ALIGN}));");
+ $self->pidl("NDR_CHECK(ndr_pull_align($ndr, $el->{ALIGN}));");
# set the current offset as base for relative pointers
# and store it based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1(ndr, $varname, ndr->offset));");
+ $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset1($ndr, $varname, $ndr->offset));");
}
- $self->ParseElementPull($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
+ $self->ParseElementPull($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 1, 0);
$self->deindent;
}
$self->pidl("break; }");
@@ -1774,21 +1778,21 @@ sub ParseUnionPullPrimitives($$$$)
}
if (! $have_default) {
$self->pidl("default:");
- $self->pidl("\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+ $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
}
$self->deindent;
$self->pidl("}");
}
-sub ParseUnionPullDeferred($$$)
+sub ParseUnionPullDeferred($$$$)
{
- my ($self,$e,$varname) = @_;
+ my ($self,$e,$ndr,$varname) = @_;
my $have_default = 0;
if (defined($e->{PROPERTIES}{relative_base})) {
# retrieve the current offset as base for relative pointers
# based on the toplevel struct/union
- $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2(ndr, $varname));");
+ $self->pidl("NDR_CHECK(ndr_pull_setup_relative_base_offset2($ndr, $varname));");
}
$self->pidl("switch (level) {");
$self->indent;
@@ -1800,7 +1804,7 @@ sub ParseUnionPullDeferred($$$)
$self->pidl("$el->{CASE}:");
if ($el->{TYPE} ne "EMPTY") {
$self->indent;
- $self->ParseElementPull($el, "ndr", {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1);
+ $self->ParseElementPull($el, $ndr, {$el->{NAME} => "$varname->$el->{NAME}"}, 0, 1);
$self->deindent;
}
$self->pidl("break;");
@@ -1808,7 +1812,7 @@ sub ParseUnionPullDeferred($$$)
}
if (! $have_default) {
$self->pidl("default:");
- $self->pidl("\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
+ $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);");
}
$self->deindent;
$self->pidl("}");
@@ -1818,9 +1822,9 @@ sub ParseUnionPullDeferred($$$)
#####################################################################
# parse a union - pull side
-sub ParseUnionPull($$$)
+sub ParseUnionPull($$$$)
{
- my ($self,$e,$varname) = @_;
+ my ($self,$e,$ndr,$varname) = @_;
my $switch_type = $e->{SWITCH_TYPE};
$self->pidl("int level;");
@@ -1839,25 +1843,25 @@ sub ParseUnionPull($$$)
$double_cases{"$el->{NAME}"} = 1;
}
- $self->start_flags($e);
+ $self->start_flags($e, $ndr);
- $self->pidl("level = ndr_pull_get_switch_value(ndr, $varname);");
+ $self->pidl("level = ndr_pull_get_switch_value($ndr, $varname);");
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
$self->indent;
- $self->ParseUnionPullPrimitives($e,$varname,$switch_type);
+ $self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
$self->deindent;
$self->pidl("}");
$self->pidl("if (ndr_flags & NDR_BUFFERS) {");
$self->indent;
- $self->ParseUnionPullDeferred($e,$varname);
+ $self->ParseUnionPullDeferred($e,$ndr,$varname);
$self->deindent;
$self->pidl("}");
$self->add_deferred();
- $self->end_flags($e);
+ $self->end_flags($e, $ndr);
}
sub DeclUnion($$$$)
@@ -1883,29 +1887,37 @@ $typefamily{UNION} = {
#####################################################################
# parse a typedef - push side
-sub ParseTypedefPush($$$)
+sub ParseTypedefPush($$$$)
{
- my($self,$e,$varname) = @_;
+ my($self,$e,$ndr,$varname) = @_;
+
+ my $env;
+
+ $env->{$e->{NAME}} = $varname;
- $typefamily{$e->{DATA}->{TYPE}}->{PUSH_FN_BODY}->($self, $e->{DATA}, $varname);
+ $self->ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $varname, $env, 1, 1);
}
#####################################################################
# parse a typedef - pull side
-sub ParseTypedefPull($$$)
+sub ParseTypedefPull($$$$)
{
- my($self,$e,$varname) = @_;
+ my($self,$e,$ndr,$varname) = @_;
- $typefamily{$e->{DATA}->{TYPE}}->{PULL_FN_BODY}->($self, $e->{DATA}, $varname);
+ my $env;
+
+ $env->{$e->{NAME}} = $varname;
+
+ $self->ParseElementPullLevel($e, $e->{LEVELS}[0], $ndr, $varname, $env, 1, 1);
}
#####################################################################
# parse a typedef - print side
-sub ParseTypedefPrint($$$$)
+sub ParseTypedefPrint($$$$$)
{
- my($self,$e,$name,$varname) = @_;
+ my($self,$e,$ndr,$name,$varname) = @_;
- $typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($self, $e->{DATA}, $name, $varname);
+ $typefamily{$e->{DATA}->{TYPE}}->{PRINT_FN_BODY}->($self, $e->{DATA}, $ndr, $name, $varname);
}
#####################################################################
@@ -1944,12 +1956,13 @@ $typefamily{TYPEDEF} = {
sub ParseFunctionPrint($$)
{
my($self, $fn) = @_;
+ my $ndr = "ndr";
- $self->pidl_hdr("void ndr_print_$fn->{NAME}(struct ndr_print *ndr, const char *name, int flags, const struct $fn->{NAME} *r);");
+ $self->pidl_hdr("void ndr_print_$fn->{NAME}(struct ndr_print *$ndr, const char *name, int flags, const struct $fn->{NAME} *r);");
return if has_property($fn, "noprint");
- $self->pidl("_PUBLIC_ void ndr_print_$fn->{NAME}(struct ndr_print *ndr, const char *name, int flags, const struct $fn->{NAME} *r)");
+ $self->pidl("_PUBLIC_ void ndr_print_$fn->{NAME}(struct ndr_print *$ndr, const char *name, int flags, const struct $fn->{NAME} *r)");
$self->pidl("{");
$self->indent;
@@ -1957,48 +1970,48 @@ sub ParseFunctionPrint($$)
$self->DeclareArrayVariables($e);
}
- $self->pidl("ndr_print_struct(ndr, name, \"$fn->{NAME}\");");
- $self->pidl("ndr->depth++;");
+ $self->pidl("ndr_print_struct($ndr, name, \"$fn->{NAME}\");");
+ $self->pidl("$ndr->depth++;");
$self->pidl("if (flags & NDR_SET_VALUES) {");
- $self->pidl("\tndr->flags |= LIBNDR_PRINT_SET_VALUES;");
+ $self->pidl("\t$ndr->flags |= LIBNDR_PRINT_SET_VALUES;");
$self->pidl("}");
$self->pidl("if (flags & NDR_IN) {");
$self->indent;
- $self->pidl("ndr_print_struct(ndr, \"in\", \"$fn->{NAME}\");");
- $self->pidl("ndr->depth++;");
+ $self->pidl("ndr_print_struct($ndr, \"in\", \"$fn->{NAME}\");");
+ $self->pidl("$ndr->depth++;");
my $env = GenerateFunctionInEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$e->{DIRECTION}})) {
- $self->ParseElementPrint($e, $env->{$e->{NAME}}, $env);
+ $self->ParseElementPrint($e, $ndr, $env->{$e->{NAME}}, $env);
}
}
- $self->pidl("ndr->depth--;");
+ $self->pidl("$ndr->depth--;");
$self->deindent;
$self->pidl("}");
$self->pidl("if (flags & NDR_OUT) {");
$self->indent;
- $self->pidl("ndr_print_struct(ndr, \"out\", \"$fn->{NAME}\");");
- $self->pidl("ndr->depth++;");
+ $self->pidl("ndr_print_struct($ndr, \"out\", \"$fn->{NAME}\");");
+ $self->pidl("$ndr->depth++;");
$env = GenerateFunctionOutEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$e->{DIRECTION}})) {
- $self->ParseElementPrint($e, $env->{$e->{NAME}}, $env);
+ $self->ParseElementPrint($e, $ndr, $env->{$e->{NAME}}, $env);
}
}
if ($fn->{RETURN_TYPE}) {
- $self->pidl("ndr_print_$fn->{RETURN_TYPE}(ndr, \"result\", r->out.result);");
+ $self->pidl("ndr_print_$fn->{RETURN_TYPE}($ndr, \"result\", r->out.result);");
}
- $self->pidl("ndr->depth--;");
+ $self->pidl("$ndr->depth--;");
$self->deindent;
$self->pidl("}");
- $self->pidl("ndr->depth--;");
+ $self->pidl("$ndr->depth--;");
$self->deindent;
$self->pidl("}");
$self->pidl("");
@@ -2009,8 +2022,9 @@ sub ParseFunctionPrint($$)
sub ParseFunctionPush($$)
{
my($self, $fn) = @_;
+ my $ndr = "ndr";
- $self->fn_declare("push", $fn, "enum ndr_err_code ndr_push_$fn->{NAME}(struct ndr_push *ndr, int flags, const struct $fn->{NAME} *r)") or return;
+ $self->fn_declare("push", $fn, "enum ndr_err_code ndr_push_$fn->{NAME}(struct ndr_push *$ndr, int flags, const struct $fn->{NAME} *r)") or return;
return if has_property($fn, "nopush");
@@ -2030,7 +2044,7 @@ sub ParseFunctionPush($$)
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$e->{DIRECTION}})) {
- $self->ParseElementPush($e, "ndr", $env, 1, 1);
+ $self->ParseElementPush($e, $ndr, $env, 1, 1);
}
}
@@ -2043,12 +2057,12 @@ sub ParseFunctionPush($$)
$env = GenerateFunctionOutEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$e->{DIRECTION}})) {
- $self->ParseElementPush($e, "ndr", $env, 1, 1);
+ $self->ParseElementPush($e, $ndr, $env, 1, 1);
}
}
if ($fn->{RETURN_TYPE}) {
- $self->pidl("NDR_CHECK(ndr_push_$fn->{RETURN_TYPE}(ndr, NDR_SCALARS, r->out.result));");
+ $self->pidl("NDR_CHECK(ndr_push_$fn->{RETURN_TYPE}($ndr, NDR_SCALARS, r->out.result));");
}
$self->deindent;
@@ -2068,7 +2082,7 @@ sub AllocateArrayLevel($$$$$$)
$pl->{TYPE} eq "POINTER" and
$pl->{POINTER_TYPE} eq "ref"
and not $l->{IS_ZERO_TERMINATED}) {
- $self->pidl("if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {");
+ $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {");
$self->pidl("\tNDR_PULL_ALLOC_N($ndr, $var, $size);");
$self->pidl("}");
if (grep(/in/,@{$e->{DIRECTION}}) and
@@ -2086,9 +2100,10 @@ sub AllocateArrayLevel($$$$$$)
sub ParseFunctionPull($$)
{
my($self,$fn) = @_;
+ my $ndr = "ndr";
# pull function args
- $self->fn_declare("pull", $fn, "enum ndr_err_code ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, int flags, struct $fn->{NAME} *r)") or return;
+ $self->fn_declare("pull", $fn, "enum ndr_err_code ndr_pull_$fn->{NAME}(struct ndr_pull *$ndr, int flags, struct $fn->{NAME} *r)") or return;
$self->pidl("{");
$self->indent;
@@ -2125,7 +2140,7 @@ sub ParseFunctionPull($$)
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless (grep(/in/, @{$e->{DIRECTION}}));
- $self->ParseElementPull($e, "ndr", $env, 1, 1);
+ $self->ParseElementPull($e, $ndr, $env, 1, 1);
}
# allocate the "simple" out ref variables. FIXME: Shouldn't this have it's
@@ -2143,9 +2158,9 @@ sub ParseFunctionPull($$)
if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") {
my $size = ParseExprExt($e->{LEVELS}[1]->{SIZE_IS}, $env, $e->{ORIGINAL},
check_null_pointer($e, $env, sub { $self->pidl(shift); },
- "return ndr_pull_error(ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
+ "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for size_is()\");"),
check_fully_dereferenced($e, $env));
- $self->pidl("NDR_PULL_ALLOC_N(ndr, r->out.$e->{NAME}, $size);");
+ $self->pidl("NDR_PULL_ALLOC_N($ndr, r->out.$e->{NAME}, $size);");
if (grep(/in/, @{$e->{DIRECTION}})) {
$self->pidl("memcpy(r->out.$e->{NAME}, r->in.$e->{NAME}, ($size) * sizeof(*r->in.$e->{NAME}));");
@@ -2153,7 +2168,7 @@ sub ParseFunctionPull($$)
$self->pidl("memset(r->out.$e->{NAME}, 0, ($size) * sizeof(*r->out.$e->{NAME}));");
}
} else {
- $self->pidl("NDR_PULL_ALLOC(ndr, r->out.$e->{NAME});");
+ $self->pidl("NDR_PULL_ALLOC($ndr, r->out.$e->{NAME});");
if (grep(/in/, @{$e->{DIRECTION}})) {
$self->pidl("*r->out.$e->{NAME} = *r->in.$e->{NAME};");
@@ -2173,11 +2188,11 @@ sub ParseFunctionPull($$)
$env = GenerateFunctionOutEnv($fn);
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless grep(/out/, @{$e->{DIRECTION}});
- $self->ParseElementPull($e, "ndr", $env, 1, 1);
+ $self->ParseElementPull($e, $ndr, $env, 1, 1);
}
if ($fn->{RETURN_TYPE}) {
- $self->pidl("NDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}(ndr, NDR_SCALARS, &r->out.result));");
+ $self->pidl("NDR_CHECK(ndr_pull_$fn->{RETURN_TYPE}($ndr, NDR_SCALARS, &r->out.result));");
}
$self->add_deferred();
@@ -2364,81 +2379,86 @@ sub HeaderInterface($$$)
}
-sub ParseTypePush($$$$$)
+sub ParseTypePush($$$$$$)
{
- my ($self,$e,$varname, $primitives, $deferred) = @_;
+ my ($self,$e, $ndr, $varname, $primitives, $deferred) = @_;
# save the old relative_base_offset
- $self->pidl("uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset(ndr);") if defined(has_property($e, "relative_base"));
- $typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($self, $e, $varname);
+ $self->pidl("uint32_t _save_relative_base_offset = ndr_push_get_relative_base_offset($ndr);") if defined(has_property($e, "relative_base"));
+ $typefamily{$e->{TYPE}}->{PUSH_FN_BODY}->($self, $e, $ndr, $varname);
# restore the old relative_base_offset
- $self->pidl("ndr_push_restore_relative_base_offset(ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base"));
+ $self->pidl("ndr_push_restore_relative_base_offset($ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base"));
}
sub ParseTypePushFunction($$$)
{
my ($self, $e, $varname) = @_;
+ my $ndr = "ndr";
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "push", $e->{NAME}, $varname);
- $self->fn_declare("push", $e, "enum ndr_err_code ".TypeFunctionName("ndr_push", $e)."(struct ndr_push *ndr, int ndr_flags, $args)") or return;
+
+ $self->fn_declare("push", $e, "enum ndr_err_code ".TypeFunctionName("ndr_push", $e)."(struct ndr_push *$ndr, int ndr_flags, $args)") or return;
$self->pidl("{");
$self->indent;
- $self->ParseTypePush($e, $varname, 1, 1);
+ $self->ParseTypePush($e, $ndr, $varname, 1, 1);
$self->pidl("return NDR_ERR_SUCCESS;");
$self->deindent;
$self->pidl("}");
$self->pidl("");;
}
-sub ParseTypePull($$$$$)
+sub ParseTypePull($$$$$$)
{
- my ($self, $e, $varname, $primitives, $deferred) = @_;
+ my ($self, $e, $ndr, $varname, $primitives, $deferred) = @_;
# save the old relative_base_offset
- $self->pidl("uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset(ndr);") if defined(has_property($e, "relative_base"));
- $typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($self, $e, $varname);
+ $self->pidl("uint32_t _save_relative_base_offset = ndr_pull_get_relative_base_offset($ndr);") if defined(has_property($e, "relative_base"));
+ $typefamily{$e->{TYPE}}->{PULL_FN_BODY}->($self, $e, $ndr, $varname);
# restore the old relative_base_offset
- $self->pidl("ndr_pull_restore_relative_base_offset(ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base"));
+ $self->pidl("ndr_pull_restore_relative_base_offset($ndr, _save_relative_base_offset);") if defined(has_property($e, "relative_base"));
}
sub ParseTypePullFunction($$)
{
my ($self, $e, $varname) = @_;
+ my $ndr = "ndr";
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "pull", $e->{NAME}, $varname);
- $self->fn_declare("pull", $e, "enum ndr_err_code ".TypeFunctionName("ndr_pull", $e)."(struct ndr_pull *ndr, int ndr_flags, $args)") or return;
+ $self->fn_declare("pull", $e, "enum ndr_err_code ".TypeFunctionName("ndr_pull", $e)."(struct ndr_pull *$ndr, int ndr_flags, $args)") or return;
$self->pidl("{");
$self->indent;
- $self->ParseTypePull($e, $varname, 1, 1);
+ $self->ParseTypePull($e, $ndr, $varname, 1, 1);
$self->pidl("return NDR_ERR_SUCCESS;");
$self->deindent;
$self->pidl("}");
$self->pidl("");
}
-sub ParseTypePrint($$$)
+sub ParseTypePrint($$$$)
{
- my ($self, $e, $varname) = @_;
+ my ($self, $e, $ndr, $varname) = @_;
- $typefamily{$e->{TYPE}}->{PRINT_FN_BODY}->($self, $e, $e->{NAME}, $varname);
+ $typefamily{$e->{TYPE}}->{PRINT_FN_BODY}->($self, $e, $ndr, $e->{NAME}, $varname);
}
sub ParseTypePrintFunction($$$)
{
my ($self, $e, $varname) = @_;
+ my $ndr = "ndr";
+
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "print", $e->{NAME}, $varname);
$self->pidl_hdr("void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args);");
return if (has_property($e, "noprint"));
- $self->pidl("_PUBLIC_ void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args)");
+ $self->pidl("_PUBLIC_ void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *$ndr, const char *name, $args)");
$self->pidl("{");
$self->indent;
- $self->ParseTypePrint($e, $varname);
+ $self->ParseTypePrint($e, $ndr, $varname);
$self->deindent;
$self->pidl("}");
$self->pidl("");