r9129: Start working on nested anonymous structures and unions. A better
authorTim Potter <tpot@samba.org>
Fri, 5 Aug 2005 18:06:15 +0000 (18:06 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:31:19 +0000 (13:31 -0500)
design is starting to become clearer.  (-:
(This used to be commit 23b9f8f3b59cc497fc7368c40ca7fce474370ed3)

source4/script/build_smb_interfaces.pl

index 3aacc6df55ff07db84dd6565250a3c97abfbbfb4..7358eab85af03023b6eac1bfd4b5813d2822b913 100755 (executable)
@@ -45,13 +45,32 @@ foreach my $x (@{$header}) {
 
   prototypes_for($x);
 
-  # Prototypes for non-anonymous nested structures and unions
-
   foreach my $e1 (@{$x->{DATA}}) {
     foreach my $e2 (@{$e1->{DATA}}) {
+
+      # Prototypes for non-anonymous nested structures and unions:
+      #
+      # e.g struct foo {...};
+
       if (defined($e2->{STRUCT_NAME}) or defined($e2->{UNION_NAME})) {
        prototypes_for($e2);
       }
+
+      # We also would like to push/pull nested structures and unions: 
+      #
+      # e.g struct foo {
+      #         struct {...} bar;
+      #     };
+
+      if ($e2->{TYPE} eq "struct") {
+       if (defined($e2->{NAME}) and !defined($e2->{STRUCT_NAME})) {
+         foreach my $x (@{$e2->{NAME}}) {
+           $name = "$e1->{NAME}[0]_$x";
+           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";
+         }
+       }
+      }
     }
   }
 }
@@ -97,6 +116,11 @@ sub print_field($$) {
     if ($f->{POINTERS} > 0) {
       print FILE "\t// alloc $x?\n";
     }
+
+    if ($f->{TYPE} eq "struct") {
+      $type = $f->{STRUCT_NAME};
+    }
+
     print FILE "\tNDR_CHECK(ejs_pull_$type(ejs, v, \"$x\", ${deref}r->$suffix.$x));\n";
   }
 }
@@ -138,6 +162,33 @@ foreach my $x (@{$header}) {
   print FILE "}\n\n";
 }
 
+# Nested anonymous structures
+
+foreach my $x (@{$header}) {
+  foreach my $e1 (@{$x->{DATA}}) {
+    foreach my $e2 (@{$e1->{DATA}}) {
+      if ($e2->{TYPE} eq "struct") {
+       if (defined($e2->{NAME}) and !defined($e2->{STRUCT_NAME})) {
+         foreach my $x (@{$e2->{NAME}}) {
+
+           $name = "$e1->{NAME}[0]_$x";
+
+           print FILE "static NTSTATUS ejs_push_$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";
+
+           print FILE "static 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";
+         }
+       }
+      }
+    }
+  }
+}
+
 # Top level call functions
 
 foreach my $x (@{$header}) {
@@ -148,7 +199,7 @@ foreach my $x (@{$header}) {
 
   print FILE "static int ejs_$x->{STRUCT_NAME}(int eid, int argc, struct MprVar **argv)\n";
   print FILE "{\n";
-  print FILE "\tstruct $x->{STRUCT_NAME} parms;\n";
+  print FILE "\tstruct $x->{STRUCT_NAME} params;\n";
   print FILE "\tstruct smbcli_tree *tree;\n";
   print FILE "\tNTSTATUS result;\n\n";
 
@@ -183,7 +234,7 @@ __HERE__
 
 print FILE "static int ejs_${basename}_init(int eid, int argc, struct MprVar **argv)\n";
 print FILE "{\n";
-print FILE "\tstruct MprVar *obj = mprInitObject(eid, \"${basename}\", argc, argtv);\n\n";
+print FILE "\tstruct MprVar *obj = mprInitObject(eid, \"${basename}\", argc, argv);\n\n";
 
 foreach my $x (@{$header}) {
   next, if $x->{STRUCT_NAME} eq "";