print PYOUT "\treturn obj;\n";
print PYOUT "}\n";
- # Emit a function to premarshal such a type. This folds the contents of
- # the cached Python objects into their raw fields.
+ # Emit a function to premarshal such a type. This checks the Python object
+ # type and folds the contents of the cached Python objects into their raw
+ # fields.
#
- if ($#single_structs + $#arrays > -2) {
- print PYHDR "extern int py_premarshal_", $struct->{type}, "(PyObject *);\n";
+ print PYHDR "extern int py_premarshal_", $struct->{type}, "(PyObject *);\n";
- print PYOUT "\n";
- print PYOUT "int py_premarshal_", $struct->{type}, "(PyObject *_self)\n";
- print PYOUT "{\n";
- print PYOUT "\tstruct py_", $struct->{type}, " *self = (struct py_", $struct->{type}, " *)_self;\n";
+ print PYOUT "\n";
+ print PYOUT "int py_premarshal_", $struct->{type}, "(PyObject *_self)\n";
+ print PYOUT "{\n";
+ print PYOUT "\tstruct py_", $struct->{type}, " *self = (struct py_", $struct->{type}, " *)_self;\n";
- # Check that the type we've been given is the right one
- print PYOUT "\n";
- print PYOUT "\tif (!PyObject_TypeCheck(self, &py_", $struct->{type}, "Type)) {\n";
- print PYOUT "\t\tPyErr_Format(PyExc_TypeError, \"Expected object of type ", $struct->{type}, "\");\n";
- print PYOUT "\t\treturn -1;\n";
- print PYOUT "\t}\n";
+ # Check that the type we've been given is the right one
+ print PYOUT "\n";
+ print PYOUT "\tif (!PyObject_TypeCheck(self, &py_", $struct->{type}, "Type)) {\n";
+ print PYOUT "\t\tPyErr_Format(PyExc_TypeError, \"Expected object of type ", $struct->{type}, "\");\n";
+ print PYOUT "\t\treturn -1;\n";
+ print PYOUT "\t}\n";
+ if ($#single_structs + $#arrays > -2) {
print PYOUT "\n";
my $first = 1;
foreach my $m (@single_structs, @arrays) {
print PYOUT ")\n";
print PYOUT "\t\treturn -1;\n";
- print PYOUT "\treturn 0;\n";
- print PYOUT "}\n";
- } else {
- print PYHDR "static inline int py_premarshal_", $struct->{type}, "(PyObject *_self)\n";
- print PYHDR "{\n";
- print PYHDR "\treturn 0;\n";
- print PYHDR "}\n";
}
+
+ print PYOUT "\treturn 0;\n";
+ print PYOUT "}\n";
}
1;