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
dc914e07
Commit
dc914e07
authored
Dec 17, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copied over CPython's str.__mod__
parent
c3a27c8b
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
621 additions
and
174 deletions
+621
-174
include/pyport.h
include/pyport.h
+15
-0
include/stringobject.h
include/stringobject.h
+2
-1
src/runtime/capi.cpp
src/runtime/capi.cpp
+9
-2
src/runtime/int.cpp
src/runtime/int.cpp
+4
-0
src/runtime/str.cpp
src/runtime/str.cpp
+590
-171
test/tests/str_functions.py
test/tests/str_functions.py
+1
-0
No files found.
include/pyport.h
View file @
dc914e07
...
@@ -271,6 +271,21 @@ typedef ssize_t Py_ssize_t;
...
@@ -271,6 +271,21 @@ typedef ssize_t Py_ssize_t;
#endif
#endif
#endif
#endif
#if defined(_MSC_VER)
#define Py_MEMCPY(target, source, length) do { \
size_t i_, n_ = (length); \
char *t_ = (void*) (target); \
const char *s_ = (void*) (source); \
if (n_ >= 16) \
memcpy(t_, s_, n_); \
else \
for (i_ = 0; i_ < n_; i_++) \
t_[i_] = s_[i_]; \
} while (0)
#else
#define Py_MEMCPY memcpy
#endif
#endif
/* Py_PYPORT_H */
#endif
/* Py_PYPORT_H */
include/stringobject.h
View file @
dc914e07
...
@@ -86,8 +86,9 @@ PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
...
@@ -86,8 +86,9 @@ PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
PyAPI_FUNC
(
int
)
_PyString_Resize
(
PyObject
**
,
Py_ssize_t
);
PyAPI_FUNC
(
int
)
_PyString_Resize
(
PyObject
**
,
Py_ssize_t
);
PyAPI_FUNC
(
int
)
_PyString_Eq
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
int
)
_PyString_Eq
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyString_Format
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyString_Format
(
PyObject
*
,
PyObject
*
);
// Pyston change: added const
PyAPI_FUNC
(
PyObject
*
)
_PyString_FormatLong
(
PyObject
*
,
int
,
int
,
PyAPI_FUNC
(
PyObject
*
)
_PyString_FormatLong
(
PyObject
*
,
int
,
int
,
int
,
char
**
,
int
*
);
int
,
c
onst
c
har
**
,
int
*
);
PyAPI_FUNC
(
PyObject
*
)
PyString_DecodeEscape
(
const
char
*
,
Py_ssize_t
,
PyAPI_FUNC
(
PyObject
*
)
PyString_DecodeEscape
(
const
char
*
,
Py_ssize_t
,
const
char
*
,
Py_ssize_t
,
const
char
*
,
Py_ssize_t
,
const
char
*
);
const
char
*
);
...
...
src/runtime/capi.cpp
View file @
dc914e07
...
@@ -725,8 +725,15 @@ extern "C" void PyMem_Free(void* ptr) {
...
@@ -725,8 +725,15 @@ extern "C" void PyMem_Free(void* ptr) {
gc_compat_free
(
ptr
);
gc_compat_free
(
ptr
);
}
}
extern
"C"
int
PyNumber_Check
(
PyObject
*
)
{
extern
"C"
int
PyNumber_Check
(
PyObject
*
obj
)
{
Py_FatalError
(
"unimplemented"
);
assert
(
obj
&&
obj
->
cls
);
// Our check, since we don't currently fill in tp_as_number:
if
(
isSubclass
(
obj
->
cls
,
int_cls
)
||
isSubclass
(
obj
->
cls
,
long_cls
))
return
true
;
// The CPython check:
return
obj
->
cls
->
tp_as_number
&&
(
obj
->
cls
->
tp_as_number
->
nb_int
||
obj
->
cls
->
tp_as_number
->
nb_float
);
}
}
extern
"C"
PyObject
*
PyNumber_Add
(
PyObject
*
lhs
,
PyObject
*
rhs
)
{
extern
"C"
PyObject
*
PyNumber_Add
(
PyObject
*
lhs
,
PyObject
*
rhs
)
{
...
...
src/runtime/int.cpp
View file @
dc914e07
...
@@ -62,6 +62,10 @@ extern "C" PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int new
...
@@ -62,6 +62,10 @@ extern "C" PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int new
Py_FatalError
(
"unimplemented"
);
Py_FatalError
(
"unimplemented"
);
}
}
extern
"C"
int
_PyInt_AsInt
(
PyObject
*
)
{
Py_FatalError
(
"unimplemented"
);
}
BoxedInt
*
interned_ints
[
NUM_INTERNED_INTS
];
BoxedInt
*
interned_ints
[
NUM_INTERNED_INTS
];
// If we don't have fast overflow-checking builtins, provide some slow variants:
// If we don't have fast overflow-checking builtins, provide some slow variants:
...
...
src/runtime/str.cpp
View file @
dc914e07
This diff is collapsed.
Click to expand it.
test/tests/str_functions.py
View file @
dc914e07
...
@@ -80,3 +80,4 @@ print "hello world".partition("o")
...
@@ -80,3 +80,4 @@ print "hello world".partition("o")
print
"hello world"
[
False
:
True
:
True
]
print
"hello world"
[
False
:
True
:
True
]
print
"{hello}"
.
format
(
hello
=
"world"
)
print
"{hello}"
.
format
(
hello
=
"world"
)
print
"%.3s"
%
"hello world"
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