Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: swig/Lib/python/pywstrings.swg

Issue 553095: Checkin swig binaries for win, linux and Mac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « swig/Lib/python/pyuserdir.swg ('k') | swig/Lib/python/std_alloc.i » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* ------------------------------------------------------------
2 * utility methods for wchar_t strings
3 * ------------------------------------------------------------ */
4
5 %fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_ pwchar_descriptor") {
6 SWIGINTERN int
7 SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
8 {
9 PyObject *tmp = 0;
10 int isunicode = PyUnicode_Check(obj);
11 %#if PY_VERSION_HEX < 0x03000000
12 if (!isunicode && PyString_Check(obj)) {
13 if (cptr) {
14 obj = tmp = PyUnicode_FromObject(obj);
15 }
16 isunicode = 1;
17 }
18 %#endif
19 if (isunicode) {
20 Py_ssize_t len = PyUnicode_GetSize(obj);
21 if (cptr) {
22 *cptr = %new_array(len + 1, wchar_t);
23 PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
24 (*cptr)[len] = 0;
25 }
26 if (psize) *psize = (size_t) len + 1;
27 if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
28 Py_XDECREF(tmp);
29 return SWIG_OK;
30 } else {
31 swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
32 if (pwchar_descriptor) {
33 void * vptr = 0;
34 if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
35 if (cptr) *cptr = (wchar_t *)vptr;
36 if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
37 return SWIG_OK;
38 }
39 }
40 }
41 return SWIG_TypeError;
42 }
43 }
44
45 %fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWI G_pwchar_descriptor") {
46 SWIGINTERNINLINE PyObject *
47 SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
48 {
49 if (carray) {
50 if (size > INT_MAX) {
51 swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
52 return pwchar_descriptor ?
53 SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : SWIG_Py_Void();
54 } else {
55 return PyUnicode_FromWideChar(carray, %numeric_cast(size,int));
56 }
57 } else {
58 return SWIG_Py_Void();
59 }
60 }
61 }
62
63
OLDNEW
« no previous file with comments | « swig/Lib/python/pyuserdir.swg ('k') | swig/Lib/python/std_alloc.i » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698