summaryrefslogtreecommitdiff
path: root/pidl/lib/Parse/Pidl/Samba4/Python.pm
diff options
context:
space:
mode:
authorbubulle <bubulle@alioth.debian.org>2010-04-04 16:44:16 +0000
committerbubulle <bubulle@alioth.debian.org>2010-04-04 16:44:16 +0000
commit9e2f5a6ab663f7a111832217c527508c75ddae8a (patch)
tree2e74616febbb3fb658ce2dcc5f9cff00ad4fdb4a /pidl/lib/Parse/Pidl/Samba4/Python.pm
parentb5556af8f75a4f74db404dd43ee7abafa2be6ca4 (diff)
downloadsamba-9e2f5a6ab663f7a111832217c527508c75ddae8a.tar.gz
Merge 3.5.1 from experimental
git-svn-id: svn://svn.debian.org/svn/pkg-samba/trunk/samba@3414 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'pidl/lib/Parse/Pidl/Samba4/Python.pm')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm46
1 files changed, 25 insertions, 21 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 6099fe5cae..c785619adb 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 {
@@ -766,6 +766,11 @@ sub register_module_import($$)
sub use_type_variable($$)
{
my ($self, $orig_ctype) = @_;
+ # FIXME: Have a global lookup table for types that look different on the
+ # wire than they are named in C?
+ if ($orig_ctype->{NAME} eq "dom_sid2") {
+ $orig_ctype->{NAME} = "dom_sid";
+ }
my $ctype = resolveType($orig_ctype);
unless (defined($ctype->{BASEFILE})) {
return undef;
@@ -815,11 +820,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,13 +844,12 @@ 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));
- $self->assign($target, "NULL");
- # FIXME:
+ error($location, "Unable to determine origin of type `" . mapTypeName($ctype) . "'");
+ $self->pidl("PyErr_SetString(PyExc_TypeError, \"Can not convert C Type " . mapTypeName($ctype) . " to Python\");");
return;
}
$self->pidl("PY_CHECK_TYPE($ctype_name, $cvar, $fail);");
- $self->assign($target, "talloc_ptrtype(py_talloc_get_ptr($cvar), $target)");
+ $self->assign($target, "py_talloc_get_ptr($cvar)");
return;
}
@@ -886,7 +890,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 +950,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 +958,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}");
}
}
@@ -994,18 +998,18 @@ sub ConvertScalarToPython($$$)
}
# Not yet supported
- if ($ctypename eq "string_array") { return "PyCObject_FromVoidPtr($cvar)"; }
+ if ($ctypename eq "string_array") { return "PyCObject_FromTallocPtr($cvar)"; }
if ($ctypename eq "ipv4address") { return "PyString_FromString($cvar)"; }
if ($ctypename eq "pointer") {
- return "PyCObject_FromVoidPtr($cvar, talloc_free)";
+ return "PyCObject_FromTallocPtr($cvar)";
}
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 +1031,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)";
+ return "py_talloc_reference_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 +1117,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 +1227,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);");