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
ee1dc804
Commit
ee1dc804
authored
Aug 12, 2013
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup type sharing.
parent
2fa32b3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
10 deletions
+32
-10
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+3
-0
Cython/Utility/CommonTypes.c
Cython/Utility/CommonTypes.c
+29
-10
No files found.
Cython/Compiler/ModuleNode.py
View file @
ee1dc804
...
@@ -532,6 +532,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -532,6 +532,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
" #error Cython requires Python 2.4+."
)
code
.
putln
(
" #error Cython requires Python 2.4+."
)
code
.
putln
(
"#else"
)
code
.
putln
(
"#else"
)
code
.
globalstate
[
"end"
].
putln
(
"#endif /* Py_PYTHON_H */"
)
code
.
globalstate
[
"end"
].
putln
(
"#endif /* Py_PYTHON_H */"
)
from
Cython
import
__version__
code
.
putln
(
'#define CYTHON_ABI "%s"'
%
__version__
.
replace
(
'.'
,
'_'
))
code
.
put
(
UtilityCode
.
load_as_string
(
"CModulePreamble"
,
"ModuleSetupCode.c"
)[
1
])
code
.
put
(
UtilityCode
.
load_as_string
(
"CModulePreamble"
,
"ModuleSetupCode.c"
)[
1
])
...
...
Cython/Utility/CommonTypes.c
View file @
ee1dc804
...
@@ -6,24 +6,43 @@ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
...
@@ -6,24 +6,43 @@ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
static
PyTypeObject
*
__Pyx_FetchCommonType
(
PyTypeObject
*
type
)
{
static
PyTypeObject
*
__Pyx_FetchCommonType
(
PyTypeObject
*
type
)
{
static
PyObject
*
fake_module
=
NULL
;
static
PyObject
*
fake_module
=
NULL
;
PyTypeObject
*
cached_type
;
PyObject
*
sys
=
NULL
;
PyObject
*
sys_modules
=
NULL
;
PyObject
*
args
=
NULL
;
PyTypeObject
*
cached_type
=
NULL
;
char
*
cython_module
=
"_cython_"
CYTHON_ABI
;
if
(
fake_module
==
NULL
)
{
if
(
fake_module
==
NULL
)
{
PyObject
*
sys
=
PyImport_ImportModule
(
"sys"
);
sys
=
PyImport_ImportModule
(
"sys"
);
if
(
sys
==
NULL
)
goto
bad
;
PyObject
*
sys_modules
=
PyObject_GetAttrString
(
sys
,
"modules"
);
sys_modules
=
PyObject_GetAttrString
(
sys
,
"modules"
);
if
(
sys_modules
==
NULL
)
goto
bad
;
fake_module
=
PyDict_GetItemString
(
sys_modules
,
"_cython"
);
fake_module
=
PyDict_GetItemString
(
sys_modules
,
cython_module
);
if
(
fake_module
==
NULL
)
{
if
(
fake_module
!=
NULL
)
{
PyObject
*
args
=
PyTuple_New
(
1
);
// borrowed
PyTuple_SET_ITEM
(
args
,
0
,
__Pyx_PyStr_FromString
(
"_cython"
));
Py_INCREF
(
fake_module
);
}
else
{
args
=
PyTuple_New
(
1
);
if
(
args
==
NULL
)
goto
bad
;
PyTuple_SET_ITEM
(
args
,
0
,
__Pyx_PyStr_FromString
(
cython_module
));
if
(
PyTuple_GET_ITEM
(
args
,
0
)
==
NULL
)
goto
bad
;
fake_module
=
PyObject_Call
((
PyObject
*
)
&
PyModule_Type
,
args
,
NULL
);
fake_module
=
PyObject_Call
((
PyObject
*
)
&
PyModule_Type
,
args
,
NULL
);
PyDict_SetItemString
(
sys_modules
,
"_cython"
,
fake_module
);
if
(
PyDict_SetItemString
(
sys_modules
,
cython_module
,
fake_module
)
<
0
)
goto
bad
;
}
}
}
}
if
(
PyObject_HasAttrString
(
fake_module
,
type
->
tp_name
))
{
if
(
PyObject_HasAttrString
(
fake_module
,
type
->
tp_name
))
{
cached_type
=
(
PyTypeObject
*
)
PyObject_GetAttrString
(
fake_module
,
type
->
tp_name
);
cached_type
=
(
PyTypeObject
*
)
PyObject_GetAttrString
(
fake_module
,
type
->
tp_name
);
}
else
{
}
else
{
PyType_Ready
(
type
);
if
(
PyType_Ready
(
type
)
<
0
)
goto
bad
;
PyObject_SetAttrString
(
fake_module
,
type
->
tp_name
,
(
PyObject
*
)
type
);
if
(
PyObject_SetAttrString
(
fake_module
,
type
->
tp_name
,
(
PyObject
*
)
type
)
<
0
)
goto
bad
;
cached_type
=
type
;
cached_type
=
type
;
}
}
cleanup:
Py_XDECREF
(
sys
);
Py_XDECREF
(
sys_modules
);
Py_XDECREF
(
args
);
return
cached_type
;
return
cached_type
;
bad:
cached_type
=
NULL
;
goto
cleanup
;
}
}
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