1/*! 2 * @header OC_PythonUnicode.h 3 * @abstract Objective-C proxy class for Python unicode 4 * @discussion 5 * This file defines the class that is used to represent Python unicode 6 * in Objective-C. 7 */ 8 9#include "pyobjc.h" 10 11/*! 12 * @class OC_PythonUnicode 13 * @abstract Objective-C proxy class for Python unicode 14 * @discussion Instances of this class are used as proxies for Python 15 * unicode when these are passed to Objective-C code. 16 */ 17@interface OC_PythonUnicode : NSString 18{ 19 PyObject* value; 20 id realObject; 21 22#ifdef PyObjC_STR_CACHE_IMP 23 /* Cache IMPs for proxied methods, for slightly better efficiency */ 24 NSUInteger (*imp_length)(id, SEL); 25 unichar (*imp_charAtIndex)(id, SEL, NSUInteger); 26 void (*imp_getCharacters)(id, SEL, unichar*, NSRange); 27#endif /* PyObjC_STR_CACHE_IMP */ 28} 29 30/*! 31 * @method newWithPythonObject: 32 * @abstract Create a new OC_PythonUnicode for a specific Python unicode 33 * @param value A python unicode 34 * @result Returns an autoreleased instance representing value 35 * 36 * Caller must own the GIL. 37 */ 38+(id)unicodeWithPythonObject:(PyObject*)value; 39 40/*! 41 * @method initWithPythonObject: 42 * @abstract Initialise a OC_PythonUnicode for a specific Python unicode 43 * @param value A python unicode 44 * @result Returns self 45 * 46 * Caller must own the GIL. 47 */ 48-(id)initWithPythonObject:(PyObject*)value; 49 50/*! 51 * @method dealloc 52 * @abstract Deallocate the object 53 */ 54-(void)dealloc; 55 56/*! 57 * @abstract Access the wrapped Python unicode 58 * @result Returns a new reference to the wrapped Python unicode. 59 */ 60-(PyObject*)__pyobjc_PythonObject__; 61 62/* 63 * Primitive NSString methods 64 * 65 */ 66-(NSUInteger)length; 67-(unichar)characterAtIndex:(NSUInteger)index; 68-(void)getCharacters:(unichar *)buffer range:(NSRange)aRange; 69 70@end 71