summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-12 05:32:37 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-12 05:32:37 +0000
commit6735b72a8d0a8e0be274208c84b65db2fa33d2a0 (patch)
tree4cea4d96b7482211d8c1328e2ae0fed1096a1c67 /source4/build
parent8830a20bce4bde93aef2752c1e87aca428169d0a (diff)
downloadsamba-6735b72a8d0a8e0be274208c84b65db2fa33d2a0.tar.gz
samba-6735b72a8d0a8e0be274208c84b65db2fa33d2a0.tar.bz2
samba-6735b72a8d0a8e0be274208c84b65db2fa33d2a0.zip
handle constant sized arrays
(This used to be commit 673e7bcdc2d7ee949ca0f56f9ba3cd04b5c38397)
Diffstat (limited to 'source4/build')
-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;