Skip to content

Commit

Permalink
Update SoulverCore framework (v2.2.1)
Browse files Browse the repository at this point in the history
Compiled with Swift 5.6 and Xcode 13
  • Loading branch information
zcohan committed Aug 24, 2022
1 parent 6ce4d1f commit 4dc2be0
Show file tree
Hide file tree
Showing 53 changed files with 347 additions and 734,368 deletions.
4 changes: 4 additions & 0 deletions MacSample/MacSample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
115D09E623EF1E080008C3B2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 115D09E523EF1E080008C3B2 /* ViewController.swift */; };
115D09E823EF1E0A0008C3B2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 115D09E723EF1E0A0008C3B2 /* Assets.xcassets */; };
115D09EB23EF1E0A0008C3B2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 115D09E923EF1E0A0008C3B2 /* Main.storyboard */; };
11672ECF28B65D1F003E1027 /* StringParsingExamples.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11672ECE28B65D1F003E1027 /* StringParsingExamples.swift */; };
11B3781623FC24E5007B160A /* SoulverCoreExamples.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B3781523FC24E5007B160A /* SoulverCoreExamples.swift */; };
11D4203D251DCC180086F5EC /* SoulverCore.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 115288C623FB5E40002251A9 /* SoulverCore.xcframework */; };
11D4203E251DCC180086F5EC /* SoulverCore.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 115288C623FB5E40002251A9 /* SoulverCore.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -39,6 +40,7 @@
115D09EA23EF1E0A0008C3B2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
115D09EC23EF1E0A0008C3B2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
115D09ED23EF1E0A0008C3B2 /* MacSample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MacSample.entitlements; sourceTree = "<group>"; };
11672ECE28B65D1F003E1027 /* StringParsingExamples.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringParsingExamples.swift; sourceTree = "<group>"; };
11B3781523FC24E5007B160A /* SoulverCoreExamples.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SoulverCoreExamples.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -77,6 +79,7 @@
115D09E323EF1E080008C3B2 /* AppDelegate.swift */,
115D09E523EF1E080008C3B2 /* ViewController.swift */,
11B3781523FC24E5007B160A /* SoulverCoreExamples.swift */,
11672ECE28B65D1F003E1027 /* StringParsingExamples.swift */,
115D09E723EF1E0A0008C3B2 /* Assets.xcassets */,
115D09E923EF1E0A0008C3B2 /* Main.storyboard */,
115D09EC23EF1E0A0008C3B2 /* Info.plist */,
Expand Down Expand Up @@ -164,6 +167,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
11672ECF28B65D1F003E1027 /* StringParsingExamples.swift in Sources */,
115D09E623EF1E080008C3B2 /* ViewController.swift in Sources */,
11B3781623FC24E5007B160A /* SoulverCoreExamples.swift in Sources */,
115D09E423EF1E080008C3B2 /* AppDelegate.swift in Sources */,
Expand Down
4 changes: 1 addition & 3 deletions MacSample/MacSample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {

SoulverCoreExamples.runAllExamples()
StringParsingExamples.runAllExamples()

}

func applicationWillTerminate(_ aNotification: Notification) {
}


}

159 changes: 159 additions & 0 deletions MacSample/MacSample/StringParsingExamples.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import SoulverCore

