mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
r9191: Generate headers for nested structures that need pushing or pulling.
(This used to be commit c56a530d3ba31a603d1a5615bdd2a0788cf1f967)
This commit is contained in:
parent
d8a490ab1b
commit
3824a0caa8
@ -46,7 +46,8 @@ sub flatten_names($) {
|
||||
foreach my $elt (@{$obj->{DATA}}) {
|
||||
foreach my $name (@{$elt->{NAME}}) {
|
||||
$obj->{FIELDS}{$name} = $elt;
|
||||
delete $obj->{FIELDS}{$name}{NAME};
|
||||
$obj->{FIELDS}{$name}{NAME} = $name;
|
||||
$obj->{FIELDS}{$name}{PARENT} = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,42 +64,13 @@ foreach my $s (@{$header}) { # For each parsed structure
|
||||
flatten_names($s);
|
||||
}
|
||||
|
||||
print Dumper($header);
|
||||
|
||||
exit;
|
||||
|
||||
foreach my $s (@{$header}) { # For each parsed structure
|
||||
print Dumper($s);
|
||||
my $newdata;
|
||||
foreach my $e (@{$s->{DATA}}) { # For each element in structure
|
||||
foreach my $n (@{$e->{NAME}}) { # For each field in element
|
||||
|
||||
my $newdata2;
|
||||
foreach my $e2 (@{$e->{DATA}}) {
|
||||
foreach my $n2 (@{$e2->{NAME}}) {
|
||||
my $d = $e2;
|
||||
$d->{NAME} = $n2;
|
||||
push(@{$newdata2}, $d);
|
||||
}
|
||||
}
|
||||
|
||||
push(@{$newdata}, {"NAME" => $n, "DATA" => $newdata2});
|
||||
}
|
||||
}
|
||||
my $newstruct = $s;
|
||||
$newstruct->{DATA} = $newdata;
|
||||
push(@{$newheader}, $newstruct);
|
||||
}
|
||||
|
||||
print Dumper($newheader);
|
||||
exit 0;
|
||||
|
||||
#
|
||||
# Generate header
|
||||
#
|
||||
|
||||
my $basename = basename($file, ".h");
|
||||
stat "libcli/gen_raw" || mkdir("libcli/gen_raw") || die("mkdir");
|
||||
|
||||
# Create header
|
||||
|
||||
open(FILE, ">libcli/gen_raw/ejs_${basename}.h");
|
||||
|
||||
print FILE "/* header auto-generated by build_smb_interfaces.pl */\n\n";
|
||||
@ -106,6 +78,36 @@ print FILE "/* header auto-generated by build_smb_interfaces.pl */\n\n";
|
||||
print FILE "#ifndef _ejs_${basename}_h\n";
|
||||
print FILE "#define _ejs_${basename}_h\n\n";
|
||||
|
||||
|
||||
# Generate a push/pull prototype for every top level structure, as
|
||||
# well as every non-anonymous nested structure (i.e TYPE_NAME element
|
||||
# is undefined.
|
||||
|
||||
foreach my $s (@{$header}) {
|
||||
|
||||
# Top level
|
||||
|
||||
print FILE "NTSTATUS ejs_push_$s->{TYPE_NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
|
||||
print FILE "NTSTATUS ejs_pull_$s->{TYPE_NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
|
||||
|
||||
sub header_for($$) {
|
||||
my $prefix = shift;
|
||||
my $obj = shift;
|
||||
|
||||
return if !($obj->{TYPE} eq "struct" or $obj->{TYPE} eq "union");
|
||||
return if ($obj->{NAME} eq "in" or $obj->{NAME} eq "out");
|
||||
|
||||
print FILE "NTSTATUS ejs_push_${prefix}_$obj->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
|
||||
print FILE "NTSTATUS ejs_pull_${prefix}_$obj->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
|
||||
|
||||
foreach my $key (%{$obj->{FIELDS}}) {
|
||||
header_for("${prefix}.$obj->{TYPE_NAME}", $obj->{FIELDS}{$key});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
sub struct_name($)
|
||||
{
|
||||
my $obj = shift;
|
||||
@ -161,7 +163,9 @@ print FILE "#endif\n";
|
||||
|
||||
close(FILE);
|
||||
|
||||
# Create file
|
||||
#
|
||||
# Generate implementation
|
||||
#
|
||||
|
||||
open(FILE, ">libcli/gen_raw/ejs_${basename}.c");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user