PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/trunk/Lib/ruby/rubywstrings.swg

#
Unknown | 72 lines | 67 code | 5 blank | 0 comment | 0 complexity | ec4eeabfa26b7dc8f7d5da43f9cd14c7 MD5 | raw file
 1/* -----------------------------------------------------------------------------
 2 * rubywstrings.swg
 3 *
 4 * Currently, Ruby does not support Unicode or WChar properly, so these
 5 * are still treated as char arrays for now.
 6 * There are other libraries available that add support to this in
 7 * ruby including WString, FXString, etc.
 8 * ----------------------------------------------------------------------------- */
 9
10/* ------------------------------------------------------------
11 *  utility methods for wchar_t strings 
12 * ------------------------------------------------------------ */
13
14%fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
15SWIGINTERN int
16SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc)
17{
18  return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc);
19//   VALUE tmp = 0;
20//   bool ok = false;
21//   if ( TYPE(obj) == T_STRING ) {
22//     if (cptr) {
23//       obj = tmp = SWIG_Unicode_FromObject(obj);
24//       ok = true;
25//     }
26//   }
27//   if (ok) {
28//     Py_ssize_t len = PyUnicode_GetSize(obj);
29//     rb_notimplement();
30//     if (cptr) {
31//       *cptr = %new_array(len + 1, wchar_t);
32//       SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
33//       (*cptr)[len] = 0;
34//     }
35//     if (psize) *psize = (size_t) len + 1;
36//     if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
37//     return SWIG_OK;
38//   } else {
39//     swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
40//     if (pwchar_descriptor) {
41//       void * vptr = 0;
42//       if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
43// 	if (cptr) *cptr = (wchar_t *)vptr;
44// 	if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
45// 	return SWIG_OK;
46//       }
47//     }
48//   }
49//   return SWIG_TypeError;
50}
51}
52
53%fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
54SWIGINTERNINLINE VALUE 
55SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
56{
57  return SWIG_FromCharPtrAndSize( (const char*)carray, size);
58//   if (carray) {
59//     if (size > INT_MAX) {
60//       swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
61//       return pwchar_descriptor ? 
62// 	SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil;
63//     } else {
64//       return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int));
65//     }
66//   } else {
67//     return Qnil;
68//   }
69}
70}
71
72