summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-09-13 11:55:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:43 -0500
commit6f2fb2feb406a9e9f1411ab37d09054b9f31cfbc (patch)
treefffbd10a64007b20dc11642cf8abc693fd5af9a8 /source4/build/pidl
parenta560d554bdfade75b81780e427e51cc436d9488a (diff)
downloadsamba-6f2fb2feb406a9e9f1411ab37d09054b9f31cfbc.tar.gz
samba-6f2fb2feb406a9e9f1411ab37d09054b9f31cfbc.tar.bz2
samba-6f2fb2feb406a9e9f1411ab37d09054b9f31cfbc.zip
r2322: More renames of autogenerated functions so they all have approximately
the same signature. Start to handle structures with no pointers. (This used to be commit c1dc9842683628e05fa66a930a074e741c4a7101)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/swig.pm45
1 files changed, 33 insertions, 12 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index 5504cfdf3c..e7f77f05ed 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -71,8 +71,15 @@ sub XFromPython($$)
$result .= DebugElement($e);
}
} else {
- # Non-scalar type
- $result .= DebugElement($e);
+ if ($e->{POINTERS} == 0) {
+ # Non-scalar type, no pointer
+ $result .= DebugElement($e);
+ } elsif ($e->{POINTERS} == 1) {
+ $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python(mem_ctx, $obj);\n";
+ } else {
+ # Non-scalar type, multiple pointers
+ $result .= DebugElement($e);
+ }
}
return $result;
@@ -111,8 +118,15 @@ sub XToPython($$)
$result .= DebugElement($e);
}
} else {
- # Non-scalar type
- $result .= DebugElement($e);
+ if ($e->{POINTERS} == 0) {
+ # Non-scalar type, no pointer
+ $result .= DebugElement($e);
+ } elsif ($e->{POINTERS} == 1) {
+ $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python(mem_ctx, $obj);\n";
+ } else {
+ # Non-scalar type, multiple pointers
+ $result .= DebugElement($e);
+ }
}
return $result;
@@ -126,28 +140,32 @@ sub ParseFunction($)
$res .= "/* Convert Python dict to struct $fn->{NAME}.in */\n\n";
- $res .= "int $fn->{NAME}_from_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s, PyObject *obj)\n";
+ $res .= "struct $fn->{NAME} *$fn->{NAME}_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)\n";
$res .= "{\n";
+ $res .= "\tstruct $fn->{NAME} *s = talloc(mem_ctx, sizeof(struct $fn->{NAME}));\n\n";
+
foreach my $e (@{$fn->{DATA}}) {
$res .= XFromPython($e, "in.") if util::has_property($e, "in")
}
$res .= "\n";
- $res .= "\treturn True;\n";
+ $res .= "\treturn s;\n";
$res .= "}\n\n";
$res .= "/* Convert struct $fn->{NAME}.out to Python dict */\n\n";
- $res .= "int $fn->{NAME}_to_python(TALLOC_CTX *mem_ctx, PyObject *obj, struct $fn->{NAME} *s)\n";
+ $res .= "PyObject *$fn->{NAME}_to_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s)\n";
$res .= "{\n";
+ $res .= "\tPyObject *obj = PyDict_New();\n\n";
+
foreach my $e (@{$fn->{DATA}}) {
$res .= XToPython($e, "out.") if util::has_property($e, "out")
}
$res .= "\n";
- $res .= "\treturn True;\n";
+ $res .= "\treturn obj;\n";
$res .= "}\n\n";
$res .= "%}\n\n";
@@ -192,28 +210,31 @@ sub ParseStruct($)
$res .= "%{\n\n";
$res .= "/* Convert Python dict to struct $s->{NAME} */\n\n";
- $res .= "int python_to_$s->{NAME}(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s, PyObject *obj)\n";
+ $res .= "struct $s->{NAME} *$s->{NAME}_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)\n";
$res .= "{\n";
+ $res .= "\tstruct $s->{NAME} *s = talloc(mem_ctx, sizeof(struct $s->{NAME}));\n\n";
foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
$res .= XFromPython($e, "");
}
$res .= "\n";
- $res .= "\treturn TRUE;\n";
+ $res .= "\treturn s;\n";
$res .= "}\n\n";
$res .= "/* Convert struct $s->{NAME} to Python dict */\n\n";
- $res .= "int $s->{NAME}_to_python(TALLOC_CTX *mem_ctx, PyObject *obj, struct $s->{NAME} *s)\n";
+ $res .= "PyObject *$s->{NAME}_to_python(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s)\n";
$res .= "{\n";
+
+ $res .= "\tPyObject *obj = PyDict_New();\n\n";
foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
$res .= XToPython($e, "");
}
$res .= "\n";
- $res .= "\treturn TRUE;\n";
+ $res .= "\treturn obj;\n";
$res .= "}\n";
$res .= "\n%}\n\n";