diff options
Diffstat (limited to 'source4/build')
-rw-r--r-- | source4/build/pidl/swig.pm | 399 |
1 files changed, 227 insertions, 172 deletions
diff --git a/source4/build/pidl/swig.pm b/source4/build/pidl/swig.pm index 071f49d399..6b5fb60c1e 100644 --- a/source4/build/pidl/swig.pm +++ b/source4/build/pidl/swig.pm @@ -7,12 +7,13 @@ package IdlSwig; use strict; +# Some build farm machines don't have the Data::Dumper module installed + eval("use Data::Dumper"); -my(%interfaces, %functions, %structs, %unions); -my($res, $name); +# Display properties of a structure field as commented out code -sub DebugElement($) +sub DebugField($) { my($e) = shift; my($result) = ""; @@ -38,6 +39,8 @@ sub DebugElement($) return $result; } +# Generate code to convert a Python object to an array + sub ArrayFromPython($$) { my($e) = shift; @@ -80,7 +83,9 @@ sub ArrayFromPython($$) return $result; } -sub XFromPython($$) +# Generate code to convert a Python object to a structure field + +sub FieldFromPython($$) { my($e) = shift; my($prefix) = shift; @@ -105,7 +110,7 @@ sub XFromPython($$) } } else { $result .= "\t// Pointer to scalar\n"; - $result .= DebugElement($e); + $result .= DebugField($e); } } else { if ($e->{POINTERS} == 0) { @@ -122,6 +127,8 @@ sub XFromPython($$) return $result; } +# Generate code to convert an array to a Python object + sub ArrayToPython($$) { my($e) = shift; @@ -164,7 +171,9 @@ sub ArrayToPython($$) return $result; } -sub XToPython($$) +# Generate code to convert a structure field to a Python object + +sub FieldToPython($$) { my($e) = shift; my($prefix) = shift; @@ -188,7 +197,7 @@ sub XToPython($$) } } else { $result .= "\t// Pointer to scalar\n"; - $result .= DebugElement($e); + $result .= DebugField($e); } } else { if ($e->{POINTERS} == 0) { @@ -208,299 +217,344 @@ sub XToPython($$) sub ParseFunction($) { my($fn) = shift; + my($result) = ""; + + $result .= "%{\n\n"; - $res .= "%{\n\n"; + $result .= "/*\n\n"; + $result .= IdlDump::DumpFunction($fn); + $result .= "*/\n\n"; - $res .= "/* Convert Python dict to struct $fn->{NAME}.in */\n\n"; + # Generate function to convert Python dict to structure pointer - $res .= "struct $fn->{NAME} *$fn->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)\n"; - $res .= "{\n"; + $result .= "/* Convert Python dict to struct $fn->{NAME}.in */\n\n"; - $res .= "\tstruct $fn->{NAME} *s;\n\n"; + $result .= "struct $fn->{NAME} *$fn->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)\n"; + $result .= "{\n"; - $res .= "\tif (!PyDict_Check(obj)) {\n"; - $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; - $res .= "\t\treturn NULL;\n"; - $res .= "\t}\n\n"; + $result .= "\tstruct $fn->{NAME} *s;\n\n"; - $res .= "\ts = talloc(mem_ctx, sizeof(struct $fn->{NAME}));\n\n"; + $result .= "\tif (!PyDict_Check(obj)) {\n"; + $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; + + $result .= "\ts = talloc(mem_ctx, sizeof(struct $fn->{NAME}));\n\n"; # Remove this when all elements are initialised - $res .= "\tmemset(s, 0, sizeof(struct $fn->{NAME}));\n\n"; + $result .= "\tmemset(s, 0, sizeof(struct $fn->{NAME}));\n\n"; foreach my $e (@{$fn->{DATA}}) { - $res .= XFromPython($e, "in.") if util::has_property($e, "in") + $result .= FieldFromPython($e, "in.") if util::has_property($e, "in") } - $res .= "\n"; - $res .= "\treturn s;\n"; - $res .= "}\n\n"; + $result .= "\n"; + $result .= "\treturn s;\n"; + $result .= "}\n\n"; + + # Generate function to convert structure pointer to Python dict - $res .= "/* Convert struct $fn->{NAME}.out to Python dict */\n\n"; + $result .= "/* Convert struct $fn->{NAME}.out to Python dict */\n\n"; - $res .= "PyObject *$fn->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s)\n"; - $res .= "{\n"; + $result .= "PyObject *$fn->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s)\n"; + $result .= "{\n"; - $res .= "\tPyObject *obj = PyDict_New();\n\n"; + $result .= "\tPyObject *obj = PyDict_New();\n\n"; foreach my $e (@{$fn->{DATA}}) { - $res .= XToPython($e, "out.") if util::has_property($e, "out") + $result .= FieldToPython($e, "out.") if util::has_property($e, "out") } - $res .= "\n"; - $res .= "\treturn obj;\n"; - $res .= "}\n\n"; + $result .= "\n"; + $result .= "\treturn obj;\n"; + $result .= "}\n\n"; - $res .= "%}\n\n"; + $result .= "%}\n\n"; # Input typemap - $res .= "%typemap(in) struct $fn->{NAME} * {\n"; - $res .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(int) $fn->{NAME}\");\n\n"; - $res .= "\t\$1 = $fn->{NAME}_ptr_from_python(mem_ctx, \$input, \"<function params>\");\n\n"; + $result .= "%typemap(in) struct $fn->{NAME} * {\n"; + $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(int) $fn->{NAME}\");\n\n"; + $result .= "\t\$1 = $fn->{NAME}_ptr_from_python(mem_ctx, \$input, \"<function params>\");\n\n"; - $res .= "\tif (PyErr_Occurred())\n"; - $res .= "\t\t\treturn NULL;\n\n"; + $result .= "\tif (PyErr_Occurred())\n"; + $result .= "\t\t\treturn NULL;\n\n"; - $res .= "}\n\n"; + $result .= "}\n\n"; # Output typemap - $res .= "%typemap(argout) struct $fn->{NAME} * {\n"; - $res .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(argout) $fn->{NAME}\");\n\n"; - $res .= "\tlong status = PyLong_AsLong(resultobj);\n"; - $res .= "\tPyObject *dict;\n"; - $res .= "\n"; + $result .= "%typemap(argout) struct $fn->{NAME} * {\n"; + $result .= "\tTALLOC_CTX *mem_ctx = talloc_init(\"typemap(argout) $fn->{NAME}\");\n\n"; + $result .= "\tlong status = PyLong_AsLong(resultobj);\n"; + $result .= "\tPyObject *dict;\n"; + $result .= "\n"; - $res .= "\tif (status != 0) {\n"; - $res .= "\t\tset_ntstatus_exception(status);\n"; - $res .= "\t\treturn NULL;\n"; - $res .= "\t}\n"; - $res .= "\n"; - $res .= "\tdict = $fn->{NAME}_ptr_to_python(mem_ctx, \$1);\n"; + $result .= "\tif (status != 0) {\n"; + $result .= "\t\tset_ntstatus_exception(status);\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n"; + $result .= "\n"; + $result .= "\tdict = $fn->{NAME}_ptr_to_python(mem_ctx, \$1);\n"; - $res .= "\tresultobj = dict;\n"; - $res .= "}\n\n"; + $result .= "\tresultobj = dict;\n"; + $result .= "}\n\n"; # Function definitions - $res .= "%rename($fn->{NAME}) dcerpc_$fn->{NAME};\n"; - $res .= "$fn->{RETURN_TYPE} dcerpc_$fn->{NAME}(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $fn->{NAME} *r);\n\n"; + $result .= "%rename($fn->{NAME}) dcerpc_$fn->{NAME};\n"; + $result .= "$fn->{RETURN_TYPE} dcerpc_$fn->{NAME}(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $fn->{NAME} *r);\n\n"; + + return $result; } sub ParseStruct($) { my($s) = shift; + my($result) = ""; + + $result .= "%{\n\n"; + + $result .= "/*\n\n"; + $result .= IdlDump::DumpTypedef($s); + $result .= "*/\n\n"; - $res .= "%{\n\n"; - $res .= "/* Convert Python dict to struct $s->{NAME} pointer */\n\n"; + # Generate function to convert Python dict to structure pointer + + $result .= "/* Convert Python dict to struct $s->{NAME} pointer */\n\n"; - $res .= "struct $s->{NAME} *$s->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)\n"; - $res .= "{\n"; - $res .= "\tstruct $s->{NAME} *s;\n\n"; + $result .= "struct $s->{NAME} *$s->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)\n"; + $result .= "{\n"; + $result .= "\tstruct $s->{NAME} *s;\n\n"; - $res .= "\tif (obj == NULL) {\n"; - $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; - $res .= "\t\treturn NULL;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (obj == NULL) {\n"; + $result .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; - $res .= "\tif (obj == Py_None) {\n"; - $res .= "\t\treturn NULL;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (obj == Py_None) {\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; - $res .= "\tif (!PyDict_Check(obj)) {\n"; - $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; - $res .= "\t\treturn NULL;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (!PyDict_Check(obj)) {\n"; + $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; - $res .= "\ts = talloc(mem_ctx, sizeof(struct $s->{NAME}));\n\n"; + $result .= "\ts = talloc(mem_ctx, sizeof(struct $s->{NAME}));\n\n"; foreach my $e (@{$s->{DATA}{ELEMENTS}}) { - $res .= XFromPython($e, ""); + $result .= FieldFromPython($e, ""); } - $res .= "\n"; - $res .= "\treturn s;\n"; - $res .= "}\n\n"; + $result .= "\n"; + $result .= "\treturn s;\n"; + $result .= "}\n\n"; + + # Generate function to convert Python dict to structure - $res .= "/* Convert Python dict to struct $s->{NAME} */\n\n"; + $result .= "/* Convert Python dict to struct $s->{NAME} */\n\n"; - $res .= "void $s->{NAME}_from_python(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s, PyObject *obj, char *name)\n"; - $res .= "{\n"; + $result .= "void $s->{NAME}_from_python(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s, PyObject *obj, char *name)\n"; + $result .= "{\n"; - $res .= "\tif (obj == NULL) {\n"; - $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; - $res .= "\t\treturn;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (obj == NULL) {\n"; + $result .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; + $result .= "\t\treturn;\n"; + $result .= "\t}\n\n"; - $res .= "\tif (!PyDict_Check(obj)) {\n"; - $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; - $res .= "\t\treturn;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (!PyDict_Check(obj)) {\n"; + $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; + $result .= "\t\treturn;\n"; + $result .= "\t}\n\n"; foreach my $e (@{$s->{DATA}{ELEMENTS}}) { - $res .= XFromPython($e, ""); + $result .= FieldFromPython($e, ""); } - $res .= "}\n\n"; + $result .= "}\n\n"; - $res .= "/* Convert struct $s->{NAME} pointer to Python dict */\n\n"; + # Generate function to convert structure pointer to Python dict - $res .= "PyObject *$s->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s)\n"; - $res .= "{\n"; + $result .= "/* Convert struct $s->{NAME} pointer to Python dict */\n\n"; + + $result .= "PyObject *$s->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s)\n"; + $result .= "{\n"; - $res .= "\tPyObject *obj = PyDict_New();\n\n"; + $result .= "\tPyObject *obj = PyDict_New();\n\n"; - $res .= "\tif (s == NULL) {\n"; - $res .= "\t\tPy_INCREF(Py_None);\n"; - $res .= "\t\treturn Py_None;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (s == NULL) {\n"; + $result .= "\t\tPy_INCREF(Py_None);\n"; + $result .= "\t\treturn Py_None;\n"; + $result .= "\t}\n\n"; foreach my $e (@{$s->{DATA}{ELEMENTS}}) { - $res .= XToPython($e, ""); + $result .= FieldToPython($e, ""); } - $res .= "\n"; - $res .= "\treturn obj;\n"; - $res .= "}\n"; + $result .= "\n"; + $result .= "\treturn obj;\n"; + $result .= "}\n"; + + $result .= "\n%}\n\n"; - $res .= "\n%}\n\n"; + return $result; } sub ParseUnion($) { my($u) = shift; + my($result) = ""; + + $result .= "/*\n\n"; + $result .= IdlDump::DumpTypedef($u); + $result .= "*/\n\n"; + + # Generate function to convert Python dict to union pointer - $res .= "%{\n\n"; - $res .= "/* Convert Python dict to union $u->{NAME} pointer */\n\n"; + $result .= "%{\n\n"; + $result .= "/* Convert Python dict to union $u->{NAME} pointer */\n\n"; - $res .= "union $u->{NAME} *$u->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)\n"; - $res .= "{\n"; + $result .= "union $u->{NAME} *$u->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj, char *name)\n"; + $result .= "{\n"; - $res .= "\tunion $u->{NAME} *u;\n"; - $res .= "\tPyObject *dict;\n\n"; + $result .= "\tunion $u->{NAME} *u;\n"; + $result .= "\tPyObject *dict;\n\n"; - $res .= "\tif (obj == NULL) {\n"; - $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; - $res .= "\t\treturn NULL;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (obj == NULL) {\n"; + $result .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; - $res .= "\tif (!PyDict_Check(obj)) {\n"; - $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; - $res .= "\t\treturn NULL;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (!PyDict_Check(obj)) {\n"; + $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; + $result .= "\t\treturn NULL;\n"; + $result .= "\t}\n\n"; - $res .= "\tu = talloc(mem_ctx, sizeof(union $u->{NAME}));\n\n"; + $result .= "\tu = talloc(mem_ctx, sizeof(union $u->{NAME}));\n\n"; for my $e (@{$u->{DATA}{DATA}}) { - $res .= "\tif ((dict = PyDict_GetItem(obj, PyString_FromString(\"$e->{DATA}{NAME}\")))) {\n"; + $result .= "\tif ((dict = PyDict_GetItem(obj, PyString_FromString(\"$e->{DATA}{NAME}\")))) {\n"; if ($e->{DATA}{POINTERS} == 0) { - $res .= "\t\t$e->{DATA}{TYPE}_from_python(mem_ctx, &u->$e->{DATA}{NAME}, dict, \"$e->{DATA}{NAME}\");\n"; + $result .= "\t\t$e->{DATA}{TYPE}_from_python(mem_ctx, &u->$e->{DATA}{NAME}, dict, \"$e->{DATA}{NAME}\");\n"; } elsif ($e->{DATA}{POINTERS} == 1) { - $res .= "\t\tu->$e->{DATA}{NAME} = $e->{DATA}{TYPE}_ptr_from_python(mem_ctx, dict, \"$e->{DATA}{NAME}\");\n"; + $result .= "\t\tu->$e->{DATA}{NAME} = $e->{DATA}{TYPE}_ptr_from_python(mem_ctx, dict, \"$e->{DATA}{NAME}\");\n"; } else { - $res .= "\t\t// $e->{DATA}{TYPE} pointers=$e->{DATA}{POINTERS}\n"; + $result .= "\t\t// $e->{DATA}{TYPE} pointers=$e->{DATA}{POINTERS}\n"; } - $res .= "\t\treturn u;\n"; - $res .= "\t}\n\n"; + $result .= "\t\treturn u;\n"; + $result .= "\t}\n\n"; } - $res .= "\treturn NULL;\n"; - $res .= "}\n\n"; - - $res .= "/* Convert union $u->{NAME} pointer to Python dict */\n\n"; - - $res .= "PyObject *$u->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, union $u->{NAME} *u)\n"; - $res .= "{\n"; - - $res .= "\tif (u == NULL) {\n"; - $res .= "\t\tPy_INCREF(Py_None);\n"; - $res .= "\t\treturn Py_None;\n"; - $res .= "\t}\n\n"; + $result .= "\treturn NULL;\n"; + $result .= "}\n\n"; - $res .= "\treturn PyDict_New();\n"; - $res .= "}\n\n"; + # Generate function to convert Python dict to union - $res .= "/* Convert Python dict to union $u->{NAME} */\n\n"; + $result .= "/* Convert Python dict to union $u->{NAME} */\n\n"; - $res .= "void $u->{NAME}_from_python(TALLOC_CTX *mem_ctx, union $u->{NAME} *u, PyObject *obj, char *name)\n"; - $res .= "{\n"; - $res .= "\tPyObject *dict;\n\n"; + $result .= "void $u->{NAME}_from_python(TALLOC_CTX *mem_ctx, union $u->{NAME} *u, PyObject *obj, char *name)\n"; + $result .= "{\n"; + $result .= "\tPyObject *dict;\n\n"; - $res .= "\tif (obj == NULL) {\n"; - $res .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; - $res .= "\t\treturn;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (obj == NULL) {\n"; + $result .= "\t\tPyErr_Format(PyExc_ValueError, \"Expecting key '%s'\", name);\n"; + $result .= "\t\treturn;\n"; + $result .= "\t}\n\n"; - $res .= "\tif (!PyDict_Check(obj)) {\n"; - $res .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; - $res .= "\t\treturn;\n"; - $res .= "\t}\n\n"; + $result .= "\tif (!PyDict_Check(obj)) {\n"; + $result .= "\t\tPyErr_Format(PyExc_TypeError, \"Expecting dict value for key '%s'\", name);\n"; + $result .= "\t\treturn;\n"; + $result .= "\t}\n\n"; for my $e (@{$u->{DATA}{DATA}}) { - $res .= "\tif ((dict = PyDict_GetItem(obj, PyString_FromString(\"$e->{DATA}{NAME}\")))) {\n"; + $result .= "\tif ((dict = PyDict_GetItem(obj, PyString_FromString(\"$e->{DATA}{NAME}\")))) {\n"; if ($e->{DATA}{POINTERS} == 0) { - $res .= "\t\t$e->{DATA}{TYPE}_from_python(mem_ctx, &u->$e->{DATA}{NAME}, dict, \"$e->{DATA}{NAME}\");\n"; + $result .= "\t\t$e->{DATA}{TYPE}_from_python(mem_ctx, &u->$e->{DATA}{NAME}, dict, \"$e->{DATA}{NAME}\");\n"; } elsif ($e->{DATA}{POINTERS} == 1) { - $res .= "\t\tu->$e->{DATA}{NAME} = $e->{DATA}{TYPE}_ptr_from_python(mem_ctx, dict, \"$e->{DATA}{NAME}\");\n"; + $result .= "\t\tu->$e->{DATA}{NAME} = $e->{DATA}{TYPE}_ptr_from_python(mem_ctx, dict, \"$e->{DATA}{NAME}\");\n"; } else { - $res .= "\t\t// $e->{DATA}{TYPE} pointers=$e->{DATA}{POINTERS}\n"; + $result .= "\t\t// $e->{DATA}{TYPE} pointers=$e->{DATA}{POINTERS}\n"; } - $res .= "\t\treturn;\n"; - $res .= "\t}\n\n"; + $result .= "\t\treturn;\n"; + $result .= "\t}\n\n"; } - $res .= "}\n"; + $result .= "}\n"; + + # Generate function to convert union pointer to Python dict + + $result .= "/* Convert union $u->{NAME} pointer to Python dict */\n\n"; + + $result .= "PyObject *$u->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, union $u->{NAME} *u)\n"; + $result .= "{\n"; + + $result .= "\tif (u == NULL) {\n"; + $result .= "\t\tPy_INCREF(Py_None);\n"; + $result .= "\t\treturn Py_None;\n"; + $result .= "\t}\n\n"; + + $result .= "\treturn PyDict_New();\n"; + $result .= "}\n\n"; + + $result .= "\n%}\n\n"; - $res .= "\n%}\n\n"; + return $result; } sub ParseTypedef($) { my($t) = shift; + my($result) = ""; foreach my $e ($t) { - ($e->{DATA}{TYPE} eq "STRUCT") && ParseStruct($e); - ($e->{DATA}{TYPE} eq "UNION") && ParseUnion($e); + $result .= ParseStruct($e) if $e->{DATA}{TYPE} eq "STRUCT"; + $result .= ParseUnion($e) if $e->{DATA}{TYPE} eq "UNION"; } + + return $result; } sub ParseInheritedData($) { my($data) = shift; + my($result) = ""; foreach my $e (@{$data}) { - ($e->{TYPE} eq "FUNCTION") && ParseFunction($e); - ($e->{TYPE} eq "TYPEDEF") && ParseTypedef($e); + $result .= ParseFunction($e) if $e->{TYPE} eq "FUNCTION"; + $result .= ParseTypedef($e) if $e->{TYPE} eq "TYPEDEF"; } + + return $result; } sub ParseHeader($) { my($hdr) = shift; + my($result) = ""; if ($hdr->{PROPERTIES}{uuid}) { - $name = $hdr->{NAME}; - $res .= "#define DCERPC_" . uc($name) . "_UUID \"$hdr->{PROPERTIES}->{uuid}\"\n"; - $res .= "const int DCERPC_" . uc($name) . "_VERSION = " . $hdr->{PROPERTIES}->{version} . ";\n"; - $res .= "#define DCERPC_" . uc($name) . "_NAME \"" . $name . "\"\n"; - $res .= "\n"; + my($name) = $hdr->{NAME}; + $result .= "#define DCERPC_" . uc($name) . "_UUID \"$hdr->{PROPERTIES}->{uuid}\"\n"; + $result .= "const int DCERPC_" . uc($name) . "_VERSION = " . $hdr->{PROPERTIES}->{version} . ";\n"; + $result .= "#define DCERPC_" . uc($name) . "_NAME \"" . $name . "\"\n"; + $result .= "\n"; } - ParseInheritedData($hdr->{INHERITED_DATA}); + $result .= ParseInheritedData($hdr->{INHERITED_DATA}); + + return $result; } sub Parse($) { my($idl) = shift; + my($result) = ""; - # Make index of functions, structs and unions + # Make index of functions, structs and unions. Currently unused. - %interfaces = (); - %functions = (); - %structs = (); - %unions = (); + my(%interfaces, %functions, %structs, %unions); foreach my $x (@{$idl}) { my($iname) = $x->{NAME}; @@ -516,13 +570,14 @@ sub Parse($) # Generate interface - $res = "/* auto-generated by pidl */\n\n"; + $result = "/* Auto-generated by pidl */\n\n"; + $result = "/* Tastes like -*- C -*- */\n\n"; foreach my $x (@{$idl}) { - ($x->{TYPE} eq "INTERFACE") && ParseHeader($x); + $result .= ParseHeader($x) if ($x->{TYPE} eq "INTERFACE"); } - return $res; + return $result; } 1; |