r2958: the warnings from the swig code in pidl were totally swamping valid
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Oct 2004 23:33:17 +0000 (23:33 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:51 +0000 (12:59 -0500)
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)

source4/build/pidl/swig.pm
source4/build/pidl/util.pm

index c558287945d9f4c0094daeceabb495a5f88289e9..76ef99b6319425f8ff284598ce870d5d604f1e79 100644 (file)
@@ -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";
     }
index 1341d77cccc497ec54beaae15675dca659b69498..e3f3b0d40db452239339e1ed2ff2c0934342e6d6 100644 (file)
@@ -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;