Author: jelmer
Date: 2006-05-13 23:58:16 +0000 (Sat, 13 May 2006)
New Revision: 15591

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15591

Log:
Generate function calls correctly as well.

Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm


Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm   
2006-05-13 23:30:05 UTC (rev 15590)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm   
2006-05-13 23:58:16 UTC (rev 15591)
@@ -26,27 +26,6 @@
 sub warning($$) { my ($e,$s) = @_; 
warn("$e->{ORIGINAL}->{FILE}:$e->{ORIGINAL}->{LINE}: $s\n"); }
 sub fn_declare($) { my ($n) = @_; pidl $n; pidl_hdr "$n;"; }
 
-sub CopyLevel($$$$)
-{
-       sub CopyLevel($$$$);
-       my ($e,$l,$argument,$member) = @_;
-
-       if ($l->{TYPE} eq "DATA") {
-               pidl "*$argument = *$member;";
-       } elsif ($l->{TYPE} eq "POINTER") {
-               pidl "if (r.ptr$l->{POINTER_INDEX}_$e->{NAME}) {";
-               indent;
-               pidl "*$argument = talloc_size(mem_ctx, sizeof(void *));";
-               CopyLevel($e,GetNextLevel($e,$l),"*$argument", $member);
-               deindent;
-               pidl "}";
-       } elsif ($l->{TYPE} eq "SWITCH") {
-               CopyLevel($e,GetNextLevel($e,$l),$argument,$member);    
-       } elsif ($l->{TYPE} eq "ARRAY") {
-               pidl "*$argument = $member;";
-       }
-}
-
 sub ParseFunction($$)
 {
        my ($if,$fn) = @_;
@@ -84,7 +63,7 @@
 
                fatal($e, "[out] argument is not a pointer") if 
($e->{LEVELS}[0]->{TYPE} ne "POINTER");
 
-               CopyLevel($e, $e->{LEVELS}[1], $e->{NAME}, "r.out.$e->{NAME}");
+               pidl "*$e->{NAME} = *r.out.$e->{NAME};";
        }
 
        pidl"";

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm        
2006-05-13 23:30:05 UTC (rev 15590)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm        
2006-05-13 23:58:16 UTC (rev 15591)
@@ -9,6 +9,7 @@
 use vars qw($VERSION);
 use Parse::Pidl::Samba4 qw(DeclLong);
 use Parse::Pidl::Typelist qw(mapType);
+use Parse::Pidl::Util qw(has_property);
 $VERSION = '0.01';
 
 use strict;
@@ -25,30 +26,35 @@
 sub indent() { $tabs.="\t"; }
 sub deindent() { $tabs = substr($tabs,0,-1); }
 
+sub IgnoreInterface($$)
+{
+       my ($basename,$if) = @_;
+
+       foreach (@{$if->{TYPES}}) {
+               next unless (has_property($_, "public"));
+               pidl "\%types($_->{NAME});";
+       }
+}
+
 sub ParseInterface($$)
 {
        my ($basename,$if) = @_;
 
-       pidl "\%{";
-       pidl "struct $if->{NAME} {";
-       indent;
-       pidl "struct dcerpc_pipe *pipe;";
-       deindent;
-       pidl "};";
-       pidl "%}";
+       pidl "\%inline {";
+       pidl "struct $if->{NAME} { struct dcerpc_pipe *pipe; };";
+       pidl "}";
        pidl "";
-
        pidl "\%extend $if->{NAME} {";
        indent();
-       pidl "struct $if->{NAME} *$if->{NAME} (const char *binding, struct 
cli_credentials *cred = NULL, TALLOC_CTX *mem_ctx = NULL, struct event_context 
*event = NULL)";
+       pidl "$if->{NAME} (const char *binding, struct cli_credentials *cred = 
NULL, TALLOC_CTX *mem_ctx = NULL, struct event_context *event = NULL)";
        pidl "{";
        indent;
        pidl "struct $if->{NAME} *ret = talloc(mem_ctx, struct $if->{NAME});";
        pidl "NTSTATUS status;";
        pidl "";
-       pidl "status = dcerpc_pipe_connect(mem_ctx, &ret->pipe, 
&dcerpc_table_$if->{NAME}, cred, event);";
+       pidl "status = dcerpc_pipe_connect(mem_ctx, &ret->pipe, binding, 
&dcerpc_table_$if->{NAME}, cred, event);";
        pidl "if (NT_STATUS_IS_ERR(status)) {";
-       pidl "\tsamba_nt_status_exception(status);";
+       pidl "\tntstatus_exception(status);";
        pidl "\treturn NULL;";
        pidl "}";
        pidl "";
@@ -75,21 +81,38 @@
                pidl "{";
                indent;
                pidl "struct $fn->{NAME} r;";
-               my $assign = "";
-               if (defined($fn->{RETURN_TYPE})) {
-                       pidl mapType($fn->{RETURN_TYPE}) . " ret;";
-                       $assign = "ret = ";
-               }
+               pidl "NTSTATUS status;";
                pidl "";
                pidl "/* Fill r structure */";
-               pidl "/* FIXME */";
+
+               foreach (@{$fn->{ELEMENTS}}) {
+                       if (grep(/in/, @{$_->{DIRECTION}})) {
+                               pidl "r.in.$_->{NAME} = $_->{NAME};";
+                       } 
+               }
+
                pidl "";
-               pidl $assign."dcerpc_$fn->{NAME}(self->pipe, mem_ctx, &r);";
+               pidl "status = dcerpc_$fn->{NAME}(self->pipe, mem_ctx, &r);";
+               pidl "if (NT_STATUS_IS_ERR(status)) {";
+               pidl "\tntstatus_exception(status);";
+               if (defined($fn->{RETURN_TYPE})) {
+                       pidl "\treturn r.out.result;";
+               } else {
+                       pidl "\treturn;";
+               }
+               pidl "}";
                pidl "";
                pidl "/* Set out arguments */";
-               pidl "/* FIXME */";
+               foreach (@{$fn->{ELEMENTS}}) {
+                       next unless (grep(/out/, @{$_->{DIRECTION}}));
+
+                       pidl ("/* FIXME: $_->{NAME} [out] argument is not a 
pointer */") if ($_->{LEVELS}[0]->{TYPE} ne "POINTER");
+
+                       pidl "*$_->{NAME} = *r.out.$_->{NAME};";
+               }
+
                if (defined($fn->{RETURN_TYPE})) {
-                       pidl "return ret;";
+                       pidl "return r.out.result;";
                }
                deindent;
                pidl "}";
@@ -97,7 +120,7 @@
        }
 
        deindent();
-       pidl "}";
+       pidl "};";
        pidl "";
 
        foreach (@{$if->{TYPES}}) {
@@ -121,10 +144,23 @@
 
        pidl "\%{";
        pidl "#include \"includes.h\"";
+       pidl "#include \"auth/credentials/credentials.h\"";
        pidl "#include \"$header\"";
+       pidl "#include \"$gen_header\"";
        pidl "%}";
-       pidl "\%include \"samba.i\"";
-       pidl "\%include \"$gen_header\"";
+       pidl "\%import \"samba.i\"";
+       pidl "";
+       pidl "\%inline {";
+       pidl "void ntstatus_exception(NTSTATUS status)"; 
+       pidl "{";
+       pidl "\t/* FIXME */";
+       pidl "}";
+       pidl "}";
+       pidl "";
+       foreach (@$ndr) {
+               IgnoreInterface($basename, $_) if ($_->{TYPE} eq "INTERFACE");
+       }
+       pidl "";
 
        pidl "";
 

Reply via email to