Fix incompatibilities with pygccxml 0.9 and Python 2.4 (I was testing with pygccxml HEAD and Python 2.5).

This commit is contained in:
Gustavo J. A. M. Carneiro committed 2008-01-24 15:58:00 +00:00
1 parent 6304d74af7
commit a4e67a145c
6 files changed
+23 -17

No files matched your search

+2 -2
View File
@@ -243,8 +243,8 @@ class PyMetaclass(object):
getsets -- name of a PyGetSetDef C array variable, or None
"""
assert getsets is None or isinstance(getsets, PyGetSetDef)
assert isinstance(name, str)
assert isinstance(parent_metaclass_expr, str)
assert isinstance(name, basestring)
assert isinstance(parent_metaclass_expr, basestring)
self.name = name
prefix = settings.name_prefix.capitalize()
+1 -1
View File
@@ -1004,7 +1004,7 @@ static void
peekref_code = " && self->obj->%s() == 1" % self.peekref_method
visit_self = '''
if (self->obj && typeid(*self->obj) == typeid(%s)%s)
Py_VISIT(self);
Py_VISIT((PyObject *) self);
''' % (self.helper_class.name, peekref_code)
code_sink.writeln(r'''
+2 -2
View File
@@ -24,12 +24,12 @@ class Enum(object):
be used when wrapping enums declared inside
C++ classes.
"""
assert isinstance(name, str)
assert isinstance(name, basestring)
assert '::' not in name
assert outer_class is None or isinstance(outer_class, CppClass)
self.outer_class = outer_class
for val in values:
if not isinstance(val, str):
if not isinstance(val, basestring):
raise TypeError
if not name:
+5 -1
View File
@@ -800,7 +800,11 @@ class ModuleParser(object):
if type_traits.has_trivial_constructor(cls):
class_wrapper.add_constructor(CppConstructor([]))
if not have_copy_constructor:
if type_traits.has_copy_constructor(cls):
try: # pygccxml > 0.9
has_copy_constructor = type_traits.has_copy_constructor(cls)
except AttributeError: # pygccxml <= 0.9
has_copy_constructor = type_traits.has_trivial_copy(cls)
if has_copy_constructor:
class_wrapper.add_constructor(CppConstructor([
class_wrapper.ThisClassRefParameter("%s const &" % class_wrapper.full_name,
'ctor_arg', is_const=True)]))
+1 -1
View File
@@ -34,7 +34,7 @@ class CodeSink(object):
def _format_code(self, code):
"""Utility method for subclasses to use for formatting code
(splits lines and indents them)"""
assert isinstance(code, str)
assert isinstance(code, basestring)
l = []
for line in code.split('\n'):
l.append(' '*self.indent_level + line)
+12 -10
View File
@@ -33,7 +33,18 @@ def write_preamble(code_sink, min_python_version=(2, 3)):
} \
} while (0)
#define Py_VISIT(op) \
do { \
if (op) { \
int vret = visit((PyObject *)(op), arg); \
if (vret) \
return vret; \
} \
} while (0)
#endif
''')
if min_python_version < (2, 5):
@@ -47,15 +58,6 @@ typedef inquiry lenfunc;
typedef intargfunc ssizeargfunc;
typedef intobjargproc ssizeobjargproc;
#define Py_VISIT(op) \
do { \
if (op) { \
int vret = visit((PyObject *)(op), arg); \
if (vret) \
return vret; \
} \
} while (0)
#endif
''')
@@ -73,7 +75,7 @@ typedef intobjargproc ssizeobjargproc;
def get_mangled_name(base_name, template_args):
"""for internal pybindgen use"""
assert isinstance(base_name, str)
assert isinstance(base_name, basestring)
assert isinstance(template_args, (tuple, list))
if template_args: