summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-08-07 21:10:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:30 -0500
commit7dfaea15b35d9c25cd9079dfc985b54176d0204d (patch)
tree987a12e00783efa6bfc0dd1613b350a213650516
parent79c1c76b26a531bba02503f26158f189cfb32560 (diff)
downloadsamba-7dfaea15b35d9c25cd9079dfc985b54176d0204d.tar.gz
samba-7dfaea15b35d9c25cd9079dfc985b54176d0204d.tar.bz2
samba-7dfaea15b35d9c25cd9079dfc985b54176d0204d.zip
r9199: Another go at recursive flattening of structs.
(This used to be commit a6541a07028d7d53e441a1eb78457c0d572109af)
-rwxr-xr-xsource4/script/build_smb_interfaces.pl43
1 files changed, 18 insertions, 25 deletions
diff --git a/source4/script/build_smb_interfaces.pl b/source4/script/build_smb_interfaces.pl
index 63cc25080c..b4fa70f4f0 100755
--- a/source4/script/build_smb_interfaces.pl
+++ b/source4/script/build_smb_interfaces.pl
@@ -16,54 +16,47 @@ my $parser = new smb_interfaces;
$header = $parser->parse($file);
#
-# Make second pass over tree to make it easier to process. Ugh - this
-# is all done in place as the parser generates references.
+# Make second pass over tree to make it easier to process.
#
-my $newheader = [];
+my @structs;
-sub flatten_names($) {
+sub flatten_structs($) {
my $obj = shift;
+ my $s = { %$obj };
# Map NAME, STRUCT_NAME and UNION_NAME elements into a more likeable
# property.
- if ($obj->{TYPE} eq "struct" or $obj->{TYPE} eq "union") {
+ if (defined($obj->{STRUCT_NAME}) or defined($obj->{UNION_NAME})) {
- # struct foo {};
- # struct {} bar;
- # struct foo {} bar;
-
- $obj->{TYPE_NAME} = defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME}
+ $s->{TYPE_DEFINED} = defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME}
: $obj->{UNION_NAME};
- delete $obj->{STRUCT_NAME};
- delete $obj->{UNION_NAME};
+ delete $s->{STRUCT_NAME};
+ delete $s->{UNION_NAME};
}
- # Convert DATA array to a hash by field name
-
foreach my $elt (@{$obj->{DATA}}) {
foreach my $name (@{$elt->{NAME}}) {
- $obj->{FIELDS}{$name} = $elt;
- $obj->{FIELDS}{$name}{NAME} = $name;
- $obj->{FIELDS}{$name}{PARENT} = $obj;
+ my $new_elt = { %$elt };
+ $new_elt->{NAME} = $name;
+ push(@{$s->{FIELDS}}, flatten_structs($new_elt));
}
}
- # Recurse down into substructures
+ delete $s->{DATA};
- foreach my $elt (@{$obj->{DATA}}) {
- flatten_names($elt);
- }
-
- delete $obj->{DATA};
+ return $s;
}
foreach my $s (@{$header}) { # For each parsed structure
- flatten_names($s);
+ print Dumper(flatten_structs($s));
}
+print Dumper(@structs);
+exit;
+
#
# Generate header
#
@@ -111,7 +104,7 @@ exit;
sub struct_name($)
{
my $obj = shift;
- return defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME} : $obj->{UNION_NAME};
+ return defined($obj->{STRUCT_NAE}) ? $obj->{STRUCT_NAME} : $obj->{UNION_NAME};
}
sub prototypes_for($)