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
dcc84ee5
Commit
dcc84ee5
authored
Aug 08, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up and fix docstring serialisation (some are const, some are not)
parent
8dc18957
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
23 deletions
+23
-23
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+0
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+6
-3
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-4
Cython/Compiler/StringEncoding.py
Cython/Compiler/StringEncoding.py
+7
-0
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+5
-7
No files found.
Cython/Compiler/Code.py
View file @
dcc84ee5
...
@@ -1180,11 +1180,6 @@ class GlobalState(object):
...
@@ -1180,11 +1180,6 @@ class GlobalState(object):
def
get_interned_identifier
(
self
,
text
):
def
get_interned_identifier
(
self
,
text
):
return
self
.
get_py_string_const
(
text
,
identifier
=
True
)
return
self
.
get_py_string_const
(
text
,
identifier
=
True
)
def
as_c_string_literal
(
self
,
byte_string
):
value
=
StringEncoding
.
split_string_literal
(
StringEncoding
.
escape_byte_string
(
byte_string
.
byteencode
()))
return
'"%s"'
%
value
def
new_string_const
(
self
,
text
,
byte_string
):
def
new_string_const
(
self
,
text
,
byte_string
):
cname
=
self
.
new_string_const_cname
(
byte_string
)
cname
=
self
.
new_string_const_cname
(
byte_string
)
c
=
StringConst
(
cname
,
text
,
byte_string
)
c
=
StringConst
(
cname
,
text
,
byte_string
)
...
@@ -1644,9 +1639,6 @@ class CCodeWriter(object):
...
@@ -1644,9 +1639,6 @@ class CCodeWriter(object):
return
self
.
globalstate
.
get_py_string_const
(
return
self
.
globalstate
.
get_py_string_const
(
text
,
identifier
,
is_str
,
unicode_value
).
cname
text
,
identifier
,
is_str
,
unicode_value
).
cname
def
as_c_string_literal
(
self
,
text
):
return
self
.
globalstate
.
as_c_string_literal
(
text
)
def
get_argument_default_const
(
self
,
type
):
def
get_argument_default_const
(
self
,
type
):
return
self
.
globalstate
.
get_py_const
(
type
).
cname
return
self
.
globalstate
.
get_py_const
(
type
).
cname
...
...
Cython/Compiler/ExprNodes.py
View file @
dcc84ee5
...
@@ -1344,7 +1344,7 @@ class BytesNode(ConstNode):
...
@@ -1344,7 +1344,7 @@ class BytesNode(ConstNode):
result
=
code
.
get_string_const
(
self
.
value
)
result
=
code
.
get_string_const
(
self
.
value
)
else
:
else
:
# not const => use plain C string literal and cast to mutable type
# not const => use plain C string literal and cast to mutable type
literal
=
code
.
as_c_string_literal
(
self
.
value
)
literal
=
self
.
value
.
as_c_string_literal
(
)
# C++ may require a cast
# C++ may require a cast
result
=
typecast
(
self
.
type
,
PyrexTypes
.
c_void_ptr_type
,
literal
)
result
=
typecast
(
self
.
type
,
PyrexTypes
.
c_void_ptr_type
,
literal
)
self
.
result_code
=
result
self
.
result_code
=
result
...
...
Cython/Compiler/ModuleNode.py
View file @
dcc84ee5
...
@@ -1949,12 +1949,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1949,12 +1949,15 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"static struct PyGetSetDef %s[] = {"
%
"static struct PyGetSetDef %s[] = {"
%
env
.
getset_table_cname
)
env
.
getset_table_cname
)
for
entry
in
env
.
property_entries
:
for
entry
in
env
.
property_entries
:
if
entry
.
doc
:
doc
=
entry
.
doc
doc_code
=
"%s"
%
code
.
get_string_const
(
entry
.
doc
)
if
doc
:
if
doc
.
is_unicode
:
doc
=
doc
.
as_utf8_string
()
doc_code
=
doc
.
as_c_string_literal
()
else
:
else
:
doc_code
=
"0"
doc_code
=
"0"
code
.
putln
(
code
.
putln
(
'{(char *)"%s", %s, %s, %s, 0},'
%
(
'{(char *)"%s", %s, %s,
(char *)
%s, 0},'
%
(
entry
.
name
,
entry
.
name
,
entry
.
getter_cname
or
"0"
,
entry
.
getter_cname
or
"0"
,
entry
.
setter_cname
or
"0"
,
entry
.
setter_cname
or
"0"
,
...
...
Cython/Compiler/Nodes.py
View file @
dcc84ee5
...
@@ -29,7 +29,7 @@ from .PyrexTypes import py_object_type, error_type
...
@@ -29,7 +29,7 @@ from .PyrexTypes import py_object_type, error_type
from
.Symtab
import
(
ModuleScope
,
LocalScope
,
ClosureScope
,
from
.Symtab
import
(
ModuleScope
,
LocalScope
,
ClosureScope
,
StructOrUnionScope
,
PyClassScope
,
CppClassScope
,
TemplateScope
)
StructOrUnionScope
,
PyClassScope
,
CppClassScope
,
TemplateScope
)
from
.Code
import
UtilityCode
from
.Code
import
UtilityCode
from
.StringEncoding
import
EncodedString
,
escape_byte_string
,
split_string_literal
from
.StringEncoding
import
EncodedString
from
.
import
Future
from
.
import
Future
from
.
import
Options
from
.
import
Options
from
.
import
DebugFlags
from
.
import
DebugFlags
...
@@ -3318,12 +3318,12 @@ class DefNodeWrapper(FuncDefNode):
...
@@ -3318,12 +3318,12 @@ class DefNodeWrapper(FuncDefNode):
docstr
=
entry
.
doc
docstr
=
entry
.
doc
if
docstr
.
is_unicode
:
if
docstr
.
is_unicode
:
docstr
=
docstr
.
utf8encode
()
docstr
=
docstr
.
as_utf8_string
()
code
.
putln
(
code
.
putln
(
'static char %s[] =
"%s"
;'
%
(
'static char %s[] =
%s
;'
%
(
entry
.
doc_cname
,
entry
.
doc_cname
,
split_string_literal
(
escape_byte_string
(
docstr
)
)))
docstr
.
as_c_string_literal
(
)))
if
entry
.
is_special
:
if
entry
.
is_special
:
code
.
putln
(
'#if CYTHON_COMPILING_IN_CPYTHON'
)
code
.
putln
(
'#if CYTHON_COMPILING_IN_CPYTHON'
)
...
...
Cython/Compiler/StringEncoding.py
View file @
dcc84ee5
...
@@ -136,6 +136,9 @@ class EncodedString(_unicode):
...
@@ -136,6 +136,9 @@ class EncodedString(_unicode):
def
contains_surrogates
(
self
):
def
contains_surrogates
(
self
):
return
string_contains_surrogates
(
self
)
return
string_contains_surrogates
(
self
)
def
as_utf8_string
(
self
):
return
BytesLiteral
(
self
.
utf8encode
())
def
string_contains_surrogates
(
ustring
):
def
string_contains_surrogates
(
ustring
):
"""
"""
...
@@ -177,6 +180,10 @@ class BytesLiteral(_bytes):
...
@@ -177,6 +180,10 @@ class BytesLiteral(_bytes):
is_unicode
=
False
is_unicode
=
False
def
as_c_string_literal
(
self
):
value
=
split_string_literal
(
escape_byte_string
(
self
))
return
'"%s"'
%
value
char_from_escape_sequence
=
{
char_from_escape_sequence
=
{
r'\a'
:
u'
\
a
'
,
r'\a'
:
u'
\
a
'
,
...
...
Cython/Compiler/TypeSlots.py
View file @
dcc84ee5
...
@@ -416,14 +416,12 @@ class DocStringSlot(SlotDescriptor):
...
@@ -416,14 +416,12 @@ class DocStringSlot(SlotDescriptor):
# Descriptor for the docstring slot.
# Descriptor for the docstring slot.
def
slot_code
(
self
,
scope
):
def
slot_code
(
self
,
scope
):
if
scope
.
doc
is
not
None
:
doc
=
scope
.
doc
if
scope
.
doc
.
is_unicode
:
if
doc
is
None
:
doc
=
scope
.
doc
.
utf8encode
()
else
:
doc
=
scope
.
doc
.
byteencode
()
return
'"%s"'
%
StringEncoding
.
escape_byte_string
(
doc
)
else
:
return
"0"
return
"0"
if
doc
.
is_unicode
:
doc
=
doc
.
as_utf8_string
()
return
doc
.
as_c_string_literal
()
class
SuiteSlot
(
SlotDescriptor
):
class
SuiteSlot
(
SlotDescriptor
):
...
...
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