Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
598b2537
Commit
598b2537
authored
Sep 18, 2007
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Class members in cdef classes
parent
c4043e82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
34 deletions
+44
-34
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+43
-32
No files found.
Cython/Compiler/Nodes.py
View file @
598b2537
...
@@ -1370,9 +1370,8 @@ class CClassDefNode(StatNode):
...
@@ -1370,9 +1370,8 @@ class CClassDefNode(StatNode):
env
.
allocate_vtable_names
(
self
.
entry
)
env
.
allocate_vtable_names
(
self
.
entry
)
def
analyse_expressions
(
self
,
env
):
def
analyse_expressions
(
self
,
env
):
scope
=
self
.
entry
.
type
.
scope
if
self
.
body
:
if
self
.
body
:
self
.
body
.
analyse_expressions
(
scope
)
self
.
body
.
analyse_expressions
(
env
)
def
generate_function_definitions
(
self
,
env
,
code
):
def
generate_function_definitions
(
self
,
env
,
code
):
if
self
.
body
:
if
self
.
body
:
...
...
Cython/Compiler/Symtab.py
View file @
598b2537
...
@@ -1050,45 +1050,56 @@ class CClassScope(ClassScope):
...
@@ -1050,45 +1050,56 @@ class CClassScope(ClassScope):
def
declare_var
(
self
,
name
,
type
,
pos
,
def
declare_var
(
self
,
name
,
type
,
pos
,
cname
=
None
,
visibility
=
'private'
,
is_cdef
=
0
):
cname
=
None
,
visibility
=
'private'
,
is_cdef
=
0
):
# Add an entry for an attribute.
if
is_cdef
:
if
self
.
defined
:
# Add an entry for an attribute.
error
(
pos
,
if
self
.
defined
:
"C attributes cannot be added in implementation part of"
" extension type"
)
if
get_special_method_signature
(
name
):
error
(
pos
,
"The name '%s' is reserved for a special method."
%
name
)
if
not
cname
:
cname
=
name
entry
=
self
.
declare
(
name
,
cname
,
type
,
pos
)
entry
.
visibility
=
visibility
entry
.
is_variable
=
1
self
.
var_entries
.
append
(
entry
)
if
type
.
is_pyobject
:
self
.
has_pyobject_attrs
=
1
if
visibility
not
in
(
'private'
,
'public'
,
'readonly'
):
error
(
pos
,
"Attribute of extension type cannot be declared %s"
%
visibility
)
if
visibility
in
(
'public'
,
'readonly'
):
if
type
.
pymemberdef_typecode
:
self
.
public_attr_entries
.
append
(
entry
)
if
name
==
"__weakref__"
:
error
(
pos
,
"Special attribute __weakref__ cannot be exposed to Python"
)
else
:
error
(
pos
,
error
(
pos
,
"C attribute of type '%s' cannot be accessed from Python"
%
type
)
"C attributes cannot be added in implementation part of"
if
visibility
==
'public'
and
type
.
is_extension_type
:
" extension type"
)
error
(
pos
,
if
get_special_method_signature
(
name
):
"Non-generic Python attribute cannot be exposed for writing from Python"
)
error
(
pos
,
return
entry
"The name '%s' is reserved for a special method."
%
name
)
if
not
cname
:
cname
=
name
entry
=
self
.
declare
(
name
,
cname
,
type
,
pos
)
entry
.
visibility
=
visibility
entry
.
is_variable
=
1
self
.
var_entries
.
append
(
entry
)
if
type
.
is_pyobject
:
self
.
has_pyobject_attrs
=
1
if
visibility
not
in
(
'private'
,
'public'
,
'readonly'
):
error
(
pos
,
"Attribute of extension type cannot be declared %s"
%
visibility
)
if
visibility
in
(
'public'
,
'readonly'
):
if
type
.
pymemberdef_typecode
:
self
.
public_attr_entries
.
append
(
entry
)
if
name
==
"__weakref__"
:
error
(
pos
,
"Special attribute __weakref__ cannot be exposed to Python"
)
else
:
error
(
pos
,
"C attribute of type '%s' cannot be accessed from Python"
%
type
)
if
visibility
==
'public'
and
type
.
is_extension_type
:
error
(
pos
,
"Non-generic Python attribute cannot be exposed for writing from Python"
)
return
entry
else
:
# Add an entry for a class attribute.
entry
=
Scope
.
declare_var
(
self
,
name
,
type
,
pos
,
cname
,
visibility
,
is_cdef
)
entry
.
is_pyglobal
=
1
entry
.
namespace_cname
=
"(PyObject *)%s"
%
self
.
parent_type
.
typeptr_cname
if
Options
.
intern_names
:
entry
.
interned_cname
=
self
.
intern
(
name
)
return
entry
def
declare_pyfunction
(
self
,
name
,
pos
):
def
declare_pyfunction
(
self
,
name
,
pos
):
# Add an entry for a method.
# Add an entry for a method.
if
name
in
(
'__eq__'
,
'__ne__'
,
'__lt__'
,
'__gt__'
,
'__le__'
,
'__ge__'
):
if
name
in
(
'__eq__'
,
'__ne__'
,
'__lt__'
,
'__gt__'
,
'__le__'
,
'__ge__'
):
error
(
pos
,
"Special method %s must be implemented via __richcmp__"
error
(
pos
,
"Special method %s must be implemented via __richcmp__"
%
name
)
%
name
)
entry
=
self
.
declare
_var
(
name
,
py_object_type
,
pos
)
entry
=
self
.
declare
(
name
,
name
,
py_object_type
,
pos
)
special_sig
=
get_special_method_signature
(
name
)
special_sig
=
get_special_method_signature
(
name
)
if
special_sig
:
if
special_sig
:
# Special methods get put in the method table with a particular
# Special methods get put in the method table with a particular
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment