-
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.
Merge pull request #698 from CruGlobal/stylesParent
GT-2450 Refactor stylesParent
- Loading branch information
Showing
9 changed files
with
47 additions
and
41 deletions.
There are no files selected for viewing
18 changes: 14 additions & 4 deletions
18
module/parser/src/commonMain/kotlin/org/cru/godtools/shared/tool/parser/model/Base.kt
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,11 +1,21 @@ | ||
package org.cru.godtools.shared.tool.parser.model | ||
|
||
import kotlin.experimental.ExperimentalObjCRefinement | ||
import kotlin.js.ExperimentalJsExport | ||
import kotlin.js.JsExport | ||
import kotlin.native.HiddenFromObjC | ||
import org.ccci.gto.support.androidx.annotation.RestrictTo | ||
import org.ccci.gto.support.androidx.annotation.RestrictToScope | ||
|
||
@OptIn(ExperimentalJsExport::class, ExperimentalObjCRefinement::class) | ||
interface Base { | ||
val manifest: Manifest | ||
val stylesParent: Styles? | ||
@HiddenFromObjC | ||
@JsExport.Ignore | ||
@get:RestrictTo(RestrictToScope.LIBRARY) | ||
val parent: Base? get() = null | ||
val manifest: Manifest get() = checkNotNull(parent?.manifest) { "No manifest found in model ancestors" } | ||
} | ||
|
||
val Base?.manifest get() = this?.manifest | ||
val Base?.stylesParent get() = this?.stylesParent | ||
val Base?.stylesParent: Styles? get() = this?.parent?.let { it as? Styles ?: it.stylesParent } | ||
|
||
internal fun Base.getResource(name: String?) = manifest.getResource(name) |
5 changes: 1 addition & 4 deletions
5
module/parser/src/commonMain/kotlin/org/cru/godtools/shared/tool/parser/model/BaseModel.kt
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,6 +1,3 @@ | ||
package org.cru.godtools.shared.tool.parser.model | ||
|
||
abstract class BaseModel internal constructor(private val parent: Base? = null) : Base { | ||
override val stylesParent get() = parent as? Styles ?: parent?.stylesParent | ||
override val manifest get() = checkNotNull(parent?.manifest) { "No manifest found in model ancestors" } | ||
} | ||
abstract class BaseModel internal constructor(override val parent: Base? = null) : Base |
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
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
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
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