public struct StringParsingExamples {

public static func runAllExamples() {

self.runBasicPercentageExtraction()
self.runPayrollExtraction()
self.runDataExtractionAndReduceFromArray()
self.runWhitespaceStandardization()
self.runNumberFormatStandardization()
self.runTemperatureStringArrayConversion()
self.runCustomTypeParsingExample()

}

static func runBasicPercentageExtraction() {

let percent = "Results of likeness test: 83% match".find(.percentage)!
print(percent)

}

static func runPayrollExtraction() {

// this string has inconsistent whitespace between entities, but this isn't a problem for us
let payrollEntry = "CREDIT 03/02/2022 Payroll from employer $200.23"
let data = payrollEntry.find(.date, .currency)!

print(data.0) // Either February 3, or March 2, depending on your system locale
print(data.1) // UnitExpression object (use .value to get the decimalValue, and .unit.identifier to get the currency code)

}

static func runDataExtractionAndReduceFromArray() {

let amounts = ["Zac spent $50", "Molly spent US$81.9 (with her 10% discount)", "Jude spent $43.90 USD"].find(.currency)

let totalAmount = amounts.reduce(0.0) {
$0 + $1.value
}

print(totalAmount)

}

static func runWhitespaceStandardization() {

let standardized = "CREDIT 03/02/2022 Payroll from employer $200.23".replacingAll(.whitespace) { whitespace in
return " "
}

print(standardized)

}

static func runNumberFormatStandardization() {
let standardized = "10.330,99 8.330,22 330,99".replacingAll(.number, locale: Locale(identifier: "en_DE")) { number in

return NumberFormatter.localizedString(from: number as NSNumber, number: .decimal)

}

print(standardized)

}

static func runTemperatureStringArrayConversion() {

let convertedTemperatures = ["25 °C", "12.5 degrees celsius", "-22.6 C"].replacingAll(.temperature) { celsius in

let measurementC: Measurement<UnitTemperature> = Measurement(value: celsius.value.doubleValue, unit: .celsius)
let measurementF = measurementC.converted(to: .fahrenheit)

let formatter = MeasurementFormatter()
formatter.unitOptions = .providedUnit
return formatter.string(from: measurementF)

}

print(convertedTemperatures)

}

static func runCustomTypeParsingExample() {

let container1 = Container("Color: blue, size: medium, volume: 12.5 cm3".find(.color, .size, .volume)!)
let container2 = Container("Color: red, size: small, volume: 6.2 cm3".find(.color, .size, .volume)!)
let container3 = Container("Color: yellow, size: large, volume: 17.82 cm3".find(.color, .size, .volume)!)

_ = [container1, container2, container3]

}


}


// MARK: - Custom Types for the Custom Parsing Example

enum Color: String, RawRepresentable {
case blue
case red
case yellow
}

enum Size: String, RawRepresentable {
case small
case medium
case large
}

struct Container {

let color: Color
let size: Size
let volume: Decimal

init(_ data: (Color, Size, UnitExpression)) {

self.color = data.0
self.size = data.1
self.volume = data.2.value

}

}

// MARK: - Implementation of parsers for the custom types above

/// In both cases, we simply check to see if we can create an enum case from the token's stringValue

struct ColorParser: DataFromTokenParser {
typealias DataType = Color

func parseDataFrom(token: SoulverCore.Token) -> Color? {
return Color(rawValue: token.stringValue.lowercased())
}
}

struct SizeParser: DataFromTokenParser {
typealias DataType = Size

func parseDataFrom(token: SoulverCore.Token) -> Size? {
return Size(rawValue: token.stringValue.lowercased())
}
}

extension DataPoint {

static var color: DataPoint<ColorParser> {
return DataPoint<ColorParser>(parser: ColorParser())
}

static var size: DataPoint<SizeParser> {
return DataPoint<SizeParser>(parser: SizeParser())
}

}
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.6

import PackageDescription

