diff options
Diffstat (limited to 'pidl/lib/Parse')
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/Python.pm | 30 | ||||
-rw-r--r-- | pidl/lib/Parse/Pidl/Typelist.pm | 7 |
2 files changed, 20 insertions, 17 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 81869b0da5..d27192d6dd 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -431,7 +431,7 @@ sub PythonFunctionUnpackOut($$$) } elsif (defined($fn->{RETURN_TYPE}) and $fn->{RETURN_TYPE} eq "WERROR") { $self->handle_werror("r->out.result", "NULL", undef); } elsif (defined($fn->{RETURN_TYPE})) { - my $conv = $self->ConvertObjectToPythonData("r", $fn->{RETURN_TYPE}, "r->out.result"); + my $conv = $self->ConvertObjectToPythonData("r", $fn->{RETURN_TYPE}, "r->out.result", $fn); if ($result_size > 1) { $self->pidl("PyTuple_SetItem(result, $i, $conv);"); } else { @@ -815,11 +815,11 @@ sub assign($$$) } } -sub ConvertObjectFromPythonData($$$$$$) +sub ConvertObjectFromPythonData($$$$$$;$) { - my ($self, $mem_ctx, $cvar, $ctype, $target, $fail) = @_; + my ($self, $mem_ctx, $cvar, $ctype, $target, $fail, $location) = @_; - die("undef type for $cvar") unless(defined($ctype)); + fatal($location, "undef type for $cvar") unless(defined($ctype)); $ctype = resolveType($ctype); @@ -839,7 +839,7 @@ sub ConvertObjectFromPythonData($$$$$$) if ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") { my $ctype_name = $self->use_type_variable($ctype); unless (defined ($ctype_name)) { - error(undef, "Unable to determine origin of type " . mapTypeName($ctype)); + error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'"); $self->assign($target, "NULL"); # FIXME: return; @@ -886,7 +886,7 @@ sub ConvertObjectFromPythonData($$$$$$) return; } - fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar"); + fatal($location, "unknown type `$actual_ctype->{TYPE}' for ".mapTypeName($ctype) . ": $cvar"); } @@ -946,7 +946,7 @@ sub ConvertObjectFromPythonLevel($$$$$$$$) if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) { $var_name = get_pointer_to($var_name); } - $self->ConvertObjectFromPythonData($mem_ctx, $py_var, $l->{DATA_TYPE}, $var_name, $fail); + $self->ConvertObjectFromPythonData($mem_ctx, $py_var, $l->{DATA_TYPE}, $var_name, $fail, $e->{ORIGINAL}); } elsif ($l->{TYPE} eq "SWITCH") { $var_name = get_pointer_to($var_name); my $switch = ParseExpr($l->{SWITCH_IS}, $env, $e); @@ -954,7 +954,7 @@ sub ConvertObjectFromPythonLevel($$$$$$$$) } elsif ($l->{TYPE} eq "SUBCONTEXT") { $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, GetNextLevel($e, $l), $var_name, $fail); } else { - die("unknown level type $l->{TYPE}"); + fatal($e->{ORIGINAL}, "unknown level type $l->{TYPE}"); } } @@ -1003,9 +1003,9 @@ sub ConvertScalarToPython($$$) die("Unknown scalar type $ctypename"); } -sub ConvertObjectToPythonData($$$$$) +sub ConvertObjectToPythonData($$$$$;$) { - my ($self, $mem_ctx, $ctype, $cvar) = @_; + my ($self, $mem_ctx, $ctype, $cvar, $location) = @_; die("undef type for $cvar") unless(defined($ctype)); @@ -1027,13 +1027,13 @@ sub ConvertObjectToPythonData($$$$$) } elsif ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") { my $ctype_name = $self->use_type_variable($ctype); unless (defined($ctype_name)) { - error(undef, "Unable to determine origin of type " . mapTypeName($ctype)); + error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'"); return "NULL"; # FIXME! } return "py_talloc_import_ex($ctype_name, $mem_ctx, $cvar)"; } - fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar"); + fatal($location, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar"); } sub fail_on_null($$$) @@ -1113,12 +1113,12 @@ sub ConvertObjectToPythonLevel($$$$$$) if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE})) { $var_name = get_pointer_to($var_name); } - my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name); + my $conv = $self->ConvertObjectToPythonData($mem_ctx, $l->{DATA_TYPE}, $var_name, $e->{ORIGINAL}); $self->pidl("$py_var = $conv;"); } elsif ($l->{TYPE} eq "SUBCONTEXT") { $self->ConvertObjectToPythonLevel($mem_ctx, $env, $e, GetNextLevel($e, $l), $var_name, $py_var, $fail); } else { - die("Unknown level type $l->{TYPE} $var_name"); + fatal($e->{ORIGINAL}, "Unknown level type $l->{TYPE} $var_name"); } } @@ -1223,7 +1223,7 @@ sub Parse($$$$$) } elsif ($cvar =~ /^".*"$/) { $py_obj = "PyString_FromString($cvar)"; } else { - $py_obj = $self->ConvertObjectToPythonData("NULL", expandAlias($ctype), $cvar); + $py_obj = $self->ConvertObjectToPythonData("NULL", expandAlias($ctype), $cvar, undef); } $self->pidl("PyModule_AddObject(m, \"$name\", $py_obj);"); diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm index e63b3c990f..12ffa92bf6 100644 --- a/pidl/lib/Parse/Pidl/Typelist.pm +++ b/pidl/lib/Parse/Pidl/Typelist.pm @@ -273,12 +273,15 @@ sub mapTypeName($) my $dt; $t = expandAlias($t); - unless ($dt or ($dt = getType($t))) { + if ($dt = getType($t)) { + return mapType($dt, $dt->{NAME}); + } elsif (ref($t) eq "HASH" and defined($t->{NAME})) { + return mapType($t, $t->{NAME}); + } else { # Best guess return "struct $t"; } - return mapType($dt, $dt->{NAME}); } sub LoadIdl($;$) |