[K/N][cinterop] Improve Imports interface
Extracting `isImported(headerId: HeaderId): Boolean` method allows mocking this interface in tests
This commit is contained in:
committed by
Space Team
parent
2f0bdfc5e2
commit
fe8e18cb33
+7
-2
@@ -21,6 +21,8 @@ import org.jetbrains.kotlin.native.interop.indexer.*
|
||||
|
||||
interface Imports {
|
||||
fun getPackage(location: Location): String?
|
||||
|
||||
fun isImported(headerId: HeaderId): Boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +37,9 @@ class ImportsImpl(internal val headerIdToPackage: Map<HeaderId, PackageInfo>) :
|
||||
return packageInfo.name
|
||||
}
|
||||
|
||||
override fun isImported(headerId: HeaderId) =
|
||||
headerId in headerIdToPackage
|
||||
|
||||
private val accessedLibraries = mutableSetOf<KonanLibrary>()
|
||||
|
||||
val requiredLibraries: Set<KonanLibrary>
|
||||
@@ -63,11 +68,11 @@ class HeaderInclusionPolicyImpl(
|
||||
}
|
||||
|
||||
class HeaderExclusionPolicyImpl(
|
||||
private val importsImpl: ImportsImpl
|
||||
private val imports: Imports
|
||||
) : HeaderExclusionPolicy {
|
||||
|
||||
override fun excludeAll(headerId: HeaderId): Boolean {
|
||||
return headerId in importsImpl.headerIdToPackage
|
||||
return imports.isImported(headerId)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -508,7 +508,7 @@ internal fun buildNativeLibrary(
|
||||
tool: ToolConfig,
|
||||
def: DefFile,
|
||||
arguments: CInteropArguments,
|
||||
imports: ImportsImpl
|
||||
imports: Imports
|
||||
): NativeLibrary {
|
||||
val additionalHeaders = (arguments.header).toTypedArray()
|
||||
val additionalCompilerOpts = (arguments.compilerOpts +
|
||||
|
||||
Reference in New Issue
Block a user