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
bba66f99
Commit
bba66f99
authored
May 11, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More fine-grained type declaration (makes new buffmt work in C++)
parent
f397ad40
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
22 deletions
+22
-22
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+7
-6
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+4
-7
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+11
-9
No files found.
Cython/Compiler/Buffer.py
View file @
bba66f99
...
@@ -607,6 +607,8 @@ def type_information_code(proto, impl, name, structinfo_name, dtype, maxdepth):
...
@@ -607,6 +607,8 @@ def type_information_code(proto, impl, name, structinfo_name, dtype, maxdepth):
if
dtype
.
is_error
:
return
if
dtype
.
is_error
:
return
complex_possible
=
dtype
.
is_struct_or_union
and
dtype
.
can_be_complex
()
complex_possible
=
dtype
.
is_struct_or_union
and
dtype
.
can_be_complex
()
code
=
proto
.
globalstate
[
'typeinfo'
]
if
maxdepth
<=
0
:
if
maxdepth
<=
0
:
assert
False
assert
False
...
@@ -620,12 +622,12 @@ def type_information_code(proto, impl, name, structinfo_name, dtype, maxdepth):
...
@@ -620,12 +622,12 @@ def type_information_code(proto, impl, name, structinfo_name, dtype, maxdepth):
assert
len
(
fields
)
>
0
assert
len
(
fields
)
>
0
types
=
[
get_type_information_cname
(
proto
,
f
.
type
,
maxdepth
-
1
)
types
=
[
get_type_information_cname
(
proto
,
f
.
type
,
maxdepth
-
1
)
for
f
in
fields
]
for
f
in
fields
]
impl
.
putln
(
"static __Pyx_StructField %s[] = {"
%
structinfo_name
,
safe
=
True
)
code
.
putln
(
"static __Pyx_StructField %s[] = {"
%
structinfo_name
,
safe
=
True
)
for
f
,
typeinfo
in
zip
(
fields
,
types
):
for
f
,
typeinfo
in
zip
(
fields
,
types
):
impl
.
putln
(
' {&%s, "%s", offsetof(%s, %s)},'
%
code
.
putln
(
' {&%s, "%s", offsetof(%s, %s)},'
%
(
typeinfo
,
f
.
name
,
dtype
.
declaration_code
(
""
),
f
.
cname
),
safe
=
True
)
(
typeinfo
,
f
.
name
,
dtype
.
declaration_code
(
""
),
f
.
cname
),
safe
=
True
)
impl
.
putln
(
' {NULL, NULL, 0}'
,
safe
=
True
)
code
.
putln
(
' {NULL, NULL, 0}'
,
safe
=
True
)
impl
.
putln
(
"};"
,
safe
=
True
)
code
.
putln
(
"};"
,
safe
=
True
)
else
:
else
:
assert
False
assert
False
...
@@ -647,8 +649,7 @@ def type_information_code(proto, impl, name, structinfo_name, dtype, maxdepth):
...
@@ -647,8 +649,7 @@ def type_information_code(proto, impl, name, structinfo_name, dtype, maxdepth):
print
dtype
print
dtype
assert
False
assert
False
proto
.
putln
(
'static __Pyx_TypeInfo %s;'
%
name
)
code
.
putln
((
'static __Pyx_TypeInfo %s = { "%s", %s, sizeof(%s),
\
'
%s
\
'
};'
impl
.
putln
((
'static __Pyx_TypeInfo %s = { "%s", %s, sizeof(%s),
\
'
%s
\
'
};'
)
%
(
name
,
)
%
(
name
,
rep
,
rep
,
structinfo_name
,
structinfo_name
,
...
...
Cython/Compiler/Code.py
View file @
bba66f99
...
@@ -230,15 +230,12 @@ class GlobalState(object):
...
@@ -230,15 +230,12 @@ class GlobalState(object):
code_layout
=
[
code_layout
=
[
'h_code'
,
'h_code'
,
'type_declarations'
,
'module_declarations'
,
'typeinfo'
,
'before_global_var'
,
'before_global_var'
,
'global_var'
,
'global_var'
,
'after_global_var'
,
'all_the_rest'
,
'utility_proto'
,
'pystring_table'
,
'init_cached_builtins'
,
'init'
,
'utility_def'
,
]
]
...
...
Cython/Compiler/ModuleNode.py
View file @
bba66f99
...
@@ -271,7 +271,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -271,7 +271,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_interned_string_decls
(
env
,
code
)
self
.
generate_interned_string_decls
(
env
,
code
)
self
.
generate_py_string_decls
(
env
,
code
)
self
.
generate_py_string_decls
(
env
,
code
)
code
=
globalstate
[
'a
fter_global_var
'
]
code
=
globalstate
[
'a
ll_the_rest
'
]
self
.
generate_cached_builtins_decls
(
env
,
code
)
self
.
generate_cached_builtins_decls
(
env
,
code
)
self
.
body
.
generate_function_definitions
(
env
,
code
)
self
.
body
.
generate_function_definitions
(
env
,
code
)
...
@@ -290,7 +290,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -290,7 +290,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_filename_table
(
code
)
self
.
generate_filename_table
(
code
)
self
.
generate_utility_functions
(
env
,
code
,
h_code
)
self
.
generate_utility_functions
(
env
,
code
,
h_code
)
self
.
generate_declarations_for_modules
(
env
,
modules
,
h_cod
e
)
self
.
generate_declarations_for_modules
(
env
,
modules
,
globalstat
e
)
h_code
.
write
(
'
\
n
'
)
h_code
.
write
(
'
\
n
'
)
globalstate
.
close_global_decls
()
globalstate
.
close_global_decls
()
...
@@ -399,18 +399,20 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -399,18 +399,20 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_exttype_vtable_struct
(
entry
,
code
)
self
.
generate_exttype_vtable_struct
(
entry
,
code
)
self
.
generate_exttype_vtabptr_declaration
(
entry
,
code
)
self
.
generate_exttype_vtabptr_declaration
(
entry
,
code
)
def
generate_declarations_for_modules
(
self
,
env
,
modules
,
code
):
def
generate_declarations_for_modules
(
self
,
env
,
modules
,
globalstate
):
code
.
putln
(
""
)
typecode
=
globalstate
[
'type_declarations'
]
code
.
putln
(
"/* Type declarations */"
)
typecode
.
putln
(
""
)
typecode
.
putln
(
"/* Type declarations */"
)
vtab_list
,
vtabslot_list
=
self
.
sort_type_hierarchy
(
modules
,
env
)
vtab_list
,
vtabslot_list
=
self
.
sort_type_hierarchy
(
modules
,
env
)
self
.
generate_type_definitions
(
self
.
generate_type_definitions
(
env
,
modules
,
vtab_list
,
vtabslot_list
,
code
)
env
,
modules
,
vtab_list
,
vtabslot_list
,
typecode
)
modulecode
=
globalstate
[
'module_declarations'
]
for
module
in
modules
:
for
module
in
modules
:
defined_here
=
module
is
env
defined_here
=
module
is
env
code
.
putln
(
"/* Module declarations from %s */"
%
module
code
.
putln
(
"/* Module declarations from %s */"
%
module
.
qualified_name
.
encode
(
"ASCII"
,
"ignore"
))
module
.
qualified_name
.
encode
(
"ASCII"
,
"ignore"
))
self
.
generate_global_declarations
(
module
,
code
,
defined_here
)
self
.
generate_global_declarations
(
module
,
module
code
,
defined_here
)
self
.
generate_cfunction_predeclarations
(
module
,
code
,
defined_here
)
self
.
generate_cfunction_predeclarations
(
module
,
module
code
,
defined_here
)
def
generate_module_preamble
(
self
,
env
,
cimported_modules
,
code
):
def
generate_module_preamble
(
self
,
env
,
cimported_modules
,
code
):
code
.
putln
(
'/* Generated by Cython %s on %s */'
%
(
code
.
putln
(
'/* Generated by Cython %s on %s */'
%
(
...
...
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