[Python-checkins] CVS: python/dist/src/Mac/Modules/cf _CFmodule.c,1.9,1.9.4.1 cfscan.py,1.5,1.5.18.1 cfsupport.py,1.13,1.13.4.1

Jack Jansen jackjansen@users.sourceforge.net
Wed, 27 Feb 2002 15:10:03 -0800


Update of /cvsroot/python/python/dist/src/Mac/Modules/cf
In directory usw-pr-cvs1:/tmp/cvs-serv755/cf

Modified Files:
      Tag: release22-maint
	_CFmodule.c cfscan.py cfsupport.py 
Log Message:
Backport of 1.8 (of _CFModule.c):
Added some support for unicode arguments.



Index: _CFmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v
retrieving revision 1.9
retrieving revision 1.9.4.1
diff -C2 -d -r1.9 -r1.9.4.1
*** _CFmodule.c	18 Dec 2001 15:38:34 -0000	1.9
--- _CFmodule.c	27 Feb 2002 23:10:00 -0000	1.9.4.1
***************
*** 2047,2050 ****
--- 2047,2070 ----
  }
  
+ static PyObject *CFMutableStringRefObj_CFStringAppendCharacters(CFMutableStringRefObject *_self, PyObject *_args)
+ {
+ 	PyObject *_res = NULL;
+ 	UniChar *chars__in__;
+ 	UniCharCount chars__len__;
+ 	int chars__in_len__;
+ #ifndef CFStringAppendCharacters
+ 	PyMac_PRECHECK(CFStringAppendCharacters);
+ #endif
+ 	if (!PyArg_ParseTuple(_args, "u#",
+ 	                      &chars__in__, &chars__in_len__))
+ 		return NULL;
+ 	chars__len__ = chars__in_len__;
+ 	CFStringAppendCharacters(_self->ob_itself,
+ 	                         chars__in__, chars__len__);
+ 	Py_INCREF(Py_None);
+ 	_res = Py_None;
+ 	return _res;
+ }
+ 
  static PyObject *CFMutableStringRefObj_CFStringAppendPascalString(CFMutableStringRefObject *_self, PyObject *_args)
  {
***************
*** 2218,2221 ****
--- 2238,2243 ----
  	{"CFStringAppend", (PyCFunction)CFMutableStringRefObj_CFStringAppend, 1,
  	 "(CFStringRef appendedString) -> None"},
+ 	{"CFStringAppendCharacters", (PyCFunction)CFMutableStringRefObj_CFStringAppendCharacters, 1,
+ 	 "(Buffer chars) -> None"},
  	{"CFStringAppendPascalString", (PyCFunction)CFMutableStringRefObj_CFStringAppendPascalString, 1,
  	 "(Str255 pStr, CFStringEncoding encoding) -> None"},
***************
*** 3222,3225 ****
--- 3244,3268 ----
  }
  
+ static PyObject *CF_CFStringCreateWithCharacters(PyObject *_self, PyObject *_args)
+ {
+ 	PyObject *_res = NULL;
+ 	CFStringRef _rv;
+ 	UniChar *chars__in__;
+ 	UniCharCount chars__len__;
+ 	int chars__in_len__;
+ #ifndef CFStringCreateWithCharacters
+ 	PyMac_PRECHECK(CFStringCreateWithCharacters);
+ #endif
+ 	if (!PyArg_ParseTuple(_args, "u#",
+ 	                      &chars__in__, &chars__in_len__))
+ 		return NULL;
+ 	chars__len__ = chars__in_len__;
+ 	_rv = CFStringCreateWithCharacters((CFAllocatorRef)NULL,
+ 	                                   chars__in__, chars__len__);
+ 	_res = Py_BuildValue("O&",
+ 	                     CFStringRefObj_New, _rv);
+ 	return _res;
+ }
+ 
  static PyObject *CF_CFStringCreateWithPascalStringNoCopy(PyObject *_self, PyObject *_args)
  {
***************
*** 3266,3269 ****
--- 3309,3334 ----
  }
  
