summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-13 23:33:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:59:51 -0500
commitbcd6d19c5050f99bb162891fc136bf988d4d0560 (patch)
treecc732aa45077820ff42eaa885d817f9b607a916d /source4/build/pidl
parent24c0fbc0e88bf0f7bc34f75c99aa276ca19b0163 (diff)
downloadsamba-bcd6d19c5050f99bb162891fc136bf988d4d0560.tar.gz
samba-bcd6d19c5050f99bb162891fc136bf988d4d0560.tar.bz2
samba-bcd6d19c5050f99bb162891fc136bf988d4d0560.zip
r2958: the warnings from the swig code in pidl were totally swamping valid
warnings, making real errors impossible to spot. this fixes the warnings, and probably fixes some pidl/python bugs as well. (This used to be commit 2f1e9954e3381b1864a6fd9fa8b2231478179d4d)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/swig.pm30
-rw-r--r--source4/build/pidl/util.pm2
2 files changed, 17 insertions, 15 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index c558287945..76ef99b631 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -141,7 +141,7 @@ sub ArrayToPython($$)
my($prefix) = shift;
my($result) = "";
- my($array_len) = $e->{ARRAY_LEN};
+ my($array_len) = util::array_size($e);
if ($array_len eq "*" or util::has_property($e, "size_is")) {
$array_len = util::has_property($e, "size_is");
@@ -476,14 +476,16 @@ sub ParseUnion($)
$result .= "\tu = talloc(mem_ctx, sizeof(union $u->{NAME}));\n\n";
for my $e (@{$u->{DATA}{DATA}}) {
- $result .= "\tif ((dict = PyDict_GetItemString(obj, \"$e->{DATA}{NAME}\"))) {\n";
- if ($e->{DATA}{POINTERS} == 0) {
- $result .= "\t\t$e->{DATA}{TYPE}_from_python(mem_ctx, &u->$e->{DATA}{NAME}, dict, \"$e->{DATA}{NAME}\");\n";
- } elsif ($e->{DATA}{POINTERS} == 1) {
- $result .= "\t\tu->$e->{DATA}{NAME} = $e->{DATA}{TYPE}_ptr_from_python(mem_ctx, dict, \"$e->{DATA}{NAME}\");\n";
- } else {
- $result .= "\t\t// $e->{DATA}{TYPE} pointers=$e->{DATA}{POINTERS}\n";
- }
+ if (defined $e->{DATA}{NAME}) {
+ $result .= "\tif ((dict = PyDict_GetItemString(obj, \"$e->{DATA}{NAME}\"))) {\n";
+ if ($e->{DATA}{POINTERS} == 0) {
+ $result .= "\t\t$e->{DATA}{TYPE}_from_python(mem_ctx, &u->$e->{DATA}{NAME}, dict, \"$e->{DATA}{NAME}\");\n";
+ } elsif ($e->{DATA}{POINTERS} == 1) {
+ $result .= "\t\tu->$e->{DATA}{NAME} = $e->{DATA}{TYPE}_ptr_from_python(mem_ctx, dict, \"$e->{DATA}{NAME}\");\n";
+ } else {
+ $result .= "\t\t// $e->{DATA}{TYPE} pointers=$e->{DATA}{POINTERS}\n";
+ }
+ }
$result .= "\t\treturn u;\n";
$result .= "\t}\n\n";
@@ -511,6 +513,7 @@ sub ParseUnion($)
$result .= "\t}\n\n";
for my $e (@{$u->{DATA}{DATA}}) {
+ if (defined $e->{DATA}{NAME}) {
$result .= "\tif ((dict = PyDict_GetItemString(obj, \"$e->{DATA}{NAME}\"))) {\n";
if ($e->{DATA}{POINTERS} == 0) {
$result .= "\t\t$e->{DATA}{TYPE}_from_python(mem_ctx, &u->$e->{DATA}{NAME}, dict, \"$e->{DATA}{NAME}\");\n";
@@ -519,7 +522,7 @@ sub ParseUnion($)
} else {
$result .= "\t\t// $e->{DATA}{TYPE} pointers=$e->{DATA}{POINTERS}\n";
}
-
+ }
$result .= "\t\treturn;\n";
$result .= "\t}\n\n";
}
@@ -542,10 +545,9 @@ sub ParseUnion($)
for my $e (@{$u->{DATA}{DATA}}) {
$result .= "\tif (switch_is == $e->{CASE}) {\n";
- if ($e->{POINTERS} == 0) {
- $result .= "\t\tPyDict_SetItemString(obj, \"$e->{DATA}{NAME}\", $e->{DATA}{TYPE}_ptr_to_python(mem_ctx, &u->$e->{DATA}{NAME}));\n";
- } else {
- $result .= "\t\tPyDict_SetItemString(obj, \"$e->{DATA}{NAME}\", $e->{DATA}{TYPE}_ptr_to_python(mem_ctx, u->$e->{DATA}{NAME}));\n";
+ my $prefix = util::c_pull_prefix($e);
+ if (defined $e->{DATA}{NAME}) {
+ $result .= "\t\tPyDict_SetItemString(obj, \"$e->{DATA}{NAME}\", $e->{DATA}{TYPE}_ptr_to_python(mem_ctx, $prefix\u->$e->{DATA}{NAME}));\n";
}
$result .= "\t}\n";
}
diff --git a/source4/build/pidl/util.pm b/source4/build/pidl/util.pm
index 1341d77ccc..e3f3b0d40d 100644
--- a/source4/build/pidl/util.pm
+++ b/source4/build/pidl/util.pm
@@ -360,7 +360,7 @@ sub has_direct_buffers($)
sub is_constant($)
{
my $s = shift;
- if ($s =~ /^\d/) {
+ if (defined $s && $s =~ /^\d/) {
return 1;
}
return 0;