@@ -26,7 +26,7 @@ fun pointers(target: File) {
26
26
27
27
val TypeBuffer = Type + " Buffer"
28
28
var maybeTimes = if (" Byte" in Type ) " " else " * $Type .BYTES.toULong()"
29
- val type = Type .decapitalize ()
29
+ val type = Type .decapitalized ()
30
30
val unsigned = Type [0 ] == ' U'
31
31
imports + = when {
32
32
unsigned -> listOf (" kool.ubuffers.$TypeBuffer " , " kool.ubuffers.as$TypeBuffer " )
@@ -35,7 +35,7 @@ fun pointers(target: File) {
35
35
}
36
36
val Ype = if (unsigned) Type .drop(1 ) else Type
37
37
val maybeToU = if (unsigned) " .to$Type ()" else " "
38
- val maybeAsU = if (unsigned) " .as$TypeBuffer ()" else " "
38
+ // val maybeAsU = if (unsigned) ".as$TypeBuffer()" else ""
39
39
val maybeToS = if (unsigned) " .to$Ype ()" else " "
40
40
41
41
val PtrType = " Ptr<$Type >"
@@ -76,24 +76,78 @@ fun pointers(target: File) {
76
76
imports + = " java.nio.ByteBuffer"
77
77
if (unsigned)
78
78
+ """
79
- inline fun $PtrType .get$Type (index: Int): $Type = get$Type (index.toULong())
80
- inline fun $PtrType .get$Type (index: UInt): $Type = get$Type (index.toULong())
81
- inline fun $PtrType .get$Type (index: Long): $Type = get$Type (index.toULong())
82
- inline fun $PtrType .get$Type (index: ULong = 0uL): $Type = unsafe.get$Ype (adr + index$maybeTimes )$maybeToU
83
- inline fun $PtrType .invoke$Type (index: Int): $Type = invoke$Type (index.toULong())
84
- inline fun $PtrType .invoke$Type (index: UInt): $Type = invoke$Type (index.toULong())
85
- inline fun $PtrType .invoke$Type (index: Long): $Type = invoke$Type (index.toULong())
86
- inline fun $PtrType .invoke$Type (index: ULong = 0uL): $Type = get$Type (index)"""
79
+ @JvmName("getInt")
80
+ inline operator infix fun $PtrType .get(index: Int): $Type = get(index.toULong())
81
+ @JvmName("getUInt")
82
+ inline infix operator fun $PtrType .get(index: UInt): $Type = get(index.toULong())
83
+ @JvmName("getLong")
84
+ inline infix operator fun $PtrType .get(index: Long): $Type = get(index.toULong())
85
+ @JvmName("getULong")
86
+ inline fun $PtrType .get(): $Type = get(0uL)
87
+ @JvmName("getULong")
88
+ inline infix operator fun $PtrType .get(index: ULong): $Type = unsafe.get$Ype (adr + index$maybeTimes )$maybeToU
89
+ @JvmName("invokeInt")
90
+ inline infix operator fun $PtrType .invoke(index: Int): $Type = invoke(index.toULong())
91
+ @JvmName("invokeUInt")
92
+ inline infix operator fun $PtrType .invoke(index: UInt): $Type = invoke(index.toULong())
93
+ @JvmName("invokeLong")
94
+ inline infix operator fun $PtrType .invoke(index: Long): $Type = invoke(index.toULong())
95
+ @JvmName("invokeULong")
96
+ inline operator fun $PtrType .invoke(): $Type = get(0uL)
97
+ @JvmName("invokeULong")
98
+ inline infix operator fun $PtrType .invoke(index: ULong): $Type = get(index)
99
+ @JvmName("plus${Type } Int")
100
+ inline infix operator fun $PtrType .plus(offset: Int): $PtrType = Ptr(address + offset.toULong())
101
+ @JvmName("plus${Type } UInt")
102
+ inline infix operator fun $PtrType .plus(offset: UInt): $PtrType = Ptr(address + offset.toULong())
103
+ @JvmName("plus${Type } Long")
104
+ inline infix operator fun $PtrType .plus(offset: Long): $PtrType = Ptr(address + offset.toULong())
105
+ @JvmName("plus${Type } ULong")
106
+ inline infix operator fun $PtrType .plus(offset: ULong): $PtrType = Ptr(address + offset)
107
+ @JvmName("minus${Type } Int")
108
+ inline infix operator fun $PtrType .minus(offset: Int): $PtrType = Ptr(address - offset.toULong())
109
+ @JvmName("minus${Type } UInt")
110
+ inline infix operator fun $PtrType .minus(offset: UInt): $PtrType = Ptr(address - offset.toULong())
111
+ @JvmName("minus${Type } Long")
112
+ inline infix operator fun $PtrType .minus(offset: Long): $PtrType = Ptr(address - offset.toULong())
113
+ @JvmName("minus${Type } ULong")
114
+ inline infix operator fun $PtrType .minus(offset: ULong): $PtrType = Ptr(address - offset)
115
+ @JvmName("inc$Type ")
116
+ inline operator fun $PtrType .inc(): $PtrType = Ptr(address + $Type .BYTES.toUInt())
117
+ @JvmName("dec$Type ")
118
+ inline operator fun $PtrType .dec(): $PtrType = Ptr(address - $Type .BYTES.toUInt())"""
87
119
else
88
120
+ """
89
- inline operator fun $PtrType .get(index: Int): $Type = get(index.toULong())
90
- inline operator fun $PtrType .get(index: UInt): $Type = get(index.toULong())
91
- inline operator fun $PtrType .get(index: Long): $Type = get(index.toULong())
92
- inline operator fun $PtrType .get(index: ULong = 0uL): $Type = unsafe.get$Ype (adr + index$maybeTimes )$maybeToU
93
- inline operator fun $PtrType .invoke(index: Int): $Type = invoke(index.toULong())
94
- inline operator fun $PtrType .invoke(index: UInt): $Type = invoke(index.toULong())
95
- inline operator fun $PtrType .invoke(index: Long): $Type = invoke(index.toULong())
96
- inline operator fun $PtrType .invoke(index: ULong = 0uL): $Type = get(index)"""
121
+ inline infix operator fun $PtrType .get(index: Int): $Type = get(index.toULong())
122
+ inline infix operator fun $PtrType .get(index: UInt): $Type = get(index.toULong())
123
+ inline infix operator fun $PtrType .get(index: Long): $Type = get(index.toULong())
124
+ inline fun $PtrType .get(): $Type = get(0uL)
125
+ inline infix operator fun $PtrType .get(index: ULong): $Type = unsafe.get$Ype (adr + index$maybeTimes )$maybeToU
126
+ inline infix operator fun $PtrType .invoke(index: Int): $Type = invoke(index.toULong())
127
+ inline infix operator fun $PtrType .invoke(index: UInt): $Type = invoke(index.toULong())
128
+ inline infix operator fun $PtrType .invoke(index: Long): $Type = invoke(index.toULong())
129
+ inline operator fun $PtrType .invoke(): $Type = get(0uL)
130
+ inline infix operator fun $PtrType .invoke(index: ULong): $Type = get(index)
131
+ @JvmName("plus${Type } Int")
132
+ inline infix operator fun $PtrType .plus(offset: Int): $PtrType = Ptr(address + offset.toULong())
133
+ @JvmName("plus${Type } UInt")
134
+ inline infix operator fun $PtrType .plus(offset: UInt): $PtrType = Ptr(address + offset.toULong())
135
+ @JvmName("plus${Type } Long")
136
+ inline infix operator fun $PtrType .plus(offset: Long): $PtrType = Ptr(address + offset.toULong())
137
+ @JvmName("plus${Type } ULong")
138
+ inline infix operator fun $PtrType .plus(offset: ULong): $PtrType = Ptr(address + offset)
139
+ @JvmName("minus${Type } Int")
140
+ inline infix operator fun $PtrType .minus(offset: Int): $PtrType = Ptr(address - offset.toULong())
141
+ @JvmName("minus${Type } UInt")
142
+ inline infix operator fun $PtrType .minus(offset: UInt): $PtrType = Ptr(address - offset.toULong())
143
+ @JvmName("minus${Type } Long")
144
+ inline infix operator fun $PtrType .minus(offset: Long): $PtrType = Ptr(address - offset.toULong())
145
+ @JvmName("minus${Type } ULong")
146
+ inline infix operator fun $PtrType .minus(offset: ULong): $PtrType = Ptr(address - offset)
147
+ @JvmName("inc$Type ")
148
+ inline operator fun $PtrType .inc(): $PtrType = Ptr(address + $Type .BYTES.toUInt())
149
+ @JvmName("dec$Type ")
150
+ inline operator fun $PtrType .dec(): $PtrType = Ptr(address - $Type .BYTES.toUInt())"""
97
151
+ """
98
152
inline operator fun $PtrType .set(index: Int, $type : $Type ) = set(index.toULong(), $type )
99
153
inline operator fun $PtrType .set(index: UInt, $type : $Type ) = set(index.toULong(), $type )
0 commit comments