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
ec1b697c
Commit
ec1b697c
authored
Jul 18, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support CythonUtilityCode dependencies in CythonUtilityCode
parent
ab8b5f9d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
1 deletion
+40
-1
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+2
-0
Cython/Compiler/CythonScope.py
Cython/Compiler/CythonScope.py
+14
-1
Cython/Compiler/UtilityCode.py
Cython/Compiler/UtilityCode.py
+6
-0
tests/run/cythonscope.pyx
tests/run/cythonscope.pyx
+18
-0
No files found.
Cython/Compiler/Code.py
View file @
ec1b697c
...
@@ -45,6 +45,8 @@ class UtilityCode(object):
...
@@ -45,6 +45,8 @@ class UtilityCode(object):
#
#
# hashes/equals by instance
# hashes/equals by instance
is_cython_utility
=
False
def
__init__
(
self
,
proto
=
None
,
impl
=
None
,
init
=
None
,
cleanup
=
None
,
requires
=
None
,
def
__init__
(
self
,
proto
=
None
,
impl
=
None
,
init
=
None
,
cleanup
=
None
,
requires
=
None
,
proto_block
=
'utility_code_proto'
):
proto_block
=
'utility_code_proto'
):
# proto_block: Which code block to dump prototype in. See GlobalState.
# proto_block: Which code block to dump prototype in. See GlobalState.
...
...
Cython/Compiler/CythonScope.py
View file @
ec1b697c
...
@@ -111,11 +111,20 @@ undecorated_methods_protos = UtilityCode(proto=u"""
...
@@ -111,11 +111,20 @@ undecorated_methods_protos = UtilityCode(proto=u"""
PyObject *self, PyObject *value);
PyObject *self, PyObject *value);
"""
)
"""
)
test_cython_utility_dep
=
CythonUtilityCode
(
u"""
@cname('__pyx_test_dep')
cdef test_dep(obj):
print 'test_dep', obj
"""
)
cython_test_extclass_utility_code
=
CythonUtilityCode
(
cython_test_extclass_utility_code
=
CythonUtilityCode
(
name
=
"TestClassUtilityCode"
,
name
=
"TestClassUtilityCode"
,
prefix
=
"__pyx_prefix_TestClass_"
,
prefix
=
"__pyx_prefix_TestClass_"
,
requires
=
[
undecorated_methods_protos
],
requires
=
[
undecorated_methods_protos
,
test_cython_utility_dep
],
impl
=
u"""
impl
=
u"""
cdef extern from *:
cdef object __pyx_test_dep(object)
@cname('__pyx_TestClass')
@cname('__pyx_TestClass')
cdef class TestClass(object):
cdef class TestClass(object):
cdef public int value
cdef public int value
...
@@ -147,6 +156,10 @@ cdef class TestClass(object):
...
@@ -147,6 +156,10 @@ cdef class TestClass(object):
def def_cname_method(self, int value):
def def_cname_method(self, int value):
print "Hello from def_cname_method", value
print "Hello from def_cname_method", value
@cname('__pyx_test_call_other_cy_util')
cdef test_call(obj):
print 'test_call'
__pyx_test_dep(obj)
@cname('__pyx_TestClass_New')
@cname('__pyx_TestClass_New')
cdef _testclass_new(int value):
cdef _testclass_new(int value):
...
...
Cython/Compiler/UtilityCode.py
View file @
ec1b697c
...
@@ -55,6 +55,8 @@ class CythonUtilityCode(object):
...
@@ -55,6 +55,8 @@ class CythonUtilityCode(object):
tests/run/cythonscope.pyx for examples.
tests/run/cythonscope.pyx for examples.
"""
"""
is_cython_utility
=
True
def
__init__
(
self
,
impl
,
name
=
"CythonUtilityCode"
,
prefix
=
""
,
requires
=
None
):
def
__init__
(
self
,
impl
,
name
=
"CythonUtilityCode"
,
prefix
=
""
,
requires
=
None
):
# 1) We need to delay the parsing/processing, so that all modules can be
# 1) We need to delay the parsing/processing, so that all modules can be
# imported without import loops
# imported without import loops
...
@@ -114,3 +116,7 @@ class CythonUtilityCode(object):
...
@@ -114,3 +116,7 @@ class CythonUtilityCode(object):
dest_scope
.
merge_in
(
self
.
tree
.
scope
,
merge_unused
=
True
)
dest_scope
.
merge_in
(
self
.
tree
.
scope
,
merge_unused
=
True
)
self
.
tree
.
scope
=
dest_scope
self
.
tree
.
scope
=
dest_scope
for
dep
in
self
.
requires
:
if
dep
.
is_cython_utility
:
dep
.
declare_in_scope
(
dest_scope
)
tests/run/cythonscope.pyx
View file @
ec1b697c
...
@@ -2,6 +2,7 @@ cimport cython
...
@@ -2,6 +2,7 @@ cimport cython
from
cython
cimport
_testscope
as
tester
from
cython
cimport
_testscope
as
tester
from
cython
cimport
TestClass
,
_testclass_new
as
TestClass_New
from
cython
cimport
TestClass
,
_testclass_new
as
TestClass_New
from
cython
cimport
test_call
,
test_dep
from
cython.view
cimport
_testscope
as
viewtester
from
cython.view
cimport
_testscope
as
viewtester
cdef
extern
from
*
:
cdef
extern
from
*
:
...
@@ -24,6 +25,9 @@ cdef extern from *:
...
@@ -24,6 +25,9 @@ cdef extern from *:
cdef
__pyx_TestClass_cpdef_cname
(
TestClass
self
,
int
value
,
int
skip_dispatch
)
cdef
__pyx_TestClass_cpdef_cname
(
TestClass
self
,
int
value
,
int
skip_dispatch
)
cdef
__pyx_TestClass_def_cname
(
object
self
,
object
value
)
cdef
__pyx_TestClass_def_cname
(
object
self
,
object
value
)
cdef
__pyx_test_dep
(
object
)
cdef
__pyx_test_call_other_cy_util
(
object
)
def
test_cdef_cython_utility
():
def
test_cdef_cython_utility
():
"""
"""
...
@@ -127,3 +131,17 @@ def test_extclass_cython_methods():
...
@@ -127,3 +131,17 @@ def test_extclass_cython_methods():
obj2
.
cpdef
_cname_method
(
5
)
obj2
.
cpdef
_cname_method
(
5
)
obj2
.
def_cname_method
(
6
)
obj2
.
def_cname_method
(
6
)
def
test_cython_utility_dep
():
"""
>>> test_cython_utility_dep()
test_dep first
test_call
test_dep second
test_dep third
test_call
test_dep fourth
"""
test_dep
(
'first'
)
test_call
(
'second'
)
__pyx_test_dep
(
'third'
)
__pyx_test_call_other_cy_util
(
'fourth'
)
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