Cleaner way of invoking callback
This commit is contained in:
parent
da0fb55ae0
commit
c9ad05a693
|
@ -17,6 +17,7 @@
|
||||||
951CD1741A23C9FC0066C1A1 /* ASBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951CD1731A23C9FC0066C1A1 /* ASBuilder.swift */; };
|
951CD1741A23C9FC0066C1A1 /* ASBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 951CD1731A23C9FC0066C1A1 /* ASBuilder.swift */; };
|
||||||
951CD1771A2615000066C1A1 /* BuildProject in Resources */ = {isa = PBXBuildFile; fileRef = 951CD1761A2615000066C1A1 /* BuildProject */; };
|
951CD1771A2615000066C1A1 /* BuildProject in Resources */ = {isa = PBXBuildFile; fileRef = 951CD1761A2615000066C1A1 /* BuildProject */; };
|
||||||
95388E5D1AB6882600061435 /* FileRevision in Resources */ = {isa = PBXBuildFile; fileRef = 95388E5C1AB6882600061435 /* FileRevision */; };
|
95388E5D1AB6882600061435 /* FileRevision in Resources */ = {isa = PBXBuildFile; fileRef = 95388E5C1AB6882600061435 /* FileRevision */; };
|
||||||
|
95388E621AB7235000061435 /* ASVestigial.mm in Sources */ = {isa = PBXBuildFile; fileRef = 95388E611AB7235000061435 /* ASVestigial.mm */; };
|
||||||
9538E0EC1A8FB215001E02CC /* ACEView.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95EA325B1A17B8DA00F66EB0 /* ACEView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
9538E0EC1A8FB215001E02CC /* ACEView.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 95EA325B1A17B8DA00F66EB0 /* ACEView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
95468DDF1A228BE600668EE2 /* ASHardware.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95468DDE1A228BE600668EE2 /* ASHardware.swift */; };
|
95468DDF1A228BE600668EE2 /* ASHardware.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95468DDE1A228BE600668EE2 /* ASHardware.swift */; };
|
||||||
95468DE31A228E1300668EE2 /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 95468DE21A228E1300668EE2 /* Defaults.plist */; };
|
95468DE31A228E1300668EE2 /* Defaults.plist in Resources */ = {isa = PBXBuildFile; fileRef = 95468DE21A228E1300668EE2 /* Defaults.plist */; };
|
||||||
|
@ -104,6 +105,8 @@
|
||||||
951CD1731A23C9FC0066C1A1 /* ASBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ASBuilder.swift; sourceTree = "<group>"; };
|
951CD1731A23C9FC0066C1A1 /* ASBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ASBuilder.swift; sourceTree = "<group>"; };
|
||||||
951CD1761A2615000066C1A1 /* BuildProject */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = BuildProject; sourceTree = "<group>"; };
|
951CD1761A2615000066C1A1 /* BuildProject */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = BuildProject; sourceTree = "<group>"; };
|
||||||
95388E5C1AB6882600061435 /* FileRevision */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = FileRevision; sourceTree = "<group>"; };
|
95388E5C1AB6882600061435 /* FileRevision */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = FileRevision; sourceTree = "<group>"; };
|
||||||
|
95388E601AB7235000061435 /* ASVestigial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASVestigial.h; sourceTree = "<group>"; };
|
||||||
|
95388E611AB7235000061435 /* ASVestigial.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASVestigial.mm; sourceTree = "<group>"; };
|
||||||
95468DDE1A228BE600668EE2 /* ASHardware.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ASHardware.swift; sourceTree = "<group>"; };
|
95468DDE1A228BE600668EE2 /* ASHardware.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ASHardware.swift; sourceTree = "<group>"; };
|
||||||
95468DE21A228E1300668EE2 /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Defaults.plist; sourceTree = "<group>"; };
|
95468DE21A228E1300668EE2 /* Defaults.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Defaults.plist; sourceTree = "<group>"; };
|
||||||
95539B661A3E7EAF00D8595C /* ASSerial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASSerial.h; sourceTree = "<group>"; };
|
95539B661A3E7EAF00D8595C /* ASSerial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASSerial.h; sourceTree = "<group>"; };
|
||||||
|
@ -219,6 +222,8 @@
|
||||||
95DF20661A45A6090013D1B5 /* ASSketchBook.swift */,
|
95DF20661A45A6090013D1B5 /* ASSketchBook.swift */,
|
||||||
956005F21A4EF79D00327007 /* ASSerialWin.swift */,
|
956005F21A4EF79D00327007 /* ASSerialWin.swift */,
|
||||||
95DA9B151A515AF700DE018D /* ACEViewExt.swift */,
|
95DA9B151A515AF700DE018D /* ACEViewExt.swift */,
|
||||||
|
95388E601AB7235000061435 /* ASVestigial.h */,
|
||||||
|
95388E611AB7235000061435 /* ASVestigial.mm */,
|
||||||
);
|
);
|
||||||
name = Source;
|
name = Source;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -409,6 +414,7 @@
|
||||||
files = (
|
files = (
|
||||||
956005F41A4EF79D00327007 /* ASSerialWin.swift in Sources */,
|
956005F41A4EF79D00327007 /* ASSerialWin.swift in Sources */,
|
||||||
9501D8041A17025C0034C530 /* ASProjDoc.swift in Sources */,
|
9501D8041A17025C0034C530 /* ASProjDoc.swift in Sources */,
|
||||||
|
95388E621AB7235000061435 /* ASVestigial.mm in Sources */,
|
||||||
95539B681A3E7EAF00D8595C /* ASSerial.mm in Sources */,
|
95539B681A3E7EAF00D8595C /* ASSerial.mm in Sources */,
|
||||||
95468DDF1A228BE600668EE2 /* ASHardware.swift in Sources */,
|
95468DDF1A228BE600668EE2 /* ASHardware.swift in Sources */,
|
||||||
95DA9B161A515AF700DE018D /* ACEViewExt.swift in Sources */,
|
95DA9B161A515AF700DE018D /* ACEViewExt.swift in Sources */,
|
||||||
|
|
|
@ -284,14 +284,9 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
|
||||||
// MARK: Printing
|
// MARK: Printing
|
||||||
|
|
||||||
override func printDocumentWithSettings(printSettings: [NSObject : AnyObject], showPrintPanel: Bool, delegate: AnyObject?, didPrintSelector: Selector, contextInfo: UnsafeMutablePointer<Void>) {
|
override func printDocumentWithSettings(printSettings: [NSObject : AnyObject], showPrintPanel: Bool, delegate: AnyObject?, didPrintSelector: Selector, contextInfo: UnsafeMutablePointer<Void>) {
|
||||||
//
|
|
||||||
// Thanks to Erica Sadun for showing me how to call a selector in Swift
|
|
||||||
//
|
|
||||||
printingDone =
|
printingDone =
|
||||||
{ () -> () in
|
{ () -> () in
|
||||||
if let del : AnyObject = delegate {
|
InvokeCallback(delegate, didPrintSelector, contextInfo);
|
||||||
NSThread.detachNewThreadSelector(didPrintSelector, toTarget: del, withObject: contextInfo as? AnyObject)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if let logNode = mainEditor as? ASLogNode {
|
if let logNode = mainEditor as? ASLogNode {
|
||||||
let url = fileURL!.URLByDeletingLastPathComponent?.URLByAppendingPathComponent(logNode.path)
|
let url = fileURL!.URLByDeletingLastPathComponent?.URLByAppendingPathComponent(logNode.path)
|
||||||
|
|
20
AVRsack/ASVestigial.h
Normal file
20
AVRsack/ASVestigial.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
//
|
||||||
|
// ASVestigial.h
|
||||||
|
// AVRsack
|
||||||
|
//
|
||||||
|
// Created by Matthias Neeracher on 16/03/15.
|
||||||
|
// Copyright © 2015 Aere Perennius. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
InvokeCallback(id target, SEL selector, void * context);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
20
AVRsack/ASVestigial.mm
Normal file
20
AVRsack/ASVestigial.mm
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
//
|
||||||
|
// ASVestigial.m
|
||||||
|
// AVRsack
|
||||||
|
//
|
||||||
|
// Created by Matthias Neeracher on 16/03/15.
|
||||||
|
// Copyright © 2015 Aere Perennius. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "ASVestigial.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
InvokeCallback(id target, SEL selector, void * context)
|
||||||
|
{
|
||||||
|
if (!target)
|
||||||
|
return;
|
||||||
|
NSMethodSignature * sig = [target methodSignatureForSelector:selector];
|
||||||
|
NSInvocation * invocation = [NSInvocation invocationWithMethodSignature:sig];
|
||||||
|
[invocation setArgument:&context atIndex:2];
|
||||||
|
[invocation invokeWithTarget:target];
|
||||||
|
}
|
|
@ -5,4 +5,5 @@
|
||||||
#import <ACEView/ACEThemeNames.h>
|
#import <ACEView/ACEThemeNames.h>
|
||||||
#import <ACEView/ACEKeyboardHandlerNames.h>
|
#import <ACEView/ACEKeyboardHandlerNames.h>
|
||||||
|
|
||||||
#import "ASSerial.h"
|
#import "ASSerial.h"
|
||||||
|
#import "ASVestigial.h"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user