svn commit: samba r2426 - in branches/SAMBA_4_0/source/build/pidl: .
tpot at samba.org
tpot at samba.org
Mon Sep 20 02:50:44 GMT 2004
Author: tpot
Date: 2004-09-20 02:50:43 +0000 (Mon, 20 Sep 2004)
New Revision: 2426
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/build/pidl&rev=2426&nolog=1
Log:
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.
Modified:
branches/SAMBA_4_0/source/build/pidl/swig.pm
Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/swig.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/swig.pm 2004-09-20 01:18:10 UTC (rev 2425)
+++ branches/SAMBA_4_0/source/build/pidl/swig.pm 2004-09-20 02:50:43 UTC (rev 2426)
@@ -47,16 +47,24 @@
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};
if (!util::is_scalar_type($type)) {
@@ -64,7 +72,7 @@
}
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 @@
$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 @@
$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 @@
$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) {
More information about the samba-cvs
mailing list