[ctypes-commit] ctypes/source cfield.c,1.48,1.49
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-10-12 09:15:11
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10669 Modified Files: cfield.c Log Message: Use the correct ffi_type for wchar_t. Index: cfield.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/cfield.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** cfield.c 12 Oct 2004 08:46:36 -0000 1.48 --- cfield.c 12 Oct 2004 09:14:58 -0000 1.49 *************** *** 1016,1021 **** { 'z', z_set, z_get, &ffi_type_pointer}, #ifdef Py_USING_UNICODE ! /* Correct or not? */ ! { 'u', u_set, u_get, &ffi_type_sshort}, { 'U', U_set, U_get, &ffi_type_pointer}, { 'Z', Z_set, Z_get, &ffi_type_pointer}, --- 1016,1020 ---- { 'z', z_set, z_get, &ffi_type_pointer}, #ifdef Py_USING_UNICODE ! { 'u', u_set, u_get, NULL}, /* ffi_type set later */ { 'U', U_set, U_get, &ffi_type_pointer}, { 'Z', Z_set, Z_get, &ffi_type_pointer}, *************** *** 1031,1036 **** --- 1030,1046 ---- getentry(char *fmt) { + static int initialized = 0; struct fielddesc *table = formattable; + if (!initialized) { + initialized = 1; + if (sizeof(wchar_t) == sizeof(short)) + getentry("u")->pffi_type = &ffi_type_sshort; + else if (sizeof(wchar_t) == sizeof(int)) + getentry("u")->pffi_type = &ffi_type_sint; + else if (sizeof(wchar_t) == sizeof(long)) + getentry("u")->pffi_type = &ffi_type_slong; + } + for (; table->code; ++table) { if (table->code == fmt[0]) |