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
ace24117
Commit
ace24117
authored
Jun 14, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make reifying narg&optarg helper use lambdas
parent
c7415220
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-5
No files found.
Cython/Compiler/ModuleNode.py
View file @
ace24117
...
@@ -1163,12 +1163,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1163,12 +1163,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
target_object_code
=
target_object_type
.
declaration_code
(
target_object_cname
)
target_object_code
=
target_object_type
.
declaration_code
(
target_object_cname
)
target_object_argument_code
=
target_object_type
.
declaration_code
(
target_object_name
)
target_object_argument_code
=
target_object_type
.
declaration_code
(
target_object_name
)
def
put_
refcount_op_on_narg_optarg
(
op
,
func_type
,
opt_arg_name
,
code
):
def
put_
cypclass_op_on_narg_optarg
(
op_lbda
,
func_type
,
opt_arg_name
,
code
):
opt_arg_count
=
func_type
.
optional_arg_count
opt_arg_count
=
func_type
.
optional_arg_count
narg_count
=
len
(
func_type
.
args
)
-
opt_arg_count
narg_count
=
len
(
func_type
.
args
)
-
opt_arg_count
for
narg
in
func_type
.
args
[:
narg_count
]:
for
narg
in
func_type
.
args
[:
narg_count
]:
if
narg
.
type
.
is_cyp_class
:
if
narg
.
type
.
is_cyp_class
:
code
.
putln
(
"%s(this->%s);"
%
(
op
,
narg
.
cname
))
code
.
putln
(
"%s(this->%s);"
%
(
op
_lbda
(
narg
)
,
narg
.
cname
))
code
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
code
.
putln
(
"if (this->%s != NULL) {"
%
opt_arg_name
)
num_if
=
0
num_if
=
0
...
@@ -1180,7 +1180,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1180,7 +1180,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
opt_idx
opt_idx
))
))
code
.
putln
(
"%s(this->%s->%s);"
%
code
.
putln
(
"%s(this->%s->%s);"
%
(
op
,
(
op
_lbda
(
optarg
)
,
opt_arg_name
,
opt_arg_name
,
func_type
.
opt_arg_cname
(
optarg
.
name
)
func_type
.
opt_arg_cname
(
optarg
.
name
)
))
))
...
@@ -1245,7 +1245,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1245,7 +1245,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"this->%s = NULL;"
%
message_opt_arg_attr_name
)
code
.
putln
(
"this->%s = NULL;"
%
message_opt_arg_attr_name
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
# Acquire a ref on CyObject, as we don't know when the message will be processed
# Acquire a ref on CyObject, as we don't know when the message will be processed
put_
refcount_op_on_narg_optarg
(
"Cy_INCREF"
,
reified_function_entry
.
type
,
message_opt_arg_attr_name
,
code
)
put_
cypclass_op_on_narg_optarg
(
lambda
_
:
"Cy_INCREF"
,
reified_function_entry
.
type
,
message_opt_arg_attr_name
,
code
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
code
.
putln
(
"int activate() {"
)
code
.
putln
(
"int activate() {"
)
code
.
putln
(
"/* Activate only if its sync object agrees to do so */"
)
code
.
putln
(
"/* Activate only if its sync object agrees to do so */"
)
...
@@ -1278,7 +1278,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1278,7 +1278,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# Destructor
# Destructor
code
.
putln
(
"virtual ~%s() {"
%
class_name
)
code
.
putln
(
"virtual ~%s() {"
%
class_name
)
put_
refcount_op_on_narg_optarg
(
"Cy_DECREF"
,
reified_function_entry
.
type
,
message_opt_arg_attr_name
,
code
)
put_
cypclass_op_on_narg_optarg
(
lambda
_
:
"Cy_DECREF"
,
reified_function_entry
.
type
,
message_opt_arg_attr_name
,
code
)
if
opt_arg_count
:
if
opt_arg_count
:
code
.
putln
(
"free(this->%s);"
%
message_opt_arg_attr_name
)
code
.
putln
(
"free(this->%s);"
%
message_opt_arg_attr_name
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
...
...
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