diff options
author | Tim Potter <tpot@samba.org> | 2004-09-12 10:56:11 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:41 -0500 |
commit | 7436bdc4f0ad5ace62d9ac5b617f3844b5dda298 (patch) | |
tree | c379529472bfa8412bb4b1ce505007115cbfd758 | |
parent | 23492b303309327bc84788432f2a2cd4e99ef093 (diff) | |
download | samba-7436bdc4f0ad5ace62d9ac5b617f3844b5dda298.tar.gz samba-7436bdc4f0ad5ace62d9ac5b617f3844b5dda298.tar.bz2 samba-7436bdc4f0ad5ace62d9ac5b617f3844b5dda298.zip |
r2298: Convert to and from string parameters.
Correct function name used when generating function to convert in
typemap so it is consistent with the others.
(This used to be commit ec23bae00fedbd1651800a8f4559dee3bd6c7025)
-rw-r--r-- | source4/build/pidl/swig.pm | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index f03467177e..5504cfdf3c 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -42,21 +42,29 @@ sub XFromPython($$) my($e) = shift; my($prefix) = shift; my($result) = ""; + my($obj) = "PyDict_GetItem(obj, PyString_FromString(\"$e->{NAME}\"))"; # Special cases - if ($e->{TYPE} eq "policy_handle" && $e->{POINTERS} == 1) { - $result .= "\ts->$prefix$e->{NAME} = policy_handle_from_python(obj);"; + if (($e->{TYPE} eq "policy_handle" || $e->{TYPE} eq "string") && $e->{POINTERS} == 1) { + $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python($obj);\n"; return $result; } + if ($e->{TYPE} eq "string" && $e->{POINTERS} == 1) { + $result .= "\ts->$prefix$e->{NAME} = policy_handle_from_python($obj);\n"; + return $result; + } + + # Generate conversion for element + if (util::is_scalar_type($e->{TYPE})) { if ($e->{POINTERS} == 0) { if ($e->{ARRAY_LEN}) { # pointer to scalar with array len property $result .= DebugElement($e); } else { - $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python(obj);\n"; + $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python($obj);\n"; } } else { # Pointer to scalar @@ -83,6 +91,13 @@ sub XToPython($$) return $result; } + if ($e->{TYPE} eq "string" && $e->{POINTERS} == 1) { + $result .= "\tPyDict_SetItem(obj, PyString_FromString(\"$e->{NAME}\"), string_to_python(s->$prefix$e->{NAME}));\n"; + return $result; + } + + # Generate conversion for element + if (util::is_scalar_type($e->{TYPE})) { if ($e->{POINTERS} == 0) { if ($e->{ARRAY_LEN}) { @@ -111,7 +126,7 @@ sub ParseFunction($) $res .= "/* Convert Python dict to struct $fn->{NAME}.in */\n\n"; - $res .= "int python_to_$fn->{NAME}(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s, PyObject *obj)\n"; + $res .= "int $fn->{NAME}_from_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s, PyObject *obj)\n"; $res .= "{\n"; foreach my $e (@{$fn->{DATA}}) { @@ -141,7 +156,7 @@ sub ParseFunction($) $res .= "%typemap(in) struct $fn->{NAME} * (struct $fn->{NAME} temp) {\n"; $res .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(int) $fn->{NAME}\");\n\n"; - $res .= "\tpython_to_$fn->{NAME}(mem_ctx, &temp, \$input);\n"; + $res .= "\t$fn->{NAME}_from_python(mem_ctx, &temp, \$input);\n"; $res .= "\t\$1 = &temp;\n"; $res .= "}\n\n"; |