@@ -97,25 +97,25 @@ fun pointers(target: File) {
97
97
@JvmName("invokeULong")
98
98
inline infix operator fun $PtrType .invoke(index: ULong): $Type = get(index)
99
99
@JvmName("plus${Type } Int")
100
- inline infix operator fun $PtrType .plus(offset: Int): $PtrType = Ptr(address + offset.toULong())
100
+ inline infix operator fun $PtrType .plus(offset: Int): $PtrType = plus( offset.toULong())
101
101
@JvmName("plus${Type } UInt")
102
- inline infix operator fun $PtrType .plus(offset: UInt): $PtrType = Ptr(address + offset.toULong())
102
+ inline infix operator fun $PtrType .plus(offset: UInt): $PtrType = plus( offset.toULong())
103
103
@JvmName("plus${Type } Long")
104
- inline infix operator fun $PtrType .plus(offset: Long): $PtrType = Ptr(address + offset.toULong())
104
+ inline infix operator fun $PtrType .plus(offset: Long): $PtrType = plus( offset.toULong())
105
105
@JvmName("plus${Type } ULong")
106
- inline infix operator fun $PtrType .plus(offset: ULong): $PtrType = Ptr(address + offset)
106
+ inline infix operator fun $PtrType .plus(offset: ULong): $PtrType = Ptr(address + offset * $Type .BYTES.toULong() )
107
107
@JvmName("minus${Type } Int")
108
- inline infix operator fun $PtrType .minus(offset: Int): $PtrType = Ptr(address - offset.toULong())
108
+ inline infix operator fun $PtrType .minus(offset: Int): $PtrType = minus( offset.toULong())
109
109
@JvmName("minus${Type } UInt")
110
- inline infix operator fun $PtrType .minus(offset: UInt): $PtrType = Ptr(address - offset.toULong())
110
+ inline infix operator fun $PtrType .minus(offset: UInt): $PtrType = minus( offset.toULong())
111
111
@JvmName("minus${Type } Long")
112
- inline infix operator fun $PtrType .minus(offset: Long): $PtrType = Ptr(address - offset.toULong())
112
+ inline infix operator fun $PtrType .minus(offset: Long): $PtrType = minus( offset.toULong())
113
113
@JvmName("minus${Type } ULong")
114
- inline infix operator fun $PtrType .minus(offset: ULong): $PtrType = Ptr(address - offset)
114
+ inline infix operator fun $PtrType .minus(offset: ULong): $PtrType = Ptr(address - offset * $Type .BYTES.toULong() )
115
115
@JvmName("inc$Type ")
116
- inline operator fun $PtrType .inc(): $PtrType = Ptr(address + $Type .BYTES.toUInt() )
116
+ inline operator fun $PtrType .inc(): $PtrType = plus(1 )
117
117
@JvmName("dec$Type ")
118
- inline operator fun $PtrType .dec(): $PtrType = Ptr(address - $Type .BYTES.toUInt() )"""
118
+ inline operator fun $PtrType .dec(): $PtrType = minus(1 )"""
119
119
else
120
120
+ """
121
121
inline infix operator fun $PtrType .get(index: Int): $Type = get(index.toULong())
@@ -129,33 +129,30 @@ fun pointers(target: File) {
129
129
inline operator fun $PtrType .invoke(): $Type = get(0uL)
130
130
inline infix operator fun $PtrType .invoke(index: ULong): $Type = get(index)
131
131
@JvmName("plus${Type } Int")
132
- inline infix operator fun $PtrType .plus(offset: Int): $PtrType = Ptr(address + offset.toULong())
132
+ inline infix operator fun $PtrType .plus(offset: Int): $PtrType = plus( offset.toULong())
133
133
@JvmName("plus${Type } UInt")
134
- inline infix operator fun $PtrType .plus(offset: UInt): $PtrType = Ptr(address + offset.toULong())
134
+ inline infix operator fun $PtrType .plus(offset: UInt): $PtrType = plus( offset.toULong())
135
135
@JvmName("plus${Type } Long")
136
- inline infix operator fun $PtrType .plus(offset: Long): $PtrType = Ptr(address + offset.toULong())
136
+ inline infix operator fun $PtrType .plus(offset: Long): $PtrType = plus( offset.toULong())
137
137
@JvmName("plus${Type } ULong")
138
- inline infix operator fun $PtrType .plus(offset: ULong): $PtrType = Ptr(address + offset)
138
+ inline infix operator fun $PtrType .plus(offset: ULong): $PtrType = Ptr(address + offset * $Type .BYTES.toULong() )
139
139
@JvmName("minus${Type } Int")
140
- inline infix operator fun $PtrType .minus(offset: Int): $PtrType = Ptr(address - offset.toULong())
140
+ inline infix operator fun $PtrType .minus(offset: Int): $PtrType = minus( offset.toULong())
141
141
@JvmName("minus${Type } UInt")
142
- inline infix operator fun $PtrType .minus(offset: UInt): $PtrType = Ptr(address - offset.toULong())
142
+ inline infix operator fun $PtrType .minus(offset: UInt): $PtrType = minus( offset.toULong())
143
143
@JvmName("minus${Type } Long")
144
- inline infix operator fun $PtrType .minus(offset: Long): $PtrType = Ptr(address - offset.toULong())
144
+ inline infix operator fun $PtrType .minus(offset: Long): $PtrType = minus( offset.toULong())
145
145
@JvmName("minus${Type } ULong")
146
- inline infix operator fun $PtrType .minus(offset: ULong): $PtrType = Ptr(address - offset)
146
+ inline infix operator fun $PtrType .minus(offset: ULong): $PtrType = Ptr(address - offset * $Type .BYTES.toUInt() )
147
147
@JvmName("inc$Type ")
148
- inline operator fun $PtrType .inc(): $PtrType = Ptr(address + $Type .BYTES.toUInt() )
148
+ inline operator fun $PtrType .inc(): $PtrType = plus(1 )
149
149
@JvmName("dec$Type ")
150
- inline operator fun $PtrType .dec(): $PtrType = Ptr(address - $Type .BYTES.toUInt() )"""
150
+ inline operator fun $PtrType .dec(): $PtrType = minus(1 )"""
151
151
+ """
152
152
inline operator fun $PtrType .set(index: Int, $type : $Type ) = set(index.toULong(), $type )
153
153
inline operator fun $PtrType .set(index: UInt, $type : $Type ) = set(index.toULong(), $type )
154
154
inline operator fun $PtrType .set(index: Long, $type : $Type ) = set(index.toULong(), $type )
155
- inline operator fun $PtrType .set(index: ULong, $type : $Type ) = unsafe.set(adr + index$maybeTimes , $type$maybeToS )
156
-
157
- // inline operator fun plus(pByte: BytePtr): BytePtr = BytePtr(adr + pByte.adr)
158
- """
155
+ inline operator fun $PtrType .set(index: ULong, $type : $Type ) = unsafe.set(adr + index$maybeTimes , $type$maybeToS )"""
159
156
}
160
157
161
158
if (Type == " Pointer" ) {
0 commit comments