summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorEric Smith <eric@trueblade.com>2008-05-30 18:10:04 (GMT)
committerEric Smith <eric@trueblade.com>2008-05-30 18:10:04 (GMT)
commitdc13b79a384691ed966f760a58d73a1b835e7d6b (patch)
tree40aa36feea2e0ee23f41801a8959990914e3fc71 /Include
parent30fadc17990baf4005081d2cdcb8d3adc9c45a7a (diff)
downloadcpython-dc13b79a384691ed966f760a58d73a1b835e7d6b.zip
cpython-dc13b79a384691ed966f760a58d73a1b835e7d6b.tar.gz
cpython-dc13b79a384691ed966f760a58d73a1b835e7d6b.tar.bz2
Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Diffstat (limited to 'Include')
-rw-r--r--Include/bytesobject.h6
-rw-r--r--Include/floatobject.h6
-rw-r--r--Include/formatter_string.h12
-rw-r--r--Include/formatter_unicode.h12
-rw-r--r--Include/intobject.h6
-rw-r--r--Include/longobject.h6
-rw-r--r--Include/unicodeobject.h6
7 files changed, 30 insertions, 24 deletions
diff --git a/Include/bytesobject.h b/Include/bytesobject.h
index 941577a..cb31da8 100644
--- a/Include/bytesobject.h
+++ b/Include/bytesobject.h
@@ -188,6 +188,12 @@ PyAPI_FUNC(int) _PyBytes_InsertThousandsGrouping(char *buffer,
Py_ssize_t *count,
int append_zero_char);
+/* Format the object based on the format_spec, as defined in PEP 3101
+ (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyBytes_FormatAdvanced(PyObject *obj,
+ char *format_spec,
+ Py_ssize_t format_spec_len);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/floatobject.h b/Include/floatobject.h
index 84398c2..04978be 100644
--- a/Include/floatobject.h
+++ b/Include/floatobject.h
@@ -115,6 +115,12 @@ PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le);
/* free list api */
PyAPI_FUNC(void) PyFloat_CompactFreeList(size_t *, size_t *, size_t *);
+/* Format the object based on the format_spec, as defined in PEP 3101
+ (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
+ char *format_spec,
+ Py_ssize_t format_spec_len);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/formatter_string.h b/Include/formatter_string.h
deleted file mode 100644
index 14c4811..0000000
--- a/Include/formatter_string.h
+++ /dev/null
@@ -1,12 +0,0 @@
-PyObject *
-string__format__(PyObject *self, PyObject *args);
-
-PyObject *
-string_long__format__(PyObject *self, PyObject *args);
-
-PyObject *
-string_int__format__(PyObject *self, PyObject *args);
-
-PyObject *
-string_float__format__(PyObject *self, PyObject *args);
-
diff --git a/Include/formatter_unicode.h b/Include/formatter_unicode.h
deleted file mode 100644
index 51406ab..0000000
--- a/Include/formatter_unicode.h
+++ /dev/null
@@ -1,12 +0,0 @@
-PyObject *
-unicode__format__(PyObject *self, PyObject *args);
-
-PyObject *
-unicode_long__format__(PyObject *self, PyObject *args);
-
-PyObject *
-unicode_int__format__(PyObject *self, PyObject *args);
-
-PyObject *
-unicode_float__format__(PyObject *self, PyObject *args);
-
diff --git a/Include/intobject.h b/Include/intobject.h
index 66a62d9..329ff45 100644
--- a/Include/intobject.h
+++ b/Include/intobject.h
@@ -68,6 +68,12 @@ PyAPI_FUNC(void) PyInt_CompactFreeList(size_t *, size_t *, size_t *);
a leading "0" */
PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle);
+/* Format the object based on the format_spec, as defined in PEP 3101
+ (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj,
+ char *format_spec,
+ Py_ssize_t format_spec_len);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/longobject.h b/Include/longobject.h
index 8a9e676..fa511a7 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -119,6 +119,12 @@ PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
a leading "0", instead of the prefix "0o" */
PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base, int addL, int newstyle);
+/* Format the object based on the format_spec, as defined in PEP 3101
+ (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
+ char *format_spec,
+ Py_ssize_t format_spec_len);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index d7ed0fa..057f770 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -553,6 +553,12 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromObject(
PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char*, va_list);
PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char*, ...);
+/* Format the object based on the format_spec, as defined in PEP 3101
+ (Advanced String Formatting). */
+PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj,
+ Py_UNICODE *format_spec,
+ Py_ssize_t format_spec_len);
+
/* --- wchar_t support for platforms which support it --------------------- */
#ifdef HAVE_WCHAR_H