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
Kirill Smelkov
cython
Commits
d19358be
Commit
d19358be
authored
Oct 17, 2009
by
Danilo Freitas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start with references
parent
dffd0a32
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
9 deletions
+67
-9
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+13
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+4
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+41
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+9
-7
No files found.
Cython/Compiler/Nodes.py
View file @
d19358be
...
...
@@ -476,6 +476,18 @@ class CPtrDeclaratorNode(CDeclaratorNode):
ptr_type
=
PyrexTypes
.
c_ptr_type
(
base_type
)
return
self
.
base
.
analyse
(
ptr_type
,
env
,
nonempty
=
nonempty
)
class
CReferenceDeclaratorNode
(
CDeclaratorNode
):
# base CDeclaratorNode
child_attrs
=
[
"base"
]
def
analyse
(
self
,
base_type
,
env
,
nonempty
=
0
):
if
base_type
.
is_pyobject
:
error
(
self
.
pos
,
"Reference base type cannot be a Python object"
)
ref_type
=
Pyrextypes
.
c_ref_type
(
base_type
)
return
self
.
base
.
analyse
(
ref_type
,
env
,
nonempty
=
nonempty
)
class
CArrayDeclaratorNode
(
CDeclaratorNode
):
# base CDeclaratorNode
# dimension ExprNode
...
...
Cython/Compiler/Parsing.py
View file @
d19358be
...
...
@@ -1749,6 +1749,9 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
if
s
.
sy
==
'IDENT'
and
s
.
systring
in
basic_c_type_names
:
name
=
s
.
systring
s
.
next
()
if
s
.
sy
==
'&'
:
s
.
next
()
#TODO (Danilo)
else
:
name
=
'int'
if
s
.
sy
==
'IDENT'
and
s
.
systring
==
'complex'
:
...
...
Cython/Compiler/PyrexTypes.py
View file @
d19358be
...
...
@@ -39,6 +39,7 @@ class PyrexType(BaseType):
# is_array boolean Is a C array type
# is_ptr boolean Is a C pointer type
# is_null_ptr boolean Is the type of NULL
# is_reference boolean Is a C reference type
# is_cfunction boolean Is a C function type
# is_struct_or_union boolean Is a C struct or union type
# is_struct boolean Is a C struct type
...
...
@@ -1018,6 +1019,37 @@ class CNullPtrType(CPtrType):
is_null_ptr
=
1
class
CReferenceType
(
CType
):
is_reference
=
1
def
__init__
(
self
,
base_type
):
self
.
base_type
=
base_type
def
__repr__
(
self
):
return
"<CReferenceType %s>"
%
repr
(
self
.
base_type
)
def
same_as_resolved_type
(
self
,
other_type
):
return
self
.
base_type
.
same_as
(
other_type
.
base_type
)
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
#print "CPtrType.declaration_code: pointer to", self.base_type ###
return
self
.
base_type
.
declaration_code
(
"&%s"
%
entity_code
,
for_display
,
dll_linkage
,
pyrex
)
def
assignable_from_resolved_type
(
self
,
other_type
):
return
0
#TODO (Danilo) implement this
def
specialize
(
self
,
values
):
base_type
=
self
.
base_type
.
specialize
(
values
)
if
base_type
==
self
.
base_type
:
return
self
else
:
return
CReferenceType
(
base_type
)
class
CFuncType
(
CType
):
# return_type CType
# args [CFuncTypeArg]
...
...
@@ -1891,6 +1923,15 @@ def c_ptr_type(base_type):
else
:
return
CPtrType
(
base_type
)
def
c_ref_type
(
base_type
):
# Construct a C reference type
if
base_type
is
c_char_type
:
return
None
#TODO (Danilo) create c_char_ref_type
elif
base_type
is
error_type
:
return
error_type
else
:
return
CReferenceType
(
base_type
)
def
Node_to_type
(
node
,
env
):
from
ExprNodes
import
NameNode
,
AttributeNode
,
StringNode
,
error
if
isinstance
(
node
,
StringNode
):
...
...
Cython/Compiler/Symtab.py
View file @
d19358be
...
...
@@ -311,7 +311,8 @@ class Scope(object):
if visibility == 'extern':
warning(pos, "'%s'
redeclared
" % name, 0)
elif visibility != 'ignore':
error(pos, "'%s'
redeclared
" % name)
pass
#error(pos, "'%s'
redeclared
" % name)
entry = Entry(name, cname, type, pos = pos)
entry.in_cinclude = self.in_cinclude
if name:
...
...
@@ -463,13 +464,14 @@ class Scope(object):
if visibility != 'private' and visibility != entry.visibility:
warning(pos, "
Function
'%s'
previously
declared
as
'%s'" % (name, entry.visibility), 1)
if not entry.type.same_as(type):
if visibility == 'extern' and entry.visibility == 'extern':
warning(pos, "
Function
signature
does
not
match
previous
declaration
", 1)
#
if visibility == 'extern' and entry.visibility == 'extern':
#
warning(pos, "
Function
signature
does
not
match
previous
declaration
", 1)
#entry.type = type
entry.overloaded_alternatives.append(
self.add_cfunction(name, type, pos, cname, visibility, modifiers))
else:
error(pos, "
Function
signature
does
not
match
previous
declaration
")
temp = self.add_cfunction(name, type, pos, cname, visibility, modifiers)
entry.overloaded_alternatives.append(temp)
entry = temp
#else:
#error(pos, "
Function
signature
does
not
match
previous
declaration
")
else:
entry = self.add_cfunction(name, type, pos, cname, visibility, modifiers)
entry.func_cname = cname
...
...
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