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
e908c0b9
Commit
e908c0b9
authored
Feb 09, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove tabs
parent
8907aefd
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
292 additions
and
292 deletions
+292
-292
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+1
-1
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+1
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+36
-36
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+59
-59
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+24
-24
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+7
-7
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+5
-5
Cython/Compiler/Scanning.py
Cython/Compiler/Scanning.py
+1
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+6
-6
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+1
-1
Cython/Distutils/build_ext.py
Cython/Distutils/build_ext.py
+15
-15
Cython/Mac/DarwinSystem.py
Cython/Mac/DarwinSystem.py
+2
-2
Cython/Mac/TS_Misc_Suite.py
Cython/Mac/TS_Misc_Suite.py
+2
-2
Cython/Plex/DFA.py
Cython/Plex/DFA.py
+6
-6
Cython/Plex/Machines.py
Cython/Plex/Machines.py
+6
-6
Cython/Plex/Regexps.py
Cython/Plex/Regexps.py
+42
-42
Cython/Plex/Scanners.py
Cython/Plex/Scanners.py
+54
-54
Cython/Plex/Transitions.py
Cython/Plex/Transitions.py
+2
-2
pyximport/Setup.py
pyximport/Setup.py
+1
-1
pyximport/test/test_pyximport.py
pyximport/test/test_pyximport.py
+2
-2
pyximport/test/test_reload.py
pyximport/test/test_reload.py
+19
-19
No files found.
Cython/Compiler/Builtin.py
View file @
e908c0b9
...
@@ -13,7 +13,7 @@ builtin_function_table = [
...
@@ -13,7 +13,7 @@ builtin_function_table = [
(
'abs'
,
"O"
,
"O"
,
"PyNumber_Absolute"
),
(
'abs'
,
"O"
,
"O"
,
"PyNumber_Absolute"
),
#('chr', "", "", ""),
#('chr', "", "", ""),
#('cmp', "", "", "", ""), # int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
#('cmp', "", "", "", ""), # int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result)
#('compile', "", "", ""), # PyObject* Py_CompileString(
char *str, char *filename, int start)
#('compile', "", "", ""), # PyObject* Py_CompileString(
char *str, char *filename, int start)
(
'delattr'
,
"OO"
,
"r"
,
"PyObject_DelAttr"
),
(
'delattr'
,
"OO"
,
"r"
,
"PyObject_DelAttr"
),
(
'dir'
,
"O"
,
"O"
,
"PyObject_Dir"
),
(
'dir'
,
"O"
,
"O"
,
"PyObject_Dir"
),
(
'divmod'
,
"OO"
,
"O"
,
"PyNumber_Divmod"
),
(
'divmod'
,
"OO"
,
"O"
,
"PyNumber_Divmod"
),
...
...
Cython/Compiler/Code.py
View file @
e908c0b9
...
@@ -849,7 +849,7 @@ class CCodeWriter(object):
...
@@ -849,7 +849,7 @@ class CCodeWriter(object):
def
put_init_var_to_py_none
(
self
,
entry
,
template
=
"%s"
,
nanny
=
True
):
def
put_init_var_to_py_none
(
self
,
entry
,
template
=
"%s"
,
nanny
=
True
):
code
=
template
%
entry
.
cname
code
=
template
%
entry
.
cname
#if entry.type.is_extension_type:
#if entry.type.is_extension_type:
#
code = "((PyObject*)%s)" % code
#
code = "((PyObject*)%s)" % code
self
.
put_init_to_py_none
(
code
,
entry
.
type
,
nanny
)
self
.
put_init_to_py_none
(
code
,
entry
.
type
,
nanny
)
def
put_pymethoddef
(
self
,
entry
,
term
):
def
put_pymethoddef
(
self
,
entry
,
term
):
...
...
Cython/Compiler/ExprNodes.py
View file @
e908c0b9
...
@@ -425,9 +425,9 @@ class ExprNode(Node):
...
@@ -425,9 +425,9 @@ class ExprNode(Node):
def
calculate_result_code
(
self
):
def
calculate_result_code
(
self
):
self
.
not_implemented
(
"calculate_result_code"
)
self
.
not_implemented
(
"calculate_result_code"
)
#
def release_target_temp(self, env):
#
def release_target_temp(self, env):
#
# Release temporaries used by LHS of an assignment.
#
# Release temporaries used by LHS of an assignment.
#
self.release_subexpr_temps(env)
#
self.release_subexpr_temps(env)
def
release_temp
(
self
,
env
):
def
release_temp
(
self
,
env
):
# If this node owns a temporary result, release it,
# If this node owns a temporary result, release it,
...
@@ -2454,7 +2454,7 @@ class SimpleCallNode(CallNode):
...
@@ -2454,7 +2454,7 @@ class SimpleCallNode(CallNode):
if
self
.
is_temp
and
self
.
type
.
is_pyobject
:
if
self
.
is_temp
and
self
.
type
.
is_pyobject
:
#return_type = self.type # func_type.return_type
#return_type = self.type # func_type.return_type
#print "SimpleCallNode.generate_result_code: casting", rhs, \
#print "SimpleCallNode.generate_result_code: casting", rhs, \
#
"from", return_type, "to pyobject" ###
#
"from", return_type, "to pyobject" ###
rhs
=
typecast
(
py_object_type
,
self
.
type
,
rhs
)
rhs
=
typecast
(
py_object_type
,
self
.
type
,
rhs
)
else
:
else
:
lhs
=
""
lhs
=
""
...
@@ -2749,7 +2749,7 @@ class AttributeNode(NewTempExprNode):
...
@@ -2749,7 +2749,7 @@ class AttributeNode(NewTempExprNode):
pass
pass
## Reference to C array turns into pointer to first element.
## Reference to C array turns into pointer to first element.
#while self.type.is_array:
#while self.type.is_array:
#
self.type = self.type.element_ptr_type()
#
self.type = self.type.element_ptr_type()
if
self
.
is_py_attr
:
if
self
.
is_py_attr
:
if
not
target
:
if
not
target
:
self
.
is_temp
=
1
self
.
is_temp
=
1
...
@@ -2990,12 +2990,12 @@ class SequenceNode(NewTempExprNode):
...
@@ -2990,12 +2990,12 @@ class SequenceNode(NewTempExprNode):
for
node
in
self
.
coerced_unpacked_items
:
for
node
in
self
.
coerced_unpacked_items
:
node
.
release_temp
(
env
)
node
.
release_temp
(
env
)
#
def release_target_temp(self, env):
#
def release_target_temp(self, env):
#
#for arg in self.args:
#
#for arg in self.args:
#
#
arg.release_target_temp(env)
#
#
arg.release_target_temp(env)
#
#for node in self.coerced_unpacked_items:
#
#for node in self.coerced_unpacked_items:
#
#
node.release_temp(env)
#
#
node.release_temp(env)
#
self.iterator.release_temp(env)
#
self.iterator.release_temp(env)
def
generate_result_code
(
self
,
code
):
def
generate_result_code
(
self
,
code
):
self
.
generate_operation_code
(
code
)
self
.
generate_operation_code
(
code
)
...
@@ -4134,17 +4134,17 @@ class NumBinopNode(BinopNode):
...
@@ -4134,17 +4134,17 @@ class NumBinopNode(BinopNode):
return
self
.
py_functions
[
self
.
operator
]
return
self
.
py_functions
[
self
.
operator
]
py_functions
=
{
py_functions
=
{
"|"
:
"PyNumber_Or"
,
"|"
:
"PyNumber_Or"
,
"^"
:
"PyNumber_Xor"
,
"^"
:
"PyNumber_Xor"
,
"&"
:
"PyNumber_And"
,
"&"
:
"PyNumber_And"
,
"<<"
:
"PyNumber_Lshift"
,
"<<"
:
"PyNumber_Lshift"
,
">>"
:
"PyNumber_Rshift"
,
">>"
:
"PyNumber_Rshift"
,
"+"
:
"PyNumber_Add"
,
"+"
:
"PyNumber_Add"
,
"-"
:
"PyNumber_Subtract"
,
"-"
:
"PyNumber_Subtract"
,
"*"
:
"PyNumber_Multiply"
,
"*"
:
"PyNumber_Multiply"
,
"/"
:
"__Pyx_PyNumber_Divide"
,
"/"
:
"__Pyx_PyNumber_Divide"
,
"//"
:
"PyNumber_FloorDivide"
,
"//"
:
"PyNumber_FloorDivide"
,
"%"
:
"PyNumber_Remainder"
,
"%"
:
"PyNumber_Remainder"
,
"**"
:
"PyNumber_Power"
"**"
:
"PyNumber_Power"
}
}
...
@@ -4834,20 +4834,20 @@ class CascadedCmpNode(Node, CmpNode):
...
@@ -4834,20 +4834,20 @@ class CascadedCmpNode(Node, CmpNode):
binop_node_classes
=
{
binop_node_classes
=
{
"or"
:
BoolBinopNode
,
"or"
:
BoolBinopNode
,
"and"
:
BoolBinopNode
,
"and"
:
BoolBinopNode
,
"|"
:
IntBinopNode
,
"|"
:
IntBinopNode
,
"^"
:
IntBinopNode
,
"^"
:
IntBinopNode
,
"&"
:
IntBinopNode
,
"&"
:
IntBinopNode
,
"<<"
:
IntBinopNode
,
"<<"
:
IntBinopNode
,
">>"
:
IntBinopNode
,
">>"
:
IntBinopNode
,
"+"
:
AddNode
,
"+"
:
AddNode
,
"-"
:
SubNode
,
"-"
:
SubNode
,
"*"
:
MulNode
,
"*"
:
MulNode
,
"/"
:
NumBinopNode
,
"/"
:
NumBinopNode
,
"//"
:
FloorDivNode
,
"//"
:
FloorDivNode
,
"%"
:
ModNode
,
"%"
:
ModNode
,
"**"
:
PowNode
"**"
:
PowNode
}
}
def
binop_node
(
pos
,
operator
,
operand1
,
operand2
):
def
binop_node
(
pos
,
operator
,
operand1
,
operand2
):
...
...
Cython/Compiler/ModuleNode.py
View file @
e908c0b9
...
@@ -695,7 +695,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -695,7 +695,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
name
))
name
))
# ??? Do we really need the rest of this? ???
# ??? Do we really need the rest of this? ???
#else:
#else:
#
code.putln("staticforward PyTypeObject %s;" % name)
#
code.putln("staticforward PyTypeObject %s;" % name)
def
generate_exttype_vtable_struct
(
self
,
entry
,
code
):
def
generate_exttype_vtable_struct
(
self
,
entry
,
code
):
code
.
mark_pos
(
entry
.
pos
)
code
.
mark_pos
(
entry
.
pos
)
...
@@ -884,7 +884,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -884,7 +884,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"p = %s;"
"p = %s;"
%
type
.
cast_code
(
"o"
))
%
type
.
cast_code
(
"o"
))
#if need_self_cast:
#if need_self_cast:
#
self.generate_self_cast(scope, code)
#
self.generate_self_cast(scope, code)
if
type
.
vtabslot_cname
:
if
type
.
vtabslot_cname
:
vtab_base_type
=
type
vtab_base_type
=
type
while
vtab_base_type
.
base_type
and
vtab_base_type
.
base_type
.
vtabstruct_cname
:
while
vtab_base_type
.
base_type
and
vtab_base_type
.
base_type
.
vtabstruct_cname
:
...
@@ -1343,7 +1343,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1343,7 +1343,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
code
.
putln
(
"return -1;"
)
"return -1;"
)
code
.
putln
(
code
.
putln
(
"}"
)
"}"
)
code
.
putln
(
code
.
putln
(
"}"
)
"}"
)
...
@@ -2234,65 +2234,65 @@ import_star_utility_code = """
...
@@ -2234,65 +2234,65 @@ import_star_utility_code = """
static int
static int
__Pyx_import_all_from(PyObject *locals, PyObject *v)
__Pyx_import_all_from(PyObject *locals, PyObject *v)
{
{
PyObject *all = __Pyx_GetAttrString(v, "__all__");
PyObject *all = __Pyx_GetAttrString(v, "__all__");
PyObject *dict, *name, *value;
PyObject *dict, *name, *value;
int skip_leading_underscores = 0;
int skip_leading_underscores = 0;
int pos, err;
int pos, err;
if (all == NULL) {
if (all == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1; /* Unexpected error */
return -1; /* Unexpected error */
PyErr_Clear();
PyErr_Clear();
dict = __Pyx_GetAttrString(v, "__dict__");
dict = __Pyx_GetAttrString(v, "__dict__");
if (dict == NULL) {
if (dict == NULL) {
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
return -1;
return -1;
PyErr_SetString(PyExc_ImportError,
PyErr_SetString(PyExc_ImportError,
"from-import-* object has no __dict__ and no __all__");
"from-import-* object has no __dict__ and no __all__");
return -1;
return -1;
}
}
all = PyMapping_Keys(dict);
all = PyMapping_Keys(dict);
Py_DECREF(dict);
Py_DECREF(dict);
if (all == NULL)
if (all == NULL)
return -1;
return -1;
skip_leading_underscores = 1;
skip_leading_underscores = 1;
}
}
for (pos = 0, err = 0; ; pos++) {
for (pos = 0, err = 0; ; pos++) {
name = PySequence_GetItem(all, pos);
name = PySequence_GetItem(all, pos);
if (name == NULL) {
if (name == NULL) {
if (!PyErr_ExceptionMatches(PyExc_IndexError))
if (!PyErr_ExceptionMatches(PyExc_IndexError))
err = -1;
err = -1;
else
else
PyErr_Clear();
PyErr_Clear();
break;
break;
}
}
if (skip_leading_underscores &&
if (skip_leading_underscores &&
#if PY_MAJOR_VERSION < 3
#if PY_MAJOR_VERSION < 3
PyString_Check(name) &&
PyString_Check(name) &&
PyString_AS_STRING(name)[0] == '_')
PyString_AS_STRING(name)[0] == '_')
#else
#else
PyUnicode_Check(name) &&
PyUnicode_Check(name) &&
PyUnicode_AS_UNICODE(name)[0] == '_')
PyUnicode_AS_UNICODE(name)[0] == '_')
#endif
#endif
{
{
Py_DECREF(name);
Py_DECREF(name);
continue;
continue;
}
}
value = PyObject_GetAttr(v, name);
value = PyObject_GetAttr(v, name);
if (value == NULL)
if (value == NULL)
err = -1;
err = -1;
else if (PyDict_CheckExact(locals))
else if (PyDict_CheckExact(locals))
err = PyDict_SetItem(locals, name, value);
err = PyDict_SetItem(locals, name, value);
else
else
err = PyObject_SetItem(locals, name, value);
err = PyObject_SetItem(locals, name, value);
Py_DECREF(name);
Py_DECREF(name);
Py_XDECREF(value);
Py_XDECREF(value);
if (err != 0)
if (err != 0)
break;
break;
}
}
Py_DECREF(all);
Py_DECREF(all);
return err;
return err;
}
}
...
...
Cython/Compiler/Nodes.py
View file @
e908c0b9
...
@@ -2994,11 +2994,11 @@ class ParallelAssignmentNode(AssignmentNode):
...
@@ -2994,11 +2994,11 @@ class ParallelAssignmentNode(AssignmentNode):
for
stat
in
self
.
stats
:
for
stat
in
self
.
stats
:
stat
.
allocate_lhs_temps
(
env
)
stat
.
allocate_lhs_temps
(
env
)
#
def analyse_expressions(self, env):
#
def analyse_expressions(self, env):
#
for stat in self.stats:
#
for stat in self.stats:
#
stat.analyse_expressions_1(env, use_temp = 1)
#
stat.analyse_expressions_1(env, use_temp = 1)
#
for stat in self.stats:
#
for stat in self.stats:
#
stat.analyse_expressions_2(env)
#
stat.analyse_expressions_2(env)
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
for
stat
in
self
.
stats
:
for
stat
in
self
.
stats
:
...
@@ -3158,18 +3158,18 @@ class InPlaceAssignmentNode(AssignmentNode):
...
@@ -3158,18 +3158,18 @@ class InPlaceAssignmentNode(AssignmentNode):
return
self
.
py_functions
[
self
.
operator
]
return
self
.
py_functions
[
self
.
operator
]
py_functions
=
{
py_functions
=
{
"|"
:
"PyNumber_InPlaceOr"
,
"|"
:
"PyNumber_InPlaceOr"
,
"^"
:
"PyNumber_InPlaceXor"
,
"^"
:
"PyNumber_InPlaceXor"
,
"&"
:
"PyNumber_InPlaceAnd"
,
"&"
:
"PyNumber_InPlaceAnd"
,
"+"
:
"PyNumber_InPlaceAdd"
,
"+"
:
"PyNumber_InPlaceAdd"
,
"-"
:
"PyNumber_InPlaceSubtract"
,
"-"
:
"PyNumber_InPlaceSubtract"
,
"*"
:
"PyNumber_InPlaceMultiply"
,
"*"
:
"PyNumber_InPlaceMultiply"
,
"/"
:
"PyNumber_InPlaceDivide"
,
"/"
:
"PyNumber_InPlaceDivide"
,
"%"
:
"PyNumber_InPlaceRemainder"
,
"%"
:
"PyNumber_InPlaceRemainder"
,
"<<"
:
"PyNumber_InPlaceLshift"
,
"<<"
:
"PyNumber_InPlaceLshift"
,
">>"
:
"PyNumber_InPlaceRshift"
,
">>"
:
"PyNumber_InPlaceRshift"
,
"**"
:
"PyNumber_InPlacePower"
,
"**"
:
"PyNumber_InPlacePower"
,
"//"
:
"PyNumber_InPlaceFloorDivide"
,
"//"
:
"PyNumber_InPlaceFloorDivide"
,
}
}
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
...
@@ -3625,8 +3625,8 @@ class IfClauseNode(Node):
...
@@ -3625,8 +3625,8 @@ class IfClauseNode(Node):
self
.
condition
.
free_temps
(
code
)
self
.
condition
.
free_temps
(
code
)
self
.
body
.
generate_execution_code
(
code
)
self
.
body
.
generate_execution_code
(
code
)
#code.putln(
#code.putln(
#
"goto %s;" %
#
"goto %s;" %
#
end_label)
#
end_label)
code
.
put_goto
(
end_label
)
code
.
put_goto
(
end_label
)
code
.
putln
(
"}"
)
code
.
putln
(
"}"
)
...
@@ -3865,9 +3865,9 @@ class ForFromStatNode(LoopNode, StatNode):
...
@@ -3865,9 +3865,9 @@ class ForFromStatNode(LoopNode, StatNode):
error
(
self
.
target
.
pos
,
error
(
self
.
target
.
pos
,
"Integer for-loop variable must be of type int or Python object"
)
"Integer for-loop variable must be of type int or Python object"
)
#if not (target_type.is_pyobject
#if not (target_type.is_pyobject
#
or target_type.assignable_from(PyrexTypes.c_int_type)):
#
or target_type.assignable_from(PyrexTypes.c_int_type)):
#
error(self.target.pos,
#
error(self.target.pos,
#
"Cannot assign integer to variable of type '%s'" % target_type)
#
"Cannot assign integer to variable of type '%s'" % target_type)
if
target_type
.
is_numeric
:
if
target_type
.
is_numeric
:
self
.
is_py_target
=
0
self
.
is_py_target
=
0
if
isinstance
(
self
.
target
,
ExprNodes
.
IndexNode
)
and
self
.
target
.
is_buffer_access
:
if
isinstance
(
self
.
target
,
ExprNodes
.
IndexNode
)
and
self
.
target
.
is_buffer_access
:
...
@@ -4383,8 +4383,8 @@ class TryFinallyStatNode(StatNode):
...
@@ -4383,8 +4383,8 @@ class TryFinallyStatNode(StatNode):
"%s = %s;"
%
(
"%s = %s;"
%
(
Naming
.
exc_lineno_name
,
Naming
.
lineno_cname
))
Naming
.
exc_lineno_name
,
Naming
.
lineno_cname
))
#code.putln(
#code.putln(
#
"goto %s;" %
#
"goto %s;" %
#
catch_label)
#
catch_label)
code
.
put_goto
(
catch_label
)
code
.
put_goto
(
catch_label
)
code
.
putln
(
code
.
putln
(
"}"
)
"}"
)
...
...
Cython/Compiler/Parsing.py
View file @
e908c0b9
...
@@ -681,11 +681,11 @@ def p_string_literal(s):
...
@@ -681,11 +681,11 @@ def p_string_literal(s):
#print "p_string_literal: value =", repr(value) ###
#print "p_string_literal: value =", repr(value) ###
return
kind
,
value
return
kind
,
value
# list_display
::=
"[" [listmaker] "]"
# list_display
::=
"[" [listmaker] "]"
# listmaker
::=
expression ( list_for | ( "," expression )* [","] )
# listmaker
::=
expression ( list_for | ( "," expression )* [","] )
# list_iter
::=
list_for | list_if
# list_iter
::=
list_for | list_if
# list_for
::=
"for" expression_list "in" testlist [list_iter]
# list_for
::=
"for" expression_list "in" testlist [list_iter]
# list_if
::=
"if" test [list_iter]
# list_if
::=
"if" test [list_iter]
def
p_list_maker
(
s
):
def
p_list_maker
(
s
):
# s.sy == '['
# s.sy == '['
...
@@ -1363,7 +1363,7 @@ def p_include_statement(s, ctx):
...
@@ -1363,7 +1363,7 @@ def p_include_statement(s, ctx):
def
p_with_statement
(
s
):
def
p_with_statement
(
s
):
pos
=
s
.
position
()
pos
=
s
.
position
()
s
.
next
()
# 'with'
s
.
next
()
# 'with'
#
if s.sy == 'IDENT' and s.systring in ('gil', 'nogil'):
#
if s.sy == 'IDENT' and s.systring in ('gil', 'nogil'):
if
s
.
sy
==
'IDENT'
and
s
.
systring
==
'nogil'
:
if
s
.
sy
==
'IDENT'
and
s
.
systring
==
'nogil'
:
state
=
s
.
systring
state
=
s
.
systring
s
.
next
()
s
.
next
()
...
@@ -1380,7 +1380,7 @@ def p_with_statement(s):
...
@@ -1380,7 +1380,7 @@ def p_with_statement(s):
s
.
error
(
"Multiple with statement target values not allowed without paranthesis"
)
s
.
error
(
"Multiple with statement target values not allowed without paranthesis"
)
body
=
p_suite
(
s
)
body
=
p_suite
(
s
)
return
Nodes
.
WithStatNode
(
pos
,
manager
=
manager
,
return
Nodes
.
WithStatNode
(
pos
,
manager
=
manager
,
target
=
target
,
body
=
body
)
target
=
target
,
body
=
body
)
def
p_simple_statement
(
s
,
first_statement
=
0
):
def
p_simple_statement
(
s
,
first_statement
=
0
):
#print "p_simple_statement:", s.sy, s.systring ###
#print "p_simple_statement:", s.sy, s.systring ###
...
...
Cython/Compiler/PyrexTypes.py
View file @
e908c0b9
...
@@ -558,7 +558,7 @@ class CBIntType(CIntType):
...
@@ -558,7 +558,7 @@ class CBIntType(CIntType):
class
CAnonEnumType
(
CIntType
):
class
CAnonEnumType
(
CIntType
):
is_enum
=
1
is_enum
=
1
class
CUIntType
(
CIntType
):
class
CUIntType
(
CIntType
):
...
@@ -754,7 +754,7 @@ class CFuncType(CType):
...
@@ -754,7 +754,7 @@ class CFuncType(CType):
def
same_c_signature_as_resolved_type
(
self
,
other_type
,
as_cmethod
=
0
):
def
same_c_signature_as_resolved_type
(
self
,
other_type
,
as_cmethod
=
0
):
#print "CFuncType.same_c_signature_as_resolved_type:", \
#print "CFuncType.same_c_signature_as_resolved_type:", \
#
self, other_type, "as_cmethod =", as_cmethod ###
#
self, other_type, "as_cmethod =", as_cmethod ###
if
other_type
is
error_type
:
if
other_type
is
error_type
:
return
1
return
1
if
not
other_type
.
is_cfunction
:
if
not
other_type
.
is_cfunction
:
...
@@ -786,7 +786,7 @@ class CFuncType(CType):
...
@@ -786,7 +786,7 @@ class CFuncType(CType):
def
compatible_signature_with_resolved_type
(
self
,
other_type
,
as_cmethod
):
def
compatible_signature_with_resolved_type
(
self
,
other_type
,
as_cmethod
):
#print "CFuncType.same_c_signature_as_resolved_type:", \
#print "CFuncType.same_c_signature_as_resolved_type:", \
#
self, other_type, "as_cmethod =", as_cmethod ###
#
self, other_type, "as_cmethod =", as_cmethod ###
if
other_type
is
error_type
:
if
other_type
is
error_type
:
return
1
return
1
if
not
other_type
.
is_cfunction
:
if
not
other_type
.
is_cfunction
:
...
@@ -901,7 +901,7 @@ class CFuncType(CType):
...
@@ -901,7 +901,7 @@ class CFuncType(CType):
return
self
.
return_type
.
declaration_code
(
return
self
.
return_type
.
declaration_code
(
"%s%s(%s)%s"
%
(
cc
,
entity_code
,
arg_decl_code
,
trailer
),
"%s%s(%s)%s"
%
(
cc
,
entity_code
,
arg_decl_code
,
trailer
),
for_display
,
dll_linkage
,
pyrex
)
for_display
,
dll_linkage
,
pyrex
)
def
function_header_code
(
self
,
func_name
,
arg_code
):
def
function_header_code
(
self
,
func_name
,
arg_code
):
return
"%s%s(%s)"
%
(
self
.
calling_convention_prefix
(),
return
"%s%s(%s)"
%
(
self
.
calling_convention_prefix
(),
func_name
,
arg_code
)
func_name
,
arg_code
)
...
@@ -1134,7 +1134,7 @@ class ErrorType(PyrexType):
...
@@ -1134,7 +1134,7 @@ class ErrorType(PyrexType):
is_error
=
1
is_error
=
1
exception_value
=
"0"
exception_value
=
"0"
exception_check
=
0
exception_check
=
0
to_py_function
=
"dummy"
to_py_function
=
"dummy"
from_py_function
=
"dummy"
from_py_function
=
"dummy"
...
...
Cython/Compiler/Scanning.py
View file @
e908c0b9
...
@@ -371,7 +371,7 @@ class PyrexScanner(Scanner):
...
@@ -371,7 +371,7 @@ class PyrexScanner(Scanner):
self
.
begin
(
''
)
self
.
begin
(
''
)
# Indentation within brackets should be ignored.
# Indentation within brackets should be ignored.
#if self.bracket_nesting_level > 0:
#if self.bracket_nesting_level > 0:
#
return
#
return
# Check that tabs and spaces are being used consistently.
# Check that tabs and spaces are being used consistently.
if
text
:
if
text
:
c
=
text
[
0
]
c
=
text
[
0
]
...
...
Cython/Compiler/Symtab.py
View file @
e908c0b9
...
@@ -392,7 +392,7 @@ class Scope:
...
@@ -392,7 +392,7 @@ class Scope:
visibility = visibility)
visibility = visibility)
entry.enum_values = []
entry.enum_values = []
self.sue_entries.append(entry)
self.sue_entries.append(entry)
return entry
return entry
def declare_var(self, name, type, pos,
def declare_var(self, name, type, pos,
cname = None, visibility = 'private', is_cdef = 0):
cname = None, visibility = 'private', is_cdef = 0):
...
@@ -662,7 +662,7 @@ class Scope:
...
@@ -662,7 +662,7 @@ class Scope:
# Test whether any of the given names are
# Test whether any of the given names are
# defined in this scope.
# defined in this scope.
for name in names:
for name in names:
if name in self.entries:
if name in self.entries:
return 1
return 1
return 0
return 0
...
@@ -1028,7 +1028,7 @@ class ModuleScope(Scope):
...
@@ -1028,7 +1028,7 @@ class ModuleScope(Scope):
if objstruct_cname:
if objstruct_cname:
type.objstruct_cname = objstruct_cname
type.objstruct_cname = objstruct_cname
elif not entry.in_cinclude:
elif not entry.in_cinclude:
type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name)
type.objstruct_cname = self.mangle(Naming.objstruct_prefix, name)
else:
else:
error(entry.pos,
error(entry.pos,
"
Object
name
required
for
'public'
or
'extern'
C
class
")
"
Object
name
required
for
'public'
or
'extern'
C
class
")
...
@@ -1067,13 +1067,13 @@ class ModuleScope(Scope):
...
@@ -1067,13 +1067,13 @@ class ModuleScope(Scope):
if objstruct_cname:
if objstruct_cname:
if type.objstruct_cname and type.objstruct_cname != objstruct_cname:
if type.objstruct_cname and type.objstruct_cname != objstruct_cname:
error(pos, "Object struct name differs from previous declaration")
error(pos, "Object struct name differs from previous declaration")
type.objstruct_cname = objstruct_cname
type.objstruct_cname = objstruct_cname
if typeobj_cname:
if typeobj_cname:
if type.typeobj_cname and type.typeobj_cname != typeobj_cname:
if type.typeobj_cname and type.typeobj_cname != typeobj_cname:
error(pos, "Type object name differs from previous declaration")
error(pos, "Type object name differs from previous declaration")
type.typeobj_cname = typeobj_cname
type.typeobj_cname = typeobj_cname
#
#
# Return new or existing entry
# Return new or existing entry
#
#
return entry
return entry
...
@@ -1329,7 +1329,7 @@ class PyClassScope(ClassScope):
...
@@ -1329,7 +1329,7 @@ class PyClassScope(ClassScope):
self
.
outer_scope
.
release_temp
(
cname
)
self
.
outer_scope
.
release_temp
(
cname
)
#def recycle_pending_temps(self):
#def recycle_pending_temps(self):
#
self.outer_scope.recycle_pending_temps()
#
self.outer_scope.recycle_pending_temps()
def
add_default_value
(
self
,
type
):
def
add_default_value
(
self
,
type
):
return
self
.
outer_scope
.
add_default_value
(
type
)
return
self
.
outer_scope
.
add_default_value
(
type
)
...
...
Cython/Compiler/TypeSlots.py
View file @
e908c0b9
...
@@ -398,7 +398,7 @@ method_name_to_slot = {}
...
@@ -398,7 +398,7 @@ method_name_to_slot = {}
## extern function pointer.
## extern function pointer.
#
#
#slots_initialised_from_extern = (
#slots_initialised_from_extern = (
#
"tp_free",
#
"tp_free",
#)
#)
#------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------
...
...
Cython/Distutils/build_ext.py
View file @
e908c0b9
...
@@ -106,17 +106,17 @@ class build_ext(_build_ext.build_ext):
...
@@ -106,17 +106,17 @@ class build_ext(_build_ext.build_ext):
# cplus will also be set to true is extension.language is equal to
# cplus will also be set to true is extension.language is equal to
# 'C++' or 'c++'.
# 'C++' or 'c++'.
#try:
#try:
#
create_listing = self.pyrex_create_listing or \
#
create_listing = self.pyrex_create_listing or \
#
extension.pyrex_create_listing
#
extension.pyrex_create_listing
#
cplus = self.pyrex_cplus or \
#
cplus = self.pyrex_cplus or \
#
extension.pyrex_cplus or \
#
extension.pyrex_cplus or \
#
(extension.language != None and \
#
(extension.language != None and \
#
extension.language.lower() == 'c++')
#
extension.language.lower() == 'c++')
#except AttributeError:
#except AttributeError:
#
create_listing = self.pyrex_create_listing
#
create_listing = self.pyrex_create_listing
#
cplus = self.pyrex_cplus or \
#
cplus = self.pyrex_cplus or \
#
(extension.language != None and \
#
(extension.language != None and \
#
extension.language.lower() == 'c++')
#
extension.language.lower() == 'c++')
create_listing
=
self
.
pyrex_create_listing
or
\
create_listing
=
self
.
pyrex_create_listing
or
\
getattr
(
extension
,
'pyrex_create_listing'
,
0
)
getattr
(
extension
,
'pyrex_create_listing'
,
0
)
...
@@ -125,10 +125,10 @@ class build_ext(_build_ext.build_ext):
...
@@ -125,10 +125,10 @@ class build_ext(_build_ext.build_ext):
pyrex_gen_pxi
=
self
.
pyrex_gen_pxi
or
getattr
(
extension
,
'pyrex_gen_pxi'
,
0
)
pyrex_gen_pxi
=
self
.
pyrex_gen_pxi
or
getattr
(
extension
,
'pyrex_gen_pxi'
,
0
)
# Set up the include_path for the Cython compiler:
# Set up the include_path for the Cython compiler:
#
1.
Start with the command line option.
#
1.
Start with the command line option.
#
2.
Add in any (unique) paths from the extension
#
2.
Add in any (unique) paths from the extension
#
pyrex_include_dirs (if Cython.Distutils.extension is used).
#
pyrex_include_dirs (if Cython.Distutils.extension is used).
#
3.
Add in any (unique) paths from the extension include_dirs
#
3.
Add in any (unique) paths from the extension include_dirs
includes
=
self
.
pyrex_include_dirs
includes
=
self
.
pyrex_include_dirs
try
:
try
:
for
i
in
extension
.
pyrex_include_dirs
:
for
i
in
extension
.
pyrex_include_dirs
:
...
@@ -162,7 +162,7 @@ class build_ext(_build_ext.build_ext):
...
@@ -162,7 +162,7 @@ class build_ext(_build_ext.build_ext):
if
ext
==
".py"
:
if
ext
==
".py"
:
# FIXME: we might want to special case this some more
# FIXME: we might want to special case this some more
ext
=
'.pyx'
ext
=
'.pyx'
if
ext
==
".pyx"
:
# Cython source file
if
ext
==
".pyx"
:
# Cython source file
output_dir
=
target_dir
or
os
.
path
.
dirname
(
source
)
output_dir
=
target_dir
or
os
.
path
.
dirname
(
source
)
new_sources
.
append
(
os
.
path
.
join
(
output_dir
,
base
+
target_ext
))
new_sources
.
append
(
os
.
path
.
join
(
output_dir
,
base
+
target_ext
))
pyrex_sources
.
append
(
source
)
pyrex_sources
.
append
(
source
)
...
...
Cython/Mac/DarwinSystem.py
View file @
e908c0b9
...
@@ -51,8 +51,8 @@ linker_options = \
...
@@ -51,8 +51,8 @@ linker_options = \
"-Wl,-F.,-w -bundle -undefined dynamic_lookup"
\
"-Wl,-F.,-w -bundle -undefined dynamic_lookup"
\
.
split
()
.
split
()
#linker_options = \
#linker_options = \
#
"-Wl,-F.,-w -bundle -framework Python" \
#
"-Wl,-F.,-w -bundle -framework Python" \
#
.split()
#
.split()
class
CCompilerError
(
PyrexError
):
class
CCompilerError
(
PyrexError
):
pass
pass
...
...
Cython/Mac/TS_Misc_Suite.py
View file @
e908c0b9
...
@@ -27,10 +27,10 @@ class TS_Misc_Suite:
...
@@ -27,10 +27,10 @@ class TS_Misc_Suite:
_reply
,
_arguments
,
_attributes
=
self
.
send
(
_code
,
_subcode
,
_reply
,
_arguments
,
_attributes
=
self
.
send
(
_code
,
_subcode
,
_arguments
,
_attributes
)
_arguments
,
_attributes
)
#if _arguments.has_key('errn'):
#if _arguments.has_key('errn'):
#
raise aetools.Error, aetools.decodeerror(_arguments)
#
raise aetools.Error, aetools.decodeerror(_arguments)
# XXXX Optionally decode result
# XXXX Optionally decode result
#if _arguments.has_key('----'):
#if _arguments.has_key('----'):
#
return _arguments['----']
#
return _arguments['----']
errn
=
0
errn
=
0
stat
=
0
stat
=
0
stdout
=
""
stdout
=
""
...
...
Cython/Plex/DFA.py
View file @
e908c0b9
...
@@ -126,12 +126,12 @@ class StateMap:
...
@@ -126,12 +126,12 @@ class StateMap:
best_priority
=
priority
best_priority
=
priority
return
best_action
return
best_action
#
def old_to_new_set(self, old_state_set):
#
def old_to_new_set(self, old_state_set):
#
"""
#
"""
#
Return the new state corresponding to a set of old states as
#
Return the new state corresponding to a set of old states as
#
a singleton set.
#
a singleton set.
#
"""
#
"""
#
return {self.old_to_new(old_state_set):1}
#
return {self.old_to_new(old_state_set):1}
def
new_to_old
(
self
,
new_state
):
def
new_to_old
(
self
,
new_state
):
"""Given a new state, return a set of corresponding old states."""
"""Given a new state, return a set of corresponding old states."""
...
...
Cython/Plex/Machines.py
View file @
e908c0b9
...
@@ -101,12 +101,12 @@ class Node:
...
@@ -101,12 +101,12 @@ class Node:
def
get_action_priority
(
self
):
def
get_action_priority
(
self
):
return
self
.
action_priority
return
self
.
action_priority
#
def merge_actions(self, other_state):
#
def merge_actions(self, other_state):
#
"""Merge actions of other state into this state according
#
"""Merge actions of other state into this state according
# to their priorities."""
# to their priorities."""
#
action = other_state.get_action()
#
action = other_state.get_action()
#
priority = other_state.get_action_priority()
#
priority = other_state.get_action_priority()
#
self.set_action(action, priority)
#
self.set_action(action, priority)
def
is_accepting
(
self
):
def
is_accepting
(
self
):
return
self
.
action
is
not
None
return
self
.
action
is
not
None
...
@@ -119,7 +119,7 @@ class Node:
...
@@ -119,7 +119,7 @@ class Node:
# Header
# Header
file
.
write
(
" State %d:
\
n
"
%
self
.
number
)
file
.
write
(
" State %d:
\
n
"
%
self
.
number
)
# Transitions
# Transitions
#
self.dump_transitions(file)
#
self.dump_transitions(file)
self
.
transitions
.
dump
(
file
)
self
.
transitions
.
dump
(
file
)
# Action
# Action
action
=
self
.
action
action
=
self
.
action
...
...
Cython/Plex/Regexps.py
View file @
e908c0b9
#=======================================================================
#=======================================================================
#
#
#
Python Lexical Analyser
#
Python Lexical Analyser
#
#
#
Regular Expressions
#
Regular Expressions
#
#
#=======================================================================
#=======================================================================
...
@@ -14,7 +14,7 @@ from sys import maxint
...
@@ -14,7 +14,7 @@ from sys import maxint
import
Errors
import
Errors
#
#
#
Constants
#
Constants
#
#
BOL
=
'bol'
BOL
=
'bol'
...
@@ -24,7 +24,7 @@ EOF = 'eof'
...
@@ -24,7 +24,7 @@ EOF = 'eof'
nl_code
=
ord
(
'
\
n
'
)
nl_code
=
ord
(
'
\
n
'
)
#
#
#
Helper functions
#
Helper functions
#
#
def
chars_to_ranges
(
s
):
def
chars_to_ranges
(
s
):
...
@@ -98,20 +98,20 @@ def CodeRange(code1, code2):
...
@@ -98,20 +98,20 @@ def CodeRange(code1, code2):
return
RawCodeRange
(
code1
,
code2
)
return
RawCodeRange
(
code1
,
code2
)
#
#
#
Abstract classes
#
Abstract classes
#
#
class
RE
:
class
RE
:
"""RE is the base class for regular expression constructors.
"""RE is the base class for regular expression constructors.
The following operators are defined on REs:
The following operators are defined on REs:
re1 + re2
is an RE which matches |re1| followed by |re2|
re1 + re2
is an RE which matches |re1| followed by |re2|
re1 | re2
is an RE which matches either |re1| or |re2|
re1 | re2
is an RE which matches either |re1| or |re2|
"""
"""
nullable
=
1
# True if this RE can match 0 input symbols
nullable
=
1
# True if this RE can match 0 input symbols
match_nl
=
1
# True if this RE can match a string ending with '\n'
match_nl
=
1
# True if this RE can match a string ending with '\n'
str
=
None
# Set to a string to override the class's __str__ result
str
=
None
# Set to a string to override the class's __str__ result
def
build_machine
(
self
,
machine
,
initial_state
,
final_state
,
def
build_machine
(
self
,
machine
,
initial_state
,
final_state
,
match_bol
,
nocase
):
match_bol
,
nocase
):
...
@@ -173,42 +173,42 @@ class RE:
...
@@ -173,42 +173,42 @@ class RE:
num
,
self
.
__class__
.
__name__
,
expected
,
got
))
num
,
self
.
__class__
.
__name__
,
expected
,
got
))
#
#
#
Primitive RE constructors
#
Primitive RE constructors
#
-------------------------
#
-------------------------
#
#
#
These are the basic REs from which all others are built.
#
These are the basic REs from which all others are built.
#
#
## class Char(RE):
## class Char(RE):
##
"""
##
"""
##
Char(c) is an RE which matches the character |c|.
##
Char(c) is an RE which matches the character |c|.
##
"""
##
"""
##
nullable = 0
##
nullable = 0
##
def __init__(self, char):
##
def __init__(self, char):
##
self.char = char
##
self.char = char
##
self.match_nl = char == '\n'
##
self.match_nl = char == '\n'
##
def build_machine(self, m, initial_state, final_state, match_bol, nocase):
##
def build_machine(self, m, initial_state, final_state, match_bol, nocase):
##
c = self.char
##
c = self.char
##
if match_bol and c != BOL:
##
if match_bol and c != BOL:
##
s1 = self.build_opt(m, initial_state, BOL)
##
s1 = self.build_opt(m, initial_state, BOL)
##
else:
##
else:
##
s1 = initial_state
##
s1 = initial_state
##
if c == '\n' or c == EOF:
##
if c == '\n' or c == EOF:
##
s1 = self.build_opt(m, s1, EOL)
##
s1 = self.build_opt(m, s1, EOL)
##
if len(c) == 1:
##
if len(c) == 1:
##
code = ord(self.char)
##
code = ord(self.char)
##
s1.add_transition((code, code+1), final_state)
##
s1.add_transition((code, code+1), final_state)
##
if nocase and is_letter_code(code):
##
if nocase and is_letter_code(code):
##
code2 = other_case_code(code)
##
code2 = other_case_code(code)
##
s1.add_transition((code2, code2+1), final_state)
##
s1.add_transition((code2, code2+1), final_state)
##
else:
##
else:
##
s1.add_transition(c, final_state)
##
s1.add_transition(c, final_state)
##
def calc_str(self):
##
def calc_str(self):
##
return "Char(%s)" % repr(self.char)
##
return "Char(%s)" % repr(self.char)
def
Char
(
c
):
def
Char
(
c
):
"""
"""
...
@@ -229,7 +229,7 @@ class RawCodeRange(RE):
...
@@ -229,7 +229,7 @@ class RawCodeRange(RE):
"""
"""
nullable
=
0
nullable
=
0
match_nl
=
0
match_nl
=
0
range
=
None
# (code, code)
range
=
None
# (code, code)
uppercase_range
=
None
# (code, code) or None
uppercase_range
=
None
# (code, code) or None
lowercase_range
=
None
# (code, code) or None
lowercase_range
=
None
# (code, code) or None
...
@@ -420,10 +420,10 @@ class SwitchCase(RE):
...
@@ -420,10 +420,10 @@ class SwitchCase(RE):
return
"%s(%s)"
%
(
name
,
self
.
re
)
return
"%s(%s)"
%
(
name
,
self
.
re
)
#
#
#
Composite RE constructors
#
Composite RE constructors
#
-------------------------
#
-------------------------
#
#
#
These REs are defined in terms of the primitive REs.
#
These REs are defined in terms of the primitive REs.
#
#
Empty
=
Seq
()
Empty
=
Seq
()
...
@@ -531,7 +531,7 @@ def Case(re):
...
@@ -531,7 +531,7 @@ def Case(re):
return
SwitchCase
(
re
,
nocase
=
0
)
return
SwitchCase
(
re
,
nocase
=
0
)
#
#
#
RE Constants
#
RE Constants
#
#
Bol
=
Char
(
BOL
)
Bol
=
Char
(
BOL
)
...
...
Cython/Plex/Scanners.py
View file @
e908c0b9
...
@@ -130,10 +130,10 @@ class Scanner:
...
@@ -130,10 +130,10 @@ class Scanner:
self
.
start_pos
=
self
.
cur_pos
self
.
start_pos
=
self
.
cur_pos
self
.
start_line
=
self
.
cur_line
self
.
start_line
=
self
.
cur_line
self
.
start_col
=
self
.
cur_pos
-
self
.
cur_line_start
self
.
start_col
=
self
.
cur_pos
-
self
.
cur_line_start
#
if self.trace:
#
if self.trace:
#
action = self.run_machine()
#
action = self.run_machine()
#
else:
#
else:
#
action = self.run_machine_inlined()
#
action = self.run_machine_inlined()
action
=
self
.
run_machine_inlined
()
action
=
self
.
run_machine_inlined
()
if
action
:
if
action
:
if
self
.
trace
:
if
self
.
trace
:
...
@@ -257,48 +257,48 @@ class Scanner:
...
@@ -257,48 +257,48 @@ class Scanner:
self
.
cur_line_start
=
cur_line_start
self
.
cur_line_start
=
cur_line_start
self
.
cur_char
=
cur_char
self
.
cur_char
=
cur_char
self
.
input_state
=
input_state
self
.
input_state
=
input_state
self
.
next_pos
=
next_pos
self
.
next_pos
=
next_pos
if
trace
:
#TRACE#
if
trace
:
#TRACE#
if
action
:
#TRACE#
if
action
:
#TRACE#
print
(
"Doing "
+
action
)
#TRACE#
print
(
"Doing "
+
action
)
#TRACE#
return
action
return
action
#
def transition(self):
#
def transition(self):
#
self.save_for_backup()
#
self.save_for_backup()
#
c = self.cur_char
#
c = self.cur_char
#
new_state = self.state.new_state(c)
#
new_state = self.state.new_state(c)
#
if new_state:
#
if new_state:
#
if self.trace:
#
if self.trace:
#
print "Scanner: read: State %d: %s --> State %d" % (
#
print "Scanner: read: State %d: %s --> State %d" % (
#
self.state.number, repr(c), new_state.number)
#
self.state.number, repr(c), new_state.number)
#
self.state = new_state
#
self.state = new_state
#
self.next_char()
#
self.next_char()
#
return 1
#
return 1
#
else:
#
else:
#
if self.trace:
#
if self.trace:
#
print "Scanner: read: State %d: %s --> blocked" % (
#
print "Scanner: read: State %d: %s --> blocked" % (
#
self.state.number, repr(c))
#
self.state.number, repr(c))
#
return 0
#
return 0
#
def save_for_backup(self):
#
def save_for_backup(self):
#
action = self.state.get_action()
#
action = self.state.get_action()
#
if action:
#
if action:
#
if self.trace:
#
if self.trace:
#
print "Scanner: read: Saving backup point at", self.cur_pos
#
print "Scanner: read: Saving backup point at", self.cur_pos
#
self.backup_state = (
#
self.backup_state = (
#
action, self.cur_pos, self.cur_line, self.cur_line_start,
#
action, self.cur_pos, self.cur_line, self.cur_line_start,
#
self.cur_char, self.input_state, self.next_pos)
#
self.cur_char, self.input_state, self.next_pos)
#
def back_up(self):
#
def back_up(self):
#
backup_state = self.backup_state
#
backup_state = self.backup_state
#
if backup_state:
#
if backup_state:
#
(action, self.cur_pos, self.cur_line, self.cur_line_start,
#
(action, self.cur_pos, self.cur_line, self.cur_line_start,
#
self.cur_char, self.input_state, self.next_pos) = backup_state
#
self.cur_char, self.input_state, self.next_pos) = backup_state
#
if self.trace:
#
if self.trace:
#
print "Scanner: read: Backing up to", self.cur_pos
#
print "Scanner: read: Backing up to", self.cur_pos
#
return action
#
return action
#
else:
#
else:
#
return None
#
return None
def
next_char
(
self
):
def
next_char
(
self
):
input_state
=
self
.
input_state
input_state
=
self
.
input_state
...
@@ -331,24 +331,24 @@ class Scanner:
...
@@ -331,24 +331,24 @@ class Scanner:
if
self
.
trace
:
if
self
.
trace
:
print
(
"--> [%d] %d %s"
%
(
input_state
,
self
.
cur_pos
,
repr
(
self
.
cur_char
)))
print
(
"--> [%d] %d %s"
%
(
input_state
,
self
.
cur_pos
,
repr
(
self
.
cur_char
)))
#
def read_char(self):
#
def read_char(self):
#
"""
#
"""
# Get the next input character, filling the buffer if necessary.
# Get the next input character, filling the buffer if necessary.
# Returns '' at end of file.
# Returns '' at end of file.
# """
# """
#
next_pos = self.next_pos
#
next_pos = self.next_pos
#
buf_index = next_pos - self.buf_start_pos
#
buf_index = next_pos - self.buf_start_pos
#
if buf_index == len(self.buffer):
#
if buf_index == len(self.buffer):
#
discard = self.start_pos - self.buf_start_pos
#
discard = self.start_pos - self.buf_start_pos
#
data = self.stream.read(0x1000)
#
data = self.stream.read(0x1000)
#
self.buffer = self.buffer[discard:] + data
#
self.buffer = self.buffer[discard:] + data
#
self.buf_start_pos = self.buf_start_pos + discard
#
self.buf_start_pos = self.buf_start_pos + discard
#
buf_index = buf_index - discard
#
buf_index = buf_index - discard
#
if not data:
#
if not data:
#
return ''
#
return ''
#
c = self.buffer[buf_index]
#
c = self.buffer[buf_index]
#
self.next_pos = next_pos + 1
#
self.next_pos = next_pos + 1
#
return c
#
return c
def
position
(
self
):
def
position
(
self
):
"""
"""
...
...
Cython/Plex/Transitions.py
View file @
e908c0b9
...
@@ -239,8 +239,8 @@ class TransitionMap:
...
@@ -239,8 +239,8 @@ class TransitionMap:
#
#
#def merge_state_sets(set1, set2):
#def merge_state_sets(set1, set2):
#
for state in set2.keys():
#
for state in set2.keys():
#
set1[state] = 1
#
set1[state] = 1
def
state_set_str
(
set
):
def
state_set_str
(
set
):
state_list
=
set
.
keys
()
state_list
=
set
.
keys
()
...
...
pyximport/Setup.py
View file @
e908c0b9
...
@@ -30,6 +30,6 @@ setup(
...
@@ -30,6 +30,6 @@ setup(
# ("examples/dependencies",
# ("examples/dependencies",
# ["README", "test.pyx", "test.pyxdep", "header.h",
# ["README", "test.pyx", "test.pyxdep", "header.h",
# "header2.h", "header3.h", "header4.h"])
# "header2.h", "header3.h", "header4.h"])
#
],
#
],
py_modules
=
[
"pyximport"
,
"pyxbuild"
])
py_modules
=
[
"pyximport"
,
"pyxbuild"
])
pyximport/test/test_pyximport.py
View file @
e908c0b9
...
@@ -38,7 +38,7 @@ def test():
...
@@ -38,7 +38,7 @@ def test():
build_file
.
write
(
"""
build_file
.
write
(
"""
from distutils.extension import Extension
from distutils.extension import Extension
def make_ext(name, filename):
def make_ext(name, filename):
return Extension(name=name, sources=[filename])
return Extension(name=name, sources=[filename])
"""
)
"""
)
build_file
.
close
()
build_file
.
close
()
...
@@ -60,5 +60,5 @@ def make_ext(name, filename):
...
@@ -60,5 +60,5 @@ def make_ext(name, filename):
remove_tempdir
(
tempdir
)
remove_tempdir
(
tempdir
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test
()
test
()
pyximport/test/test_reload.py
View file @
e908c0b9
...
@@ -4,30 +4,30 @@ import test_pyximport
...
@@ -4,30 +4,30 @@ import test_pyximport
# debugging the 2.2 problem
# debugging the 2.2 problem
if
1
:
if
1
:
from
distutils
import
sysconfig
from
distutils
import
sysconfig
try
:
try
:
sysconfig
.
set_python_build
()
sysconfig
.
set_python_build
()
except
AttributeError
:
except
AttributeError
:
pass
pass
import
pyxbuild
import
pyxbuild
print
pyxbuild
.
distutils
.
sysconfig
==
sysconfig
print
pyxbuild
.
distutils
.
sysconfig
==
sysconfig
def
test
():
def
test
():
tempdir
=
test_pyximport
.
make_tempdir
()
tempdir
=
test_pyximport
.
make_tempdir
()
sys
.
path
.
append
(
tempdir
)
sys
.
path
.
append
(
tempdir
)
hello_file
=
os
.
path
.
join
(
tempdir
,
"hello.pyx"
)
hello_file
=
os
.
path
.
join
(
tempdir
,
"hello.pyx"
)
open
(
hello_file
,
"w"
).
write
(
"x = 1; print x; before = 'before'
\
n
"
)
open
(
hello_file
,
"w"
).
write
(
"x = 1; print x; before = 'before'
\
n
"
)
import
hello
import
hello
assert
hello
.
x
==
1
assert
hello
.
x
==
1
time
.
sleep
(
1
)
# sleep to make sure that new "hello.pyx" has later
time
.
sleep
(
1
)
# sleep to make sure that new "hello.pyx" has later
# timestamp than object file.
# timestamp than object file.
open
(
hello_file
,
"w"
).
write
(
"x = 2; print x; after = 'after'
\
n
"
)
open
(
hello_file
,
"w"
).
write
(
"x = 2; print x; after = 'after'
\
n
"
)
reload
(
hello
)
reload
(
hello
)
assert
hello
.
x
==
2
,
"Reload should work on Python 2.3 but not 2.2"
assert
hello
.
x
==
2
,
"Reload should work on Python 2.3 but not 2.2"
test_pyximport
.
remove_tempdir
(
tempdir
)
test_pyximport
.
remove_tempdir
(
tempdir
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test
()
test
()
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