pidl:Samba3/ClientNDR: allow passing optional variable prefixes to ParseOutputArgument()
authorStefan Metzmacher <metze@samba.org>
Thu, 30 Jul 2009 13:14:25 +0000 (15:14 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 31 Jul 2009 10:49:46 +0000 (12:49 +0200)
metze

pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm

index a2a61d87d07319546e54ea1b6988304bea577282..9ae943fecf19871253d9d2dbf548b70df83ea72e 100644 (file)
@@ -71,10 +71,12 @@ sub HeaderProperties($$)
        }
 }
 
-sub ParseOutputArgument($$$)
+sub ParseOutputArgument($$$;$$)
 {
-       my ($self, $fn, $e) = @_;
+       my ($self, $fn, $e, $r, $o) = @_;
        my $level = 0;
+       $r = "r." unless defined($r);
+       $o = "" unless defined($o);
 
        if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY") {
                $self->pidl("return NT_STATUS_NOT_SUPPORTED;");
@@ -85,7 +87,7 @@ sub ParseOutputArgument($$$)
        if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
                $level = 1;
                if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
-                       $self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
+                       $self->pidl("if ($o$e->{NAME} && ${r}out.$e->{NAME}) {");
                        $self->indent;
                }
        }
@@ -95,7 +97,7 @@ sub ParseOutputArgument($$$)
                # Since the data is being copied into a user-provided data 
                # structure, the user should be able to know the size beforehand 
                # to allocate a structure of the right size.
-               my $env = GenerateFunctionInEnv($fn, "r.");
+               my $env = GenerateFunctionInEnv($fn, $r);
                my $l = $e->{LEVELS}[$level];
                unless (defined($l->{SIZE_IS})) {
                        error($e->{ORIGINAL}, "no size known for [out] array `$e->{NAME}'");
@@ -103,13 +105,13 @@ sub ParseOutputArgument($$$)
                } else {
                        my $size_is = ParseExpr($l->{SIZE_IS}, $env, $e->{ORIGINAL});
                        if (has_property($e, "charset")) {
-                               $self->pidl("memcpy(CONST_DISCARD(char *, $e->{NAME}), r.out.$e->{NAME}, $size_is * sizeof(*$e->{NAME}));");
+                               $self->pidl("memcpy(CONST_DISCARD(char *, $o$e->{NAME}), ${r}out.$e->{NAME}, $size_is * sizeof(*$o$e->{NAME}));");
                        } else {
-                               $self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is * sizeof(*$e->{NAME}));");
+                               $self->pidl("memcpy($o$e->{NAME}, ${r}out.$e->{NAME}, $size_is * sizeof(*$o$e->{NAME}));");
                        }
                }
        } else {
-               $self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
+               $self->pidl("*$o$e->{NAME} = *${r}out.$e->{NAME};");
        }
 
        if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {