forked from jerrykrinock/ClassesObjC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNSString+PythonPickles.h
44 lines (29 loc) · 1.02 KB
/
NSString+PythonPickles.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#import <Cocoa/Cocoa.h>
extern NSString* const SSYPythonPicklesErrorDomain ;
extern NSString* const SSYPythonPicklesUnderErrorDomain ;
@interface NSString (PythonPickles)
- (NSString*)pythonUnpickledError_p:(NSError**)error_p ;
@end
#if 0
TEST CODE
int main(int argc, char *argv[]) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;
// The following string is an actual Python pickle.
// Of course, one would never hard code such a thing in a real program.
// This is just a test :)
NSString* s = @"V/Users/jk/Dropbox2/Dropbox\np1\n.\n" ;
NSError* error = nil ;
// Do it three times to test for Python initialization issues.
NSLog(@"Unpickled result: %@\n",
[s pythonUnpickledError_p:&error]) ;
NSLog(@"Unpickled result: %@\n",
[s pythonUnpickledError_p:&error]) ;
NSLog(@"Unpickled result: %@\n",
[s pythonUnpickledError_p:&error]) ;
// The correct answer for Unpickled result is:
// "/Users/jk/Dropbox2/Dropbox"
NSLog(@"error:\n%@", error) ;
[pool release] ;
return 0 ;
}
#endif