Last active
March 30, 2023 00:01
-
-
Save dmitrykolesnikovich/4727ad93fb0dbff274388bd8893b700c to your computer and use it in GitHub Desktop.
how to implement artifact DSL
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
package featurea.obj | |
import featurea.content.contentTypes | |
import featurea.runtime.Artifact | |
val artifact = Artifact("featurea.obj") { | |
include(featurea.image.artifact) | |
"ObjCache" to ::ObjCache | |
static { | |
"ObjReader" to ::ObjReader | |
} | |
contentTypes { | |
"ObjContentType" to ::ObjContentType | |
} | |
// research | |
component("Obj") { ObjContentType() } | |
component("ObjCache") { ObjCache() } | |
static { | |
component("ObjReader") { ObjReader() } | |
} | |
component("createFont") { createFont() } | |
// >> | |
WindowPlugin { | |
"CameraElementProvider" to ::CameraElementProvider | |
} | |
Window.component("CameraElementProvider") { CameraElementProvider() } | |
// << | |
} | |
/*actions*/ | |
fun createFont() = action { args: Array<Any> -> | |
val fntFile: File = File(args[0] as String) | |
val name: String = args[1] as String | |
val size: Int = args[2] as Int | |
val isBold: Boolean = args[3] as Boolean | |
val isItalic: Boolean = args[4] as Boolean | |
if (!fntFile.exists()) { | |
createFntFile(fntFile, name, size, isBold, isItalic) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment