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