Modernize
This commit is contained in:
parent
f334836fb2
commit
7e17c0601c
|
@ -539,7 +539,7 @@
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MTL_ENABLE_DEBUG_INFO = YES;
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx10.12;
|
SDKROOT = macosx10.13;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
@ -577,7 +577,7 @@
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
SDKROOT = macosx10.12;
|
SDKROOT = macosx10.13;
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
};
|
};
|
||||||
|
|
|
@ -85,6 +85,8 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||||
let examplePath = arduinoURL.appendingPathComponent("Contents/Resources/Java/examples", isDirectory:true).path
|
let examplePath = arduinoURL.appendingPathComponent("Contents/Resources/Java/examples", isDirectory:true).path
|
||||||
ASSketchBook.addSketches(menu: menu, target: self, action: #selector(ASApplication.openExample(_:)), path: examplePath, sketches: &examples)
|
ASSketchBook.addSketches(menu: menu, target: self, action: #selector(ASApplication.openExample(_:)), path: examplePath, sketches: &examples)
|
||||||
}
|
}
|
||||||
|
ASLibraries.instance().addContribLibraryExamplesToMenu(menu: menu, sketches: &examples)
|
||||||
|
ASLibraries.instance().addStandardLibraryExamplesToMenu(menu: menu, sketches: &examples)
|
||||||
case "Import Standard Library":
|
case "Import Standard Library":
|
||||||
menu.removeAllItems()
|
menu.removeAllItems()
|
||||||
ASLibraries.instance().addStandardLibrariesToMenu(menu: menu)
|
ASLibraries.instance().addStandardLibrariesToMenu(menu: menu)
|
||||||
|
|
|
@ -189,6 +189,31 @@ class ASLibraries : NSObject {
|
||||||
menuItem.tag = index
|
menuItem.tag = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func addStandardLibraryExamplesToMenu(menu: NSMenu, sketches: inout [String]) {
|
||||||
|
addLibraryExamplesToMenu(library: standardLib, menu: menu, sketches: &sketches)
|
||||||
|
}
|
||||||
|
func addContribLibraryExamplesToMenu(menu: NSMenu, sketches: inout [String]) {
|
||||||
|
addLibraryExamplesToMenu(library: contribLib, menu: menu, sketches: &sketches)
|
||||||
|
}
|
||||||
|
func addLibraryExamplesToMenu(library: [String], menu: NSMenu, sketches: inout [String]) {
|
||||||
|
let fileManager = FileManager.default
|
||||||
|
let application = NSApplication.shared().delegate as! ASApplication
|
||||||
|
var hasSeparator = false
|
||||||
|
for (_,lib) in library.enumerated() {
|
||||||
|
let examplePath = (lib as NSString).appendingPathComponent("examples")
|
||||||
|
if fileManager.fileExists(atPath: examplePath) {
|
||||||
|
if !hasSeparator {
|
||||||
|
menu.addItem(NSMenuItem.separator())
|
||||||
|
hasSeparator = true
|
||||||
|
}
|
||||||
|
let menuItem = menu.addItem(withTitle: (lib as NSString).lastPathComponent, action: nil, keyEquivalent: "")
|
||||||
|
let submenu = NSMenu()
|
||||||
|
submenu.autoenablesItems = false
|
||||||
|
ASSketchBook.addSketches(menu: submenu, target: application, action: #selector(ASApplication.openExample(_:)), path: examplePath, sketches: &sketches)
|
||||||
|
menu.setSubmenu(submenu, for: menuItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@IBAction func importStandardLibrary(_ menuItem: AnyObject) {
|
@IBAction func importStandardLibrary(_ menuItem: AnyObject) {
|
||||||
if let tag = (menuItem as? NSMenuItem)?.tag {
|
if let tag = (menuItem as? NSMenuItem)?.tag {
|
||||||
NSApplication.shared().sendAction(#selector(ASProjDoc.importLibrary(_:)), to: nil, from: standardLib[tag])
|
NSApplication.shared().sendAction(#selector(ASProjDoc.importLibrary(_:)), to: nil, from: standardLib[tag])
|
||||||
|
|
|
@ -78,9 +78,9 @@ def parseInoFiles
|
||||||
# Find protypes:
|
# Find protypes:
|
||||||
prototypes = contents.dup
|
prototypes = contents.dup
|
||||||
# - Strip comments, quoted strings, and preprocessor directives
|
# - Strip comments, quoted strings, and preprocessor directives
|
||||||
prototypes.gsub!(%r{'(?:[^']|\\')+'|"(?:[^"]|\\")*"|//.*?$|/\*.*?\*/|^\s*?#.*?$}m, ' ')
|
prototypes.gsub!(%r{'(?:\\'|[^'])+'|"(?:\\"|[^"])*"|//.*?$|/\*.*?\*/|^\s*?#.*?$}m, ' ')
|
||||||
# Collapse braces
|
# Collapse braces
|
||||||
while prototypes.sub!(/(\{)(?:[^{}]+|\{[^{}]*\})/m, '\1') do
|
while prototypes.sub!(/(\{)([^{}]+|\{[^{}]*\})/m, '\1') do
|
||||||
end
|
end
|
||||||
existingProto = {}
|
existingProto = {}
|
||||||
prototypes.scan(/[\w\[\]\*]+\s+[&\[\]\*\w\s]+\([&,\[\]\*\w\s]*\)(?=\s*;)/) {|p|
|
prototypes.scan(/[\w\[\]\*]+\s+[&\[\]\*\w\s]+\([&,\[\]\*\w\s]*\)(?=\s*;)/) {|p|
|
||||||
|
@ -92,7 +92,7 @@ def parseInoFiles
|
||||||
proto << p+";\n" unless existingProto[p]
|
proto << p+";\n" unless existingProto[p]
|
||||||
}
|
}
|
||||||
contents.each_line do |line|
|
contents.each_line do |line|
|
||||||
if line =~ /^\s*#include\s+[<"](.*)[">]\s*(#.*)?$/
|
if line =~ %r{^\s*#include\s+[<"](.*)[">]\s*(#.*|/\*.*?\*/\s*|//.*)?$}
|
||||||
addLibrary($1)
|
addLibrary($1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user