Author: jelmer Date: 2007-11-25 04:53:54 +0000 (Sun, 25 Nov 2007) New Revision: 26110
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26110 Log: Create separate function for connecting, add helper for creating result typemaps. Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm Changeset: 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 2007-11-25 03:50:05 UTC (rev 26109) +++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm 2007-11-25 04:53:54 UTC (rev 26110) @@ -36,6 +36,22 @@ } } +sub GenerateResultTypemap($) +{ + my $name = shift; + pidl "%typemap(in,numinputs=0) $name*result ($name tmp) {"; + indent; + pidl "\$1 = &tmp;"; + deindent; + pidl "}"; + pidl ""; + pidl "%typemap(argout) $name*result {"; + indent; + pidl "\$result = SWIG_NewPointerObj(*\$1, \$1_descriptor, 0);"; + deindent; + pidl "}"; +} + sub ParseInterface($$) { my ($basename,$if) = @_; @@ -46,12 +62,16 @@ pidl ""; pidl "\%extend $if->{NAME} {"; indent(); - pidl "NTSTATUS $if->{NAME} (const char *binding, struct cli_credentials *cred, TALLOC_CTX *mem_ctx, struct event_context *event, struct $if->{NAME} **result)"; + pidl "$if->{NAME} () {"; + indent; + pidl "return talloc(NULL, struct $if->{NAME});"; + deindent; + pidl "}"; + pidl ""; + pidl "NTSTATUS connect (const char *binding, struct cli_credentials *cred, struct event_context *event)"; pidl "{"; indent; - pidl "*result = talloc(mem_ctx, struct $if->{NAME});"; - pidl ""; - pidl "return dcerpc_pipe_connect(mem_ctx, &(*result)->pipe, binding, &ndr_table_$if->{NAME}, cred, event);"; + pidl "return dcerpc_pipe_connect(\$self, &\$self->pipe, binding, &ndr_table_$if->{NAME}, cred, event);"; deindent; pidl "}"; pidl ""; @@ -85,7 +105,7 @@ } pidl ""; - pidl "status = 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 "\treturn status;"; pidl "}";
