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
066c5b04
Commit
066c5b04
authored
Dec 07, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor duplicated code
parent
0c6e62fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+14
-11
No files found.
Cython/Compiler/Builtin.py
View file @
066c5b04
...
@@ -83,6 +83,15 @@ class _BuiltinOverride(object):
...
@@ -83,6 +83,15 @@ class _BuiltinOverride(object):
self
.
is_strict_signature
=
is_strict_signature
self
.
is_strict_signature
=
is_strict_signature
self
.
utility_code
=
utility_code
self
.
utility_code
=
utility_code
def
build_func_type
(
self
,
sig
=
None
,
self_arg
=
None
):
if
sig
is
None
:
sig
=
Signature
(
self
.
args
,
self
.
ret_type
)
func_type
=
sig
.
function_type
(
self_arg
)
if
self
.
is_strict_signature
:
func_type
.
is_strict_signature
=
True
return
func_type
class
BuiltinAttribute
(
object
):
class
BuiltinAttribute
(
object
):
def
__init__
(
self
,
py_name
,
cname
=
None
,
field_type
=
None
,
field_type_name
=
None
):
def
__init__
(
self
,
py_name
,
cname
=
None
,
field_type
=
None
,
field_type_name
=
None
):
self
.
py_name
=
py_name
self
.
py_name
=
py_name
...
@@ -99,33 +108,27 @@ class BuiltinAttribute(object):
...
@@ -99,33 +108,27 @@ class BuiltinAttribute(object):
entry
=
self_type
.
scope
.
declare
(
self
.
py_name
,
self
.
cname
,
field_type
,
None
,
'private'
)
entry
=
self_type
.
scope
.
declare
(
self
.
py_name
,
self
.
cname
,
field_type
,
None
,
'private'
)
entry
.
is_variable
=
True
entry
.
is_variable
=
True
class
BuiltinFunction
(
_BuiltinOverride
):
class
BuiltinFunction
(
_BuiltinOverride
):
def
declare_in_scope
(
self
,
scope
):
def
declare_in_scope
(
self
,
scope
):
func_type
,
sig
=
self
.
func_type
,
self
.
sig
func_type
,
sig
=
self
.
func_type
,
self
.
sig
if
func_type
is
None
:
if
func_type
is
None
:
if
sig
is
None
:
func_type
=
self
.
build_func_type
(
sig
)
sig
=
Signature
(
self
.
args
,
self
.
ret_type
)
func_type
=
sig
.
function_type
()
if
self
.
is_strict_signature
:
func_type
.
is_strict_signature
=
True
scope
.
declare_builtin_cfunction
(
self
.
py_name
,
func_type
,
self
.
cname
,
scope
.
declare_builtin_cfunction
(
self
.
py_name
,
func_type
,
self
.
cname
,
self
.
py_equiv
,
self
.
utility_code
)
self
.
py_equiv
,
self
.
utility_code
)
class
BuiltinMethod
(
_BuiltinOverride
):
class
BuiltinMethod
(
_BuiltinOverride
):
def
declare_in_type
(
self
,
self_type
):
def
declare_in_type
(
self
,
self_type
):
method_type
,
sig
=
self
.
func_type
,
self
.
sig
method_type
,
sig
=
self
.
func_type
,
self
.
sig
if
method_type
is
None
:
if
method_type
is
None
:
if
sig
is
None
:
sig
=
Signature
(
self
.
args
,
self
.
ret_type
)
# override 'self' type (first argument)
# override 'self' type (first argument)
self_arg
=
PyrexTypes
.
CFuncTypeArg
(
""
,
self_type
,
None
)
self_arg
=
PyrexTypes
.
CFuncTypeArg
(
""
,
self_type
,
None
)
self_arg
.
not_none
=
True
self_arg
.
not_none
=
True
self_arg
.
accept_builtin_subtypes
=
True
self_arg
.
accept_builtin_subtypes
=
True
method_type
=
sig
.
function_type
(
self_arg
)
method_type
=
self
.
build_func_type
(
sig
,
self_arg
)
if
self
.
is_strict_signature
:
method_type
.
is_strict_signature
=
True
self_type
.
scope
.
declare_builtin_cfunction
(
self_type
.
scope
.
declare_builtin_cfunction
(
self
.
py_name
,
method_type
,
self
.
cname
,
utility_code
=
self
.
utility_code
)
self
.
py_name
,
method_type
,
self
.
cname
,
utility_code
=
self
.
utility_code
)
builtin_function_table
=
[
builtin_function_table
=
[
...
...
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