Mercurial > projects > dstep
comparison dstep/appkit/NSPersistentDocument.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSPersistentDocument; | |
8 | |
9 import dstep.appkit.NSDocument; | |
10 import dstep.coredata.NSManagedObjectContext; | |
11 import dstep.coredata.NSManagedObjectModel; | |
12 import dstep.foundation.NSDictionary; | |
13 import dstep.foundation.NSError; | |
14 import dstep.foundation.NSObject; | |
15 import dstep.foundation.NSString; | |
16 import dstep.foundation.NSURL; | |
17 import dstep.objc.bridge.Bridge; | |
18 import dstep.objc.objc; | |
19 | |
20 const TNSPersistentDocumentDeprecated = ` | |
21 | |
22 bool configurePersistentStoreCoordinatorForURL (NSURL url, NSString fileType, NSError** error) | |
23 { | |
24 return invokeObjcSelf!(bool, "configurePersistentStoreCoordinatorForURL:ofType:error:", NSURL, NSString, NSError**)(url, fileType, error); | |
25 } | |
26 | |
27 //mixin ObjcBindMethod!(configurePersistentStoreCoordinatorForURL, "configurePersistentStoreCoordinatorForURL:ofType:error:"); | |
28 | |
29 `; | |
30 | |
31 class NSPersistentDocument : NSDocument | |
32 { | |
33 mixin (ObjcWrap); | |
34 | |
35 NSManagedObjectContext managedObjectContext () | |
36 { | |
37 return invokeObjcSelf!(NSManagedObjectContext, "managedObjectContext"); | |
38 } | |
39 | |
40 void setManagedObjectContext (NSManagedObjectContext managedObjectContext) | |
41 { | |
42 return invokeObjcSelf!(void, "setManagedObjectContext:", NSManagedObjectContext)(managedObjectContext); | |
43 } | |
44 | |
45 Object managedObjectModel () | |
46 { | |
47 return invokeObjcSelf!(Object, "managedObjectModel"); | |
48 } | |
49 | |
50 bool configurePersistentStoreCoordinatorForURL (NSURL url, NSString fileType, NSString configuration, NSDictionary storeOptions, NSError** error) | |
51 { | |
52 return invokeObjcSelf!(bool, "configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:", NSURL, NSString, NSString, NSDictionary, NSError**)(url, fileType, configuration, storeOptions, error); | |
53 } | |
54 | |
55 NSString persistentStoreTypeForFileType (NSString fileType) | |
56 { | |
57 return invokeObjcSelf!(NSString, "persistentStoreTypeForFileType:", NSString)(fileType); | |
58 } | |
59 | |
60 bool writeToURL (NSURL absoluteURL, NSString typeName, uint saveOperation, NSURL absoluteOriginalContentsURL, ref NSError error) | |
61 { | |
62 id err; | |
63 | |
64 if (error) | |
65 err = error.objcObject; | |
66 | |
67 bool result = invokeObjcSelf!(bool, "writeToURL:ofType:forSaveOperation:originalContentsURL:error:", NSURL, NSString, uint, NSURL, id*)(absoluteURL, typeName, saveOperation, absoluteOriginalContentsURL, &err); | |
68 | |
69 if (err) | |
70 error = new NSError(err); | |
71 | |
72 return result; | |
73 } | |
74 | |
75 bool readFromURL (NSURL absoluteURL, NSString typeName, ref NSError error) | |
76 { | |
77 id err; | |
78 | |
79 if (error) | |
80 err = error.objcObject; | |
81 | |
82 bool result = invokeObjcSelf!(bool, "readFromURL:ofType:error:", NSURL, NSString, id*)(absoluteURL, typeName, &err); | |
83 | |
84 if (err) | |
85 error = new NSError(err); | |
86 | |
87 return result; | |
88 } | |
89 | |
90 bool revertToContentsOfURL (NSURL inAbsoluteURL, NSString inTypeName, ref NSError outError) | |
91 { | |
92 id error; | |
93 | |
94 if (outError) | |
95 error = outError.objcObject; | |
96 | |
97 bool result = invokeObjcSelf!(bool, "revertToContentsOfURL:ofType:error:", NSURL, NSString, id*)(inAbsoluteURL, inTypeName, &error); | |
98 | |
99 if (error) | |
100 outError = new NSError(error); | |
101 | |
102 return result; | |
103 } | |
104 | |
105 // NSPersistentDocumentDeprecated | |
106 bool configurePersistentStoreCoordinatorForURL (NSURL url, NSString fileType, NSError** error) | |
107 { | |
108 return invokeObjcSelf!(bool, "configurePersistentStoreCoordinatorForURL:ofType:error:", NSURL, NSString, NSError**)(url, fileType, error); | |
109 } | |
110 } |