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

Side by Side Diff: swig/Lib/python/jstring.i

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, 10 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/implicit.i ('k') | swig/Lib/python/pyabc.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 %include <typemaps/valtypes.swg>
2
3 %fragment(SWIG_AsVal_frag(jstring),"header") {
4 SWIGINTERN int
5 SWIG_AsVal(jstring)(PyObject *obj, jstring *val)
6 {
7 if (obj == Py_None) {
8 if (val) *val = 0;
9 return SWIG_OK;
10 }
11
12 PyObject *tmp = 0;
13 int isunicode = PyUnicode_Check(obj);
14 if (!isunicode && PyString_Check(obj)) {
15 if (val) {
16 obj = tmp = PyUnicode_FromObject(obj);
17 }
18 isunicode = 1;
19 }
20 if (isunicode) {
21 if (val) {
22 if (sizeof(Py_UNICODE) == sizeof(jchar)) {
23 *val = JvNewString((const jchar *) PyUnicode_AS_UNICODE(obj),PyUnicode_G ET_SIZE(obj));
24 return SWIG_NEWOBJ;
25 } else {
26 int len = PyUnicode_GET_SIZE(obj);
27 Py_UNICODE *pchars = PyUnicode_AS_UNICODE(obj);
28 *val = JvAllocString (len);
29 jchar *jchars = JvGetStringChars (*val);
30 for (int i = 0; i < len; ++i) {
31 jchars[i] = pchars[i];
32 }
33 return SWIG_NEWOBJ;
34 }
35 }
36 Py_XDECREF(tmp);
37 return SWIG_OK;
38 }
39 return SWIG_TypeError;
40 }
41 }
42
43 %fragment(SWIG_From_frag(jstring),"header") {
44 SWIGINTERNINLINE PyObject *
45 SWIG_From(jstring)(jstring val)
46 {
47 if (!val) {
48 return SWIG_Py_Void();
49 }
50 if (sizeof(Py_UNICODE) == sizeof(jchar)) {
51 return PyUnicode_FromUnicode((const Py_UNICODE *) JvGetStringChars(val),
52 JvGetStringUTFLength(val));
53 } else {
54 int len = JvGetStringUTFLength(val);
55 Py_UNICODE pchars[len];
56 jchar *jchars = JvGetStringChars(val);
57
58 for (int i = 0; i < len; i++) {
59 pchars[i] = jchars[i];
60 }
61 return PyUnicode_FromUnicode((const Py_UNICODE *) pchars, len);
62 }
63 }
64 }
65
66 %typemaps_asvalfrom(%checkcode(STRING),
67 %arg(SWIG_AsVal(jstring)),
68 %arg(SWIG_From(jstring)),
69 %arg(SWIG_AsVal_frag(jstring)),
70 %arg(SWIG_From_frag(jstring)),
71 java::lang::String *);
72
OLDNEW
« no previous file with comments | « swig/Lib/python/implicit.i ('k') | swig/Lib/python/pyabc.i » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698