@@ -49,6 +49,7 @@ def parseArgumentList(self, args):
4949#include <CFDictionary.h>
5050#include <CFString.h>
5151#include <CFURL.h>
52+ #include <CFPropertyList.h>
5253#else
5354#include <CoreServices/CoreServices.h>
5455#endif
@@ -195,6 +196,7 @@ def parseArgumentList(self, args):
195196CFMutableStringRef = OpaqueByValueType ("CFMutableStringRef" , "CFMutableStringRefObj" )
196197CFURLRef = OpaqueByValueType ("CFURLRef" , "CFURLRefObj" )
197198OptionalCFURLRef = OpaqueByValueType ("CFURLRef" , "OptionalCFURLRefObj" )
199+ ##CFPropertyListRef = OpaqueByValueType("CFPropertyListRef", "CFTypeRefObj")
198200# ADD object type here
199201
200202# Our (opaque) objects
@@ -301,6 +303,18 @@ def outputRepr(self):
301303class CFDataRefObjectDefinition (MyGlobalObjectDefinition ):
302304 basechain = "&CFTypeRefObj_chain"
303305
306+ def outputCheckConvertArg (self ):
307+ Out ("""
308+ if (v == Py_None) { *p_itself = NULL; return 1; }
309+ if (PyString_Check(v)) {
310+ char *cStr;
311+ int cLen;
312+ if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
313+ *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
314+ return 1;
315+ }
316+ """ )
317+
304318 def outputRepr (self ):
305319 Output ()
306320 Output ("static PyObject * %s_repr(%s *self)" , self .prefix , self .objecttype )
@@ -491,6 +505,21 @@ def outputRepr(self):
491505return PyCF_CF2Python(_self->ob_itself);
492506"""
493507
508+ # Get data from CFDataRef
509+ getasdata_body = """
510+ int size = CFDataGetLength(_self->ob_itself);
511+ char *data = (char *)CFDataGetBytePtr(_self->ob_itself);
512+
513+ _res = (PyObject *)PyString_FromStringAndSize(data, size);
514+ return _res;
515+ """
516+
517+ f = ManualGenerator ("CFDataGetData" , getasdata_body );
518+ f .docstring = lambda : "() -> (string _rv)"
519+ CFDataRef_object .add (f )
520+
521+
522+
494523f = ManualGenerator ("toPython" , toPython_body );
495524f .docstring = lambda : "() -> (python_object)"
496525CFTypeRef_object .add (f )
0 commit comments