Expand All @@ -12,7 +12,7 @@ let package = Package(
targets: [
.binaryTarget(
name: "SoulverCore",
url: "https://github.com/soulverteam/SoulverCore/releases/download/2.2.0/SoulverCore.xcframework.zip",
checksum: "112aec3310ce1bbf7706d110c971151df8eae7108c687946e3fb70d31fa6d47f"),
url: "https://github.com/soulverteam/SoulverCore/releases/download/2.2.1/SoulverCore.xcframework.zip",
checksum: "c1fc37e912413d1ad0f44e6d6f79b0c2c7baee4acf669df9f0490579f39b055d"),
]
)
16 changes: 8 additions & 8 deletions SoulverCore.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-maccatalyst</string>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>SoulverCore.framework</string>
<key>SupportedArchitectures</key>
Expand All @@ -15,13 +15,11 @@
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>maccatalyst</string>
<string>macos</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>SoulverCore.framework</string>
<key>SupportedArchitectures</key>
Expand All @@ -30,11 +28,13 @@
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64_x86_64-maccatalyst</string>
<key>LibraryPath</key>
<string>SoulverCore.framework</string>
<key>SupportedArchitectures</key>
Expand All @@ -45,7 +45,7 @@
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
<string>maccatalyst</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if 0
#elif defined(__arm64__) && __arm64__
// Generated by Apple Swift version 5.7 (swiftlang-5.7.0.123.8 clang-1400.0.29.50)
// Generated by Apple Swift version 5.6.1 (swiftlang-5.6.0.323.66 clang-1316.0.20.12)
#ifndef SOULVERCORE_SWIFT_H
#define SOULVERCORE_SWIFT_H
#pragma clang diagnostic push
Expand All @@ -24,18 +22,10 @@
#endif

#pragma clang diagnostic ignored "-Wauto-import"
#if defined(__OBJC__)
#include <Foundation/Foundation.h>
#endif
#if defined(__cplusplus)
#include <cstdint>
#include <cstddef>
#include <cstdbool>
#else
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#endif

#if !defined(SWIFT_TYPEDEFS)
# define SWIFT_TYPEDEFS 1
Expand Down Expand Up @@ -191,56 +181,30 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
#else
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
#endif
#if defined(__OBJC__)
#if !defined(IBSegueAction)
# define IBSegueAction
#endif
#endif
#if !defined(SWIFT_EXTERN)
# if defined(__cplusplus)
# define SWIFT_EXTERN extern "C"
# else
# define SWIFT_EXTERN extern
# endif
#endif
#if !defined(SWIFT_CALL)
# define SWIFT_CALL __attribute__((swiftcall))
#endif
#if defined(__cplusplus)
#if !defined(SWIFT_NOEXCEPT)
# define SWIFT_NOEXCEPT noexcept
#endif
#else
#if !defined(SWIFT_NOEXCEPT)
# define SWIFT_NOEXCEPT
#endif
#endif
#if defined(__cplusplus)
#if !defined(SWIFT_CXX_INT_DEFINED)
#define SWIFT_CXX_INT_DEFINED
namespace swift {
using Int = ptrdiff_t;
using UInt = size_t;
}
#endif
#endif
#if defined(__OBJC__)
#if __has_feature(modules)
#if __has_warning("-Watimport-in-framework-header")
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
#endif
@import Foundation;
#endif
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
#if __has_warning("-Wpragma-clang-attribute")
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
#endif
#pragma clang diagnostic ignored "-Wunknown-pragmas"
#pragma clang diagnostic ignored "-Wnullability"
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
#if __has_attribute(external_source_symbol)
# pragma push_macro("any")
Expand All @@ -249,7 +213,6 @@ using UInt = size_t;
# pragma pop_macro("any")
#endif
#if defined(__OBJC__)
/// Subclass of <code>Operation</code> that adds support of asynchronous operations.
/// <ol>
Expand Down Expand Up @@ -293,15 +256,8 @@ SWIFT_CLASS("_TtC11SoulverCore46VanillaBackgroundEvaluationAndMergingOperation")
+ (nonnull instancetype)new SWIFT_UNAVAILABLE_MSG("-init is unavailable");
@end
#endif
#if defined(__cplusplus)
#endif
#if __has_attribute(external_source_symbol)
# pragma clang attribute pop
#endif
#pragma clang diagnostic pop
#endif
#else
#error unsupported Swift architecture
#endif
Binary file not shown.
Loading

0 comments on commit 4dc2be0

Please sign in to comment.