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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
55ae33d7
Commit
55ae33d7
authored
Oct 30, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support 'internal' cdef classes that do not show up in the module dict
parent
46e443be
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
8 deletions
+45
-8
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+10
-6
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+4
-0
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+1
-1
tests/run/internal_cdef_class.pyx
tests/run/internal_cdef_class.pyx
+29
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
55ae33d7
...
@@ -2075,6 +2075,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -2075,6 +2075,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
type
.
vtabptr_cname
,
type
.
vtabptr_cname
,
code
.
error_goto
(
entry
.
pos
)))
code
.
error_goto
(
entry
.
pos
)))
env
.
use_utility_code
(
Nodes
.
set_vtable_utility_code
)
env
.
use_utility_code
(
Nodes
.
set_vtable_utility_code
)
if
not
type
.
scope
.
is_internal
and
not
type
.
scope
.
directives
[
'internal'
]:
# scope.is_internal is set for types defined by
# Cython (such as closures), the 'internal'
# directive is set by users
code
.
putln
(
code
.
putln
(
'if (__Pyx_SetAttrString(%s, "%s", (PyObject *)&%s) < 0) %s'
%
(
'if (__Pyx_SetAttrString(%s, "%s", (PyObject *)&%s) < 0) %s'
%
(
Naming
.
module_cname
,
Naming
.
module_cname
,
...
...
Cython/Compiler/Nodes.py
View file @
55ae33d7
...
@@ -3107,7 +3107,7 @@ class CClassDefNode(ClassDefNode):
...
@@ -3107,7 +3107,7 @@ class CClassDefNode(ClassDefNode):
error
(
self
.
pos
,
"Base class '%s' of type '%s' is incomplete"
%
(
error
(
self
.
pos
,
"Base class '%s' of type '%s' is incomplete"
%
(
self
.
base_class_name
,
self
.
class_name
))
self
.
base_class_name
,
self
.
class_name
))
elif
base_class_entry
.
type
.
scope
and
base_class_entry
.
type
.
scope
.
directives
and
\
elif
base_class_entry
.
type
.
scope
and
base_class_entry
.
type
.
scope
.
directives
and
\
base_class_entry
.
type
.
scope
.
directives
.
get
(
'final'
,
False
)
:
base_class_entry
.
type
.
scope
.
directives
[
'final'
]
:
error
(
self
.
pos
,
"Base class '%s' of type '%s' is final"
%
(
error
(
self
.
pos
,
"Base class '%s' of type '%s' is final"
%
(
self
.
base_class_name
,
self
.
class_name
))
self
.
base_class_name
,
self
.
class_name
))
else
:
else
:
...
...
Cython/Compiler/Options.py
View file @
55ae33d7
...
@@ -62,6 +62,8 @@ directive_defaults = {
...
@@ -62,6 +62,8 @@ directive_defaults = {
'wraparound'
:
True
,
'wraparound'
:
True
,
'ccomplex'
:
False
,
# use C99/C++ for complex types and arith
'ccomplex'
:
False
,
# use C99/C++ for complex types and arith
'callspec'
:
""
,
'callspec'
:
""
,
'final'
:
False
,
'internal'
:
False
,
'profile'
:
False
,
'profile'
:
False
,
'infer_types'
:
None
,
'infer_types'
:
None
,
'infer_types.verbose'
:
False
,
'infer_types.verbose'
:
False
,
...
@@ -82,6 +84,7 @@ directive_defaults = {
...
@@ -82,6 +84,7 @@ directive_defaults = {
# Override types possibilities above, if needed
# Override types possibilities above, if needed
directive_types
=
{
directive_types
=
{
'final'
:
bool
,
# final cdef classes and methods
'final'
:
bool
,
# final cdef classes and methods
'internal'
:
bool
,
# cdef class visibility in the module dict
'infer_types'
:
bool
,
# values can be True/None/False
'infer_types'
:
bool
,
# values can be True/None/False
}
}
...
@@ -92,6 +95,7 @@ for key, val in directive_defaults.items():
...
@@ -92,6 +95,7 @@ for key, val in directive_defaults.items():
directive_scopes
=
{
# defaults to available everywhere
directive_scopes
=
{
# defaults to available everywhere
# 'module', 'function', 'class', 'with statement'
# 'module', 'function', 'class', 'with statement'
'final'
:
(
'cclass'
,),
# add 'method' in the future
'final'
:
(
'cclass'
,),
# add 'method' in the future
'internal'
:
(
'cclass'
,),
'autotestdict'
:
(
'module'
,),
'autotestdict'
:
(
'module'
,),
'test_assert_path_exists'
:
(
'function'
,),
'test_assert_path_exists'
:
(
'function'
,),
'test_fail_if_path_exists'
:
(
'function'
,),
'test_fail_if_path_exists'
:
(
'function'
,),
...
...
Cython/Compiler/TypeSlots.py
View file @
55ae33d7
...
@@ -324,7 +324,7 @@ class TypeFlagsSlot(SlotDescriptor):
...
@@ -324,7 +324,7 @@ class TypeFlagsSlot(SlotDescriptor):
def
slot_code
(
self
,
scope
):
def
slot_code
(
self
,
scope
):
value
=
"Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER"
value
=
"Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER"
if
not
scope
.
directives
.
get
(
'final'
,
False
)
:
if
not
scope
.
directives
[
'final'
]
:
value
+=
"|Py_TPFLAGS_BASETYPE"
value
+=
"|Py_TPFLAGS_BASETYPE"
if
scope
.
needs_gc
():
if
scope
.
needs_gc
():
value
+=
"|Py_TPFLAGS_HAVE_GC"
value
+=
"|Py_TPFLAGS_HAVE_GC"
...
...
tests/run/internal_cdef_class.pyx
0 → 100644
View file @
55ae33d7
cimport
cython
@
cython
.
internal
cdef
class
InternalType
:
"""
NOTE: this doesn't fail because it is never tested !
>>> i = InternalType
"""
cdef
class
PublicType
:
"""
>>> p = PublicType
"""
def
test
():
"""
>>> p,i = test()
>>> p = PublicType
>>> i = InternalType
Traceback (most recent call last):
NameError: name 'InternalType' is not defined
"""
p
=
PublicType
i
=
InternalType
return
p
,
i
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