diff options
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/idl.gram | 3 | ||||
-rw-r--r-- | source4/build/pidl/parser.pm | 23 | ||||
-rw-r--r-- | source4/build/pidl/util.pm | 2 |
3 files changed, 25 insertions, 3 deletions
diff --git a/source4/build/pidl/idl.gram b/source4/build/pidl/idl.gram index f340b9787e..a4435819d5 100644 --- a/source4/build/pidl/idl.gram +++ b/source4/build/pidl/idl.gram @@ -107,7 +107,8 @@ property: 'unique' | 'context_handle' | 'string' | 'public' - | 'relative' + | 'relative' + | 'nodiscriminant' | 'subcontext' | 'byte_count_pointer' '(' expression ')' {{ "$item[1]" => "$item{expression}" }} | 'size_is' '(' expression ')' {{ "$item[1]" => "$item{expression}" }} diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm index 6037fb3d89..67118488d4 100644 --- a/source4/build/pidl/parser.pm +++ b/source4/build/pidl/parser.pm @@ -475,6 +475,8 @@ sub ParseStructPush($) $res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; + $res .= "\tNDR_CHECK(ndr_push_struct_start(ndr));\n"; + my $align = struct_alignment($struct); $res .= "\tNDR_CHECK(ndr_push_align(ndr, $align));\n"; @@ -483,6 +485,8 @@ sub ParseStructPush($) ParseElementPushScalar($e, "r->", "NDR_SCALARS"); } + $res .= "\tndr_push_struct_end(ndr);\n"; + $res .= "buffers:\n"; $res .= "\tif (!(ndr_flags & NDR_BUFFERS)) goto done;\n"; foreach my $e (@{$struct->{ELEMENTS}}) { @@ -540,6 +544,7 @@ sub ParseStructPull($) } } + $res .= "\tNDR_CHECK(ndr_pull_struct_start(ndr));\n"; if (defined $conform_e) { $res .= "\tNDR_CHECK(ndr_pull_uint32(ndr, &$conform_e->{CONFORMANT_SIZE}));\n"; @@ -554,6 +559,8 @@ sub ParseStructPull($) ParseElementPullScalar($e, "r->", "NDR_SCALARS"); } + $res .= "\tndr_pull_struct_end(ndr);\n"; + $res .= "buffers:\n"; $res .= "\tif (!(ndr_flags & NDR_BUFFERS)) goto done;\n"; foreach my $e (@{$struct->{ELEMENTS}}) { @@ -570,7 +577,12 @@ sub ParseUnionPush($) { my $e = shift; $res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; - $res .= "\tNDR_CHECK(ndr_push_uint16(ndr, level));\n"; + + $res .= "\tNDR_CHECK(ndr_push_struct_start(ndr));\n"; + + if (!util::has_property($e, "nodiscriminant")) { + $res .= "\tNDR_CHECK(ndr_push_uint16(ndr, level));\n"; + } $res .= "\tswitch (level) {\n"; foreach my $el (@{$e->{DATA}}) { $res .= "\tcase $el->{CASE}:\n"; @@ -580,6 +592,7 @@ sub ParseUnionPush($) $res .= "\tdefault:\n"; $res .= "\t\treturn ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);\n"; $res .= "\t}\n"; + $res .= "\tndr_push_struct_end(ndr);\n"; $res .= "buffers:\n"; $res .= "\tif (!(ndr_flags & NDR_BUFFERS)) goto done;\n"; $res .= "\tswitch (level) {\n"; @@ -617,7 +630,12 @@ sub ParseUnionPull($) my $e = shift; $res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; - $res .= "\tNDR_CHECK(ndr_pull_uint16(ndr, level));\n"; + + $res .= "\tNDR_CHECK(ndr_pull_struct_start(ndr));\n"; + + if (!util::has_property($e, "nodiscriminant")) { + $res .= "\tNDR_CHECK(ndr_pull_uint16(ndr, level));\n"; + } $res .= "\tswitch (*level) {\n"; foreach my $el (@{$e->{DATA}}) { $res .= "\tcase $el->{CASE}: {\n"; @@ -631,6 +649,7 @@ sub ParseUnionPull($) $res .= "\tdefault:\n"; $res .= "\t\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", *level);\n"; $res .= "\t}\n"; + $res .= "\tndr_pull_struct_end(ndr);\n"; $res .= "buffers:\n"; $res .= "\tif (!(ndr_flags & NDR_BUFFERS)) goto done;\n"; $res .= "\tswitch (*level) {\n"; diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm index 16cb012d0c..949946d328 100644 --- a/source4/build/pidl/util.pm +++ b/source4/build/pidl/util.pm @@ -183,6 +183,7 @@ sub is_scalar_type($) return 1, if ($type eq "NTTIME"); return 1, if ($type eq "HYPER_T"); return 1, if ($type eq "wchar_t"); + return 1, if ($type eq "DATA_BLOB"); return 0; } @@ -207,6 +208,7 @@ sub type_align($) return 4, if ($type eq "NTTIME"); return 8, if ($type eq "HYPER_T"); return 2, if ($type eq "wchar_t"); + return 4, if ($type eq "DATA_BLOB"); return 0; } |