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
28601834
Commit
28601834
authored
Jul 01, 2009
by
Danilo Freitas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working with 'new' operator
parent
22e2b0e0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
9 deletions
+44
-9
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+16
-8
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+24
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
28601834
...
...
@@ -1080,13 +1080,11 @@ class ImagNode(AtomicNewTempExprNode):
class
NewExprNode
(
AtomicExprNode
):
type
=
PyrexTypes
.
cpp_class_type
subexpr
=
[
'arg'
]
subexpr
=
[
'arg
s
'
]
def
analyse_types
(
self
,
env
):
entry
=
env
.
lookup
(
self
.
arg
.
name
)
if
not
entry
:
self
.
type
=
PyrexTypes
.
error_type
return
for
arg
in
self
.
args
:
arg
.
analyse_types
(
env
)
def
coerce_to
(
self
,
type
,
env
):
return
self
...
...
@@ -1095,7 +1093,7 @@ class NewExprNode(AtomicExprNode):
pass
def
calculate_result_code
(
self
):
pass
return
""
class
NameNode
(
AtomicExprNode
):
...
...
@@ -1247,7 +1245,8 @@ class NameNode(AtomicExprNode):
entry
=
self
.
entry
#entry.used = 1
if
not
(
entry
.
is_const
or
entry
.
is_variable
or
entry
.
is_builtin
or
entry
.
is_cfunction
):
or
entry
.
is_builtin
or
entry
.
is_cfunction
or
entry
.
is_cpp_class
):
if
self
.
entry
.
as_variable
:
self
.
entry
=
self
.
entry
.
as_variable
else
:
...
...
@@ -2375,6 +2374,15 @@ class SimpleCallNode(CallNode):
self
.
type
=
py_object_type
self
.
gil_check
(
env
)
self
.
is_temp
=
1
if
func_type
.
is_cpp_class
:
for
arg
in
self
.
args
:
arg
.
analyse_types
(
env
)
entry
=
env
.
lookup
(
self
.
function
.
name
)
self
.
type
=
entry
.
type
self
.
function
.
type
=
PyrexTypes
.
CppMethodType
(
self
.
function
.
name
,
PyrexTypes
.
CppClassType
(
self
.
function
.
name
,
"cppclass"
,
entry
.
scope
,
0
,
entry
.
cname
,
[]),
self
.
args
)
self
.
analyse_c_function_call
(
env
)
else
:
for
arg
in
self
.
args
:
arg
.
analyse_types
(
env
)
...
...
@@ -2398,7 +2406,7 @@ class SimpleCallNode(CallNode):
def
analyse_c_function_call
(
self
,
env
):
func_type
=
self
.
function_type
()
# Check function type
if
not
func_type
.
is_cfunction
:
if
not
func_type
.
is_cfunction
and
not
func_type
.
is_cpp_method
:
if
not
func_type
.
is_error
:
error
(
self
.
pos
,
"Calling non-function type '%s'"
%
func_type
)
...
...
Cython/Compiler/Nodes.py
View file @
28601834
...
...
@@ -931,6 +931,7 @@ class CppClassNode(CStructOrUnionDefNode):
self
.
entry
=
env
.
declare_cpp_class
(
self
.
name
,
"cppclass"
,
scope
,
0
,
self
.
pos
,
self
.
cname
,
base_class_types
,
visibility
=
self
.
visibility
)
self
.
entry
.
is_cpp_class
=
1
if
self
.
attributes
is
not
None
:
if
self
.
in_pxd
and
not
env
.
in_cinclude
:
self
.
entry
.
defined_in_pxd
=
1
...
...
Cython/Compiler/Parsing.py
View file @
28601834
...
...
@@ -296,7 +296,7 @@ def p_new_expr(s):
pos
=
s
.
position
()
s
.
next
()
args
=
p_simple_expr_list
(
s
)
return
ExprNodes
.
NewExprNode
(
pos
,
arg
=
args
[
0
]
)
return
ExprNodes
.
NewExprNode
(
pos
,
arg
s
=
args
)
#trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
...
...
Cython/Compiler/PyrexTypes.py
View file @
28601834
...
...
@@ -39,6 +39,7 @@ class PyrexType(BaseType):
# is_ptr boolean Is a C pointer type
# is_null_ptr boolean Is the type of NULL
# is_cfunction boolean Is a C function type
# is_cpp_method boolean Is a C++ method type
# is_struct_or_union boolean Is a C struct or union type
# is_struct boolean Is a C struct type
# is_enum boolean Is a C enum type
...
...
@@ -90,6 +91,7 @@ class PyrexType(BaseType):
is_ptr
=
0
is_null_ptr
=
0
is_cfunction
=
0
is_cpp_method
=
0
is_struct_or_union
=
0
is_cpp_class
=
0
is_struct
=
0
...
...
@@ -1228,6 +1230,28 @@ class CFuncType(CType):
s
=
self
.
declaration_code
(
"(*)"
,
with_calling_convention
=
False
)
return
'(%s)'
%
s
class
CppMethodType
(
CFuncType
):
# return_type CppClassType
is_cpp_method
=
1
def
__init__
(
self
,
class_name
,
return_type
,
args
,
has_varargs
=
0
,
exception_value
=
None
,
exception_check
=
0
,
calling_convention
=
""
,
nogil
=
0
,
with_gil
=
0
,
is_overridable
=
0
,
optional_arg_count
=
0
):
self
.
class_name
=
class_name
self
.
return_type
=
return_type
self
.
args
=
args
self
.
has_varargs
=
has_varargs
self
.
exception_value
=
exception_value
self
.
exception_check
=
exception_check
self
.
calling_convention
=
calling_convention
self
.
nogil
=
nogil
self
.
with_gil
=
with_gil
self
.
is_overridable
=
is_overridable
self
.
optional_arg_count
=
optional_arg_count
class
CFuncTypeArg
(
object
):
# name string
...
...
Cython/Compiler/Symtab.py
View file @
28601834
...
...
@@ -74,6 +74,7 @@ class Entry(object):
# is_unbound_cmethod boolean Is an unbound C method of an extension type
# is_type boolean Is a type definition
# is_cclass boolean Is an extension class
# is_cpp_class boolean Is a C++ class
# is_const boolean Is a constant
# is_property boolean Is a property of an extension type:
# doc_cname string or None C const holding the docstring
...
...
@@ -131,6 +132,7 @@ class Entry(object):
is_unbound_cmethod = 0
is_type = 0
is_cclass = 0
is_cpp_class = 0
is_const = 0
is_property = 0
doc_cname = None
...
...
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