diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-02-28 13:25:53 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:49:00 -0500 |
commit | 5ba8169109253c96f71e0e039b1c0b7a1056eab0 (patch) | |
tree | 575fe0e0904e7596a5d1d02691fcdc733a28cd87 /source4/pidl/lib/Parse/Pidl/Samba4 | |
parent | c2003743256bc0312c5360821d501591039dafcd (diff) | |
download | samba-5ba8169109253c96f71e0e039b1c0b7a1056eab0.tar.gz samba-5ba8169109253c96f71e0e039b1c0b7a1056eab0.tar.bz2 samba-5ba8169109253c96f71e0e039b1c0b7a1056eab0.zip |
r21584: Support for tagged types has landed!
It's now possible to use "struct foo" without a typedef in IDL files.
echo_info4 is the first type that's been converted.
(This used to be commit 3ac68e858df9b53cf5e0a84741916214a53b3121)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba4')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm | 46 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 22 |
2 files changed, 35 insertions, 33 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm b/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm index c254bfad38..054074297b 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/EJS.pm @@ -426,14 +426,7 @@ sub EjsPushScalar($$$$$) $var = get_pointer_to($var); } - my $t; - if (ref($e->{TYPE}) eq "HASH") { - $t = "$e->{TYPE}->{TYPE}_$e->{TYPE}->{NAME}"; - } else { - $t = $e->{TYPE}; - } - - pidl "NDR_CHECK(ejs_push_$t(ejs, v, $name, $var));"; + pidl "NDR_CHECK(".TypeFunctionName("ejs_push", $e->{TYPE})."(ejs, v, $name, $var));"; } } @@ -619,21 +612,22 @@ sub EjsTypePushFunction($$) my ($d, $name) = @_; return if (has_property($d, "noejs")); - if ($d->{TYPE} eq "TYPEDEF") { - EjsTypePushFunction($d->{DATA}, $name); - return; - } - - if ($d->{TYPE} eq "STRUCT") { - fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const struct $name *r)"); - } elsif ($d->{TYPE} eq "UNION") { - fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const union $name *r)"); - } elsif ($d->{TYPE} eq "ENUM") { - fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const enum $name *r)"); - } elsif ($d->{TYPE} eq "BITMAP") { - my($type_decl) = Parse::Pidl::Typelist::mapTypeName($d->{BASE_TYPE}); - fn_declare($d, "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const $type_decl *r)"); - } + my $var = undef; + my $dt = $d; + if ($dt->{TYPE} eq "TYPEDEF") { + $dt = $dt->{DATA}; + } + if ($dt->{TYPE} eq "STRUCT") { + $var = "const struct $name *r"; + } elsif ($dt->{TYPE} eq "UNION") { + $var = "const union $name *r"; + } elsif ($dt->{TYPE} eq "ENUM") { + $var = "const enum $name *r"; + } elsif ($dt->{TYPE} eq "BITMAP") { + my($type_decl) = Parse::Pidl::Typelist::mapTypeName($dt->{BASE_TYPE}); + $var = "const $type_decl *r"; + } + fn_declare($d, "NTSTATUS ".TypeFunctionName("ejs_push", $d) . "(struct ejs_rpc *ejs, struct MprVar *v, const char *name, $var)"); pidl "{"; indent; EjsTypePush($d, "r"); @@ -644,6 +638,7 @@ sub EjsTypePushFunction($$) sub EjsTypePush($$) { + sub EjsTypePush($$); my ($d, $varname) = @_; if ($d->{TYPE} eq 'STRUCT') { @@ -654,6 +649,8 @@ sub EjsTypePush($$) EjsEnumPush($d, $varname); } elsif ($d->{TYPE} eq 'BITMAP') { EjsBitmapPush($d, $varname); + } elsif ($d->{TYPE} eq 'TYPEDEF') { + EjsTypePush($d->{DATA}, $varname); } else { warn "Unhandled push $varname of type $d->{TYPE}"; } @@ -677,8 +674,7 @@ sub EjsPushFunction($) } if ($d->{RETURN_TYPE}) { - my $t = $d->{RETURN_TYPE}; - pidl "NDR_CHECK(ejs_push_$t(ejs, v, \"result\", &r->out.result));"; + pidl "NDR_CHECK(".TypeFunctionName("ejs_push", $d->{RETURN_TYPE})."(ejs, v, \"result\", &r->out.result));"; } pidl "return NT_STATUS_OK;"; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 11ecc17001..2eddf22b05 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -57,7 +57,11 @@ sub HeaderElement($) if (has_property($element, "represent_as")) { pidl mapTypeName($element->{PROPERTIES}->{represent_as})." "; } else { - HeaderType($element, $element->{TYPE}, ""); + if (ref($element->{TYPE}) eq "HASH") { + HeaderType($element, $element->{TYPE}, $element->{TYPE}->{NAME}); + } else { + HeaderType($element, $element->{TYPE}, ""); + } pidl " "; my $numstar = $element->{POINTERS}; if ($numstar >= 1) { @@ -90,14 +94,14 @@ sub HeaderElement($) sub HeaderStruct($$) { my($struct,$name) = @_; - pidl "struct $name {\n"; + pidl "struct $name"; + return if (not defined($struct->{ELEMENTS})); + pidl " {\n"; $tab_depth++; my $el_count=0; - if (defined $struct->{ELEMENTS}) { - foreach (@{$struct->{ELEMENTS}}) { - HeaderElement($_); - $el_count++; - } + foreach (@{$struct->{ELEMENTS}}) { + HeaderElement($_); + $el_count++; } if ($el_count == 0) { # some compilers can't handle empty structures @@ -174,7 +178,9 @@ sub HeaderUnion($$) my($union,$name) = @_; my %done = (); - pidl "union $name {\n"; + pidl "union $name"; + return if (not defined($union->{ELEMENTS})); + pidl " {\n"; $tab_depth++; foreach my $e (@{$union->{ELEMENTS}}) { if ($e->{TYPE} ne "EMPTY") { |