diff --git a/pybindgen/typehandlers/ctypeparser/__init__.py b/pybindgen/typehandlers/ctypeparser/__init__.py index 0346217..ba2fe66 100644 --- a/pybindgen/typehandlers/ctypeparser/__init__.py +++ b/pybindgen/typehandlers/ctypeparser/__init__.py @@ -1,5 +1,5 @@ import tokenizer -import copy + MODIFIERS = ['const', 'volatile'] # XXX: are there others? @@ -21,6 +21,9 @@ class CType(object): else: self.tokens = tokens + def clone(self): + return CType(list(self.tokens)) + def reorder_modifiers(self): """ Reoder const modifiers, as rightward as possible without @@ -298,10 +301,10 @@ class TypeTraits(object): def __init__(self, ctype): self.ctype = parse_type(ctype) - self.ctype_no_modifiers = copy.deepcopy(self.ctype) + self.ctype_no_modifiers = self.ctype.clone() self.ctype_no_modifiers.remove_modifiers() - self.ctype_no_const = copy.deepcopy(self.ctype) - tokens = copy.copy(self.ctype.tokens) + self.ctype_no_const = self.ctype.clone() + tokens = list(self.ctype.tokens) tokens.reverse() ptr_ref_level = 0 self.type_is_const = False