Skip to content

Instantly share code, notes, and snippets.

@dmitrykolesnikovich
Last active March 30, 2023 00:01
Show Gist options
  • Save dmitrykolesnikovich/4727ad93fb0dbff274388bd8893b700c to your computer and use it in GitHub Desktop.
Save dmitrykolesnikovich/4727ad93fb0dbff274388bd8893b700c to your computer and use it in GitHub Desktop.
how to implement artifact DSL
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