mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Migrated analysis logic from the document controller to the document.
This commit is contained in:
parent
0c75c2fc41
commit
989a1581da
@ -9,7 +9,7 @@
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class DocumentController: NSDocumentController {
|
class DocumentController: NSDocumentController {
|
||||||
override func makeDocument(withContentsOf url: URL, ofType typeName: String) throws -> NSDocument {
|
/* override func makeDocument(withContentsOf url: URL, ofType typeName: String) throws -> NSDocument {
|
||||||
if let analyser = CSStaticAnalyser(fileAt: url) {
|
if let analyser = CSStaticAnalyser(fileAt: url) {
|
||||||
if let documentClass = analyser.documentClass as? NSDocument.Type {
|
if let documentClass = analyser.documentClass as? NSDocument.Type {
|
||||||
let document = documentClass.init()
|
let document = documentClass.init()
|
||||||
@ -22,5 +22,5 @@ class DocumentController: NSDocumentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return try super.makeDocument(withContentsOf: url, ofType: typeName)
|
return try super.makeDocument(withContentsOf: url, ofType: typeName)
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,13 @@ class MachineDocument:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func read(from url: URL, ofType typeName: String) throws {
|
||||||
|
if let analyser = CSStaticAnalyser(fileAt: url) {
|
||||||
|
self.displayName = analyser.displayName
|
||||||
|
self.configureAs(analyser)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: the pasteboard
|
// MARK: the pasteboard
|
||||||
func paste(_ sender: AnyObject!) {
|
func paste(_ sender: AnyObject!) {
|
||||||
let pasteboard = NSPasteboard.general()
|
let pasteboard = NSPasteboard.general()
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).Atari2600Document</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).ElectronDocument</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).ElectronDocument</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).ElectronDocument</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -86,7 +86,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).Vic20Document</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -100,7 +100,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).Vic20Document</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -114,7 +114,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).Vic20Document</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -128,7 +128,7 @@
|
|||||||
<key>LSTypeIsPackage</key>
|
<key>LSTypeIsPackage</key>
|
||||||
<integer>0</integer>
|
<integer>0</integer>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).Vic20Document</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleTypeExtensions</key>
|
<key>CFBundleTypeExtensions</key>
|
||||||
@ -144,7 +144,7 @@
|
|||||||
<key>CFBundleTypeRole</key>
|
<key>CFBundleTypeRole</key>
|
||||||
<string>Viewer</string>
|
<string>Viewer</string>
|
||||||
<key>NSDocumentClass</key>
|
<key>NSDocumentClass</key>
|
||||||
<string>$(PRODUCT_MODULE_NAME).ElectronDocument</string>
|
<string>$(PRODUCT_MODULE_NAME).MachineDocument</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
- (instancetype)initWithFileAtURL:(NSURL *)url;
|
- (instancetype)initWithFileAtURL:(NSURL *)url;
|
||||||
|
|
||||||
@property(nonatomic, readonly) Class documentClass;
|
|
||||||
|
|
||||||
@property(nonatomic, readonly) NSString *optionsPanelNibName;
|
@property(nonatomic, readonly) NSString *optionsPanelNibName;
|
||||||
@property(nonatomic, readonly) NSString *userDefaultsPrefix;
|
@property(nonatomic, readonly) NSString *userDefaultsPrefix;
|
||||||
- (CSMachine *)newMachine;
|
- (CSMachine *)newMachine;
|
||||||
|
@ -34,18 +34,6 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (Class)documentClass
|
|
||||||
{
|
|
||||||
switch(_target.machine)
|
|
||||||
{
|
|
||||||
case StaticAnalyser::Target::Electron: return [ElectronDocument class];
|
|
||||||
case StaticAnalyser::Target::Vic20: return [Vic20Document class];
|
|
||||||
case StaticAnalyser::Target::Atari2600: return [MachineDocument class];
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *)optionsPanelNibName
|
- (NSString *)optionsPanelNibName
|
||||||
{
|
{
|
||||||
switch(_target.machine)
|
switch(_target.machine)
|
||||||
@ -62,8 +50,8 @@
|
|||||||
{
|
{
|
||||||
switch(_target.machine)
|
switch(_target.machine)
|
||||||
{
|
{
|
||||||
case StaticAnalyser::Target::Electron: return nil;
|
case StaticAnalyser::Target::Electron: return [[CSElectron alloc] init];
|
||||||
case StaticAnalyser::Target::Vic20: return nil;
|
case StaticAnalyser::Target::Vic20: return [[CSVic20 alloc] init];
|
||||||
case StaticAnalyser::Target::Atari2600: return [[CSAtari2600 alloc] init];
|
case StaticAnalyser::Target::Atari2600: return [[CSAtari2600 alloc] init];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user