Commit e3aec038 authored by Xavier Thompson's avatar Xavier Thompson

Revert "Generate code correctly for 'const' cypclasses"

This reverts commit f6afb399.
parent b498f088
...@@ -842,7 +842,7 @@ class FunctionState(object): ...@@ -842,7 +842,7 @@ class FunctionState(object):
A C string referring to the variable is returned. A C string referring to the variable is returned.
""" """
if type.is_cv_qualified and not type.is_reference and not type.is_cyp_class: if type.is_cv_qualified and not type.is_reference:
type = type.cv_base_type type = type.cv_base_type
elif type.is_reference and not type.is_fake_reference: elif type.is_reference and not type.is_fake_reference:
type = type.ref_base_type type = type.ref_base_type
......
...@@ -2099,7 +2099,7 @@ class NameNode(AtomicExprNode): ...@@ -2099,7 +2099,7 @@ class NameNode(AtomicExprNode):
entry = self.entry = entry.as_variable entry = self.entry = entry.as_variable
self.type = entry.type self.type = entry.type
if self.type.is_const and not self.type.is_cyp_class: if self.type.is_const:
error(self.pos, "Assignment to const '%s'" % self.name) error(self.pos, "Assignment to const '%s'" % self.name)
if self.type.is_reference: if self.type.is_reference:
error(self.pos, "Assignment to reference '%s'" % self.name) error(self.pos, "Assignment to reference '%s'" % self.name)
......
...@@ -1847,6 +1847,8 @@ class CConstOrVolatileType(BaseType): ...@@ -1847,6 +1847,8 @@ class CConstOrVolatileType(BaseType):
def cv_string(self): def cv_string(self):
cvstring = "" cvstring = ""
if self.is_cyp_class:
return cvstring
if self.is_const: if self.is_const:
cvstring = "const " + cvstring cvstring = "const " + cvstring
if self.is_volatile: if self.is_volatile:
...@@ -1864,18 +1866,9 @@ class CConstOrVolatileType(BaseType): ...@@ -1864,18 +1866,9 @@ class CConstOrVolatileType(BaseType):
cv = self.cv_string() cv = self.cv_string()
if for_display or pyrex: if for_display or pyrex:
return cv + self.cv_base_type.declaration_code(entity_code, for_display, dll_linkage, pyrex) return cv + self.cv_base_type.declaration_code(entity_code, for_display, dll_linkage, pyrex)
elif self.cv_base_type.is_cyp_class:
return cv + self.cv_base_type.declaration_code(entity_code, for_display, dll_linkage, pyrex)
else: else:
return self.cv_base_type.declaration_code(cv + entity_code, for_display, dll_linkage, pyrex) return self.cv_base_type.declaration_code(cv + entity_code, for_display, dll_linkage, pyrex)
def empty_declaration_code(self):
if self.cv_base_type.is_cyp_class:
cv = self.cv_string()
return cv + self.cv_base_type.empty_declaration_code()
else:
return super(CConstOrVolatileType, self).empty_declaration_code()
def specialize(self, values): def specialize(self, values):
base_type = self.cv_base_type.specialize(values) base_type = self.cv_base_type.specialize(values)
if base_type == self.cv_base_type: if base_type == self.cv_base_type:
...@@ -1903,15 +1896,6 @@ class CConstOrVolatileType(BaseType): ...@@ -1903,15 +1896,6 @@ class CConstOrVolatileType(BaseType):
# Accept cv LHS <- non-cv RHS. # Accept cv LHS <- non-cv RHS.
return self.cv_base_type.same_as_resolved_type(other_type) return self.cv_base_type.same_as_resolved_type(other_type)
def as_argument_type(self):
if self.is_cyp_class:
# A const cypclass is actually a pointer to a const cypclass.
return self
else:
# This strips 'const' and 'volatile' qualifiers, which is not the documented goal
# but temporaries and Python function argument conversions rely on that.
return self.cv_base_type.as_argument_type()
def __getattr__(self, name): def __getattr__(self, name):
return getattr(self.cv_base_type, name) return getattr(self.cv_base_type, name)
......
...@@ -3236,20 +3236,13 @@ class CConstOrVolatileScope(Scope): ...@@ -3236,20 +3236,13 @@ class CConstOrVolatileScope(Scope):
self.base_type_scope = base_type_scope self.base_type_scope = base_type_scope
self.is_const = is_const self.is_const = is_const
self.is_volatile = is_volatile self.is_volatile = is_volatile
self.cached_const_entries = {}
def lookup_here(self, name): def lookup_here(self, name):
try:
return self.cached_const_entries[name]
except KeyError:
entry = self.base_type_scope.lookup_here(name) entry = self.base_type_scope.lookup_here(name)
if entry is not None: if entry is not None:
entry = copy.copy(entry) entry = copy.copy(entry)
entry.type = PyrexTypes.c_const_or_volatile_type( entry.type = PyrexTypes.c_const_or_volatile_type(
entry.type, self.is_const, self.is_volatile) entry.type, self.is_const, self.is_volatile)
# The entry must be cached because otherwise a new type is created at
# each lookup, which can cause type inference to reinfer forever.
self.cached_const_entries[name] = entry
return entry return entry
......
...@@ -536,7 +536,7 @@ def simply_type(result_type, pos): ...@@ -536,7 +536,7 @@ def simply_type(result_type, pos):
result_type = result_type.checked_base_type result_type = result_type.checked_base_type
if result_type.is_reference: if result_type.is_reference:
result_type = result_type.ref_base_type result_type = result_type.ref_base_type
if result_type.is_cv_qualified and not result_type.is_cyp_class: if result_type.is_cv_qualified:
result_type = result_type.cv_base_type result_type = result_type.cv_base_type
if result_type.is_cpp_class: if result_type.is_cpp_class:
result_type.check_nullary_constructor(pos) result_type.check_nullary_constructor(pos)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment