1/*! 2 * @header OC_PythonData.h 3 * @abstract Objective-C proxy class for Python buffers 4 * @discussion 5 * This file defines the class that is used to represent Python buffers 6 * in Objective-C. 7 */ 8 9#import "pyobjc.h" 10#import <Foundation/Foundation.h> 11 12/*! 13 * @class OC_PythonData 14 * @abstract Objective-C proxy class for Python buffers 15 * @discussion Instances of this class are used as proxies for Python 16 * buffers when these are passed to Objective-C code. Because 17 * this class is a subclass of NSData, Python buffers 18 * (except str, unicode) can be used everywhere where NSData 19 * is expected. 20 */ 21@interface OC_PythonData : NSData 22{ 23 PyObject* value; 24 25 /* XXX: why are these here? These fields don't seem to be necessary 26 * at all! 27 */ 28 Py_ssize_t buffer_len; 29 const void *buffer; 30} 31 32/*! 33 * @method newWithPythonObject: 34 * @abstract Create a new OC_PythonData for a specific Python buffer 35 * @param value A python buffer 36 * @result Returns an autoreleased instance representing value 37 * 38 * Caller must own the GIL. 39 */ 40+ dataWithPythonObject:(PyObject*)value; 41 42/*! 43 * @method initWithPythonObject: 44 * @abstract Initialise a OC_PythonData for a specific Python buffer 45 * @param value A python buffer 46 * @result Returns self 47 * 48 * Caller must own the GIL. 49 */ 50- initWithPythonObject:(PyObject*)value; 51 52/*! 53 * @method dealloc 54 * @abstract Deallocate the object 55 */ 56-(void)dealloc; 57 58/*! 59 * @method dealloc 60 * @abstract Access the wrapped Python buffer 61 * @result Returns a new reference to the wrapped Python buffer. 62 */ 63-(PyObject*)__pyobjc_PythonObject__; 64 65/*! 66 * @method length 67 * @result Returns the length of the wrapped Python buffer 68 */ 69-(NSUInteger)length; 70 71/*! 72 * @method bytes 73 * @result Returns a pointer to the contents of the Python buffer 74 */ 75-(const void *)bytes; 76 77@end 78