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
2b51fc1f
Commit
2b51fc1f
authored
Dec 10, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enforce safety rules for 'active' cypclasses
parent
e9fbd755
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
7 deletions
+10
-7
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+1
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-2
tests/run/cypclass_acthon.pyx
tests/run/cypclass_acthon.pyx
+4
-4
No files found.
Cython/Compiler/Builtin.py
View file @
2b51fc1f
...
@@ -606,7 +606,7 @@ def inject_acthon_interfaces(self):
...
@@ -606,7 +606,7 @@ def inject_acthon_interfaces(self):
activable_scope
.
var_entries
.
append
(
activable_result_attr_entry
)
activable_scope
.
var_entries
.
append
(
activable_result_attr_entry
)
activable_queue_attr_entry
=
activable_scope
.
declare
(
"_active_queue_class"
,
"_active_queue_class"
,
activable_queue_attr_entry
=
activable_scope
.
declare
(
"_active_queue_class"
,
"_active_queue_class"
,
queue_type
,
None
,
"extern"
)
PyrexTypes
.
cyp_class_qualified_type
(
queue_type
,
'locked'
)
,
None
,
"extern"
)
activable_queue_attr_entry
.
is_variable
=
1
activable_queue_attr_entry
.
is_variable
=
1
activable_scope
.
var_entries
.
append
(
activable_queue_attr_entry
)
activable_scope
.
var_entries
.
append
(
activable_queue_attr_entry
)
...
...
Cython/Compiler/Symtab.py
View file @
2b51fc1f
...
@@ -875,7 +875,8 @@ class Scope(object):
...
@@ -875,7 +875,8 @@ class Scope(object):
# === Acthon ===
# === Acthon ===
# Declare 'activate' function for this class
# Declare 'activate' function for this class
activate_func_arg
=
PyrexTypes
.
CFuncTypeArg
(
EncodedString
(
"o"
),
entry
.
type
,
pos
)
activate_func_arg_type
=
PyrexTypes
.
cyp_class_qualified_type
(
entry
.
type
,
'iso'
)
activate_func_arg
=
PyrexTypes
.
CFuncTypeArg
(
EncodedString
(
"o"
),
activate_func_arg_type
,
pos
)
activate_func_return
=
PyrexTypes
.
cyp_class_qualified_type
(
entry
.
type
,
'active'
)
activate_func_return
=
PyrexTypes
.
cyp_class_qualified_type
(
entry
.
type
,
'active'
)
activate_func_type
=
PyrexTypes
.
CFuncType
(
activate_func_return
,
[
activate_func_arg
],
nogil
=
1
)
activate_func_type
=
PyrexTypes
.
CFuncType
(
activate_func_return
,
[
activate_func_arg
],
nogil
=
1
)
builtin_scope
=
scope
.
builtin_scope
()
builtin_scope
=
scope
.
builtin_scope
()
...
@@ -2836,7 +2837,9 @@ class CppClassScope(Scope):
...
@@ -2836,7 +2837,9 @@ class CppClassScope(Scope):
# create the active method type
# create the active method type
activated_method_type
=
copy
.
copy
(
entry
.
type
)
activated_method_type
=
copy
.
copy
(
entry
.
type
)
activated_method_type
.
return_type
=
result_type
activated_method_type
.
return_type
=
result_type
activated_method_type
.
args
=
[
activated_method_sync_attr_type
]
+
entry
.
type
.
args
copied_args
=
(
copy
.
copy
(
arg
)
for
arg
in
entry
.
type
.
args
)
sendable_args
=
[
setattr
(
arg
,
'type'
,
viewpoint_adaptation
(
arg
.
type
))
or
arg
for
arg
in
copied_args
]
activated_method_type
.
args
=
[
activated_method_sync_attr_type
]
+
sendable_args
# create the active method entry
# create the active method entry
activated_method_cname
=
"%s%s"
%
(
Naming
.
cypclass_active_func_prefix
,
entry
.
cname
)
activated_method_cname
=
"%s%s"
%
(
Naming
.
cypclass_active_func_prefix
,
entry
.
cname
)
activated_method_entry
=
Entry
(
entry
.
name
,
activated_method_cname
,
activated_method_type
,
entry
.
pos
)
activated_method_entry
=
Entry
(
entry
.
name
,
activated_method_cname
,
activated_method_type
,
entry
.
pos
)
...
...
tests/run/cypclass_acthon.pyx
View file @
2b51fc1f
...
@@ -134,7 +134,7 @@ cdef cypclass A activable:
...
@@ -134,7 +134,7 @@ cdef cypclass A activable:
__init__
(
self
):
__init__
(
self
):
self
.
a
=
0
self
.
a
=
0
self
.
_active_result_class
=
WaitResult
.
construct
self
.
_active_result_class
=
WaitResult
.
construct
self
.
_active_queue_class
=
BasicQueue
()
self
.
_active_queue_class
=
consume
BasicQueue
()
int
getter
(
const
self
):
int
getter
(
const
self
):
return
self
.
a
return
self
.
a
void
setter
(
self
,
int
a
):
void
setter
(
self
,
int
a
):
...
@@ -146,19 +146,19 @@ def test_acthon_chain(n):
...
@@ -146,19 +146,19 @@ def test_acthon_chain(n):
42
42
"""
"""
cdef
ActhonResultInterface
res
cdef
ActhonResultInterface
res
cdef
ActhonQueueInterface
queue
cdef
locked
ActhonQueueInterface
queue
sync1
=
ActivityCounterSync
()
sync1
=
ActivityCounterSync
()
after_sync1
=
ActivityCounterSync
(
sync1
)
after_sync1
=
ActivityCounterSync
(
sync1
)
obj
=
A
()
obj
=
A
()
obj_actor
=
activate
(
obj
)
queue
=
obj
.
_active_queue_class
obj_actor
=
activate
(
consume
obj
)
# Pushing things in the queue
# Pushing things in the queue
obj_actor
.
setter
(
sync1
,
n
)
obj_actor
.
setter
(
sync1
,
n
)
res
=
obj_actor
.
getter
(
after_sync1
)
res
=
obj_actor
.
getter
(
after_sync1
)
# Processing the queue
# Processing the queue
queue
=
obj
.
_active_queue_class
while
not
queue
.
is_empty
():
while
not
queue
.
is_empty
():
queue
.
activate
()
queue
.
activate
()
print
<
int
>
res
print
<
int
>
res
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