Commit 53eb14de authored by mattip's avatar mattip

MAINT: changes from review

parent 2816f789
......@@ -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:
......
......@@ -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':
......
......@@ -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
......
......@@ -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
......
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