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
5225e53d
Commit
5225e53d
authored
Aug 16, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sizeof() works on cdef attributes and cimported types
parent
e9cbbf22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+14
-0
tests/compile/pylong.pyx
tests/compile/pylong.pyx
+20
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
5225e53d
...
...
@@ -3086,6 +3086,20 @@ class SizeofTypeNode(SizeofNode):
subexprs
=
[]
def
analyse_types
(
self
,
env
):
# we may have incorrectly interpreted a dotted name as a type rather than an attribute
# this could be better handled by more uniformly treating types as runtime-available objects
if
self
.
base_type
.
module_path
:
path
=
self
.
base_type
.
module_path
obj
=
env
.
lookup
(
path
[
0
])
if
obj
.
as_module
is
None
:
operand
=
NameNode
(
pos
=
self
.
pos
,
name
=
path
[
0
])
for
attr
in
path
[
1
:]:
operand
=
AttributeNode
(
pos
=
self
.
pos
,
obj
=
operand
,
attribute
=
attr
)
operand
=
AttributeNode
(
pos
=
self
.
pos
,
obj
=
operand
,
attribute
=
self
.
base_type
.
name
)
self
.
operand
=
operand
self
.
__class__
=
SizeofVarNode
self
.
analyse_types
(
env
)
return
base_type
=
self
.
base_type
.
analyse
(
env
)
_
,
arg_type
=
self
.
declarator
.
analyse
(
base_type
,
env
)
self
.
arg_type
=
arg_type
...
...
tests/compile/pylong.pyx
0 → 100644
View file @
5225e53d
cdef
extern
from
"Python.h"
:
ctypedef
struct
PyTypeObject
:
pass
ctypedef
struct
PyObject
:
Py_ssize_t
ob_refcnt
PyTypeObject
*
ob_type
cdef
extern
from
"longintrepr.h"
:
cdef
struct
_longobject
:
int
ob_refcnt
PyTypeObject
*
ob_type
int
ob_size
unsigned
int
*
ob_digit
def
test
(
temp
=
long
(
0
)):
cdef
_longobject
*
l
l
=
<
_longobject
*>
temp
print
sizeof
(
l
.
ob_size
)
print
sizeof
(
l
.
ob_digit
[
0
])
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