[PATCH] util.h: Defined macros for working with strings using the python C API

Renato Cunha renatoc at gmail.com
Thu Jun 17 16:46:45 CDT 2010


# HG changeset patch
# User Renato Cunha <renatoc at gmail.com>
# Date 1276805424 10800
# Node ID 0d5fe990dc8d42f69ee3ac5da3fc21050a56b6b1
# Parent  7d74873cb3f7ecdf59db6d5ad8ee5316d1578741
util.h: Defined macros for working with strings using the python C API.

diff --git a/mercurial/util.h b/mercurial/util.h
--- a/mercurial/util.h
+++ b/mercurial/util.h
@@ -11,9 +11,48 @@
 #if PY_MAJOR_VERSION >= 3
 
 #define IS_PY3K
+
 #define PyInt_FromLong PyLong_FromLong
 #define PyInt_AsLong PyLong_AsLong
 
+/*
+ PyString stuff designed to be the string equivalent of the bytes strings
+ below
+*/
+
+#define PyStringObject PyUnicodeObject
+#define PyString_Type PyUnicode_Type
+
+#define PyString_Check PyUnicode_Check
+#define PyString_CheckExact PyUnicode_CheckExact
+#define PyString_CHECK_INTERNED PyUnicode_CHECK_INTERNED
+#define PyString_AS_STRING PyUnicode_AsLatin1String
+#define PyString_GET_SIZE PyUnicode_GET_SIZE
+
+#define PyString_FromStringAndSize PyUnicode_FromStringAndSize
+#define PyString_FromString PyUnicode_FromString
+#define PyString_FromFormatV PyUnicode_FromFormatV
+#define PyString_FromFormat PyUnicode_FromFormat
+//#define PyString_Size PyUnicode_GET_SIZE
+#define PyString_AsString(string) PyBytes_AsString(PyUnicode_AsLatin1String(string))
+//#define PyString_Repr
+#define PyString_Concat PyUnicode_Concat
+#define PyString_ConcatAndDel PyUnicode_AppendAndDel
+#define _PyString_Resize PyUnicode_Resize
+//#define _PyString_Eq
+#define PyString_Format PyUnicode_Format
+//#define _PyString_FormatLong
+//#define PyString_DecodeEscape
+#define _PyString_Join PyUnicode_Join
+#define PyString_Decode PyUnicode_Decode
+#define PyString_Encode PyUnicode_Encode
+#define PyString_AsEncodedObject PyUnicode_AsEncodedObject
+#define PyString_AsEncodedString PyUnicode_AsEncodedString
+#define PyString_AsDecodedObject PyUnicode_AsDecodedObject
+#define PyString_AsDecodedString PyUnicode_AsDecodedUnicode
+//#define PyString_AsStringAndSize
+#define _PyString_InsertThousandsGrouping _PyUnicode_InsertThousandsGrouping
+
 #endif /* PY_MAJOR_VERSION */
 
 /* Backports from 2.6 */


More information about the Mercurial-devel mailing list