From 07aed4b599ebd5436a0005804ce800aa46ad5ff5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 26 Nov 2001 05:27:32 +0000 Subject: [PATCH] Start generating code for unions. (This used to be commit ac71046754b3a4bee53dab64ed73c176074482a0) --- source4/build/pidl/eparser.pm | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm index 835173a66f7..672768d4577 100644 --- a/source4/build/pidl/eparser.pm +++ b/source4/build/pidl/eparser.pm @@ -80,9 +80,17 @@ sub ParseStruct($) sub ParseUnionElement($) { my($element) = shift; - $res .= "[case($element->{CASE})] "; - ParseElement($element->{DATA}); - $res .= ";\n"; + +# $res .= "void prs_$element->{DATA}->{TYPE}()\n{\n"; + +# $res .= "}\n\n"; + + $res .= "\tcase $element->{DATA}->{NAME}: \n"; + $res .= "\t\tprs_$element->{DATA}->{TYPE}();\n\t\tbreak;\n"; + +# $res .= "[case($element->{CASE})] "; +# ParseElement($element->{DATA}); +# $res .= ";\n"; } ##################################################################### @@ -90,12 +98,17 @@ sub ParseUnionElement($) sub ParseUnion($) { my($union) = shift; + +# print Dumper($union); + + $res .= "\tswitch (level) {\n"; + (defined $union->{PROPERTIES}) && ParseProperties($union->{PROPERTIES}); - $res .= "union {\n"; foreach my $e (@{$union->{DATA}}) { ParseUnionElement($e); } - $res .= "}"; + + $res .= "\t}\n"; } ##################################################################### @@ -103,6 +116,9 @@ sub ParseUnion($) sub ParseType($) { my($data) = shift; + + print Dumper $data; + if (ref($data) eq "HASH") { ($data->{TYPE} eq "STRUCT") && ParseStruct($data); @@ -118,6 +134,7 @@ sub ParseType($) sub ParseTypedef($) { my($typedef) = shift; + $res .= "void prs_$typedef->{NAME}(void)\n{\n"; ParseType($typedef->{DATA}); $res .= "}\n\n";