Skip to content

Commit 41ea6ed

Browse files
authored
Don't inline bitfields. (#820)
Otherwise, not visible to Java/Scala
1 parent d93c76f commit 41ea6ed

File tree

23 files changed

+343
-85
lines changed

23 files changed

+343
-85
lines changed

harness/tests/src/main/java/godot/tests/JavaTestClass.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package godot.tests;
22

33
import godot.api.Button;
4+
import godot.api.Control;
45
import godot.api.Node;
56
import godot.api.RenderingServer;
67
import godot.annotation.*;
@@ -87,6 +88,10 @@ public void _ready() {
8788
long constant = RenderingServer.NO_INDEX_ARRAY;
8889
Signal signal = RenderingServer.getFramePreDraw();
8990
RenderingServer.getDefaultClearColor();
91+
// Check what Enum/Bitfields look like
92+
Control control = new Control();
93+
control.setHSizeFlags(Control.SizeFlags.FILL);
94+
control.free();
9095
}
9196

9297
@RegisterFunction

kt/api-generator/src/main/kotlin/godot/codegen/generation/rule/EnumRule.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ class EnumRule : GodotApiRule<EnrichedEnumTask>() {
6565
fun TypeSpec.Builder.generateBitfield(enum: EnrichedEnum) {
6666
val className = enum.className
6767

68-
addAnnotation(JvmInline::class)
69-
addModifiers(KModifier.VALUE)
7068
primaryConstructor(
7169
FunSpec.constructorBuilder()
7270
.addParameter(
@@ -118,6 +116,7 @@ class EnumRule : GodotApiRule<EnrichedEnumTask>() {
118116
bitfieldCompanion
119117
.addProperty(
120118
PropertySpec.builder(value.name, className)
119+
.addAnnotation(JvmField::class)
121120
.initializer(CodeBlock.of("%T(%L)", className, value.value))
122121
.addKdoc(value)
123122
.build()

kt/godot-library/godot-api-library/src/main/kotlin/godot/api/Control.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import kotlin.NotImplementedError
4848
import kotlin.String
4949
import kotlin.Suppress
5050
import kotlin.Unit
51-
import kotlin.jvm.JvmInline
51+
import kotlin.jvm.JvmField
5252
import kotlin.jvm.JvmName
5353
import kotlin.jvm.JvmOverloads
5454

@@ -3042,8 +3042,7 @@ public open class Control : CanvasItem() {
30423042
}
30433043
}
30443044

3045-
@JvmInline
3046-
public value class SizeFlags(
3045+
public class SizeFlags(
30473046
public val flag: Long,
30483047
) {
30493048
public infix fun or(other: SizeFlags): SizeFlags = SizeFlags(flag.or(other.flag))
@@ -3078,13 +3077,15 @@ public open class Control : CanvasItem() {
30783077
*
30793078
* **Note:** Setting this flag is equal to not having any size flags.
30803079
*/
3080+
@JvmField
30813081
public val SHRINK_BEGIN: SizeFlags = SizeFlags(0)
30823082

30833083
/**
30843084
* Tells the parent [Container] to expand the bounds of this node to fill all the available
30853085
* space without pushing any other node. It is mutually exclusive with shrink size flags. Use
30863086
* with [sizeFlagsHorizontal] and [sizeFlagsVertical].
30873087
*/
3088+
@JvmField
30883089
public val FILL: SizeFlags = SizeFlags(1)
30893090

30903091
/**
@@ -3093,26 +3094,30 @@ public open class Control : CanvasItem() {
30933094
* stretch ratio. See [sizeFlagsStretchRatio]. Use with [sizeFlagsHorizontal] and
30943095
* [sizeFlagsVertical].
30953096
*/
3097+
@JvmField
30963098
public val EXPAND: SizeFlags = SizeFlags(2)
30973099

30983100
/**
30993101
* Sets the node's size flags to both fill and expand. See [SIZE_FILL] and [SIZE_EXPAND] for
31003102
* more information.
31013103
*/
3104+
@JvmField
31023105
public val EXPAND_FILL: SizeFlags = SizeFlags(3)
31033106

31043107
/**
31053108
* Tells the parent [Container] to center the node in the available space. It is mutually
31063109
* exclusive with [SIZE_FILL] and other shrink size flags, but can be used with [SIZE_EXPAND] in
31073110
* some containers. Use with [sizeFlagsHorizontal] and [sizeFlagsVertical].
31083111
*/
3112+
@JvmField
31093113
public val SHRINK_CENTER: SizeFlags = SizeFlags(4)
31103114

31113115
/**
31123116
* Tells the parent [Container] to align the node with its end, either the bottom or the right
31133117
* edge. It is mutually exclusive with [SIZE_FILL] and other shrink size flags, but can be used
31143118
* with [SIZE_EXPAND] in some containers. Use with [sizeFlagsHorizontal] and [sizeFlagsVertical].
31153119
*/
3120+
@JvmField
31163121
public val SHRINK_END: SizeFlags = SizeFlags(8)
31173122
}
31183123
}

kt/godot-library/godot-api-library/src/main/kotlin/godot/api/FileAccess.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import kotlin.Long
3131
import kotlin.String
3232
import kotlin.Suppress
3333
import kotlin.Unit
34-
import kotlin.jvm.JvmInline
34+
import kotlin.jvm.JvmField
3535
import kotlin.jvm.JvmName
3636
import kotlin.jvm.JvmOverloads
3737
import kotlin.jvm.JvmStatic
@@ -769,8 +769,7 @@ public open class FileAccess internal constructor() : RefCounted() {
769769
}
770770
}
771771

772-
@JvmInline
773-
public value class UnixPermissionFlags(
772+
public class UnixPermissionFlags(
774773
public val flag: Long,
775774
) {
776775
public infix fun or(other: UnixPermissionFlags): UnixPermissionFlags =
@@ -804,61 +803,73 @@ public open class FileAccess internal constructor() : RefCounted() {
804803
/**
805804
* Read for owner bit.
806805
*/
806+
@JvmField
807807
public val READ_OWNER: UnixPermissionFlags = UnixPermissionFlags(256)
808808

809809
/**
810810
* Write for owner bit.
811811
*/
812+
@JvmField
812813
public val WRITE_OWNER: UnixPermissionFlags = UnixPermissionFlags(128)
813814

814815
/**
815816
* Execute for owner bit.
816817
*/
818+
@JvmField
817819
public val EXECUTE_OWNER: UnixPermissionFlags = UnixPermissionFlags(64)
818820

819821
/**
820822
* Read for group bit.
821823
*/
824+
@JvmField
822825
public val READ_GROUP: UnixPermissionFlags = UnixPermissionFlags(32)
823826

824827
/**
825828
* Write for group bit.
826829
*/
830+
@JvmField
827831
public val WRITE_GROUP: UnixPermissionFlags = UnixPermissionFlags(16)
828832

829833
/**
830834
* Execute for group bit.
831835
*/
836+
@JvmField
832837
public val EXECUTE_GROUP: UnixPermissionFlags = UnixPermissionFlags(8)
833838

834839
/**
835840
* Read for other bit.
836841
*/
842+
@JvmField
837843
public val READ_OTHER: UnixPermissionFlags = UnixPermissionFlags(4)
838844

839845
/**
840846
* Write for other bit.
841847
*/
848+
@JvmField
842849
public val WRITE_OTHER: UnixPermissionFlags = UnixPermissionFlags(2)
843850

844851
/**
845852
* Execute for other bit.
846853
*/
854+
@JvmField
847855
public val EXECUTE_OTHER: UnixPermissionFlags = UnixPermissionFlags(1)
848856

849857
/**
850858
* Set user id on execution bit.
851859
*/
860+
@JvmField
852861
public val SET_USER_ID: UnixPermissionFlags = UnixPermissionFlags(2048)
853862

854863
/**
855864
* Set group id on execution bit.
856865
*/
866+
@JvmField
857867
public val SET_GROUP_ID: UnixPermissionFlags = UnixPermissionFlags(1024)
858868

859869
/**
860870
* Restricted deletion (sticky) bit.
861871
*/
872+
@JvmField
862873
public val RESTRICTED_DELETE: UnixPermissionFlags = UnixPermissionFlags(512)
863874
}
864875
}

kt/godot-library/godot-api-library/src/main/kotlin/godot/api/ImageFormatLoader.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlin.Int
1111
import kotlin.Long
1212
import kotlin.Suppress
1313
import kotlin.Unit
14-
import kotlin.jvm.JvmInline
14+
import kotlin.jvm.JvmField
1515

1616
public infix fun Long.or(other: ImageFormatLoader.LoaderFlags): Long = this.or(other.flag)
1717

@@ -30,8 +30,7 @@ public open class ImageFormatLoader internal constructor() : RefCounted() {
3030
createNativeObject(283, scriptIndex)
3131
}
3232

33-
@JvmInline
34-
public value class LoaderFlags(
33+
public class LoaderFlags(
3534
public val flag: Long,
3635
) {
3736
public infix fun or(other: LoaderFlags): LoaderFlags = LoaderFlags(flag.or(other.flag))
@@ -59,10 +58,13 @@ public open class ImageFormatLoader internal constructor() : RefCounted() {
5958
public infix fun ushr(bits: Int): LoaderFlags = LoaderFlags(flag ushr bits)
6059

6160
public companion object {
61+
@JvmField
6262
public val FLAG_NONE: LoaderFlags = LoaderFlags(0)
6363

64+
@JvmField
6465
public val FLAG_FORCE_LINEAR: LoaderFlags = LoaderFlags(1)
6566

67+
@JvmField
6668
public val FLAG_CONVERT_COLORS: LoaderFlags = LoaderFlags(2)
6769
}
6870
}

0 commit comments

Comments
 (0)