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
Gwenaël Samain
cython
Commits
b05b8fd8
Commit
b05b8fd8
authored
Jun 12, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce 'activable' keyword
parent
4112265c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
25 deletions
+37
-25
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-2
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+9
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+2
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+18
-17
No files found.
Cython/Compiler/ModuleNode.py
View file @
b05b8fd8
...
...
@@ -820,10 +820,11 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def
generate_cyp_class_deferred_definitions
(
self
,
type_entries
,
code
):
for
entry
in
type_entries
:
if
entry
.
type
.
is_cyp_class
:
# Generate acthon-specific classes
self
.
generate_cyp_class_reifying_entries
(
entry
,
code
)
self
.
generate_cyp_class_activated_class
(
entry
,
code
)
self
.
generate_cyp_class_activate_function
(
entry
,
code
)
if
entry
.
type
.
activable
:
# Generate acthon-specific classes
self
.
generate_cyp_class_reifying_entries
(
entry
,
code
)
self
.
generate_cyp_class_activated_class
(
entry
,
code
)
self
.
generate_cyp_class_activate_function
(
entry
,
code
)
# Generate cypclass attr destructor
self
.
generate_cyp_class_attrs_destructor_definition
(
entry
,
code
)
# Generate wrapper constructor
...
...
Cython/Compiler/Nodes.py
View file @
b05b8fd8
...
...
@@ -1522,7 +1522,7 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
error
(
self
.
pos
,
"Required template parameters must precede optional template parameters."
)
self
.
entry
=
env
.
declare_cpp_class
(
self
.
name
,
None
,
self
.
pos
,
self
.
cname
,
base_classes
=
[],
visibility
=
self
.
visibility
,
templates
=
template_types
,
cypclass
=
self
.
cypclass
,
lock_mode
=
self
.
lock_mode
)
base_classes
=
[],
visibility
=
self
.
visibility
,
templates
=
template_types
,
cypclass
=
self
.
cypclass
,
lock_mode
=
self
.
lock_mode
,
activable
=
self
.
activable
)
def
analyse_declarations
(
self
,
env
):
if
self
.
templates
is
None
:
...
...
@@ -1549,7 +1549,8 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
base_class_types
=
filter
(
base_ok
,
base_types_list
)
self
.
entry
=
env
.
declare_cpp_class
(
self
.
name
,
scope
,
self
.
pos
,
self
.
cname
,
base_class_types
,
visibility
=
self
.
visibility
,
templates
=
template_types
,
cypclass
=
self
.
cypclass
,
lock_mode
=
self
.
lock_mode
)
self
.
cname
,
base_class_types
,
visibility
=
self
.
visibility
,
templates
=
template_types
,
cypclass
=
self
.
cypclass
,
lock_mode
=
self
.
lock_mode
,
activable
=
self
.
activable
)
if
self
.
entry
is
None
:
return
self
.
entry
.
is_cpp_class
=
1
...
...
Cython/Compiler/Parsing.py
View file @
b05b8fd8
...
...
@@ -3798,8 +3798,10 @@ def p_cpp_class_definition(s, pos, ctx):
error
(
s
.
position
(),
"Name options not allowed for C++ class"
)
nogil
=
p_nogil
(
s
)
or
cypclass
lock_mode
=
None
activable
=
False
if
cypclass
:
lock_mode
=
p_cypclass_lock_mode
(
s
)
activable
=
p_cypclass_activable
(
s
)
if
s
.
sy
==
':'
:
s
.
next
()
s
.
expect
(
'NEWLINE'
)
...
...
@@ -3825,7 +3827,7 @@ def p_cpp_class_definition(s, pos, ctx):
visibility
=
ctx
.
visibility
,
in_pxd
=
ctx
.
level
==
'module_pxd'
,
attributes
=
attributes
,
templates
=
templates
,
cypclass
=
cypclass
,
lock_mode
=
lock_mode
)
templates
=
templates
,
cypclass
=
cypclass
,
lock_mode
=
lock_mode
,
activable
=
activable
)
def
p_cpp_class_attribute
(
s
,
ctx
):
decorators
=
None
...
...
@@ -3859,6 +3861,12 @@ def p_cypclass_lock_mode(s):
else
:
return
None
def
p_cypclass_activable
(
s
):
if
s
.
sy
==
'IDENT'
and
s
.
systring
==
'activable'
:
s
.
next
()
return
True
else
:
return
False
#----------------------------------------------
#
...
...
Cython/Compiler/PyrexTypes.py
View file @
b05b8fd8
...
...
@@ -3900,9 +3900,10 @@ class CypClassType(CppClassType):
is_cyp_class
=
1
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
,
nogil
=
0
,
lock_mode
=
None
):
def
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
=
None
,
template_type
=
None
,
nogil
=
0
,
lock_mode
=
None
,
activable
=
False
):
CppClassType
.
__init__
(
self
,
name
,
scope
,
cname
,
base_classes
,
templates
,
template_type
,
nogil
)
self
.
lock_mode
=
lock_mode
if
lock_mode
else
"autolock"
self
.
activable
=
activable
def
empty_declaration_code
(
self
):
if
self
.
_empty_declaration
is
None
:
...
...
Cython/Compiler/Symtab.py
View file @
b05b8fd8
...
...
@@ -628,7 +628,7 @@ class Scope(object):
def
declare_cpp_class
(
self
,
name
,
scope
,
pos
,
cname
=
None
,
base_classes
=
(),
visibility
=
'extern'
,
templates
=
None
,
cypclass
=
0
,
lock_mode
=
None
):
visibility
=
'extern'
,
templates
=
None
,
cypclass
=
0
,
lock_mode
=
None
,
activable
=
False
):
if
cname
is
None
:
if
self
.
in_cinclude
or
(
visibility
!=
'private'
):
cname
=
name
...
...
@@ -639,7 +639,7 @@ class Scope(object):
if
not
entry
:
if
cypclass
:
type
=
PyrexTypes
.
CypClassType
(
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
,
lock_mode
=
lock_mode
)
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
,
lock_mode
=
lock_mode
,
activable
=
activable
)
else
:
type
=
PyrexTypes
.
CppClassType
(
name
,
scope
,
cname
,
base_classes
,
templates
=
templates
)
...
...
@@ -707,20 +707,21 @@ class Scope(object):
alloc_entry
.
is_builtin_cmethod
=
1
alloc_entry
.
func_cname
=
"%s::%s"
%
(
entry
.
type
.
empty_declaration_code
(),
alloc_cname
)
# === Acthon ===
# Declare activated class
act_scope
=
CppClassScope
(
"Activated"
,
scope
)
act_type
=
PyrexTypes
.
CypClassType
(
"Activated"
,
act_scope
,
"Activated"
,
None
,
templates
=
templates
,
lock_mode
=
"nolock"
)
act_type
.
set_scope
(
act_scope
)
act_type
.
namespace
=
entry
.
type
#scope.declare_cpp_class("Activated", act_scope, pos)
scope
.
declare
(
"Activated"
,
"Activated"
,
act_type
,
pos
,
visibility
)
# Declaring active_self member and activate function (its definition is generated automatically)
act_attr_name
=
Naming
.
builtin_prefix
+
"_active_self"
scope
.
declare_var
(
"<active_self>"
,
act_type
,
pos
,
cname
=
act_attr_name
)
activate_type
=
PyrexTypes
.
CFuncType
(
act_type
,
[])
scope
.
declare_var
(
"__activate__"
,
activate_type
,
pos
,
cname
=
"__activate__"
,
defining
=
1
)
if
entry
.
type
.
activable
:
# === Acthon ===
# Declare activated class
act_scope
=
CppClassScope
(
"Activated"
,
scope
)
act_type
=
PyrexTypes
.
CypClassType
(
"Activated"
,
act_scope
,
"Activated"
,
None
,
templates
=
templates
,
lock_mode
=
"nolock"
)
act_type
.
set_scope
(
act_scope
)
act_type
.
namespace
=
entry
.
type
#scope.declare_cpp_class("Activated", act_scope, pos)
scope
.
declare
(
"Activated"
,
"Activated"
,
act_type
,
pos
,
visibility
)
# Declaring active_self member and activate function (its definition is generated automatically)
act_attr_name
=
Naming
.
builtin_prefix
+
"_active_self"
scope
.
declare_var
(
"<active_self>"
,
act_type
,
pos
,
cname
=
act_attr_name
)
activate_type
=
PyrexTypes
.
CFuncType
(
act_type
,
[])
scope
.
declare_var
(
"__activate__"
,
activate_type
,
pos
,
cname
=
"__activate__"
,
defining
=
1
)
if
self
.
is_cpp_class_scope
:
entry
.
type
.
namespace
=
self
.
outer_scope
.
lookup
(
self
.
name
).
type
...
...
@@ -2579,7 +2580,7 @@ class CppClassScope(Scope):
def
declare_cfunction
(
self
,
name
,
type
,
pos
,
cname
=
None
,
visibility
=
'extern'
,
api
=
0
,
in_pxd
=
0
,
defining
=
0
,
modifiers
=
(),
utility_code
=
None
,
overridable
=
False
):
reify
=
self
.
type
.
is_cyp_class
reify
=
self
.
type
.
is_cyp_class
and
self
.
type
.
activable
class_name
=
self
.
name
.
split
(
'::'
)[
-
1
]
if
name
in
(
class_name
,
'__init__'
)
and
cname
is
None
:
reify
=
False
...
...
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