diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index 83d5c3c15..46a191fcd 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -165,7 +165,10 @@ class MachineDocument: } final func openGLView(_ view: CSOpenGLView, didReceiveFileAt URL: URL) { - // TODO: pass to machine. + let mediaSet = CSMediaSet(fileAt: URL) + if let mediaSet = mediaSet { + mediaSet.apply(to: self.machine) + } } // MARK: NSDocument overrides diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine+Target.h b/OSBindings/Mac/Clock Signal/Machine/CSMachine+Target.h index 6e720d929..f2f299396 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine+Target.h +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine+Target.h @@ -12,6 +12,7 @@ @interface CSMachine(Target) -- (void)applyTarget:(StaticAnalyser::Target)target; +- (void)applyTarget:(const StaticAnalyser::Target &)target; +- (void)applyMedia:(const StaticAnalyser::Media &)media; @end diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm index a5aaa10ef..58401636b 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm @@ -139,7 +139,7 @@ struct MachineDelegate: CRTMachine::Machine::Delegate { typeRecipient->set_typer_for_string([paste UTF8String]); } -- (void)applyTarget:(StaticAnalyser::Target)target { +- (void)applyTarget:(const StaticAnalyser::Target &)target { @synchronized(self) { ConfigurationTarget::Machine *const configurationTarget = dynamic_cast(self.machine); @@ -147,4 +147,12 @@ struct MachineDelegate: CRTMachine::Machine::Delegate { } } +- (void)applyMedia:(const StaticAnalyser::Media &)media { + @synchronized(self) { + ConfigurationTarget::Machine *const configurationTarget = + dynamic_cast(self.machine); + if(configurationTarget) configurationTarget->insert_media(media); + } +} + @end diff --git a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h index 90bf509a6..bf3499e84 100644 --- a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.h @@ -22,3 +22,10 @@ - (void)applyToMachine:(CSMachine *)machine; @end + +@interface CSMediaSet : NSObject + +- (instancetype)initWithFileAtURL:(NSURL *)url; +- (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 index 7a3b12b09..3ed7a118e 100644 --- a/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm +++ b/OSBindings/Mac/Clock Signal/Machine/StaticAnalyser/CSStaticAnalyser.mm @@ -69,3 +69,21 @@ } @end + +@implementation CSMediaSet { + StaticAnalyser::Media _media; +} + +- (instancetype)initWithFileAtURL:(NSURL *)url { + self = [super init]; + if(self) { + _media = StaticAnalyser::GetMedia([url fileSystemRepresentation]); + } + return self; +} + +- (void)applyToMachine:(CSMachine *)machine { + [machine applyMedia:_media]; +} + +@end