summaryrefslogtreecommitdiff
path: root/source4/build
diff options
context:
space:
mode:
Diffstat (limited to 'source4/build')
-rw-r--r--source4/build/pidl/swig.pm125
1 files changed, 62 insertions, 63 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm
index afb6364721..68d67b4879 100644
--- a/source4/build/pidl/swig.pm
+++ b/source4/build/pidl/swig.pm
@@ -257,68 +257,6 @@ sub ParseFunction($)
$result .= IdlDump::DumpFunction($fn);
$result .= "*/\n\n";
- # Generate function to convert Python dict to structure pointer
-
- $result .= "/* Convert Python dict to struct $fn->{NAME}.in */\n\n";
-
- $result .= "struct $fn->{NAME} *$fn->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)\n";
- $result .= "{\n";
-
- $result .= "\tstruct $fn->{NAME} *s;\n\n";
-
- $result .= "\tif (!PyDict_Check(obj)) {\n";
- $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n";
- $result .= "\t\t\treturn NULL;\n";
- $result .= "\t}\n\n";
-
- $result .= "\ts = talloc_p(mem_ctx, struct $fn->{NAME});\n\n";
-
- # Remove this when all elements are initialised
- $result .= "\tmemset(s, 0, sizeof(struct $fn->{NAME}));\n\n";
-
- foreach my $e (@{$fn->{DATA}}) {
- if (util::has_property($e, "in")) {
- if (util::has_property($e, "ref")) {
- $result .= "\tif (PyDict_GetItemString(obj, \"$e->{NAME}\") == Py_None) {\n";
- $result .= "\t\tPyErr_Format(PyExc_ValueError, \"Key '$e->{NAME}' cannot be None\");\n";
- $result .= "\t\treturn NULL;\n";
- $result .= "\t}\n";
- }
- $result .= FieldFromPython($e, "in.") ;
- }
- }
-
- $result .= "\n";
- $result .= "\treturn s;\n";
- $result .= "}\n\n";
-
- # Generate function to convert structure pointer to Python dict
-
- $result .= "/* Convert struct $fn->{NAME}.out to Python dict */\n\n";
-
- $result .= "PyObject *$fn->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s";
-
- foreach my $e (@{$fn->{DATA}}) {
- if (isunion($e->{TYPE})) {
- $result .= ", int $e->{NAME}_switch_is";
- }
- }
- $result .= ")\n";
-
- $result .= "{\n";
-
- $result .= "\tPyObject *obj = PyDict_New();\n\n";
-
- foreach my $e (@{$fn->{DATA}}) {
- $result .= FieldToPython($e, "out.") if util::has_property($e, "out")
- }
-
- $result .= "\n";
- $result .= "\treturn obj;\n";
- $result .= "}\n\n";
-
- $result .= "%}\n\n";
-
# Input typemap
$result .= "%typemap(in) struct $fn->{NAME} * {\n";
@@ -689,7 +627,6 @@ sub ParseInheritedData($)
foreach my $e (@{$data}) {
$result .= ParseFunction($e) if $e->{TYPE} eq "FUNCTION";
- $result .= ParseTypedef($e) if $e->{TYPE} eq "TYPEDEF";
}
return $result;
@@ -744,4 +681,66 @@ sub Parse($)
return $result;
}
+sub pidl($)
+{
+ print OUT shift;
+}
+
+#####################################################################
+# rewrite autogenerated header file
+sub RewriteHeader($$$)
+{
+ my($idl) = shift;
+ my($input) = shift;
+ my($output) = shift;
+
+ open(IN, "<$input") || die "can't open $input for reading";
+ open(OUT, ">$output") || die "can't open $output for writing";
+
+ pidl "%{\n";
+ pidl "#define data_in in\n";
+ pidl "#define data_out out\n";
+ pidl "%}\n\n";
+
+ while(<IN>) {
+
+ # Copy structure definitions
+
+ if (/^struct .*? {$/ .. /^\};$/) {
+ s/\} (in|out);/\} data_$1;/; # "in" is a Python keyword
+ pidl $_;
+ next;
+ }
+
+ # Copy dcerpc functions
+
+ pidl $_ if /^NTSTATUS dcerpc_.*?\(struct dcerpc_pipe/;
+
+ # Copy interface definitions
+
+ pidl $_
+ if /^\#define DCERPC_.*?_UUID/ or /^\#define DCERPC_.*?_VERSION/;
+ }
+
+ close(OUT);
+}
+
+#####################################################################
+# rewrite autogenerated header file
+sub RewriteC($$$)
+{
+ my($idl) = shift;
+ my($input) = shift;
+ my($output) = shift;
+
+ open(IN, "<$input") || die "can't open $input for reading";
+ open(OUT, ">>$output") || die "can't open $output for writing";
+
+ while(<IN>) {
+ }
+
+ close(OUT);
+}
+
+
1;