summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattip <matti.picus@gmail.com>2019-01-05 23:05:27 +0200
committermattip <matti.picus@gmail.com>2019-01-05 23:15:33 +0200
commit53eb14dec2e73a111a7c2316aa426710db0fdabc (patch)
tree090a5165699541f30bd594fb99a0e92f956f66d5
parent2816f789a0b00c7f45c1b773f8ad84030dcaa39e (diff)
downloadcython-53eb14dec2e73a111a7c2316aa426710db0fdabc.tar.gz
MAINT: changes from review
-rw-r--r--Cython/Compiler/ExprNodes.py6
-rw-r--r--Cython/Compiler/Nodes.py13
-rw-r--r--Cython/Compiler/Symtab.py18
-rw-r--r--tests/run/ext_attr_getter.srctree6
4 files changed, 19 insertions, 24 deletions
diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index b00544ba7..d29764371 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -6976,11 +6976,7 @@ class AttributeNode(ExprNode):
self.obj = self.obj.analyse_types(env)
self.analyse_attribute(env)
if self.entry and self.entry.is_cmethod and not self.is_called:
- if getattr(self.entry, 'is_cgetter', False):
- # This should be done at a different level??
- self.is_called = 1
- self.op = ''
- self.result_ctype = self.type.return_type
+# error(self.pos, "C method can only be called")
pass
## Reference to C array turns into pointer to first element.
#while self.type.is_array:
diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py
index 682547222..6828f2ac8 100644
--- a/Cython/Compiler/Nodes.py
+++ b/Cython/Compiler/Nodes.py
@@ -2340,11 +2340,14 @@ class CFuncDefNode(FuncDefNode):
return self.py_func.code_object if self.py_func else None
def analyse_declarations(self, env):
+ is_property = False
if self.decorators:
for decorator in self.decorators:
func = decorator.decorator
if func.is_name:
- if func.name in ('property', 'staticmethod'):
+ if func.name == 'property':
+ is_property = True
+ elif func.name == 'staticmethod':
pass
else:
error(self.pos, "Cannot handle %s decorators yet" % func.name)
@@ -2421,16 +2424,12 @@ class CFuncDefNode(FuncDefNode):
type.is_const_method = self.is_const_method
type.is_static_method = self.is_static_method
- property = False
- if self.decorators:
- for _node in self.decorators:
- if _node.decorator.is_name and _node.decorator.name == 'property':
- property = True
+
self.entry = env.declare_cfunction(
name, type, self.pos,
cname=cname, visibility=self.visibility, api=self.api,
defining=self.body is not None, modifiers=self.modifiers,
- overridable=self.overridable, property=property)
+ overridable=self.overridable, is_property=is_property)
self.entry.inline_func_in_pxd = self.inline_in_pxd
self.return_type = type.return_type
if self.return_type.is_array and self.visibility != 'extern':
diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py
index 5c27046eb..6a69b18d1 100644
--- a/Cython/Compiler/Symtab.py
+++ b/Cython/Compiler/Symtab.py
@@ -753,7 +753,7 @@ class Scope(object):
def declare_cfunction(self, name, type, pos,
cname=None, visibility='private', api=0, in_pxd=0,
defining=0, modifiers=(), utility_code=None,
- overridable=False, property=False):
+ overridable=False, is_property=False):
# Add an entry for a C function.
if not cname:
if visibility != 'private' or api:
@@ -831,7 +831,7 @@ class Scope(object):
return entry
def add_cfunction(self, name, type, pos, cname, visibility, modifiers,
- inherited=False, property=False):
+ inherited=False, is_property=False):
# Add a C function entry without giving it a func_cname.
entry = self.declare(name, cname, type, pos, visibility)
entry.is_cfunction = 1
@@ -839,7 +839,7 @@ class Scope(object):
entry.func_modifiers = modifiers
if inherited or type.is_fused:
self.cfunc_entries.append(entry)
- elif property:
+ elif is_property:
self.property_entries.append(entry)
else:
# For backwards compatibility reasons, we must keep all non-fused methods
@@ -1440,7 +1440,7 @@ class ModuleScope(Scope):
def declare_cfunction(self, name, type, pos,
cname=None, visibility='private', api=0, in_pxd=0,
defining=0, modifiers=(), utility_code=None,
- overridable=False, property=False):
+ overridable=False, is_property=False):
if not defining and 'inline' in modifiers:
# TODO(github/1736): Make this an error.
warning(pos, "Declarations should not be declared inline.", 1)
@@ -1464,7 +1464,7 @@ class ModuleScope(Scope):
self, name, type, pos,
cname=cname, visibility=visibility, api=api, in_pxd=in_pxd,
defining=defining, modifiers=modifiers, utility_code=utility_code,
- overridable=overridable, property=property)
+ overridable=overridable, is_property=is_property)
return entry
def declare_global(self, name, pos):
@@ -2220,7 +2220,7 @@ class CClassScope(ClassScope):
def declare_cfunction(self, name, type, pos,
cname=None, visibility='private', api=0, in_pxd=0,
defining=0, modifiers=(), utility_code=None,
- overridable=False, property=False):
+ overridable=False, is_property=False):
if get_special_method_signature(name) and not self.parent_type.is_builtin_type:
error(pos, "Special methods must be declared with 'def', not 'cdef'")
args = type.args
@@ -2265,7 +2265,7 @@ class CClassScope(ClassScope):
"C method '%s' not previously declared in definition part of"
" extension type '%s'" % (name, self.class_name))
entry = self.add_cfunction(name, type, pos, cname, visibility,
- modifiers, property=property)
+ modifiers, is_property=is_property)
if defining:
entry.func_cname = self.mangle(Naming.func_prefix, name)
entry.utility_code = utility_code
@@ -2282,12 +2282,12 @@ class CClassScope(ClassScope):
return entry
def add_cfunction(self, name, type, pos, cname, visibility, modifiers,
- inherited=False, property=False):
+ inherited=False, is_property=False):
# Add a cfunction entry without giving it a func_cname.
prev_entry = self.lookup_here(name)
entry = ClassScope.add_cfunction(self, name, type, pos, cname,
visibility, modifiers,
- inherited=inherited, property=property)
+ inherited=inherited, is_property=is_property)
entry.is_cmethod = 1
entry.prev_entry = prev_entry
return entry
diff --git a/tests/run/ext_attr_getter.srctree b/tests/run/ext_attr_getter.srctree
index e295f091c..c63f0a1e7 100644
--- a/tests/run/ext_attr_getter.srctree
+++ b/tests/run/ext_attr_getter.srctree
@@ -44,17 +44,17 @@ typedef struct {
int PyFoo_Get0F(FooStructOpaque *f)
{
- return ((FooStructNominal*)f)->f0;
+ return PyFoo_GET0M(f);
}
int PyFoo_Get1F(FooStructOpaque *f)
{
- return ((FooStructNominal*)f)->f1;
+ return PyFoo_GET1M(f);
}
int PyFoo_Get2F(FooStructOpaque *f)
{
- return ((FooStructNominal*)f)->f2;
+ return PyFoo_GET2M(f);
}
#ifdef __cplusplus