Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
a91f0526
Commit
a91f0526
authored
Mar 08, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unichr()
parent
4480e933
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+12
-0
test/tests/unicode_test.py
test/tests/unicode_test.py
+2
-0
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
a91f0526
...
@@ -349,6 +349,16 @@ extern "C" Box* chr(Box* arg) {
...
@@ -349,6 +349,16 @@ extern "C" Box* chr(Box* arg) {
return
boxString
(
std
::
string
(
1
,
(
char
)
n
));
return
boxString
(
std
::
string
(
1
,
(
char
)
n
));
}
}
extern
"C"
Box
*
unichr
(
Box
*
arg
)
{
if
(
arg
->
cls
!=
int_cls
)
raiseExcHelper
(
TypeError
,
"an integer is required"
);
i64
n
=
static_cast
<
BoxedInt
*>
(
arg
)
->
n
;
Box
*
rtn
=
PyUnicode_FromOrdinal
(
n
);
checkAndThrowCAPIException
();
return
rtn
;
}
extern
"C"
Box
*
ord
(
Box
*
obj
)
{
extern
"C"
Box
*
ord
(
Box
*
obj
)
{
long
ord
;
long
ord
;
Py_ssize_t
size
;
Py_ssize_t
size
;
...
@@ -1022,6 +1032,8 @@ void setupBuiltins() {
...
@@ -1022,6 +1032,8 @@ void setupBuiltins() {
builtins_module
->
giveAttr
(
"id"
,
id_obj
);
builtins_module
->
giveAttr
(
"id"
,
id_obj
);
chr_obj
=
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
chr
,
STR
,
1
),
"chr"
);
chr_obj
=
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
chr
,
STR
,
1
),
"chr"
);
builtins_module
->
giveAttr
(
"chr"
,
chr_obj
);
builtins_module
->
giveAttr
(
"chr"
,
chr_obj
);
builtins_module
->
giveAttr
(
"unichr"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
unichr
,
UNKNOWN
,
1
),
"unichr"
));
ord_obj
=
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
ord
,
BOXED_INT
,
1
),
"ord"
);
ord_obj
=
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
ord
,
BOXED_INT
,
1
),
"ord"
);
builtins_module
->
giveAttr
(
"ord"
,
ord_obj
);
builtins_module
->
giveAttr
(
"ord"
,
ord_obj
);
trap_obj
=
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
trap
,
UNKNOWN
,
0
),
"trap"
);
trap_obj
=
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
trap
,
UNKNOWN
,
0
),
"trap"
);
...
...
test/tests/unicode_test.py
View file @
a91f0526
...
@@ -89,3 +89,5 @@ print "hello world".startswith(u'hello')
...
@@ -89,3 +89,5 @@ print "hello world".startswith(u'hello')
print
"hello world"
.
startswith
(
u'world'
)
print
"hello world"
.
startswith
(
u'world'
)
print
float
(
u'1.0'
)
print
float
(
u'1.0'
)
print
unichr
(
97
)
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