summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-07 08:20:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:19 -0500
commitf44b9ae3e6e7d37020d4e644862772428b3a68ae (patch)
treeb453e266aea2c39619fe008e75c242cd3bb370bf /source4/build/pidl
parent3c2dc30b3ee719ceb7846f975b83a79c9cb1a9d7 (diff)
downloadsamba-f44b9ae3e6e7d37020d4e644862772428b3a68ae.tar.gz
samba-f44b9ae3e6e7d37020d4e644862772428b3a68ae.tar.bz2
samba-f44b9ae3e6e7d37020d4e644862772428b3a68ae.zip
r8198: - handled push/pull of simple strings in ejs
- improved the error handling, so the ejs wrappers don't just ignore a type they don't handle, instead an exception is issued saying what isn't handled (This used to be commit a77c2aa8606ad668f6a513211a1d9e7d6193d741)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/ejs.pm76
1 files changed, 56 insertions, 20 deletions
diff --git a/source4/build/pidl/ejs.pm b/source4/build/pidl/ejs.pm
index 14c0c3668f..bd35078abd 100644
--- a/source4/build/pidl/ejs.pm
+++ b/source4/build/pidl/ejs.pm
@@ -97,6 +97,18 @@ sub EjsPullScalar($$)
pidl "\tNDR_CHECK(ejs_pull_$e->{TYPE}(ejs, v, \"$e->{NAME}\", $ptr));\n";
}
+###########################
+# pull a string element
+sub EjsPullString($$$)
+{
+ my $e = shift;
+ my $l = shift;
+ my $env = shift;
+ my $var = util::ParseExpr($e->{NAME}, $env);
+ my $ptr = get_pointer_to($var);
+ pidl "\tNDR_CHECK(ejs_pull_string(ejs, v, \"$e->{NAME}\", $ptr));\n";
+}
+
###########################
# pull an arrar element
@@ -109,7 +121,7 @@ sub EjsPullArray($$$)
my $length = util::ParseExpr($l->{LENGTH_IS}, $env);
my $var = util::ParseExpr($e->{NAME}, $env);
my $ptr = get_pointer_to($var);
- pidl "\tNDR_CHECK(ejs_pull_array(ejs, v, \"$e->{NAME}\", $length, sizeof($ptr\[0]), (void **)$ptr, (ejs_pull_t)ejs_pull_$e->{TYPE}));\n";
+ pidl "\tNDR_CHECK(ejs_pull_array(ejs, v, \"$e->{NAME}\", $length, sizeof($var\[0]), (void **)$ptr, (ejs_pull_t)ejs_pull_$e->{TYPE}));\n";
}
###########################
@@ -119,8 +131,15 @@ sub EjsPullElement($$)
my $e = shift;
my $env = shift;
my $l = $e->{LEVELS}[0];
- ($l->{TYPE} eq "ARRAY") && EjsPullArray($e, $l, $env);
- ($l->{TYPE} eq "DATA") && EjsPullScalar($e, $env);
+ if (util::has_property($e, "charset")) {
+ EjsPullString($e, $l, $env);
+ } elsif ($l->{TYPE} eq "ARRAY") {
+ EjsPullArray($e, $l, $env);
+ } elsif ($l->{TYPE} eq "DATA") {
+ EjsPullScalar($e, $env);
+ } else {
+ pidl "return ejs_panic(ejs, \"unhandled pull type $l->{TYPE}\");\n";
+ }
}
###########################
@@ -169,11 +188,12 @@ sub EjsPullFunction($)
{
my $d = shift;
my $env = GenerateFunctionInEnv($d);
+ my $name = $d->{NAME};
- pidl "\nstatic NTSTATUS ejs_pull_$d->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, struct $d->{NAME} *r)\n";
+ pidl "\nstatic NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, struct $name *r)\n";
pidl "{\n";
- pidl "\tNDR_CHECK(ejs_pull_struct_start(ejs, &v, \"in\"));\n";
+ pidl "\tNDR_CHECK(ejs_pull_struct_start(ejs, &v, \"input\"));\n";
foreach my $e (@{$d->{ELEMENTS}}) {
next unless (grep(/in/, @{$e->{DIRECTION}}));
@@ -194,15 +214,24 @@ sub EjsPushScalar($$$)
my $env = shift;
my $var = util::ParseExpr($e->{NAME}, $env);
- if (not typelist::is_scalar($l->{DATA_TYPE}) or
- typelist::scalar_is_reference($l->{DATA_TYPE})) {
- $var = get_pointer_to($var);
- }
+ $var = get_pointer_to($var);
pidl "\tNDR_CHECK(ejs_push_$e->{TYPE}(ejs, v, \"$e->{NAME}\", $var));\n";
}
###########################
+# pull a string element
+sub EjsPushString($$$)
+{
+ my $e = shift;
+ my $l = shift;
+ my $env = shift;
+ my $var = util::ParseExpr($e->{NAME}, $env);
+
+ pidl "\tNDR_CHECK(ejs_push_string(ejs, v, \"$e->{NAME}\", $var));\n";
+}
+
+###########################
# pull a pointer element
sub EjsPushPointer($$$)
{
@@ -215,9 +244,7 @@ sub EjsPushPointer($$$)
$var = get_value_of($var);
$l = Ndr::GetNextLevel($e, $l);
}
- if (not typelist::is_scalar($l->{DATA_TYPE})) {
- $var = get_pointer_to($var);
- }
+ $var = get_pointer_to($var);
pidl "\tNDR_CHECK(ejs_push_$e->{TYPE}(ejs, v, \"$e->{NAME}\", $var));\n";
}
@@ -243,9 +270,17 @@ sub EjsPushElement($$)
my $e = shift;
my $env = shift;
my $l = $e->{LEVELS}[0];
- ($l->{TYPE} eq "ARRAY") && EjsPushArray($e, $l, $env);
- ($l->{TYPE} eq "DATA") && EjsPushScalar($e, $l, $env);
- ($l->{TYPE} eq "POINTER") && EjsPushPointer($e, $l, $env);
+ if (util::has_property($e, "charset")) {
+ EjsPushString($e, $l, $env);
+ } elsif ($l->{TYPE} eq "ARRAY") {
+ EjsPushArray($e, $l, $env);
+ } elsif ($l->{TYPE} eq "DATA") {
+ EjsPushScalar($e, $l, $env);
+ } elsif (($l->{TYPE} eq "POINTER")) {
+ EjsPushPointer($e, $l, $env);
+ } else {
+ pidl "return ejs_panic(ejs, \"unhandled push type $l->{TYPE}\");\n";
+ }
}
###########################
@@ -255,7 +290,7 @@ sub EjsStructPush($$)
my $name = shift;
my $d = shift;
my $env = GenerateStructEnv($d);
- pidl "\nstatic NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, struct $name *r)\n{\n";
+ pidl "\nstatic NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const struct $name *r)\n{\n";
pidl "\tNDR_CHECK(ejs_push_struct_start(ejs, &v, name));\n";
foreach my $e (@{$d->{ELEMENTS}}) {
EjsPushElement($e, $env);
@@ -270,7 +305,7 @@ sub EjsUnionPush($$)
{
my $name = shift;
my $d = shift;
- pidl "\nstatic NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, union $name *r)\n{\n";
+ pidl "\nstatic NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const union $name *r)\n{\n";
pidl "\treturn NT_STATUS_OK;\n";
pidl "}\n\n";
}
@@ -281,8 +316,9 @@ sub EjsEnumPush($$)
{
my $name = shift;
my $d = shift;
- pidl "\nstatic NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, enum $name r)\n{\n";
- pidl "\tNDR_CHECK(ejs_push_enum(ejs, v, name, r));\n";
+ pidl "\nstatic NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const enum $name *r)\n{\n";
+ pidl "\tunsigned e = *r;\n";
+ pidl "\tNDR_CHECK(ejs_push_enum(ejs, v, name, &e));\n";
pidl "\treturn NT_STATUS_OK;\n";
pidl "}\n\n";
}
@@ -309,7 +345,7 @@ sub EjsPushFunction($)
pidl "\nstatic NTSTATUS ejs_push_$d->{NAME}(struct ejs_rpc *ejs, struct MprVar *v, const struct $d->{NAME} *r)\n";
pidl "{\n";
- pidl "\tNDR_CHECK(ejs_push_struct_start(ejs, &v, \"out\"));\n";
+ pidl "\tNDR_CHECK(ejs_push_struct_start(ejs, &v, \"output\"));\n";
foreach my $e (@{$d->{ELEMENTS}}) {
next unless (grep(/out/, @{$e->{DIRECTION}}));