summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-17 11:53:12 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-17 11:53:12 +0000
commitfb53302c8eb32603098b17bcf2fad16af66e9a60 (patch)
tree8470e109d4afdf5ca0d9b3034cc21542eba0493c /source4
parente62c5c9a8dd1258b776d40918026a1be4b71fb72 (diff)
downloadsamba-fb53302c8eb32603098b17bcf2fad16af66e9a60.tar.gz
samba-fb53302c8eb32603098b17bcf2fad16af66e9a60.tar.bz2
samba-fb53302c8eb32603098b17bcf2fad16af66e9a60.zip
auto-generate functions for printing top-level function
parameters. You can choose to print just the [in] parameters, just the [out] parameters or both (This used to be commit 6afc3a465e3fc568636ff52975a6d339f8bc3179)
Diffstat (limited to 'source4')
-rw-r--r--source4/build/pidl/parser.pm51
-rw-r--r--source4/build/pidl/util.pm4
2 files changed, 48 insertions, 7 deletions
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm
index 97300eda91..050ebdda02 100644
--- a/source4/build/pidl/parser.pm
+++ b/source4/build/pidl/parser.pm
@@ -232,7 +232,7 @@ sub ParseElementPrintScalar($$)
} elsif (util::has_direct_buffers($e)) {
$res .= "\tndr_print_ptr(ndr, \"$e->{NAME}\", $var_prefix$e->{NAME});\n";
$res .= "\tndr->depth++;\n";
- ParseElementPrintBuffer($e, "r->");
+ ParseElementPrintBuffer($e, $var_prefix);
$res .= "\tndr->depth--;\n";
} elsif (my $switch = util::has_property($e, "switch_is")) {
ParseElementPrintSwitch($e, $var_prefix, $switch);
@@ -387,16 +387,12 @@ sub ParseElementPrintBuffer($$)
my($var_prefix) = shift;
my $cprefix = util::c_push_prefix($e);
- if (util::is_pure_scalar($e)) {
- return;
- }
-
if (util::need_wire_pointer($e)) {
$res .= "\tif ($var_prefix$e->{NAME}) {\n";
}
if (util::array_size($e)) {
- ParseArrayPrint($e, "r->");
+ ParseArrayPrint($e, $var_prefix);
} elsif (my $switch = util::has_property($e, "switch_is")) {
ParseElementPrintSwitch($e, $var_prefix, $switch);
} else {
@@ -777,7 +773,7 @@ sub ParseTypedefPull($)
#####################################################################
-# parse a typedef - push side
+# parse a typedef - print side
sub ParseTypedefPrint($)
{
my($e) = shift;
@@ -799,6 +795,43 @@ sub ParseTypedefPrint($)
}
}
+#####################################################################
+# parse a function - print side
+sub ParseFunctionPrint($)
+{
+ my($fn) = shift;
+
+ $res .= "void ndr_print_$fn->{NAME}(struct ndr_print *ndr, const char *name, int flags, struct $fn->{NAME} *r)";
+ $res .= "\n{\n";
+ $res .= "\tndr_print_struct(ndr, name, \"$fn->{NAME}\");\n";
+ $res .= "\tndr->depth++;\n";
+
+ $res .= "\tif (flags & NDR_IN) {\n";
+ $res .= "\t\tndr_print_struct(ndr, \"in\", \"$fn->{NAME}\");\n";
+ $res .= "\tndr->depth++;\n";
+ foreach my $e (@{$fn->{DATA}}) {
+ if (util::has_property($e, "in")) {
+ ParseElementPrintScalar($e, "r->in.");
+ }
+ }
+ $res .= "\tndr->depth--;\n";
+ $res .= "\t}\n";
+
+ $res .= "\tif (flags & NDR_OUT) {\n";
+ $res .= "\t\tndr_print_struct(ndr, \"out\", \"$fn->{NAME}\");\n";
+ $res .= "\tndr->depth++;\n";
+ foreach my $e (@{$fn->{DATA}}) {
+ if (util::has_property($e, "out")) {
+ ParseElementPrintScalar($e, "r->out.");
+ }
+ }
+ $res .= "\tndr->depth--;\n";
+ $res .= "\t}\n";
+
+ $res .= "\tndr->depth--;\n";
+ $res .= "}\n\n";
+}
+
#####################################################################
# parse a function
@@ -901,6 +934,10 @@ sub ParseInterface($)
!util::has_property($d->{DATA}, "noprint")) {
ParseTypedefPrint($d);
}
+ if ($d->{TYPE} eq "FUNCTION" &&
+ !util::has_property($d, "noprint")) {
+ ParseFunctionPrint($d);
+ }
}
}
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index fcc6c54216..67f97e647e 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -150,6 +150,10 @@ sub has_property($$)
my($e) = shift;
my($p) = shift;
+ if (!defined $e->{PROPERTIES}) {
+ return;
+ }
+
my($props) = $e->{PROPERTIES};
foreach my $d (@{$props}) {