From 9261314a9ddf3b0886f9fc2886401bb1e8c21738 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 19 Sep 2004 12:37:32 +0000 Subject: r2418: Handle a pointer to a scalar when converting a field from Python. Handle a pointer to an array of structures when converting to Python. (This used to be commit e135265d1d91ff9a6a4e7ec0079ecd88f0afe784) --- source4/build/pidl/swig.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source4/build/pidl/swig.pm') diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index 6b5fb60c1e..dc4afa1787 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -102,6 +102,7 @@ sub FieldFromPython($$) # Generate conversion for element if (util::is_scalar_type($e->{TYPE})) { + if ($e->{POINTERS} == 0) { if ($e->{ARRAY_LEN}) { $result .= ArrayFromPython($e, $prefix); @@ -109,8 +110,8 @@ sub FieldFromPython($$) $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python($obj, \"$e->{NAME}\");\n"; } } else { - $result .= "\t// Pointer to scalar\n"; - $result .= DebugField($e); + $result .= "\ts->$prefix$e->{NAME} = talloc(mem_ctx, sizeof($e->{TYPE}));\n"; + $result .= "\t*s->$prefix$e->{NAME} = $e->{TYPE}_from_python($obj, \"$e->{NAME}\");\n"; } } else { if ($e->{POINTERS} == 0) { @@ -137,7 +138,7 @@ sub ArrayToPython($$) my($array_len) = $e->{ARRAY_LEN}; - if ($array_len eq "*") { + if ($array_len eq "*" or util::has_property($e, "size_is")) { $array_len = util::has_property($e, "size_is"); } @@ -207,7 +208,11 @@ sub FieldToPython($$) $result .= "\tPyDict_SetItem(obj, PyString_FromString(\"$e->{NAME}\"), $e->{TYPE}_ptr_to_python(mem_ctx, &s->$prefix$e->{NAME}));\n"; } } else { - $result .= "\tPyDict_SetItem(obj, PyString_FromString(\"$e->{NAME}\"), $e->{TYPE}_ptr_to_python(mem_ctx, s->$prefix$e->{NAME}));\n"; + if ($e->{ARRAY_LEN} or util::has_property($e, "size_is")) { + $result .= ArrayToPython($e, $prefix); + } else { + $result .= "\tPyDict_SetItem(obj, PyString_FromString(\"$e->{NAME}\"), $e->{TYPE}_ptr_to_python(mem_ctx, s->$prefix$e->{NAME}));\n"; + } } } -- cgit