summaryrefslogtreecommitdiff
path: root/source4/pidl
diff options
context:
space:
mode:
Diffstat (limited to 'source4/pidl')
-rw-r--r--source4/pidl/README2
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm73
-rwxr-xr-xsource4/pidl/tests/ndr_tagtype.pl4
-rwxr-xr-xsource4/pidl/tests/samba-ndr.pl44
4 files changed, 67 insertions, 56 deletions
diff --git a/source4/pidl/README b/source4/pidl/README
index f29e274192..8856993816 100644
--- a/source4/pidl/README
+++ b/source4/pidl/README
@@ -4,7 +4,7 @@ This directory contains the source code of the pidl (Perl IDL)
compiler for Samba 4.
The main sources for pidl are available by Subversion on
-svn+ssh://svnanon.samba.org/samba/branches/SAMBA_4_0/source/pidl
+svn://svn.samba.org/samba/branches/SAMBA_4_0/source/pidl
Pidl works by building a parse tree from a .pidl file (a simple
dump of it's internal parse tree) or a .idl file
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index e1a19a7d3b..16d60ace53 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -12,7 +12,7 @@ require Exporter;
@EXPORT = qw(is_charset_array);
@EXPORT_OK = qw(check_null_pointer GenerateFunctionInEnv
GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv NeededFunction
- NeededElement NeededType $res NeededInterface);
+ NeededElement NeededType $res NeededInterface TypeFunctionName);
use strict;
use Parse::Pidl::Typelist qw(hasType getType mapTypeName);
@@ -898,20 +898,14 @@ sub ParseDataPull($$$$$$)
defined($l->{DATA_TYPE}->{NAME})) {
my $ndr_flags = CalcNdrFlags($l, $primitives, $deferred);
- my $t;
- if (ref($l->{DATA_TYPE}) eq "HASH") {
- $t = "$l->{DATA_TYPE}->{TYPE}_$l->{DATA_TYPE}->{NAME}";
- } else {
- $t = $l->{DATA_TYPE};
- }
- if (Parse::Pidl::Typelist::scalar_is_reference($t)) {
+ if (Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) {
$var_name = get_pointer_to($var_name);
}
$var_name = get_pointer_to($var_name);
- pidl "NDR_CHECK(ndr_pull_$t($ndr, $ndr_flags, $var_name));";
+ pidl "NDR_CHECK(".TypeFunctionName("ndr_pull", $l->{DATA_TYPE})."($ndr, $ndr_flags, $var_name));";
if (my $range = has_property($e, "range")) {
$var_name = get_value_of($var_name);
@@ -2457,7 +2451,7 @@ sub ParseTypePushFunction($$)
my ($e, $varname) = @_;
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "push", $e->{NAME}, $varname);
- fn_declare("push", $e, "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, $args)") or return;
+ fn_declare("push", $e, "NTSTATUS ".TypeFunctionName("ndr_push", $e)."(struct ndr_push *ndr, int ndr_flags, $args)") or return;
pidl "{";
indent;
@@ -2485,7 +2479,7 @@ sub ParseTypePullFunction($$)
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "pull", $e->{NAME}, $varname);
- fn_declare("pull", $e, "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, $args)") or return;
+ fn_declare("pull", $e, "NTSTATUS ".TypeFunctionName("ndr_pull", $e)."(struct ndr_pull *ndr, int ndr_flags, $args)") or return;
pidl "{";
indent;
@@ -2508,11 +2502,11 @@ sub ParseTypePrintFunction($$)
my ($e, $varname) = @_;
my $args = $typefamily{$e->{TYPE}}->{DECL}->($e, "print", $e->{NAME}, $varname);
- pidl_hdr "void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, $args);";
+ pidl_hdr "void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args);";
return if (has_property($e, "noprint"));
- pidl "_PUBLIC_ void ndr_print_$e->{NAME}(struct ndr_print *ndr, const char *name, $args)";
+ pidl "_PUBLIC_ void ".TypeFunctionName("ndr_print", $e)."(struct ndr_print *ndr, const char *name, $args)";
pidl "{";
indent;
ParseTypePrint($e, $varname);
@@ -2558,26 +2552,27 @@ sub ParseInterface($$)
# Typedefs
foreach my $d (@{$interface->{TYPES}}) {
- ($needed->{"push_$d->{NAME}"}) && ParseTypePushFunction($d, "r");
- ($needed->{"pull_$d->{NAME}"}) && ParseTypePullFunction($d, "r");
- ($needed->{"print_$d->{NAME}"}) && ParseTypePrintFunction($d, "r");
+ ($needed->{TypeFunctionName("ndr_push", $d)}) && ParseTypePushFunction($d, "r");
+ ($needed->{TypeFunctionName("ndr_pull", $d)}) && ParseTypePullFunction($d, "r");
+ ($needed->{TypeFunctionName("ndr_print", $d)}) && ParseTypePrintFunction($d, "r");
# Make sure we don't generate a function twice...
- $needed->{"push_$d->{NAME}"} = $needed->{"pull_$d->{NAME}"} =
- $needed->{"print_$d->{NAME}"} = 0;
+ $needed->{TypeFunctionName("ndr_push", $d)} =
+ $needed->{TypeFunctionName("ndr_pull", $d)} =
+ $needed->{TypeFunctionName("ndr_print", $d)} = 0;
($needed->{"ndr_size_$d->{NAME}"}) && ParseTypeNdrSize($d);
}
# Functions
foreach my $d (@{$interface->{FUNCTIONS}}) {
- ($needed->{"push_$d->{NAME}"}) && ParseFunctionPush($d);
- ($needed->{"pull_$d->{NAME}"}) && ParseFunctionPull($d);
- ($needed->{"print_$d->{NAME}"}) && ParseFunctionPrint($d);
+ ($needed->{"ndr_push_$d->{NAME}"}) && ParseFunctionPush($d);
+ ($needed->{"ndr_pull_$d->{NAME}"}) && ParseFunctionPull($d);
+ ($needed->{"ndr_print_$d->{NAME}"}) && ParseFunctionPrint($d);
# Make sure we don't generate a function twice...
- $needed->{"push_$d->{NAME}"} = $needed->{"pull_$d->{NAME}"} =
- $needed->{"print_$d->{NAME}"} = 0;
+ $needed->{"ndr_push_$d->{NAME}"} = $needed->{"ndr_pull_$d->{NAME}"} =
+ $needed->{"ndr_print_$d->{NAME}"} = 0;
}
FunctionTable($interface);
@@ -2670,13 +2665,13 @@ sub NeededElement($$$)
my @fn = ();
if ($dir eq "print") {
- push(@fn, "print_$rt");
+ push(@fn, TypeFunctionName("ndr_print", $e->{REPRESENTATION_TYPE}));
} elsif ($dir eq "pull") {
- push (@fn, "pull_$t");
+ push (@fn, TypeFunctionName("ndr_pull", $e->{TYPE}));
push (@fn, "ndr_$t\_to_$rt")
if ($rt ne $t);
} elsif ($dir eq "push") {
- push (@fn, "push_$t");
+ push (@fn, TypeFunctionName("ndr_push", $e->{TYPE}));
push (@fn, "ndr_$rt\_to_$t")
if ($rt ne $t);
} else {
@@ -2693,9 +2688,9 @@ sub NeededElement($$$)
sub NeededFunction($$)
{
my ($fn,$needed) = @_;
- $needed->{"pull_$fn->{NAME}"} = 1;
- $needed->{"push_$fn->{NAME}"} = 1;
- $needed->{"print_$fn->{NAME}"} = 1;
+ $needed->{"ndr_pull_$fn->{NAME}"} = 1;
+ $needed->{"ndr_push_$fn->{NAME}"} = 1;
+ $needed->{"ndr_print_$fn->{NAME}"} = 1;
foreach my $e (@{$fn->{ELEMENTS}}) {
$e->{PARENT} = $fn;
NeededElement($e, $_, $needed) foreach ("pull", "push", "print");
@@ -2729,17 +2724,27 @@ sub NeededInterface($$)
NeededFunction($_, $needed) foreach (@{$interface->{FUNCTIONS}});
foreach (reverse @{$interface->{TYPES}}) {
if (has_property($_, "public")) {
- $needed->{"pull\_$_->{NAME}"} = $needed->{"push\_$_->{NAME}"} =
- $needed->{"print\_$_->{NAME}"} = 1;
+ $needed->{TypeFunctionName("ndr_pull", $_)} = $needed->{TypeFunctionName("ndr_push", $_)} =
+ $needed->{TypeFunctionName("ndr_print", $_)} = 1;
}
- NeededType($_, $needed, "pull") if ($needed->{"pull_$_->{NAME}"});
- NeededType($_, $needed, "push") if ($needed->{"push_$_->{NAME}"});
- NeededType($_, $needed, "print") if ($needed->{"print_$_->{NAME}"});
+ NeededType($_, $needed, "pull") if ($needed->{TypeFunctionName("ndr_pull", $_)});
+ NeededType($_, $needed, "push") if ($needed->{TypeFunctionName("ndr_push", $_)});
+ NeededType($_, $needed, "print") if ($needed->{TypeFunctionName("ndr_print", $_)});
if (has_property($_, "gensize")) {
$needed->{"ndr_size_$_->{NAME}"} = 1;
}
}
}
+sub TypeFunctionName($$)
+{
+ my ($prefix, $t) = @_;
+
+ return "$prefix\_$t->{NAME}" if (ref($t) eq "HASH" and
+ ($t->{TYPE} eq "TYPEDEF" or $t->{TYPE} eq "DECLARE"));
+ return "$prefix\_$t->{TYPE}_$t->{NAME}" if (ref($t) eq "HASH");
+ return "$prefix\_$t";
+}
+
1;
diff --git a/source4/pidl/tests/ndr_tagtype.pl b/source4/pidl/tests/ndr_tagtype.pl
index efc5b67746..d7839426d5 100755
--- a/source4/pidl/tests/ndr_tagtype.pl
+++ b/source4/pidl/tests/ndr_tagtype.pl
@@ -17,7 +17,7 @@ test_samba4_ndr('struct-notypedef', '[public] struct bla { uint8 x; }; ',
DATA_BLOB result_blob;
r.x = 13;
- if (NT_STATUS_IS_ERR(ndr_push_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_STRUCT_bla(ndr, NDR_SCALARS|NDR_BUFFERS, &r)))
return 1;
result_blob = ndr_push_blob(ndr);
@@ -56,7 +56,7 @@ test_samba4_ndr('struct-notypedef-embedded', 'struct bla { uint8 x; };
DATA_BLOB result_blob;
r.x = 13;
- if (NT_STATUS_IS_ERR(ndr_push_myfn(ndr, NDR_IN, &r)))
+ if (NT_STATUS_IS_ERR(ndr_push_STRUCT_myfn(ndr, NDR_IN, &r)))
return 1;
result_blob = ndr_push_blob(ndr);
diff --git a/source4/pidl/tests/samba-ndr.pl b/source4/pidl/tests/samba-ndr.pl
index d956402e64..a806d33417 100755
--- a/source4/pidl/tests/samba-ndr.pl
+++ b/source4/pidl/tests/samba-ndr.pl
@@ -4,7 +4,7 @@
use strict;
use warnings;
-use Test::More tests => 34;
+use Test::More tests => 38;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@@ -12,7 +12,7 @@ use Parse::Pidl::Util qw(MyDumper);
use Parse::Pidl::Samba4::NDR::Parser qw(check_null_pointer
GenerateFunctionInEnv GenerateFunctionOutEnv GenerateStructEnv
EnvSubstituteValue NeededFunction NeededElement NeededType $res
- NeededInterface);
+ NeededInterface TypeFunctionName);
my $output;
sub print_fn($) { my $x = shift; $output.=$x; }
@@ -185,28 +185,28 @@ is_deeply($env, { foo => 0, this => "r" });
my $needed = {};
NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed);
-is_deeply($needed, { pull_foo => 1 });
+is_deeply($needed, { ndr_pull_foo => 1 });
# old settings should be kept
-$needed = { pull_foo => 0 };
+$needed = { ndr_pull_foo => 0 };
NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "pull", $needed);
-is_deeply($needed, { pull_foo => 0 });
+is_deeply($needed, { ndr_pull_foo => 0 });
# print/pull/push are independent of each other
-$needed = { pull_foo => 0 };
+$needed = { ndr_pull_foo => 0 };
NeededElement({ TYPE => "foo", REPRESENTATION_TYPE => "foo" }, "print", $needed);
-is_deeply($needed, { pull_foo => 0, print_foo => 1 });
+is_deeply($needed, { ndr_pull_foo => 0, ndr_print_foo => 1 });
$needed = { };
NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed);
-is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
- pull_bar => 1, print_bar => 1, push_bar => 1});
+is_deeply($needed, { ndr_pull_foo => 1, ndr_print_foo => 1, ndr_push_foo => 1,
+ ndr_pull_bar => 1, ndr_print_bar => 1, ndr_push_bar => 1});
# push/pull/print are always set for functions
-$needed = { pull_foo => 0 };
+$needed = { ndr_pull_foo => 0 };
NeededFunction({ NAME => "foo", ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] }, $needed);
-is_deeply($needed, { pull_foo => 1, print_foo => 1, push_foo => 1,
- pull_bar => 1, push_bar => 1, print_bar => 1});
+is_deeply($needed, { ndr_pull_foo => 1, ndr_print_foo => 1, ndr_push_foo => 1,
+ ndr_pull_bar => 1, ndr_push_bar => 1, ndr_print_bar => 1});
# public structs are always needed
$needed = {};
@@ -220,7 +220,7 @@ NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla",
TYPE => "TYPEDEF",
DATA => { TYPE => "STRUCT", ELEMENTS => [] } } ] },
$needed);
-is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1 });
+is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1 });
# make sure types for elements are set too
$needed = {};
@@ -229,8 +229,8 @@ NeededInterface({ TYPES => [ { PROPERTIES => { public => 1 }, NAME => "bla",
DATA => { TYPE => "STRUCT",
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } } ] },
$needed);
-is_deeply($needed, { pull_bla => 1, pull_bar => 1, push_bla => 1, push_bar => 1,
- print_bla => 1, print_bar => 1});
+is_deeply($needed, { ndr_pull_bla => 1, ndr_pull_bar => 1, ndr_push_bla => 1, ndr_push_bar => 1,
+ ndr_print_bla => 1, ndr_print_bar => 1});
$needed = {};
NeededInterface({ TYPES => [ { PROPERTIES => { gensize => 1}, NAME => "bla",
@@ -241,13 +241,13 @@ NeededInterface({ TYPES => [ { PROPERTIES => { gensize => 1}, NAME => "bla",
is_deeply($needed, { ndr_size_bla => 1 });
# make sure types for elements are set too
-$needed = { pull_bla => 1 };
+$needed = { ndr_pull_bla => 1 };
NeededType({ NAME => "bla",
TYPE => "TYPEDEF",
DATA => { TYPE => "STRUCT",
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "bar" } ] } },
$needed, "pull");
-is_deeply($needed, { pull_bla => 1, pull_bar => 1 });
+is_deeply($needed, { ndr_pull_bla => 1, ndr_pull_bar => 1 });
$needed = {};
NeededInterface({ TYPES => [ { PROPERTIES => { public => 1},
@@ -255,8 +255,9 @@ NeededInterface({ TYPES => [ { PROPERTIES => { public => 1},
TYPE => "TYPEDEF",
DATA => { TYPE => "STRUCT",
ELEMENTS => [ { TYPE => "bar", REPRESENTATION_TYPE => "rep" } ] } } ] }, $needed);
-is_deeply($needed, { pull_bla => 1, push_bla => 1, print_bla => 1, print_rep => 1,
- pull_bar => 1, push_bar => 1,
+is_deeply($needed, { ndr_pull_bla => 1, ndr_push_bla => 1, ndr_print_bla => 1,
+ ndr_print_rep => 1,
+ ndr_pull_bar => 1, ndr_push_bar => 1,
ndr_bar_to_rep => 1, ndr_rep_to_bar => 1});
$res = "";
@@ -297,3 +298,8 @@ is($res, "if (ndr_flags & NDR_SCALARS) {
if (ndr_flags & NDR_BUFFERS) {
}
");
+
+is(TypeFunctionName("ndr_pull", "uint32"), "ndr_pull_uint32");
+is(TypeFunctionName("ndr_pull", {TYPE => "ENUM", NAME => "bar"}), "ndr_pull_ENUM_bar");
+is(TypeFunctionName("ndr_pull", {TYPE => "TYPEDEF", NAME => "bar", DATA => undef}), "ndr_pull_bar");
+is(TypeFunctionName("ndr_push", {TYPE => "STRUCT", NAME => "bar"}), "ndr_push_STRUCT_bar");