-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 70e98ff.
- Loading branch information
Showing
15 changed files
with
112 additions
and
1,102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ __pycache__/ | |
*.py[cdo] | ||
*.egg-info/ | ||
*.so | ||
.swiftpm/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
// swift-tools-version: 5.8 | ||
// swift-tools-version:5.1 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "uklatn", | ||
products: [ | ||
.library( | ||
name: "UkrainianLatin", | ||
targets: ["UkrainianLatin"]), | ||
.executable( | ||
name: "uklatn", | ||
targets: ["cli"]), | ||
name: "UKLatn", | ||
targets: ["UKLatn"]), | ||
], | ||
targets: [ | ||
.target( | ||
name: "UkrainianLatin", | ||
path: "swift/Sources/UkrainianLatin"), | ||
name: "UKLatn", | ||
dependencies: ["_uklatn"], | ||
path: "swift/Sources/UKLatn"), | ||
.target( | ||
name: "_uklatn", | ||
path: "swift/Sources/_uklatn", | ||
cSettings: [ | ||
.headerSearchPath("../../../c/include"), | ||
], | ||
linkerSettings: [ | ||
.linkedLibrary("icuuc"), | ||
.linkedLibrary("icui18n"), | ||
]), | ||
.testTarget( | ||
name: "UKLatnTests", | ||
dependencies: ["UkrainianLatin"], | ||
path: "swift/Tests/UkrainianLatinTests"), | ||
.executableTarget( | ||
name: "cli", | ||
dependencies: ["UkrainianLatin"], | ||
path: "swift/Sources/cli"), | ||
dependencies: ["UKLatn"], | ||
path: "swift/Tests/UKLatnTests"), | ||
], | ||
swiftLanguageVersions: [.v5] | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import _uklatn | ||
|
||
|
||
public struct UKLatnTable { | ||
public static let DSTU_9112_A = Int(_uklatn.UklatnTable_DSTU_9112_A.rawValue) | ||
public static let DSTU_9112_B = Int(_uklatn.UklatnTable_DSTU_9112_B.rawValue) | ||
public static let KMU_55 = Int(_uklatn.UklatnTable_KMU_55.rawValue) | ||
} | ||
|
||
|
||
public enum UKLatnError: Error { | ||
case failed(code: Int) | ||
} | ||
|
||
|
||
public func encode(_ text: String, table: Int = 0) throws -> String { | ||
let n = text.utf8.count | ||
let dst = UnsafeMutableBufferPointer<CChar>.allocate(capacity: n * 3) | ||
defer { | ||
dst.deallocate() | ||
} | ||
let err = _uklatn.uklatn_encode(text, Int32(table), dst.baseAddress, Int32(dst.count)) | ||
if err != 0 { | ||
throw UKLatnError.failed(code: Int(err)) | ||
} | ||
let res = String(cString: dst.baseAddress!) | ||
return res | ||
} | ||
|
||
|
||
public func decode(_ text: String, table: Int = 0) throws -> String { | ||
let n = text.utf8.count | ||
let dst = UnsafeMutableBufferPointer<CChar>.allocate(capacity: n * 3) | ||
defer { | ||
dst.deallocate() | ||
} | ||
let err = _uklatn.uklatn_decode(text, Int32(table), dst.baseAddress, Int32(dst.count)) | ||
if err != 0 { | ||
throw UKLatnError.failed(code: Int(err)) | ||
} | ||
let res = String(cString: dst.baseAddress!) | ||
return res | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#include "include/_uklatn/_uklatn.h" | ||
#include "../../../c/uklatn.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
#include "../../../../../c/include/uklatn.h" | ||
|
Oops, something went wrong.