summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-09-12 10:13:24 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:40 -0500
commitb5119cd6629e1fd5d52161253c16d3bf79d13df8 (patch)
tree7a01826fa8fe1bbd57e75ff4c194ea6678957d12 /source4/build
parentf8f2630c0d65460435598f3b1db5672091df99e7 (diff)
downloadsamba-b5119cd6629e1fd5d52161253c16d3bf79d13df8.tar.gz
samba-b5119cd6629e1fd5d52161253c16d3bf79d13df8.tar.bz2
samba-b5119cd6629e1fd5d52161253c16d3bf79d13df8.zip
r2295: Convert simple scalar types and policy handles between dcerpc function
call request and response structures. (This used to be commit d31d23b944b7e4ef300d75dad5038727e9133af1)
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/swig.pm104
1 files changed, 96 insertions, 8 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index 59eb493bf2..f03467177e 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -11,6 +11,98 @@ use Data::Dumper;
my($res);
my($name);
+sub DebugElement($)
+{
+ my($e) = shift;
+ my($result) = "";
+
+ $result .= "\t// $e->{TYPE} $e->{NAME} ";
+
+ $result .= "(scalar) "
+ if util::is_scalar_type($e->{TYPE});
+
+ $result .= "pointers=$e->{POINTERS} "
+ if $e->{POINTERS} > 0;
+
+ my($size_is) = util::has_property($e, "size_is");
+ $result .= "size_is=" . $size_is . " " if $size_is;
+
+ my($length_is) = util::has_property($e, "length_is");
+ $result .= "length_is=" . $length_is . " " if $length_is;
+
+ $result .= "array_len=" . $e->{ARRAY_LEN} . " " if $e->{ARRAY_LEN};
+
+ $result .= "\n";
+
+ return $result;
+}
+
+sub XFromPython($$)
+{
+ my($e) = shift;
+ my($prefix) = shift;
+ my($result) = "";
+
+ # Special cases
+
+ if ($e->{TYPE} eq "policy_handle" && $e->{POINTERS} == 1) {
+ $result .= "\ts->$prefix$e->{NAME} = policy_handle_from_python(obj);";
+ return $result;
+ }
+
+ if (util::is_scalar_type($e->{TYPE})) {
+ if ($e->{POINTERS} == 0) {
+ if ($e->{ARRAY_LEN}) {
+ # pointer to scalar with array len property
+ $result .= DebugElement($e);
+ } else {
+ $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python(obj);\n";
+ }
+ } else {
+ # Pointer to scalar
+ $result .= DebugElement($e);
+ }
+ } else {
+ # Non-scalar type
+ $result .= DebugElement($e);
+ }
+
+ return $result;
+}
+
+sub XToPython($$)
+{
+ my($e) = shift;
+ my($prefix) = shift;
+ my($result) = "";
+
+ # Special cases
+
+ if ($e->{TYPE} eq "policy_handle" && $e->{POINTERS} == 1) {
+ $result .= "\tPyDict_SetItem(obj, PyString_FromString(\"$e->{NAME}\"), policy_handle_to_python(s->$prefix$e->{NAME}));\n";
+ return $result;
+ }
+
+ if (util::is_scalar_type($e->{TYPE})) {
+ if ($e->{POINTERS} == 0) {
+ if ($e->{ARRAY_LEN}) {
+ # pointer to scalar with array len property
+ $result .= DebugElement($e);
+ } else {
+ $result .= "\tPyDict_SetItem(obj, PyString_FromString(\"$e->{NAME}\"), $e->{TYPE}_to_python(s->$prefix$e->{NAME}));\n";
+ }
+ } else {
+ # Pointer to scalar
+ $result .= DebugElement($e);
+ }
+ } else {
+ # Non-scalar type
+ $result .= DebugElement($e);
+ }
+
+ return $result;
+}
+
sub ParseFunction($)
{
my($fn) = shift;
@@ -23,9 +115,7 @@ sub ParseFunction($)
$res .= "{\n";
foreach my $e (@{$fn->{DATA}}) {
- if (util::has_property($e, "in")) {
- $res .= "\t// $e->{TYPE} $e->{NAME}\n";
- }
+ $res .= XFromPython($e, "in.") if util::has_property($e, "in")
}
$res .= "\n";
@@ -38,9 +128,7 @@ sub ParseFunction($)
$res .= "{\n";
foreach my $e (@{$fn->{DATA}}) {
- if (util::has_property($e, "out")) {
- $res .= "\t// $e->{TYPE} $e->{NAME}\n";
- }
+ $res .= XToPython($e, "out.") if util::has_property($e, "out")
}
$res .= "\n";
@@ -93,7 +181,7 @@ sub ParseStruct($)
$res .= "{\n";
foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
- $res .= "\t// $e->{TYPE} $e->{NAME}\n";
+ $res .= XFromPython($e, "");
}
$res .= "\n";
@@ -106,7 +194,7 @@ sub ParseStruct($)
$res .= "{\n";
foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
- $res .= "\t// $e->{TYPE} $e->{NAME}\n";
+ $res .= XToPython($e, "");
}
$res .= "\n";