svn commit: samba r9199 - in branches/SAMBA_4_0/source/script: .
tpot at samba.org
tpot at samba.org
Sun Aug 7 21:10:33 GMT 2005
Author: tpot
Date: 2005-08-07 21:10:32 +0000 (Sun, 07 Aug 2005)
New Revision: 9199
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9199
Log:
Another go at recursive flattening of structs.
Modified:
branches/SAMBA_4_0/source/script/build_smb_interfaces.pl
Changeset:
Modified: branches/SAMBA_4_0/source/script/build_smb_interfaces.pl
===================================================================
--- branches/SAMBA_4_0/source/script/build_smb_interfaces.pl 2005-08-07 20:59:28 UTC (rev 9198)
+++ branches/SAMBA_4_0/source/script/build_smb_interfaces.pl 2005-08-07 21:10:32 UTC (rev 9199)
@@ -16,54 +16,47 @@
$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 @@
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($)
More information about the samba-cvs
mailing list