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
8f14ad8c
Commit
8f14ad8c
authored
Dec 08, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix const-correctness of cypclass active methods
parent
fb0630cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+6
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+8
-10
No files found.
Cython/Compiler/ModuleNode.py
View file @
8f14ad8c
...
@@ -1124,14 +1124,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1124,14 +1124,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
reifying_class_name
=
"%s%s"
%
(
Naming
.
cypclass_reified_prefix
,
reified_function_entry
.
name
)
reifying_class_name
=
"%s%s"
%
(
Naming
.
cypclass_reified_prefix
,
reified_function_entry
.
name
)
reifying_class_full_name
=
"%s::%s"
%
(
entry
.
type
.
empty_declaration_code
(),
reifying_class_name
)
reifying_class_full_name
=
"%s::%s"
%
(
entry
.
type
.
empty_declaration_code
(),
reifying_class_name
)
class_name
=
reifying_class_full_name
.
split
(
'::'
)[
-
1
]
class_name
=
reifying_class_full_name
.
split
(
'::'
)[
-
1
]
if
reified_function_entry
.
type
.
is_const_method
:
qualified_target_object_code
=
"const %s"
%
target_object_code
else
:
qualified_target_object_code
=
target_object_code
if
entry
.
type
.
templates
:
if
entry
.
type
.
templates
:
templates_code
=
"template <typename %s>"
%
", typename "
.
join
(
t
.
name
for
t
in
entry
.
type
.
templates
)
templates_code
=
"template <typename %s>"
%
", typename "
.
join
(
t
.
name
for
t
in
entry
.
type
.
templates
)
code
.
putln
(
templates_code
)
code
.
putln
(
templates_code
)
code
.
putln
(
"struct %s : public %s {"
%
(
reifying_class_full_name
,
message_base_type
.
empty_declaration_code
()))
code
.
putln
(
"struct %s : public %s {"
%
(
reifying_class_full_name
,
message_base_type
.
empty_declaration_code
()))
# Declaring target object & reified method arguments
# Declaring target object & reified method arguments
code
.
putln
(
"%s;"
%
target_object_code
)
code
.
putln
(
"%s;"
%
qualified_
target_object_code
)
constructor_args_decl_list
=
[
constructor_args_decl_list
=
[
target_object_code
,
qualified_
target_object_code
,
sync_type
.
declaration_code
(
sync_arg_name
),
sync_type
.
declaration_code
(
sync_arg_name
),
result_type
.
declaration_code
(
result_arg_name
)
result_type
.
declaration_code
(
result_arg_name
)
]
]
...
...
Cython/Compiler/Symtab.py
View file @
8f14ad8c
...
@@ -2821,25 +2821,22 @@ class CppClassScope(Scope):
...
@@ -2821,25 +2821,22 @@ class CppClassScope(Scope):
if
entry
.
type
.
has_varargs
:
if
entry
.
type
.
has_varargs
:
error
(
entry
.
pos
,
"Could not reify method with ellipsis (you can use optional arguments)"
)
error
(
entry
.
pos
,
"Could not reify method with ellipsis (you can use optional arguments)"
)
self
.
reified_entries
.
append
(
entry
)
self
.
reified_entries
.
append
(
entry
)
# create
corresponding active
entry
# create
the corresponding active type and
entry
from
.
import
Builtin
from
.
import
Builtin
result_type
=
Builtin
.
acthon_result_type
result_type
=
Builtin
.
acthon_result_type
sync_type
=
Builtin
.
acthon_sync_type
sync_type
=
Builtin
.
acthon_sync_type
# create the sync argument type
activated_method_sync_attr_type
=
PyrexTypes
.
CFuncTypeArg
(
activated_method_sync_attr_type
=
PyrexTypes
.
CFuncTypeArg
(
EncodedString
(
"sync_method"
),
EncodedString
(
"sync_method"
),
PyrexTypes
.
CConstOrVolatileType
(
sync_type
,
is_const
=
1
),
PyrexTypes
.
CConstOrVolatileType
(
sync_type
,
is_const
=
1
),
entry
.
pos
,
entry
.
pos
,
"sync_method"
,
"sync_method"
,
)
)
activated_method_type
=
PyrexTypes
.
CFuncType
(
# create the active method type
result_type
,
activated_method_type
=
copy
.
copy
(
entry
.
type
)
[
activated_method_sync_attr_type
]
+
entry
.
type
.
args
,
activated_method_type
.
return_type
=
result_type
nogil
=
entry
.
type
.
nogil
,
activated_method_type
.
args
=
[
activated_method_sync_attr_type
]
+
entry
.
type
.
args
has_varargs
=
entry
.
type
.
has_varargs
,
# create the active method entry
optional_arg_count
=
entry
.
type
.
optional_arg_count
,
)
if
hasattr
(
entry
.
type
,
'op_arg_struct'
):
activated_method_type
.
op_arg_struct
=
entry
.
type
.
op_arg_struct
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
)
activated_method_entry
.
func_cname
=
"%s::%s"
%
(
self
.
type
.
empty_declaration_code
(),
activated_method_cname
)
activated_method_entry
.
func_cname
=
"%s::%s"
%
(
self
.
type
.
empty_declaration_code
(),
activated_method_cname
)
...
@@ -2847,6 +2844,7 @@ class CppClassScope(Scope):
...
@@ -2847,6 +2844,7 @@ class CppClassScope(Scope):
activated_method_entry
.
scope
=
self
activated_method_entry
.
scope
=
self
activated_method_entry
.
is_cfunction
=
1
activated_method_entry
.
is_cfunction
=
1
activated_method_entry
.
is_variable
=
1
activated_method_entry
.
is_variable
=
1
# associate the active entry to the passive entry
entry
.
active_entry
=
activated_method_entry
entry
.
active_entry
=
activated_method_entry
...
...
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