Skip to content

Commit ce41ce7

Browse files
authored
Merge pull request #20 from Code-Sakura/release/v1.3.3
Release/v1.3.3
2 parents a3275e7 + f879a57 commit ce41ce7

29 files changed

+145
-89
lines changed

convention-plugins/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ fun pluginId(pluginName: String, version: String) = "$pluginName:$pluginName.gra
66
dependencies {
77
implementation(libs.nexus.publish)
88
implementation(pluginId("org.jetbrains.kotlin.multiplatform", "2.1.0"))
9+
implementation(pluginId("net.kigawa.renlin-compiler", "1.3.8"))
910
}

convention-plugins/src/main/kotlin/renlin.common.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
22

33
plugins {
44
kotlin("multiplatform")
5-
5+
id("net.kigawa.renlin-compiler")
66
}
77

88

generate/src/jvmMain/kotlin/generator/DslGenerator.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ class DslGenerator(
1111
fun generate() {
1212
// DSLクラスの生成
1313
(tagCategories.map { it.allowedCategories } +
14-
tagCategories.flatMap { it.allowedCategories.categories }.map { AllowedCategories(it) })
14+
tagCategories.flatMap { it.allowedCategories.categories }.map { AllowedCategories(it) })
1515
.filter { it.categories.isNotEmpty() }
1616
.forEach { allowedCategories ->
1717
val dslName = allowedCategories.connectedStr() + "Dsl"
1818
if (!processedDsls.contains(dslName)) {
1919
processedDsls.add(dslName)
2020
val categories = allowedCategories.categories
21-
21+
val extends = categories
22+
.filter { it.trim() + "Dsl" != dslName.trim() }
23+
.map { "${it}Dsl<CATEGORY_DSL>" } +
24+
"StatedDsl<CATEGORY_DSL>"
2225

2326
val imports = mutableListOf<String>()
2427

@@ -35,16 +38,15 @@ class DslGenerator(
3538
allowedCategories.connectedStr()
3639
}"
3740
}
41+
import net.kigawa.renlin.dsl.StatedDsl
3842
3943
4044
/**
4145
* DSL for ${categories.joinToString(", ")}
4246
*/
4347
interface ${dslName}<CATEGORY_DSL : ${allowedCategories.connectedStr()}>${
44-
if (categories.size <= 1) ""
45-
else (categories.filter { it.trim() != dslName.trim() }
46-
.joinToString(separator = ",", prefix = ":")
47-
{ "\n ${it}Dsl<CATEGORY_DSL>" })
48+
(extends.joinToString(separator = ",", prefix = ":")
49+
{ "\n $it" })
4850
}
4951
""".trimIndent()
5052

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#Gradle
2-
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx4096M"
2+
org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8
3+
kotlin.daemon.jvmargs=-Xmx4096M
34
org.gradle.caching=true
45
# https://github.com/gradle/gradle/issues/22779 le sigh
56
#org.gradle.configuration-cache=true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.kigawa.renlin
2+
3+
/**
4+
* Marks a parameter for automatic value injection when passed as null.
5+
* When applied to a function parameter, the plugin will automatically generate and inject a value if null is passed for this parameter.
6+
*/
7+
@Target(AnnotationTarget.VALUE_PARAMETER)
8+
@Retention(AnnotationRetention.RUNTIME)
9+
annotation class AutoFill
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package net.kigawa.renlin.component
22

3+
import net.kigawa.renlin.AutoFill
34
import net.kigawa.renlin.dsl.StatedDsl
45
import net.kigawa.renlin.tag.Tag
56
import net.kigawa.renlin.w3c.category.ContentCategory
67

78
interface Component0<out TAG: Tag<in CONTENT_CATEGORY>, CONTENT_CATEGORY: ContentCategory>: Component<TAG> {
8-
fun render(parentDsl: StatedDsl<out CONTENT_CATEGORY>, key: String?)
9+
fun render(parentDsl: StatedDsl<out CONTENT_CATEGORY>, @AutoFill key: String?)
910

1011
}

renlin/src/commonMain/kotlin/net/kigawa/renlin/dsl/StatedDsl.kt

Lines changed: 57 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.kigawa.renlin.dsl
22

33
import net.kigawa.hakate.api.state.State
4+
import net.kigawa.renlin.AutoFill
45
import net.kigawa.renlin.component.*
56
import net.kigawa.renlin.state.DslState
67
import net.kigawa.renlin.tag.Fragment
@@ -25,7 +26,7 @@ import net.kigawa.renlin.w3c.element.TagNode
2526
*
2627
* @param CONTENT_CATEGORY このDSLが生成できるHTMLコンテンツのカテゴリ
2728
*/
28-
interface StatedDsl< CONTENT_CATEGORY: ContentCategory>: Dsl {
29+
interface StatedDsl<CONTENT_CATEGORY: ContentCategory>: Dsl {
2930
/**
3031
* 現在のDSLに関連付けられた状態。
3132
* この状態はDSLの動作と描画を制御します。
@@ -58,66 +59,66 @@ interface StatedDsl< CONTENT_CATEGORY: ContentCategory>: Dsl {
5859

5960

6061
operator fun <TAG: Tag<in CONTENT_CATEGORY>> Component0<TAG, in CONTENT_CATEGORY>.invoke(
61-
key: String? = null,
62+
@AutoFill key: String? = null,
6263
) = this.render(this@StatedDsl, key)
6364

64-
/**
65-
* コンポーネントを呼び出し、レンダリングするための演算子オーバーロード。
66-
*
67-
* @param key コンポーネントの一意のキー(オプション)
68-
* @param block コンポーネントの内容を定義するブロック
69-
* @return コンポーネントのレンダリング結果
70-
*/
71-
operator fun <TAG: Tag<in CONTENT_CATEGORY>, DSL> Component1<TAG, in CONTENT_CATEGORY, DSL>.invoke(
72-
key: String? = null, block: DSL,
73-
) {
74-
return this@invoke.render(this@StatedDsl, block, key)
75-
}
65+
/**
66+
* コンポーネントを呼び出し、レンダリングするための演算子オーバーロード。
67+
*
68+
* @param key コンポーネントの一意のキー(オプション)
69+
* @param block コンポーネントの内容を定義するブロック
70+
* @return コンポーネントのレンダリング結果
71+
*/
72+
operator fun <TAG: Tag<in CONTENT_CATEGORY>, DSL> Component1<TAG, in CONTENT_CATEGORY, DSL>.invoke(
73+
@AutoFill key: String? = null, block: DSL,
74+
) {
75+
return this@invoke.render(this@StatedDsl, block, key)
76+
}
7677

77-
/**
78-
* Component2を呼び出し、レンダリングするための演算子オーバーロード。
79-
*
80-
* @param key コンポーネントの一意のキー(オプション)
81-
* @param arg1 第1引数
82-
* @param arg2 第2引数
83-
* @return コンポーネントのレンダリング結果
84-
*/
85-
operator fun <TAG: Tag<in CONTENT_CATEGORY>, ARG1, ARG2> Component2<TAG, in CONTENT_CATEGORY, ARG1, ARG2>.invoke(
86-
arg1: ARG1, arg2: ARG2, key: String? = null,
87-
) {
88-
return this@invoke.render(this@StatedDsl, arg1, arg2, key)
89-
}
78+
/**
79+
* Component2を呼び出し、レンダリングするための演算子オーバーロード。
80+
*
81+
* @param key コンポーネントの一意のキー(オプション)
82+
* @param arg1 第1引数
83+
* @param arg2 第2引数
84+
* @return コンポーネントのレンダリング結果
85+
*/
86+
operator fun <TAG: Tag<in CONTENT_CATEGORY>, ARG1, ARG2> Component2<TAG, in CONTENT_CATEGORY, ARG1, ARG2>.invoke(
87+
arg1: ARG1, arg2: ARG2, @AutoFill key: String? = null,
88+
) {
89+
return this@invoke.render(this@StatedDsl, arg1, arg2, key)
90+
}
9091

91-
/**
92-
* Component3を呼び出し、レンダリングするための演算子オーバーロード。
93-
*
94-
* @param key コンポーネントの一意のキー(オプション)
95-
* @param arg1 第1引数
96-
* @param arg2 第2引数
97-
* @param arg3 第3引数
98-
* @return コンポーネントのレンダリング結果
99-
*/
100-
operator fun <TAG: Tag<in CONTENT_CATEGORY>, ARG1, ARG2, ARG3> Component3<TAG, in CONTENT_CATEGORY, ARG1, ARG2, ARG3>.invoke(
101-
arg1: ARG1, arg2: ARG2, arg3: ARG3, key: String? = null,
102-
) {
103-
return this@invoke.render(this@StatedDsl, arg1, arg2, arg3, key)
104-
}
92+
/**
93+
* Component3を呼び出し、レンダリングするための演算子オーバーロード。
94+
*
95+
* @param key コンポーネントの一意のキー(オプション)
96+
* @param arg1 第1引数
97+
* @param arg2 第2引数
98+
* @param arg3 第3引数
99+
* @return コンポーネントのレンダリング結果
100+
*/
101+
operator fun <TAG: Tag<in CONTENT_CATEGORY>, ARG1, ARG2, ARG3> Component3<TAG, in CONTENT_CATEGORY, ARG1, ARG2, ARG3>.invoke(
102+
arg1: ARG1, arg2: ARG2, arg3: ARG3, @AutoFill key: String? = null,
103+
) {
104+
return this@invoke.render(this@StatedDsl, arg1, arg2, arg3, key)
105+
}
105106

106-
/**
107-
* Component4を呼び出し、レンダリングするための演算子オーバーロード。
108-
*
109-
* @param key コンポーネントの一意のキー(オプション)
110-
* @param arg1 第1引数
111-
* @param arg2 第2引数
112-
* @param arg3 第3引数
113-
* @param arg4 第4引数
114-
* @return コンポーネントのレンダリング結果
115-
*/
116-
operator fun <TAG: Tag<in CONTENT_CATEGORY>, ARG1, ARG2, ARG3, ARG4> Component4<TAG, in CONTENT_CATEGORY, ARG1, ARG2, ARG3, ARG4>.invoke(
117-
arg1: ARG1, arg2: ARG2, arg3: ARG3, arg4: ARG4, key: String? = null,
118-
) {
119-
return this@invoke.render(this@StatedDsl, arg1, arg2, arg3, arg4, key)
120-
}
107+
/**
108+
* Component4を呼び出し、レンダリングするための演算子オーバーロード。
109+
*
110+
* @param key コンポーネントの一意のキー(オプション)
111+
* @param arg1 第1引数
112+
* @param arg2 第2引数
113+
* @param arg3 第3引数
114+
* @param arg4 第4引数
115+
* @return コンポーネントのレンダリング結果
116+
*/
117+
operator fun <TAG: Tag<in CONTENT_CATEGORY>, ARG1, ARG2, ARG3, ARG4> Component4<TAG, in CONTENT_CATEGORY, ARG1, ARG2, ARG3, ARG4>.invoke(
118+
arg1: ARG1, arg2: ARG2, arg3: ARG3, arg4: ARG4, @AutoFill key: String? = null,
119+
) {
120+
return this@invoke.render(this@StatedDsl, arg1, arg2, arg3, arg4, key)
121+
}
121122

122123

123124
/**

renlin/src/commonMain/kotlin/net/kigawa/renlin/state/DslStateData.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.kigawa.renlin.state
22

3+
import net.kigawa.renlin.AutoFill
34
import net.kigawa.renlin.w3c.event.WebPointerEvent
45
import kotlin.reflect.KClass
56
import kotlin.reflect.typeOf
@@ -42,7 +43,7 @@ data class DslStateData(
4243
* @param T 追加データの値の型
4344
* @param key 追加データの一意のキー
4445
*/
45-
inline fun <reified T : Any> setAdditionalData(contextClass: KClass<*>, value: T, key: String? = null) {
46+
inline fun <reified T : Any> setAdditionalData(contextClass: KClass<*>, value: T, @AutoFill key: String? = null) {
4647
removeAdditionalData<T>(contextClass)
4748
additionalData = additionalData + AdditionalDslStateData(
4849
contextClass, typeOf<T>(), key, value
@@ -55,7 +56,7 @@ data class DslStateData(
5556
* @param T 追加データの値の型
5657
* @param key 追加データの一意のキー
5758
*/
58-
inline fun <reified T : Any> removeAdditionalData(contextClass: KClass<*>,key: String? = null) {
59+
inline fun <reified T : Any> removeAdditionalData(contextClass: KClass<*>, @AutoFill key: String? = null) {
5960
additionalData = additionalData.filter {
6061
it.contextClass != contextClass || it.valueType != typeOf<T>() || it.key != key
6162
}
@@ -71,7 +72,7 @@ data class DslStateData(
7172
* @return 一致するデータが見つかった場合はその値、見つからない場合はnul
7273
*
7374
*/
74-
inline fun <reified T : Any> getAdditionalData(contextClass: KClass<*>, key: String? = null): T? {
75+
inline fun <reified T : Any> getAdditionalData(contextClass: KClass<*>, @AutoFill key: String? = null): T? {
7576
@Suppress("UNCHECKED_CAST")
7677
return additionalData
7778
.firstOrNull {

renlin/src/commonMain/kotlin/net/kigawa/renlin/w3c/category/Func.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package net.kigawa.renlin.w3c.category
22

3+
import net.kigawa.renlin.AutoFill
34
import net.kigawa.renlin.dsl.StatedDsl
45
import net.kigawa.renlin.tag.text
56
import net.kigawa.renlin.w3c.category.native.PhrasingContent
67

78

8-
fun <CONTENT_CATEGORY : PhrasingContent> StatedDsl<out CONTENT_CATEGORY>.t(str: String, key: String? = null) {
9+
fun <CONTENT_CATEGORY: PhrasingContent> StatedDsl<out CONTENT_CATEGORY>.t(str: String, @AutoFill key: String? = null) {
910
text.render(this, {
1011
this@render.text = str
1112
}, key)

renlin/src/commonMain/kotlin/net/kigawa/renlin/w3c/category/dsl/AutocapitalizeInheritingFormContentDsl.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package net.kigawa.renlin.w3c.category.dsl
22

33

44
import net.kigawa.renlin.w3c.category.native.AutocapitalizeInheritingFormContent
5+
import net.kigawa.renlin.dsl.StatedDsl
56

67

78
/**
89
* DSL for AutocapitalizeInheritingFormContent
910
*/
10-
interface AutocapitalizeInheritingFormContentDsl<CATEGORY_DSL : AutocapitalizeInheritingFormContent>
11+
interface AutocapitalizeInheritingFormContentDsl<CATEGORY_DSL : AutocapitalizeInheritingFormContent>:
12+
StatedDsl<CATEGORY_DSL>

0 commit comments

Comments
 (0)