Commit dc914e07 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Copied over CPython's str.__mod__

parent c3a27c8b
...@@ -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 */
...@@ -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, const char**, 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 *);
......
...@@ -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) {
......
...@@ -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:
......
This diff is collapsed.
...@@ -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"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment