summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-10-16 00:19:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:56 -0500
commitaddb2a9fd45ad4df21f22d1b712e37ff0a5affd4 (patch)
tree50f2596749cf91304abe0408fd40d5f38eee3d60 /source4/build/pidl
parent04767ce90619b5936c3a1e346a74a3293bbc9472 (diff)
downloadsamba-addb2a9fd45ad4df21f22d1b712e37ff0a5affd4.tar.gz
samba-addb2a9fd45ad4df21f22d1b712e37ff0a5affd4.tar.bz2
samba-addb2a9fd45ad4df21f22d1b712e37ff0a5affd4.zip
r3001: Expose unmarshalling functions for structures marked "public" in the
idl. This allows us to pass a buffer of bytes returned from a spoolss call and convert it to a Python dictionary. Works for enumprinters level 1! (This used to be commit 4bc497a2994b12845a46b2d19f60bb81c9869fc9)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/swig.pm43
1 files changed, 33 insertions, 10 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index cdfe90450d..b75891df17 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -351,8 +351,6 @@ sub ParseFunction($)
$result .= "\tresultobj = temp;\n\n";
-
-
$result .= "\tif (NT_STATUS_IS_ERR(result)) {\n";
$result .= "\t\tset_ntstatus_exception(NT_STATUS_V(result));\n";
$result .= "\t\tgoto fail;\n";
@@ -466,19 +464,30 @@ sub ParseStruct($)
# Generate function to convert DATA_BLOB to Python dict
- if (util::has_property($s, "public")) {
- $result .= "/* Convert DATA_BLOB to python dict of struct $s->{NAME} */\n\n";
-
- $result .= "NTSTATUS DATA_BLOB_to_python_$s->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, PyObject **obj)\n";
+ if (util::has_property($s->{DATA}, "public")) {
+ $result .= "/* Convert a Python string to a struct $s->{NAME} python dict */\n\n";
+ $result .= "NTSTATUS unmarshall_$s->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct $s->{NAME} *s)\n";
$result .= "{\n";
- $result .= "\tstruct $s->{NAME} s;\n";
- $result .= "\tNTSTATUS result = ndr_pull_struct_blob(blob, mem_ctx, &s, ndr_pull_$s->{NAME});\n\n";
- $result .= "\treturn NT_STATUS_OK;\n";
- $result .= "}\n";
+ $result .= "\treturn ndr_pull_struct_blob(blob, mem_ctx, s, ndr_pull_$s->{NAME});\n";
+ $result .= "}\n\n";
}
$result .= "\n%}\n\n";
+ if (util::has_property($s->{DATA}, "public")) {
+
+ $result .= "%typemap(in, numinputs=0) struct $s->{NAME} *EMPTY (struct $s->{NAME} *temp_$s->{NAME}) {\n";
+ $result .= "\t\$1 = &temp_$s->{NAME};\n";
+ $result .= "}\n\n";
+
+ $result .= "%typemap(argout) struct $s->{NAME} * {\n";
+ $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(argout) $s->{NAME}\");\n\n";
+ $result .= "\tresultobj = $s->{NAME}_ptr_to_python(mem_ctx, \$1);\n";
+ $result .= "}\n\n";
+
+ $result .= "NTSTATUS unmarshall_$s->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, struct $s->{NAME} *EMPTY);\n\n";
+ }
+
return $result;
}
@@ -595,8 +604,22 @@ sub ParseUnion($)
$result .= "}\n\n";
+ # Generate function to convert DATA_BLOB to Python dict
+
+ if (util::has_property($u->{DATA}, "public")) {
+ $result .= "/* Convert a Python string to a struct $u->{NAME} python dict */\n\n";
+ $result .= "NTSTATUS unmarshall_$u->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, union $u->{NAME} *u)\n";
+ $result .= "{\n";
+ $result .= "\treturn NT_STATUS_OK;\n";
+ $result .= "}\n\n";
+ }
+
$result .= "\n%}\n\n";
+ if (util::has_property($u->{DATA}, "public")) {
+ $result .= "NTSTATUS unmarshall_$u->{NAME}(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, union $u->{NAME} *EMPTY);\n\n";
+ }
+
return $result;
}