+ static PyObject *CF_CFStringCreateWithCharactersNoCopy(PyObject *_self, PyObject *_args)
+ {
+ 	PyObject *_res = NULL;
+ 	CFStringRef _rv;
+ 	UniChar *chars__in__;
+ 	UniCharCount chars__len__;
+ 	int chars__in_len__;
+ #ifndef CFStringCreateWithCharactersNoCopy
+ 	PyMac_PRECHECK(CFStringCreateWithCharactersNoCopy);
+ #endif
+ 	if (!PyArg_ParseTuple(_args, "u#",
+ 	                      &chars__in__, &chars__in_len__))
+ 		return NULL;
+ 	chars__len__ = chars__in_len__;
+ 	_rv = CFStringCreateWithCharactersNoCopy((CFAllocatorRef)NULL,
+ 	                                         chars__in__, chars__len__,
+ 	                                         (CFAllocatorRef)NULL);
+ 	_res = Py_BuildValue("O&",
+ 	                     CFStringRefObj_New, _rv);
+ 	return _res;
+ }
+ 
  static PyObject *CF_CFStringCreateMutable(PyObject *_self, PyObject *_args)
  {
***************
*** 3668,3675 ****
--- 3733,3744 ----
  	{"CFStringCreateWithCString", (PyCFunction)CF_CFStringCreateWithCString, 1,
  	 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
+ 	{"CFStringCreateWithCharacters", (PyCFunction)CF_CFStringCreateWithCharacters, 1,
+ 	 "(Buffer chars) -> (CFStringRef _rv)"},
  	{"CFStringCreateWithPascalStringNoCopy", (PyCFunction)CF_CFStringCreateWithPascalStringNoCopy, 1,
  	 "(Str255 pStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
  	{"CFStringCreateWithCStringNoCopy", (PyCFunction)CF_CFStringCreateWithCStringNoCopy, 1,
  	 "(char* cStr, CFStringEncoding encoding) -> (CFStringRef _rv)"},
+ 	{"CFStringCreateWithCharactersNoCopy", (PyCFunction)CF_CFStringCreateWithCharactersNoCopy, 1,
+ 	 "(Buffer chars) -> (CFStringRef _rv)"},
  	{"CFStringCreateMutable", (PyCFunction)CF_CFStringCreateMutable, 1,
  	 "(CFIndex maxLength) -> (CFMutableStringRef _rv)"},

Index: cfscan.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfscan.py,v
retrieving revision 1.5
retrieving revision 1.5.18.1
diff -C2 -d -r1.5 -r1.5.18.1
*** cfscan.py	17 Jul 2001 20:47:08 -0000	1.5
--- cfscan.py	27 Feb 2002 23:10:01 -0000	1.5.18.1
***************
*** 93,96 ****
--- 93,99 ----
  			"CFStringGetCharacters",
  			"CFURLCreateStringWithFileSystemPath", # Gone in later releases
+ 			"CFStringCreateMutableWithExternalCharactersNoCopy", # Not a clue...
+ 			"CFStringSetExternalCharactersNoCopy",
+ 			"CFStringGetCharacterAtIndex", # No format for single unichars yet.
  			]
  
***************
*** 106,112 ****
  			"CFArrayApplierFunction", # Callback function pointer
  			"CFDictionaryApplierFunction", # Callback function pointer
- 			"UniChar_ptr", # XXXX To be done
- 			"const_UniChar_ptr", # XXXX To be done
- 			"UniChar", # XXXX To be done
  			"va_list", # For printf-to-a-cfstring. Use Python.
  			"const_CFStringEncoding_ptr", # To be done, I guess
--- 109,112 ----
***************
*** 119,122 ****
--- 119,125 ----
  			 [("UcharInBuffer", "*", "*")]),
  			 
+ 			([("UniChar_ptr", "*", "InMode"), ("CFIndex", "*", "InMode")],
+ 			 [("UnicodeInBuffer", "*", "*")]),
+ 
  			# Some functions return a const char *. Don't worry, we won't modify it.
  			([("const_char_ptr", "*", "ReturnMode")],

Index: cfsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -C2 -d -r1.13 -r1.13.4.1
*** cfsupport.py	16 Dec 2001 20:18:18 -0000	1.13
--- cfsupport.py	27 Feb 2002 23:10:01 -0000	1.13.4.1
***************
*** 172,177 ****
  CFComparisonResult = Type("CFComparisonResult", "l")  # a bit dangerous, it's an enum
  CFURLPathStyle = Type("CFURLPathStyle", "l") #  a bit dangerous, it's an enum
- FSRef_ptr = OpaqueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef")
- FSRef = OpaqueByValueType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef")
  
  char_ptr = stringptr
--- 172,175 ----