@@ -35,6 +35,14 @@ cdef extern from * nogil:
3535 cdef const GDNativeExtensionClassLibraryPtr pythonscript_gdlibrary
3636
3737
38+ ##############################################################################
39+ # Conversion helpers #
40+ ##############################################################################
41+
42+
43+ {% include 'gdapi.conversion.pxd.j2' %}
44+
45+
3846##############################################################################
3947# Builtins #
4048##############################################################################
@@ -52,10 +60,6 @@ cdef extern from *:
5260{% endfor %}
5361
5462
55- # String conversion helpers defined in the jungle below
56- # gd_string_t gd_string_from_utf8(const char *cstr, size_t cstr_size)
57- # gd_string_t gd_string_from_pystr(object pystr)
58- # object gd_string_to_pystr(gd_string_t *gdstr)
5963{% for spec in api ["builtins" ] if not spec .is_scalar %}
6064
6165
@@ -110,34 +114,6 @@ cdef extern from *:
110114# and nicer inline function
111115
112116
113- ##############################################################################
114- # Inline defs: String conversion helpers #
115- ##############################################################################
116-
117-
118- cdef extern from "Python.h":
119- const char* PyUnicode_AsUTF8AndSize(object, size_t*)
120- object PyUnicode_DecodeUTF32(const char *s, size_t size, const char *errors, int *byteorder)
121-
122-
123- cdef inline gd_string_t gd_string_from_utf8(const char *cstr, size_t cstr_size):
124- cdef gd_string_t gdstr
125- pythonscript_gdapi.string_new_with_utf8_chars_and_len(&gdstr, cstr, cstr_size)
126- return gdstr
127-
128-
129- cdef inline gd_string_t gd_string_from_unchecked_pystr(object pystr):
130- cdef size_t buffsize
131- cdef const char *buff = PyUnicode_AsUTF8AndSize(pystr, &buffsize)
132- return gd_string_from_utf8(buff, buffsize)
133-
134-
135- cdef inline object gd_string_to_pystr(gd_string_t *gdstr):
136- cdef GDNativeInt l = pythonscript_gdapi.string_to_utf32_chars(gdstr, NULL, 0)
137- cdef const char32_t *gdbuff = pythonscript_gdapi.string_operator_index_const(gdstr, 0)
138- return PyUnicode_DecodeUTF32(<char * >gdbuff, l * cython.sizeof(char32_t), NULL, NULL)
139-
140-
141117##############################################################################
142118# Inline defs: Utility functions #
143119##############################################################################
0 commit comments