From 7436bdc4f0ad5ace62d9ac5b617f3844b5dda298 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 12 Sep 2004 10:56:11 +0000 Subject: 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) --- source4/build/pidl/swig.pm | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'source4/build') 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"; -- cgit