summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/parser.pm24
-rw-r--r--source4/build/pidl/util.pm10
2 files changed, 29 insertions, 5 deletions
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index 004a9b971a..eb7758b1cc 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -36,6 +36,10 @@ sub find_size_var($$)
my($e) = shift;
my($size) = shift;
my($fn) = $e->{PARENT};
+
+ if (util::is_constant($size)) {
+ return $size;
+ }
if ($fn->{TYPE} ne "FUNCTION") {
return "r->$size";
@@ -77,11 +81,16 @@ sub ParseArrayPush($$)
my $e = shift;
my $var_prefix = shift;
my $size = find_size_var($e, util::array_size($e));
+ my $const = "";
+
+ if (util::is_constant($size)) {
+ $const = "_const";
+ }
if (util::is_scalar_type($e->{TYPE})) {
- $res .= "\t\tNDR_CHECK(ndr_push_array_$e->{TYPE}(ndr, $var_prefix$e->{NAME}, $size));\n";
+ $res .= "\t\tNDR_CHECK(ndr_push$const\_array_$e->{TYPE}(ndr, $var_prefix$e->{NAME}, $size));\n";
} else {
- $res .= "\t\tNDR_CHECK(ndr_push_array(ndr, ndr_flags, $var_prefix$e->{NAME}, sizeof($var_prefix$e->{NAME}\[0]), $size, (ndr_push_flags_fn_t)ndr_push_$e->{TYPE}));\n";
+ $res .= "\t\tNDR_CHECK(ndr_push$const\_array(ndr, ndr_flags, $var_prefix$e->{NAME}, sizeof($var_prefix$e->{NAME}\[0]), $size, (ndr_push_flags_fn_t)ndr_push_$e->{TYPE}));\n";
}
}
@@ -107,14 +116,19 @@ sub ParseArrayPull($$)
my $e = shift;
my $var_prefix = shift;
my $size = find_size_var($e, util::array_size($e));
+ my $const = "";
+
+ if (util::is_constant($size)) {
+ $const = "_const";
+ }
- if (util::need_alloc($e)) {
+ if (util::need_alloc($e) && !util::is_constant($size)) {
$res .= "\t\tNDR_ALLOC_N_SIZE(ndr, $var_prefix$e->{NAME}, $size, sizeof($var_prefix$e->{NAME}\[0]));\n";
}
if (util::is_scalar_type($e->{TYPE})) {
- $res .= "\t\tNDR_CHECK(ndr_pull_array_$e->{TYPE}(ndr, $var_prefix$e->{NAME}, $size));\n";
+ $res .= "\t\tNDR_CHECK(ndr_pull$const\_array_$e->{TYPE}(ndr, $var_prefix$e->{NAME}, $size));\n";
} else {
- $res .= "\t\tNDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)$var_prefix$e->{NAME}, sizeof($var_prefix$e->{NAME}\[0]), $size, (ndr_pull_flags_fn_t)ndr_pull_$e->{TYPE}));\n";
+ $res .= "\t\tNDR_CHECK(ndr_pull$const\_array(ndr, ndr_flags, (void **)$var_prefix$e->{NAME}, sizeof($var_prefix$e->{NAME}\[0]), $size, (ndr_pull_flags_fn_t)ndr_pull_$e->{TYPE}));\n";
}
}
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index 267cf36fef..9e7b909109 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -343,5 +343,15 @@ sub has_direct_buffers($)
return 0;
}
+# return 1 if the string is a C constant
+sub is_constant($)
+{
+ my $s = shift;
+ if ($s =~ /^\d/) {
+ return 1;
+ }
+ return 0;
+}
+
1;