diff options
author | Tim Potter <tpot@samba.org> | 2004-09-20 02:50:43 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:51 -0500 |
commit | d072e9e2ca7df4f53a581156614f0c2658af1f05 (patch) | |
tree | cc3d72cbfd3dde2d1c369f505e0caab8fcf53940 /source4/build/pidl | |
parent | f41310583f2f4d77682d6d89992efd3fa69fd690 (diff) | |
download | samba-d072e9e2ca7df4f53a581156614f0c2658af1f05.tar.gz samba-d072e9e2ca7df4f53a581156614f0c2658af1f05.tar.bz2 samba-d072e9e2ca7df4f53a581156614f0c2658af1f05.zip |
r2426: Handle pointer to scalars converting C to Python.
Peeked at parser.pm for some hints at getting array lengths right
when the length_is property is present.
(This used to be commit a17aaadb7d57dbe4cf0a62634f405c61b79a953f)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r-- | source4/build/pidl/swig.pm | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index 042587a538..e8928aae53 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -47,14 +47,22 @@ sub ArrayFromPython($$) my($prefix) = shift; my($result) = ""; - my($array_len) = $e->{ARRAY_LEN}; + $result .= "/* " . Dumper($e) . " */\n"; - if ($array_len eq "*") { - $array_len = util::has_property($e, "size_is"); + my($size); + + if (util::has_property($e, "size_is")) { + $size = util::has_property($e, "size_is"); + } else { + $size = $e->{ARRAY_LEN}; } - if (!util::is_constant($array_len)) { - $array_len = "s->$prefix$array_len"; + if (util::has_property($e, "length_is")) { + $size = util::has_property($e, "length_is"); + } + + if (!util::is_constant($size)) { + $size = "s->$prefix$size"; } my($type) = $e->{TYPE}; @@ -64,7 +72,7 @@ sub ArrayFromPython($$) } if (!util::is_constant($e->{ARRAY_LEN})) { - $result .= "\ts->$prefix$e->{NAME} = talloc(mem_ctx, $array_len * sizeof($type));\n"; + $result .= "\ts->$prefix$e->{NAME} = talloc(mem_ctx, $size * sizeof($type));\n"; } $result .= "\tif (!PyDict_GetItemString(obj, \"$e->{NAME}\")) {\n"; @@ -80,7 +88,7 @@ sub ArrayFromPython($$) $result .= "\t{\n"; $result .= "\t\tint i;\n\n"; - $result .= "\t\tfor (i = 0; i < $array_len; i++) {\n"; + $result .= "\t\tfor (i = 0; i < $size; i++) {\n"; if (util::is_scalar_type($e->{TYPE})) { $result .= "\t\t\ts->$prefix$e->{NAME}\[i\] = $e->{TYPE}_from_python(PyList_GetItem(PyDict_GetItemString(obj, \"$e->{NAME}\"), i), \"$e->{NAME}\");\n"; } else { @@ -131,7 +139,11 @@ sub FieldFromPython($$) $result .= "\t$e->{TYPE}_from_python(mem_ctx, &s->$prefix$e->{NAME}, $obj, \"$e->{NAME}\");\n"; } } else { - $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_ptr_from_python(mem_ctx, $obj, \"$e->{NAME}\");\n"; + if ($e->{ARRAY_LEN} or util::has_property($e, "size_is")) { + $result .= ArrayFromPython($e, $prefix); + } else { + $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_ptr_from_python(mem_ctx, $obj, \"$e->{NAME}\");\n"; + } } } @@ -207,8 +219,12 @@ sub FieldToPython($$) $result .= "\tPyDict_SetItemString(obj, \"$e->{NAME}\", $e->{TYPE}_to_python(s->$prefix$e->{NAME}));\n"; } } else { - $result .= "\t// Pointer to scalar\n"; - $result .= DebugField($e); + if ($e->{ARRAY_LEN} or util::has_property($e, "size_is")) { + $result .= ArrayToPython($e, $prefix); + } else { + $result .= "\t// Pointer to scalar\n"; + $result .= DebugField($e); + } } } else { if ($e->{POINTERS} == 0) { |