Skip to content

Commit 231f51a

Browse files
committed
Framework initialize
1 parent 1b3c559 commit 231f51a

File tree

4 files changed

+24
-15
lines changed

4 files changed

+24
-15
lines changed

Hangul/HGInputContext.m

+14-5
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,24 @@
1313

1414
NS_ASSUME_NONNULL_BEGIN
1515

16-
@implementation HGKeyboard
17-
@synthesize data=_data;
18-
19-
+ (void)initialize {
20-
if (self == [HGKeyboard class]) {
16+
__attribute__((constructor))
17+
static void HangulInitialize() {
18+
static bool initialized = 0;
19+
if (!initialized) {
20+
// Initialization code.
21+
initialized = 1;
2122
hangul_init();
2223
}
2324
}
2425

26+
__attribute__((destructor))
27+
static void HangulFinalize() {
28+
hangul_fini();
29+
}
30+
31+
@implementation HGKeyboard
32+
@synthesize data=_data;
33+
2534
//! @ref hangul_keyboard_new
2635
- (instancetype)init {
2736
self = [self init];

Hangul/Hangul-Umbrella.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Hangul
44
//
55
// Created by Jeong YunWon on 2018. 9. 26..
6-
// Copyright © 2018년 youknowone.org. All rights reserved.
6+
// Copyright © 2018 youknowone.org. All rights reserved.
77
//
88

99
@import Foundation;

Hangul/libhangul.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
// Hangul
44
//
55
// Created by Jeong YunWon on 2018. 9. 26..
6-
// Copyright © 2018년 youknowone.org. All rights reserved.
6+
// Copyright © 2018 youknowone.org. All rights reserved.
77
//
88

99
@import Foundation;
1010

11+
#import "Hangul/HGInputContext.h"
12+
1113
const char *libhangul_data_dir() {
12-
NSBundle *hangulBundle = [NSBundle mainBundle];
14+
NSBundle *hangulBundle = [NSBundle bundleForClass:[HGKeyboard class]];
1315
NSString *path = hangulBundle.resourcePath;
1416
return path.fileSystemRepresentation;
1517
}

HangulTests/HangulTests.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@
66
// Copyright © 2017 youknowone.org. All rights reserved.
77
//
88

9-
import XCTest
109
import Hangul
10+
import XCTest
1111

1212
func ord(_ c: String) -> Int32 {
1313
return Int32(c.unicodeScalars.first!.value)
1414
}
1515

1616
class HangulTests: XCTestCase {
17-
1817
override func setUp() {
1918
super.setUp()
2019
// Put setup code here. This method is called before the invocation of each test method in the class.
2120
}
22-
21+
2322
override func tearDown() {
2423
// Put teardown code here. This method is called after the invocation of each test method in the class.
2524
super.tearDown()
@@ -36,7 +35,7 @@ class HangulTests: XCTestCase {
3635
}
3736

3837
func testKeyboard2() {
39-
hangul_init();
38+
hangul_init()
4039
let hic = hangul_ic_new("3gs")
4140
hangul_ic_process(hic, ord("j"))
4241
hangul_ic_process(hic, ord("t"))
@@ -46,7 +45,7 @@ class HangulTests: XCTestCase {
4645
}
4746

4847
func testBackspace() {
49-
hangul_init();
48+
hangul_init()
5049
let hic = hangul_ic_new("3gs")
5150
hangul_ic_process(hic, ord("j"))
5251
hangul_ic_process(hic, ord("t"))
@@ -57,9 +56,8 @@ class HangulTests: XCTestCase {
5756

5857
func testPerformanceExample() {
5958
// This is an example of a performance test case.
60-
self.measure {
59+
measure {
6160
// Put the code you want to measure the time of here.
6261
}
6362
}
64-
6563
}

0 commit comments

Comments
 (0)