diff options
author | Tim Potter <tpot@samba.org> | 2004-09-19 12:37:32 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:50 -0500 |
commit | 9261314a9ddf3b0886f9fc2886401bb1e8c21738 (patch) | |
tree | 024d319b827b3f5a2ad6212ce979c39483efe668 /source4/build | |
parent | ce52465165907c9f1dc4f20599b05da72558d1e3 (diff) | |
download | samba-9261314a9ddf3b0886f9fc2886401bb1e8c21738.tar.gz samba-9261314a9ddf3b0886f9fc2886401bb1e8c21738.tar.bz2 samba-9261314a9ddf3b0886f9fc2886401bb1e8c21738.zip |
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)
Diffstat (limited to 'source4/build')
-rw-r--r-- | source4/build/pidl/swig.pm | 13 |
1 files changed, 9 insertions, 4 deletions
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"; + } } } |