1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 18:30:21 +00:00

Added the minor piece that will allow analysis results to be obtained from Objective-C, and exposed to Swift in sufficient detail for it to be able to pass on to the machine.

This commit is contained in:
Thomas Harte 2016-08-31 20:43:29 -04:00
parent 9d7962d6c0
commit 7bc2b6b161
6 changed files with 107 additions and 1 deletions

View File

@ -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 = "<group>"; };
4B55CE5C1C3B7D6F0093A61B /* CSOpenGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSOpenGLView.m; sourceTree = "<group>"; };
4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MachineDocument.swift; sourceTree = "<group>"; };
4B643F381D77AD1900D431D6 /* CSStaticAnalyser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSStaticAnalyser.h; path = StaticAnalyser/CSStaticAnalyser.h; sourceTree = "<group>"; };
4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CSStaticAnalyser.mm; path = StaticAnalyser/CSStaticAnalyser.mm; sourceTree = "<group>"; };
4B643F3C1D77AE5C00D431D6 /* CSMachine+Target.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CSMachine+Target.h"; sourceTree = "<group>"; };
4B69FB3B1C4D908A00B5F0AA /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Tape.cpp; sourceTree = "<group>"; };
4B69FB3C1C4D908A00B5F0AA /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Tape.hpp; sourceTree = "<group>"; };
4B69FB421C4D941400B5F0AA /* TapeUEF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TapeUEF.cpp; sourceTree = "<group>"; };
@ -881,6 +885,8 @@
4B2A53961D117D36003C6002 /* CSMachine.mm */,
4B2A53971D117D36003C6002 /* KeyCodes.h */,
4B2A53981D117D36003C6002 /* Wrappers */,
4B643F3B1D77AD6D00D431D6 /* StaticAnalyser */,
4B643F3C1D77AE5C00D431D6 /* CSMachine+Target.h */,
);
path = Machine;
sourceTree = "<group>";
@ -997,6 +1003,15 @@
path = Views;
sourceTree = "<group>";
};
4B643F3B1D77AD6D00D431D6 /* StaticAnalyser */ = {
isa = PBXGroup;
children = (
4B643F381D77AD1900D431D6 /* CSStaticAnalyser.h */,
4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */,
);
name = StaticAnalyser;
sourceTree = "<group>";
};
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 */,

View File

@ -0,0 +1,17 @@
//
// Target.h
// Clock Signal
//
// Created by Thomas Harte on 31/08/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#import <Foundation/Foundation.h>
#include "StaticAnalyser.hpp"
@interface CSMachine(Target)
- (void)applyTarget:(StaticAnalyser::Target)target;
@end

View File

@ -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

View File

@ -0,0 +1,20 @@
//
// CSStaticAnalyser.h
// Clock Signal
//
// Created by Thomas Harte on 31/08/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#import <Foundation/Foundation.h>
@class CSMachine;
@interface CSStaticAnalyser : NSObject
- (instancetype)initWithFileAtURL:(NSURL *)url;
@property(nonatomic, readonly) Class documentClass;
- (void)applyToMachine:(CSMachine *)machine;
@end

View File

@ -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<StaticAnalyser::Target> 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

View File

@ -7,7 +7,7 @@
//
#import <Foundation/Foundation.h>
@import CoreVideo;
#import <CoreVideo/CoreVideo.h>
@class CSBestEffortUpdater;