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
Boxiang Sun
cython
Commits
48409561
Commit
48409561
authored
Apr 12, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid redundantly recreating templated utility code
parent
374eb179
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+19
-19
No files found.
Cython/Compiler/PyrexTypes.py
View file @
48409561
...
@@ -393,7 +393,7 @@ class CTypedefType(BaseType):
...
@@ -393,7 +393,7 @@ class CTypedefType(BaseType):
base_type
=
self
.
typedef_base_type
base_type
=
self
.
typedef_base_type
if
type
(
base_type
)
is
CIntType
:
if
type
(
base_type
)
is
CIntType
:
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"CIntToPy"
,
"TypeConversion.c"
,
"CIntToPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
...
@@ -415,7 +415,7 @@ class CTypedefType(BaseType):
...
@@ -415,7 +415,7 @@ class CTypedefType(BaseType):
base_type
=
self
.
typedef_base_type
base_type
=
self
.
typedef_base_type
if
type
(
base_type
)
is
CIntType
:
if
type
(
base_type
)
is
CIntType
:
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"CIntFromPy"
,
"TypeConversion.c"
,
"CIntFromPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
...
@@ -450,17 +450,17 @@ class CTypedefType(BaseType):
...
@@ -450,17 +450,17 @@ class CTypedefType(BaseType):
type
=
self
.
empty_declaration_code
()
type
=
self
.
empty_declaration_code
()
name
=
self
.
specialization_name
()
name
=
self
.
specialization_name
()
if
binop
==
"lshift"
:
if
binop
==
"lshift"
:
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"LeftShift"
,
"Overflow.c"
,
"LeftShift"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'SIGNED'
:
self
.
signed
}))
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'SIGNED'
:
self
.
signed
}))
else
:
else
:
if
const_rhs
:
if
const_rhs
:
binop
+=
"_const"
binop
+=
"_const"
_load_overflow_base
(
env
)
_load_overflow_base
(
env
)
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"SizeCheck"
,
"Overflow.c"
,
"SizeCheck"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"Binop"
,
"Overflow.c"
,
"Binop"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
return
"__Pyx_%s_%s_checking_overflow"
%
(
binop
,
name
)
return
"__Pyx_%s_%s_checking_overflow"
%
(
binop
,
name
)
...
@@ -697,10 +697,9 @@ class MemoryViewSliceType(PyrexType):
...
@@ -697,10 +697,9 @@ class MemoryViewSliceType(PyrexType):
# We don't have 'code', so use a LazyUtilityCode with a callback.
# We don't have 'code', so use a LazyUtilityCode with a callback.
def
lazy_utility_callback
(
code
):
def
lazy_utility_callback
(
code
):
context
[
'dtype_typeinfo'
]
=
Buffer
.
get_type_information_cname
(
context
[
'dtype_typeinfo'
]
=
Buffer
.
get_type_information_cname
(
code
,
self
.
dtype
)
code
,
self
.
dtype
)
return
TempitaUtilityCode
.
load
(
return
TempitaUtilityCode
.
load
(
"ObjectToMemviewSlice"
,
"MemoryView_C.c"
,
context
=
context
)
"ObjectToMemviewSlice"
,
"MemoryView_C.c"
,
context
=
context
)
env
.
use_utility_code
(
Buffer
.
acquire_utility_code
)
env
.
use_utility_code
(
Buffer
.
acquire_utility_code
)
env
.
use_utility_code
(
MemoryView
.
memviewslice_init_code
)
env
.
use_utility_code
(
MemoryView
.
memviewslice_init_code
)
...
@@ -777,8 +776,8 @@ class MemoryViewSliceType(PyrexType):
...
@@ -777,8 +776,8 @@ class MemoryViewSliceType(PyrexType):
error_condition
=
error_condition
,
error_condition
=
error_condition
,
)
)
utility
=
TempitaUtilityCode
.
load
(
utility
=
TempitaUtilityCode
.
load
_cached
(
utility_name
,
"MemoryView_C.c"
,
context
=
context
)
utility_name
,
"MemoryView_C.c"
,
context
=
context
)
env
.
use_utility_code
(
utility
)
env
.
use_utility_code
(
utility
)
return
get_function
,
set_function
return
get_function
,
set_function
...
@@ -1490,7 +1489,7 @@ class CIntType(CNumericType):
...
@@ -1490,7 +1489,7 @@ class CIntType(CNumericType):
def
create_to_py_utility_code
(
self
,
env
):
def
create_to_py_utility_code
(
self
,
env
):
if
type
(
self
).
to_py_function
is
None
:
if
type
(
self
).
to_py_function
is
None
:
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
self
.
to_py_function
=
"__Pyx_PyInt_From_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"CIntToPy"
,
"TypeConversion.c"
,
"CIntToPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
"TO_PY_FUNCTION"
:
self
.
to_py_function
}))
...
@@ -1499,7 +1498,7 @@ class CIntType(CNumericType):
...
@@ -1499,7 +1498,7 @@ class CIntType(CNumericType):
def
create_from_py_utility_code
(
self
,
env
):
def
create_from_py_utility_code
(
self
,
env
):
if
type
(
self
).
from_py_function
is
None
:
if
type
(
self
).
from_py_function
is
None
:
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
self
.
from_py_function
=
"__Pyx_PyInt_As_"
+
self
.
specialization_name
()
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"CIntFromPy"
,
"TypeConversion.c"
,
"CIntFromPy"
,
"TypeConversion.c"
,
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
context
=
{
"TYPE"
:
self
.
empty_declaration_code
(),
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
"FROM_PY_FUNCTION"
:
self
.
from_py_function
}))
...
@@ -1539,18 +1538,18 @@ class CIntType(CNumericType):
...
@@ -1539,18 +1538,18 @@ class CIntType(CNumericType):
type
=
self
.
empty_declaration_code
()
type
=
self
.
empty_declaration_code
()
name
=
self
.
specialization_name
()
name
=
self
.
specialization_name
()
if
binop
==
"lshift"
:
if
binop
==
"lshift"
:
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"LeftShift"
,
"Overflow.c"
,
"LeftShift"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'SIGNED'
:
self
.
signed
}))
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'SIGNED'
:
self
.
signed
}))
else
:
else
:
if
const_rhs
:
if
const_rhs
:
binop
+=
"_const"
binop
+=
"_const"
if
type
in
(
'int'
,
'long'
,
'long long'
):
if
type
in
(
'int'
,
'long'
,
'long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"BaseCaseSigned"
,
"Overflow.c"
,
"BaseCaseSigned"
,
"Overflow.c"
,
context
=
{
'INT'
:
type
,
'NAME'
:
name
}))
context
=
{
'INT'
:
type
,
'NAME'
:
name
}))
elif
type
in
(
'unsigned int'
,
'unsigned long'
,
'unsigned long long'
):
elif
type
in
(
'unsigned int'
,
'unsigned long'
,
'unsigned long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"BaseCaseUnsigned"
,
"Overflow.c"
,
"BaseCaseUnsigned"
,
"Overflow.c"
,
context
=
{
'UINT'
:
type
,
'NAME'
:
name
}))
context
=
{
'UINT'
:
type
,
'NAME'
:
name
}))
elif
self
.
rank
<=
1
:
elif
self
.
rank
<=
1
:
...
@@ -1558,22 +1557,23 @@ class CIntType(CNumericType):
...
@@ -1558,22 +1557,23 @@ class CIntType(CNumericType):
return
"__Pyx_%s_%s_no_overflow"
%
(
binop
,
name
)
return
"__Pyx_%s_%s_no_overflow"
%
(
binop
,
name
)
else
:
else
:
_load_overflow_base
(
env
)
_load_overflow_base
(
env
)
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"SizeCheck"
,
"Overflow.c"
,
"SizeCheck"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"Binop"
,
"Overflow.c"
,
"Binop"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
return
"__Pyx_%s_%s_checking_overflow"
%
(
binop
,
name
)
return
"__Pyx_%s_%s_checking_overflow"
%
(
binop
,
name
)
def
_load_overflow_base
(
env
):
def
_load_overflow_base
(
env
):
env
.
use_utility_code
(
UtilityCode
.
load
(
"Common"
,
"Overflow.c"
))
env
.
use_utility_code
(
UtilityCode
.
load
(
"Common"
,
"Overflow.c"
))
for
type
in
(
'int'
,
'long'
,
'long long'
):
for
type
in
(
'int'
,
'long'
,
'long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"BaseCaseSigned"
,
"Overflow.c"
,
"BaseCaseSigned"
,
"Overflow.c"
,
context
=
{
'INT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
context
=
{
'INT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
for
type
in
(
'unsigned int'
,
'unsigned long'
,
'unsigned long long'
):
for
type
in
(
'unsigned int'
,
'unsigned long'
,
'unsigned long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
env
.
use_utility_code
(
TempitaUtilityCode
.
load
_cached
(
"BaseCaseUnsigned"
,
"Overflow.c"
,
"BaseCaseUnsigned"
,
"Overflow.c"
,
context
=
{
'UINT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
context
=
{
'UINT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
...
...
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