summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-04-08 01:23:19 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-04-08 01:23:19 +0200
commita5d51180baf302ff109b9985b74d7a60b21ee73c (patch)
treead2b74ece52f054894f0097f2793015a7e32074b /source4/pidl/lib/Parse/Pidl
parent6f02fdea23b97204db3f1ac7a266cbde657371ff (diff)
downloadsamba-a5d51180baf302ff109b9985b74d7a60b21ee73c.tar.gz
samba-a5d51180baf302ff109b9985b74d7a60b21ee73c.tar.bz2
samba-a5d51180baf302ff109b9985b74d7a60b21ee73c.zip
Add function signature to docstrings in python.
(This used to be commit 61f331e9748bf5b3a1120ef19f93790facf9f64c)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm34
1 files changed, 31 insertions, 3 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index efec2cae1f..3043430b68 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -260,7 +260,7 @@ sub PythonStruct($$$$$$)
sub PythonFunction($$$)
{
- my ($self, $fn, $iface) = @_;
+ my ($self, $fn, $iface, $prettyname) = @_;
my $docstring = $self->DocString($fn, $fn->{NAME});
@@ -282,6 +282,8 @@ sub PythonFunction($$$)
my $args_string = "";
my $args_names = "";
+ my $signature = "S.$prettyname(";
+
foreach my $e (@{$fn->{ELEMENTS}}) {
$self->pidl("PyObject *py_$e->{NAME};");
if (grep(/out/,@{$e->{DIRECTION}})) {
@@ -291,8 +293,14 @@ sub PythonFunction($$$)
$args_format .= "O";
$args_string .= ", &py_$e->{NAME}";
$args_names .= "\"$e->{NAME}\", ";
+ $signature .= "$e->{NAME}, ";
}
}
+ if (substr($signature, -2) eq ", ") {
+ $signature = substr($signature, 0, -2);
+ }
+ $signature.= ") -> ";
+
$self->pidl("const char *kwnames[] = {");
$self->indent;
$self->pidl($args_names . "NULL");
@@ -323,6 +331,9 @@ sub PythonFunction($$$)
if ($result_size > 1) {
$self->pidl("result = PyTuple_New($result_size);");
+ $signature .= "(";
+ } elsif ($result_size == 0) {
+ $signature .= "None";
}
foreach my $e (@{$fn->{ELEMENTS}}) {
@@ -332,8 +343,10 @@ sub PythonFunction($$$)
if ($result_size > 1) {
$self->pidl("PyTuple_SetItem(result, $i, $py_name);");
$i++;
+ $signature .= "$e->{NAME}, ";
} else {
$self->pidl("result = $py_name;");
+ $signature .= "result";
}
}
}
@@ -346,17 +359,32 @@ sub PythonFunction($$$)
my $conv = $self->ConvertObjectToPythonData("r", $fn->{RETURN_TYPE}, "r->out.result");
if ($result_size > 1) {
$self->pidl("PyTuple_SetItem(result, $i, $conv);");
+ $signature .= "result";
} else {
$self->pidl("result = $conv;");
+ $signature .= "result";
}
}
+ if (substr($signature, -2) eq ", ") {
+ $signature = substr($signature, 0, -2);
+ }
+ if ($result_size > 1) {
+ $signature .= ")";
+ }
+
$self->pidl("talloc_free(mem_ctx);");
$self->pidl("return result;");
$self->deindent;
$self->pidl("}");
$self->pidl("");
+ if ($docstring eq "NULL") {
+ $docstring = "\"$signature\"";
+ } else {
+ $docstring = "\"$signature\\n\\n\"$docstring";
+ }
+
return ($fnname, $docstring);
}
@@ -487,13 +515,13 @@ sub Interface($$$)
next if not defined($d->{OPNUM});
next if has_property($d, "nopython");
- my ($fnname, $fndocstring) = $self->PythonFunction($d, $interface->{NAME});
-
my $prettyname = $d->{NAME};
$prettyname =~ s/^$interface->{NAME}_//;
$prettyname =~ s/^$basename\_//;
+ my ($fnname, $fndocstring) = $self->PythonFunction($d, $interface->{NAME}, $prettyname);
+
push (@fns, [$fnname, $prettyname, $fndocstring]);
}