Skip to content

Commit

Permalink
buildme correction for Linux + "get" vars in Extensions.swift (Clover…
Browse files Browse the repository at this point in the history
….app)
  • Loading branch information
vectorsigma72 committed Apr 10, 2020
1 parent ada5582 commit a53de40
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 27 deletions.
77 changes: 52 additions & 25 deletions CloverApp/Clover/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ extension String {

/// - returns: A quoted string for nvram
var nvramString: String {
return "'\(self)'"
get {
return "'\(self)'"
}
}


Expand All @@ -44,7 +46,9 @@ extension String {

/// - returns: only digits contained from the given string
var keepNumericsOnly: String {
return self.components(separatedBy: CharacterSet(charactersIn: "0123456789").inverted).joined(separator: "")
get {
return self.components(separatedBy: CharacterSet(charactersIn: "0123456789").inverted).joined(separator: "")
}
}

//: ### Base64 encoding a string
Expand Down Expand Up @@ -84,19 +88,27 @@ extension String {
}

var lastPath: String {
return (self as NSString).lastPathComponent
get {
return (self as NSString).lastPathComponent
}
}

var fileExtension: String {
return (self as NSString).pathExtension
get {
return (self as NSString).pathExtension
}
}

var deletingLastPath: String {
return (self as NSString).deletingLastPathComponent
get {
return (self as NSString).deletingLastPathComponent
}
}

var deletingFileExtension: String {
return (self as NSString).deletingPathExtension
get {
return (self as NSString).deletingPathExtension
}
}

var componentsPath: [String] {
Expand Down Expand Up @@ -209,38 +221,48 @@ extension String {

extension NSNumber {
var hexString: String {
if (self.intValue > 0xFFFF) {
return String(format: "0x%08llx", self.intValue)
} else {
return String(format: "0x%04llx", self.intValue)
get {
if (self.intValue > 0xFFFF) {
return String(format: "0x%08llx", self.intValue)
} else {
return String(format: "0x%04llx", self.intValue)
}
}
}
}

extension Int {
var data: Data {
var num = self
return Data(bytes: &num, count: MemoryLayout<Int>.size)
get {
var num = self
return Data(bytes: &num, count: MemoryLayout<Int>.size)
}
}
}

extension UInt8 {
var data: Data {
var num = self
return Data(bytes: &num, count: MemoryLayout<UInt8>.size)
get {
var num = self
return Data(bytes: &num, count: MemoryLayout<UInt8>.size)
}
}
}
extension UInt16 {
var data: Data {
var num = self
return Data(bytes: &num, count: MemoryLayout<UInt16>.size)
get {
var num = self
return Data(bytes: &num, count: MemoryLayout<UInt16>.size)
}
}
}

extension UInt32 {
var data: Data {
var num = self
return Data(bytes: &num, count: MemoryLayout<UInt32>.size)
get {
var num = self
return Data(bytes: &num, count: MemoryLayout<UInt32>.size)
}
}
}

Expand All @@ -255,12 +277,14 @@ extension Data {
}

var sha1: String {
var h = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))

self.withUnsafeBytes {
_ = CC_SHA1($0.baseAddress, CC_LONG(self.count), &h)
get {
var h = [UInt8](repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))

self.withUnsafeBytes {
_ = CC_SHA1($0.baseAddress, CC_LONG(self.count), &h)
}
return Data(h).hexadecimal()
}
return Data(h).hexadecimal()
}

func castToCPointer<T>() -> T {
Expand Down Expand Up @@ -318,7 +342,6 @@ extension URL {

/// Set extended attribute.
func setExtendedAttribute(data: Data, forName name: String) throws {

try self.withUnsafeFileSystemRepresentation { fileSystemPath in
let result = data.withUnsafeBytes {
setxattr(fileSystemPath, name, $0.baseAddress, data.count, 0, 0)
Expand Down Expand Up @@ -395,7 +418,11 @@ extension io_object_t {
}

extension NSBitmapImageRep {
var png: Data? { representation(using: .png, properties: [:]) }
var png: Data? {
get {
representation(using: .png, properties: [:])
}
}
}

extension NSView {
Expand Down
4 changes: 3 additions & 1 deletion CloverApp/Clover/ThemeManager/ThemeManagerVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ NSComboBoxDataSource {
}
self.loaded = true


self.view.window?.title = self.view.window!.title.locale
let settingVC = AppSD.settingsWC?.contentViewController as? SettingsViewController
settingVC?.themeUserCBox.isEnabled = false
Expand Down Expand Up @@ -341,6 +341,7 @@ NSComboBoxDataSource {
}

func showIndexing() {
self.webView.drawsBackground = true
// https://www.w3schools.com/howto/howto_css_loader.asp
self.webView.mainFrame.loadHTMLString("""
<html>
Expand Down Expand Up @@ -578,6 +579,7 @@ NSComboBoxDataSource {
}

func tableViewSelectionDidChange(_ notification: Notification) {
self.webView.drawsBackground = false
if self.isBusy {
NSSound.beep()
return
Expand Down
6 changes: 5 additions & 1 deletion buildme
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,11 @@ do
break
;;
"quit")
osascript -e 'tell application "Terminal" to close first window' & exit
if [[ "$SYSNAME" == Darwin ]]; then
osascript -e 'tell application "Terminal" to close first window' & exit
else
exit 0
fi
;;
*)
echo "invalid option $REPLY"
Expand Down

0 comments on commit a53de40

Please sign in to comment.