diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 55a2cfd86..d9ceada4e 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ 4B55CE591C3B7D360093A61B /* ElectronDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE571C3B7D360093A61B /* ElectronDocument.swift */; }; 4B55CE5D1C3B7D6F0093A61B /* CSOpenGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE5C1C3B7D6F0093A61B /* CSOpenGLView.m */; }; 4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */; }; + 4B643F3A1D77AD1900D431D6 /* CSStaticAnalyser.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */; }; 4B69FB3D1C4D908A00B5F0AA /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B69FB3B1C4D908A00B5F0AA /* Tape.cpp */; }; 4B69FB441C4D941400B5F0AA /* TapeUEF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B69FB421C4D941400B5F0AA /* TapeUEF.cpp */; }; 4B69FB461C4D950F00B5F0AA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B69FB451C4D950F00B5F0AA /* libz.tbd */; }; @@ -434,6 +435,9 @@ 4B55CE5B1C3B7D6F0093A61B /* CSOpenGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSOpenGLView.h; sourceTree = ""; }; 4B55CE5C1C3B7D6F0093A61B /* CSOpenGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSOpenGLView.m; sourceTree = ""; }; 4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MachineDocument.swift; sourceTree = ""; }; + 4B643F381D77AD1900D431D6 /* CSStaticAnalyser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSStaticAnalyser.h; path = StaticAnalyser/CSStaticAnalyser.h; sourceTree = ""; }; + 4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CSStaticAnalyser.mm; path = StaticAnalyser/CSStaticAnalyser.mm; sourceTree = ""; }; + 4B643F3C1D77AE5C00D431D6 /* CSMachine+Target.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CSMachine+Target.h"; sourceTree = ""; }; 4B69FB3B1C4D908A00B5F0AA /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Tape.cpp; sourceTree = ""; }; 4B69FB3C1C4D908A00B5F0AA /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Tape.hpp; sourceTree = ""; }; 4B69FB421C4D941400B5F0AA /* TapeUEF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TapeUEF.cpp; sourceTree = ""; }; @@ -881,6 +885,8 @@ 4B2A53961D117D36003C6002 /* CSMachine.mm */, 4B2A53971D117D36003C6002 /* KeyCodes.h */, 4B2A53981D117D36003C6002 /* Wrappers */, + 4B643F3B1D77AD6D00D431D6 /* StaticAnalyser */, + 4B643F3C1D77AE5C00D431D6 /* CSMachine+Target.h */, ); path = Machine; sourceTree = ""; @@ -997,6 +1003,15 @@ path = Views; sourceTree = ""; }; + 4B643F3B1D77AD6D00D431D6 /* StaticAnalyser */ = { + isa = PBXGroup; + children = ( + 4B643F381D77AD1900D431D6 /* CSStaticAnalyser.h */, + 4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */, + ); + name = StaticAnalyser; + sourceTree = ""; + }; 4B69FB391C4D908A00B5F0AA /* Storage */ = { isa = PBXGroup; children = ( @@ -2016,6 +2031,7 @@ 4BBF99141C8FBA6F0075DAFB /* CRTInputBufferBuilder.cpp in Sources */, 4B2409551C45AB05004DA684 /* Speaker.cpp in Sources */, 4B6C73BD1D387AE500AFCFCA /* DiskDrive.cpp in Sources */, + 4B643F3A1D77AD1900D431D6 /* CSStaticAnalyser.mm in Sources */, 4B4DC8281D2C2470003C5BF8 /* C1540.cpp in Sources */, 4B1E85751D170228001EF87D /* Typer.cpp in Sources */, 4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */, diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine+Target.h b/OSBindings/Mac/Clock Signal/Machine/CSMachine+Target.h new file mode 100644 index 000000000..6e720d929 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine+Target.h @@ -0,0 +1,17 @@ +// +// Target.h +// Clock Signal +// +// Created by Thomas Harte on 31/08/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#import + +#include "StaticAnalyser.hpp" + +@interface CSMachine(Target) + +- (void)applyTarget:(StaticAnalyser::Target)target; + +@end diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm index 195788843..af551587d 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm @@ -8,6 +8,7 @@ #import "CSMachine.h" #import "CSMachine+Subclassing.h" +#import "CSMachine+Target.h" #include "Typer.hpp" @interface CSMachine() @@ -122,4 +123,6 @@ struct MachineDelegate: CRTMachine::Machine::Delegate { typeRecipient->set_typer_for_string([paste UTF8String]); } +- (void)applyTarget:(StaticAnalyser::Target)target {} + @end diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h new file mode 100644 index 000000000..b57aeb86c --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h @@ -0,0 +1,20 @@ +// +// CSStaticAnalyser.h +// Clock Signal +// +// Created by Thomas Harte on 31/08/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#import + +@class CSMachine; + +@interface CSStaticAnalyser : NSObject + +- (instancetype)initWithFileAtURL:(NSURL *)url; + +@property(nonatomic, readonly) Class documentClass; +- (void)applyToMachine:(CSMachine *)machine; + +@end diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm new file mode 100644 index 000000000..8ea40d5b8 --- /dev/null +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm @@ -0,0 +1,50 @@ +// +// CSStaticAnalyser.m +// Clock Signal +// +// Created by Thomas Harte on 31/08/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#import "CSStaticAnalyser.h" + +#import "CSMachine.h" +#import "CSMachine+Target.h" +#import "Clock_Signal-Swift.h" +#include "StaticAnalyser.hpp" + +@implementation CSStaticAnalyser +{ + StaticAnalyser::Target _target; +} + +- (instancetype)initWithFileAtURL:(NSURL *)url +{ + self = [super init]; + if(self) + { + std::list targets = StaticAnalyser::GetTargets([url fileSystemRepresentation]); + if(!targets.size()) return nil; + _target = targets.front(); + } + 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 [Atari2600Document class]; + } + + return nil; +} + +- (void)applyToMachine:(CSMachine *)machine +{ + [machine applyTarget:_target]; +} + +@end diff --git a/OSBindings/Mac/Clock Signal/Updater/CSBestEffortUpdater.h b/OSBindings/Mac/Clock Signal/Updater/CSBestEffortUpdater.h index eed663901..f8608a600 100644 --- a/OSBindings/Mac/Clock Signal/Updater/CSBestEffortUpdater.h +++ b/OSBindings/Mac/Clock Signal/Updater/CSBestEffortUpdater.h @@ -7,7 +7,7 @@ // #import -@import CoreVideo; +#import @class CSBestEffortUpdater;