11/*
22 This source file is part of the Swift.org open source project
33
4- Copyright (c) 2019 Apple Inc. and the Swift project authors
4+ Copyright (c) 2019 - 2020 Apple Inc. and the Swift project authors
55 Licensed under Apache License v2.0 with Runtime Library Exception
66
77 See http://swift.org/LICENSE.txt for license information
88 See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99 */
1010
1111import TSCBasic
12- import TSCclibc
12+ @ _implementationOnly import TSCclibc
1313
1414public final class IndexStore {
1515
@@ -19,22 +19,52 @@ public final class IndexStore {
1919 public var methods : [ String ]
2020 }
2121
22- let api : IndexStoreAPI
22+ fileprivate var impl : IndexStoreImpl { _impl as! IndexStoreImpl }
23+ private let _impl : Any
2324
24- var fn : indexstore_functions_t {
25- return api . fn
25+ fileprivate init ( _ impl : IndexStoreImpl ) {
26+ self . _impl = impl
2627 }
2728
29+ static public func open( store path: AbsolutePath , api: IndexStoreAPI ) throws -> IndexStore {
30+ let impl = try IndexStoreImpl . open ( store: path, api: api. impl)
31+ return IndexStore ( impl)
32+ }
33+
34+ public func listTests( inObjectFile object: AbsolutePath ) throws -> [ TestCaseClass ] {
35+ return try impl. listTests ( inObjectFile: object)
36+ }
37+ }
38+
39+ public final class IndexStoreAPI {
40+ fileprivate var impl : IndexStoreAPIImpl {
41+ _impl as! IndexStoreAPIImpl
42+ }
43+ private let _impl : Any
44+
45+ public init ( dylib path: AbsolutePath ) throws {
46+ self . _impl = try IndexStoreAPIImpl ( dylib: path)
47+ }
48+ }
49+
50+ private final class IndexStoreImpl {
51+
52+ typealias TestCaseClass = IndexStore . TestCaseClass
53+
54+ let api : IndexStoreAPIImpl
55+
56+ var fn : indexstore_functions_t { api. fn }
57+
2858 let store : indexstore_t
2959
30- private init ( store: indexstore_t , api: IndexStoreAPI ) {
60+ private init ( store: indexstore_t , api: IndexStoreAPIImpl ) {
3161 self . store = store
3262 self . api = api
3363 }
3464
35- static public func open( store path: AbsolutePath , api: IndexStoreAPI ) throws -> IndexStore {
65+ static public func open( store path: AbsolutePath , api: IndexStoreAPIImpl ) throws -> IndexStoreImpl {
3666 if let store = try api. call ( { api. fn. store_create ( path. pathString, & $0) } ) {
37- return IndexStore ( store: store, api: api)
67+ return IndexStoreImpl ( store: store, api: api)
3868 }
3969 throw StringError ( " Unable to open store at \( path) " )
4070 }
@@ -156,15 +186,15 @@ public final class IndexStore {
156186}
157187
158188private class Ref < T> {
159- let api : IndexStoreAPI
189+ let api : IndexStoreAPIImpl
160190 var instance : T
161- init ( _ instance: T , api: IndexStoreAPI ) {
191+ init ( _ instance: T , api: IndexStoreAPIImpl ) {
162192 self . instance = instance
163193 self . api = api
164194 }
165195}
166196
167- public final class IndexStoreAPI {
197+ private final class IndexStoreAPIImpl {
168198
169199 /// The path of the index store dylib.
170200 private let path : AbsolutePath
0 commit comments