summaryrefslogtreecommitdiff
path: root/source4/script
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-08-02 18:56:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:30:58 -0500
commit4216c18f34ad29d015e853f4d1cb1900f754ad44 (patch)
tree688c8c20571e71c3e05e42ee68b949aaa9c47e40 /source4/script
parent5e1a9fe62b2ce1af3d710af4f1282a9c7c193d3a (diff)
downloadsamba-4216c18f34ad29d015e853f4d1cb1900f754ad44.tar.gz
samba-4216c18f34ad29d015e853f4d1cb1900f754ad44.tar.bz2
samba-4216c18f34ad29d015e853f4d1cb1900f754ad44.zip
r8934: Some refactoring of smb_interfaces code generator.
(This used to be commit c016487a0148694a1a1464bb5f7ba0d0e142d14f)
Diffstat (limited to 'source4/script')
-rwxr-xr-xsource4/script/build_smb_interfaces.pl61
1 files changed, 50 insertions, 11 deletions
diff --git a/source4/script/build_smb_interfaces.pl b/source4/script/build_smb_interfaces.pl
index cc3a352987..075786fb04 100755
--- a/source4/script/build_smb_interfaces.pl
+++ b/source4/script/build_smb_interfaces.pl
@@ -11,7 +11,7 @@ require smb_interfaces;
my $parser = new smb_interfaces;
$header = $parser->parse($file);
-#use Data::Dumper;
+use Data::Dumper;
#print Dumper($header);
# Create header
@@ -23,9 +23,55 @@ 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";
+sub struct_name($)
+{
+ my $obj = shift;
+ return defined($obj->{STRUCT_NAME}) ? $obj->{STRUCT_NAME} : $obj->{UNION_NAME};
+}
+
+sub prototypes_for($)
+{
+ my $obj = shift;
+ my $name = struct_name($obj);
+
+ print FILE "NTSTATUS ejs_push_$name(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
+ print FILE "NTSTATUS ejs_pull_$name(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
+}
+
+sub pushpull_for($)
+{
+ my $obj = shift;
+ my $name = struct_name($obj);
+
+ print FILE "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const uint32_t *r)\n";
+ print FILE "{\n";
+
+ print FILE "\tNDR_CHECK(ejs_push_struct_start(ejs, &v, name));\n";
+
+ print FILE "\n\treturn NT_STATUS_OK;\n";
+ print FILE "}\n\n";
+
+ print FILE "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const uint32_t *r)\n";
+ print FILE "{\n";
+ print FILE "\treturn NT_STATUS_OK;\n";
+ print FILE "}\n\n";
+}
+
foreach my $x (@{$header}) {
- print FILE "NTSTATUS ejs_push_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
- print FILE "NTSTATUS ejs_pull_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *);\n";
+
+ # Prototypes for top level structures and unions
+
+ prototypes_for($x);
+
+ # Prototypes for non-anonymous nested structures and unions
+
+ foreach my $e1 (@{$x->{DATA}}) {
+ foreach my $e2 (@{$e1->{DATA}}) {
+ if (defined($e2->{STRUCT_NAME}) or defined($e2->{UNION_NAME})) {
+ prototypes_for($e2);
+ }
+ }
+ }
}
print FILE "#endif\n";
@@ -41,14 +87,7 @@ print FILE "/* EJS wrapper functions auto-generated by build_smb_interfaces.pl *
# Top level functions
foreach my $x (@{$header}) {
- print FILE "NTSTATUS ejs_push_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *)\n";
- print FILEq "{\n";
- print FILE "\treturn NT_STATUS_OK;\n";
- print FILE "}\n\n";
- print FILE "NTSTATUS ejs_pull_$x->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const uint32_t *)\n";
- print FILE "{\n";
- print FILE "\treturn NT_STATUS_OK;\n";
- print FILE "}\n\n";
+ pushpull_for($x);
}
close(FILE);