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
44adaf70
Commit
44adaf70
authored
Dec 14, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C++ check code
parent
38c1b13d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
3 deletions
+22
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-0
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+4
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+10
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+7
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
44adaf70
...
@@ -1089,6 +1089,7 @@ class NewExprNode(AtomicExprNode):
...
@@ -1089,6 +1089,7 @@ class NewExprNode(AtomicExprNode):
if
entry
is
None
or
not
entry
.
is_cpp_class
:
if
entry
is
None
or
not
entry
.
is_cpp_class
:
error
(
self
.
pos
,
"new operator can only be applied to a C++ class"
)
error
(
self
.
pos
,
"new operator can only be applied to a C++ class"
)
return
return
self
.
cpp_check
(
env
)
if
self
.
template_parameters
is
not
None
:
if
self
.
template_parameters
is
not
None
:
template_types
=
[
v
.
analyse_as_type
(
env
)
for
v
in
self
.
template_parameters
]
template_types
=
[
v
.
analyse_as_type
(
env
)
for
v
in
self
.
template_parameters
]
type
=
entry
.
type
.
specialize_here
(
self
.
pos
,
template_types
)
type
=
entry
.
type
.
specialize_here
(
self
.
pos
,
template_types
)
...
...
Cython/Compiler/Main.py
View file @
44adaf70
...
@@ -59,7 +59,7 @@ class Context(object):
...
@@ -59,7 +59,7 @@ class Context(object):
# include_directories [string]
# include_directories [string]
# future_directives [object]
# future_directives [object]
def
__init__
(
self
,
include_directories
,
pragma_overrides
):
def
__init__
(
self
,
include_directories
,
pragma_overrides
,
cpp
=
False
):
#self.modules = {"__builtin__" : BuiltinScope()}
#self.modules = {"__builtin__" : BuiltinScope()}
import
Builtin
,
CythonScope
import
Builtin
,
CythonScope
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
...
@@ -67,6 +67,7 @@ class Context(object):
...
@@ -67,6 +67,7 @@ class Context(object):
self
.
include_directories
=
include_directories
self
.
include_directories
=
include_directories
self
.
future_directives
=
set
()
self
.
future_directives
=
set
()
self
.
pragma_overrides
=
pragma_overrides
self
.
pragma_overrides
=
pragma_overrides
self
.
cpp
=
cpp
self
.
pxds
=
{}
# full name -> node tree
self
.
pxds
=
{}
# full name -> node tree
...
@@ -423,6 +424,7 @@ class Context(object):
...
@@ -423,6 +424,7 @@ class Context(object):
if
not
isinstance
(
source_desc
,
FileSourceDescriptor
):
if
not
isinstance
(
source_desc
,
FileSourceDescriptor
):
raise
RuntimeError
(
"Only file sources for code supported"
)
raise
RuntimeError
(
"Only file sources for code supported"
)
source_filename
=
Utils
.
encode_filename
(
source_desc
.
filename
)
source_filename
=
Utils
.
encode_filename
(
source_desc
.
filename
)
scope
.
cpp
=
self
.
cpp
# Parse the given source file and return a parse tree.
# Parse the given source file and return a parse tree.
try
:
try
:
f
=
Utils
.
open_source_file
(
source_filename
,
"rU"
)
f
=
Utils
.
open_source_file
(
source_filename
,
"rU"
)
...
@@ -521,7 +523,7 @@ def create_default_resultobj(compilation_source, options):
...
@@ -521,7 +523,7 @@ def create_default_resultobj(compilation_source, options):
def
run_pipeline
(
source
,
options
,
full_module_name
=
None
):
def
run_pipeline
(
source
,
options
,
full_module_name
=
None
):
# Set up context
# Set up context
context
=
Context
(
options
.
include_path
,
options
.
pragma_overrides
)
context
=
Context
(
options
.
include_path
,
options
.
pragma_overrides
,
options
.
cplus
)
# Set up source object
# Set up source object
cwd
=
os
.
getcwd
()
cwd
=
os
.
getcwd
()
...
...
Cython/Compiler/Nodes.py
View file @
44adaf70
...
@@ -139,6 +139,15 @@ class Node(object):
...
@@ -139,6 +139,15 @@ class Node(object):
def
gil_error
(
self
):
def
gil_error
(
self
):
error
(
self
.
pos
,
"%s not allowed without gil"
%
self
.
gil_message
)
error
(
self
.
pos
,
"%s not allowed without gil"
%
self
.
gil_message
)
cpp_message
=
"Operation"
def
cpp_check
(
self
,
env
):
if
not
env
.
is_cpp
():
self
.
cpp_error
()
def
cpp_error
(
self
):
error
(
self
.
pos
,
"%s only allowed in c++"
%
self
.
cpp_message
)
def
clone_node
(
self
):
def
clone_node
(
self
):
"""Clone the node. This is defined as a shallow copy, except for member lists
"""Clone the node. This is defined as a shallow copy, except for member lists
amongst the child attributes (from get_child_accessors) which are also
amongst the child attributes (from get_child_accessors) which are also
...
@@ -3430,7 +3439,7 @@ class DelStatNode(StatNode):
...
@@ -3430,7 +3439,7 @@ class DelStatNode(StatNode):
if
arg
.
type
.
is_pyobject
:
if
arg
.
type
.
is_pyobject
:
self
.
gil_check
(
env
)
self
.
gil_check
(
env
)
elif
arg
.
type
.
is_ptr
and
arg
.
type
.
base_type
.
is_cpp_class
:
elif
arg
.
type
.
is_ptr
and
arg
.
type
.
base_type
.
is_cpp_class
:
pass
self
.
cpp_check
(
env
)
elif
arg
.
type
.
is_cpp_class
:
elif
arg
.
type
.
is_cpp_class
:
error
(
arg
.
pos
,
"Deletion of non-heap C++ object"
)
error
(
arg
.
pos
,
"Deletion of non-heap C++ object"
)
else
:
else
:
...
...
Cython/Compiler/Symtab.py
View file @
44adaf70
...
@@ -701,6 +701,9 @@ class Scope(object):
...
@@ -701,6 +701,9 @@ class Scope(object):
return 1
return 1
return 0
return 0
def is_cpp(self):
return self.outer_scope.is_cpp()
class PreImportScope(Scope):
class PreImportScope(Scope):
namespace_cname = Naming.preimport_cname
namespace_cname = Naming.preimport_cname
...
@@ -832,6 +835,7 @@ class ModuleScope(Scope):
...
@@ -832,6 +835,7 @@ class ModuleScope(Scope):
# all_pystring_entries [Entry] Python string consts from all scopes
# all_pystring_entries [Entry] Python string consts from all scopes
# types_imported {PyrexType : 1} Set of types for which import code generated
# types_imported {PyrexType : 1} Set of types for which import code generated
# has_import_star boolean Module contains import *
# has_import_star boolean Module contains import *
# cpp boolean Compiling a C++ file
is_module_scope = 1
is_module_scope = 1
has_import_star = 0
has_import_star = 0
...
@@ -1241,6 +1245,9 @@ class ModuleScope(Scope):
...
@@ -1241,6 +1245,9 @@ class ModuleScope(Scope):
var_entry.is_readonly = 1
var_entry.is_readonly = 1
entry.as_variable = var_entry
entry.as_variable = var_entry
def is_cpp(self):
return self.cpp
class LocalScope(Scope):
class LocalScope(Scope):
def __init__(self, name, outer_scope):
def __init__(self, name, outer_scope):
...
...
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