Skip to content

Commit 9d67fda

Browse files
committed
up
1 parent 24f8e56 commit 9d67fda

File tree

2 files changed

+132
-91
lines changed

2 files changed

+132
-91
lines changed

src/main/kotlin/glm_/vec2/Vec2i.kt

Lines changed: 106 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package glm_.vec2
22

33
import glm_.*
4-
import glm_.vec2.operators.vec2i_operators
4+
import glm_.vec2.operators.opVec2i
55
import glm_.vec3.Vec3bool
66
import glm_.vec3.Vec3t
77
import glm_.vec4.Vec4bool
@@ -130,7 +130,7 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
130130
fun comptimes() = x * y
131131

132132

133-
companion object : vec2i_operators {
133+
companion object : opVec2i() {
134134
@JvmField
135135
val length = 2
136136
@JvmField
@@ -148,12 +148,12 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
148148

149149
operator fun inc() = plus(Vec2i(), this, 1, 1)
150150
infix fun inc(res: Vec2i) = plus(res, this, 1, 1)
151-
fun inc_() = plus(this, this, 1, 1)
151+
fun incAssign() = plus(this, this, 1, 1)
152152

153153

154154
operator fun dec() = minus(Vec2i(), this, 1, 1)
155155
infix fun dec(res: Vec2i) = minus(res, this, 1, 1)
156-
fun dec_() = minus(this, this, 1, 1)
156+
fun decAssign() = minus(this, this, 1, 1)
157157

158158

159159
// -- Specific binary arithmetic operators --
@@ -167,9 +167,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
167167
fun plus(b: Int, res: Vec2i) = plus(res, this, b, b)
168168
fun plus(b: Vec2i, res: Vec2i) = plus(res, this, b.x, b.y)
169169

170-
fun plus_(bX: Int, bY: Int) = plus(this, this, bX, bY)
171-
infix fun plus_(b: Int) = plus(this, this, b, b)
172-
infix fun plus_(b: Vec2i) = plus(this, this, b.x, b.y)
170+
fun plusAssign(bX: Int, bY: Int) = plus(this, this, bX, bY)
171+
infix operator fun plusAssign(b: Int) {
172+
plus(this, this, b, b)
173+
}
174+
infix operator fun plusAssign(b: Vec2i) {
175+
plus(this, this, b.x, b.y)
176+
}
173177

174178

175179
infix operator fun minus(b: Int) = minus(Vec2i(), this, b, b)
@@ -181,9 +185,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
181185
fun minus(b: Int, res: Vec2i) = minus(res, this, b, b)
182186
fun minus(b: Vec2i, res: Vec2i) = minus(res, this, b.x, b.y)
183187

184-
fun minus_(bX: Int, bY: Int) = minus(this, this, bX, bY)
185-
infix fun minus_(b: Int) = minus(this, this, b, b)
186-
infix fun minus_(b: Vec2i) = minus(this, this, b.x, b.y)
188+
fun minusAssign(bX: Int, bY: Int) = minus(this, this, bX, bY)
189+
infix operator fun minusAssign(b: Int) {
190+
minus(this, this, b, b)
191+
}
192+
infix operator fun minusAssign(b: Vec2i) {
193+
minus(this, this, b.x, b.y)
194+
}
187195

188196

189197
infix operator fun times(b: Int) = times(Vec2i(), this, b, b)
@@ -195,9 +203,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
195203
fun times(b: Int, res: Vec2i) = times(res, this, b, b)
196204
fun times(b: Vec2i, res: Vec2i) = times(res, this, b.x, b.y)
197205

198-
fun times_(bX: Int, bY: Int) = times(this, this, bX, bY)
199-
infix fun times_(b: Int) = times(this, this, b, b)
200-
infix fun times_(b: Vec2i) = times(this, this, b.x, b.y)
206+
fun timesAssign(bX: Int, bY: Int) = times(this, this, bX, bY)
207+
infix operator fun timesAssign(b: Int) {
208+
times(this, this, b, b)
209+
}
210+
infix operator fun timesAssign(b: Vec2i) {
211+
times(this, this, b.x, b.y)
212+
}
201213

202214

203215
infix operator fun div(b: Int) = div(Vec2i(), this, b, b)
@@ -209,9 +221,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
209221
fun div(b: Int, res: Vec2i) = div(res, this, b, b)
210222
fun div(b: Vec2i, res: Vec2i) = div(res, this, b.x, b.y)
211223

212-
fun div_(bX: Int, bY: Int) = div(this, this, bX, bY)
213-
infix fun div_(b: Int) = div(this, this, b, b)
214-
infix fun div_(b: Vec2i) = div(this, this, b.x, b.y)
224+
fun divAssign(bX: Int, bY: Int) = div(this, this, bX, bY)
225+
infix operator fun divAssign(b: Int) {
226+
div(this, this, b, b)
227+
}
228+
infix operator fun divAssign(b: Vec2i) {
229+
div(this, this, b.x, b.y)
230+
}
215231

216232

217233
infix operator fun rem(b: Int) = rem(Vec2i(), this, b, b)
@@ -223,9 +239,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
223239
fun rem(b: Int, res: Vec2i) = rem(res, this, b, b)
224240
fun rem(b: Vec2i, res: Vec2i) = rem(res, this, b.x, b.y)
225241

226-
fun rem_(bX: Int, bY: Int) = rem(this, this, bX, bY)
227-
infix fun rem_(b: Int) = rem(this, this, b, b)
228-
infix fun rem_(b: Vec2i) = rem(this, this, b.x, b.y)
242+
fun remAssign(bX: Int, bY: Int) = rem(this, this, bX, bY)
243+
infix operator fun remAssign(b: Int) {
244+
rem(this, this, b, b)
245+
}
246+
infix operator fun remAssign(b: Vec2i) {
247+
rem(this, this, b.x, b.y)
248+
}
229249

230250

231251
// -- Generic binary arithmetic operators --
@@ -239,9 +259,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
239259
fun plus(b: Number, res: Vec2i) = plus(res, this, b.i, b.i)
240260
fun plus(b: Vec2t<out Number>, res: Vec2i) = plus(res, this, b.x.i, b.y.i)
241261

242-
fun plus_(bX: Number, bY: Number) = plus(this, this, bX.i, bY.i)
243-
infix fun plus_(b: Number) = plus(this, this, b.i, b.i)
244-
infix fun plus_(b: Vec2t<out Number>) = plus(this, this, b.x.i, b.y.i)
262+
fun plusAssign(bX: Number, bY: Number) = plus(this, this, bX.i, bY.i)
263+
infix operator fun plusAssign(b: Number) {
264+
plus(this, this, b.i, b.i)
265+
}
266+
infix operator fun plusAssign(b: Vec2t<out Number>) {
267+
plus(this, this, b.x.i, b.y.i)
268+
}
245269

246270

247271
infix operator fun minus(b: Number) = minus(Vec2i(), this, b.i, b.i)
@@ -253,9 +277,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
253277
fun minus(b: Number, res: Vec2i) = minus(res, this, b.i, b.i)
254278
fun minus(b: Vec2t<out Number>, res: Vec2i) = minus(res, this, b.x.i, b.y.i)
255279

256-
fun minus_(bX: Number, bY: Number) = minus(this, this, bX.i, bY.i)
257-
infix fun minus_(b: Number) = minus(this, this, b.i, b.i)
258-
infix fun minus_(b: Vec2t<out Number>) = minus(this, this, b.x.i, b.y.i)
280+
fun minusAssign(bX: Number, bY: Number) = minus(this, this, bX.i, bY.i)
281+
infix operator fun minusAssign(b: Number) {
282+
minus(this, this, b.i, b.i)
283+
}
284+
infix operator fun minusAssign(b: Vec2t<out Number>) {
285+
minus(this, this, b.x.i, b.y.i)
286+
}
259287

260288

261289
infix operator fun times(b: Number) = times(Vec2i(), this, b.i, b.i)
@@ -267,9 +295,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
267295
fun times(b: Number, res: Vec2i) = times(res, this, b.i, b.i)
268296
fun times(b: Vec2t<out Number>, res: Vec2i) = times(res, this, b.x.i, b.y.i)
269297

270-
fun times_(bX: Number, bY: Number) = times(this, this, bX.i, bY.i)
271-
infix fun times_(b: Number) = times(this, this, b.i, b.i)
272-
infix fun times_(b: Vec2t<out Number>) = times(this, this, b.x.i, b.y.i)
298+
fun timesAssign(bX: Number, bY: Number) = times(this, this, bX.i, bY.i)
299+
infix operator fun timesAssign(b: Number) {
300+
times(this, this, b.i, b.i)
301+
}
302+
infix operator fun timesAssign(b: Vec2t<out Number>) {
303+
times(this, this, b.x.i, b.y.i)
304+
}
273305

274306

275307
infix operator fun div(b: Number) = div(Vec2i(), this, b.i, b.i)
@@ -281,9 +313,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
281313
fun div(b: Number, res: Vec2i) = div(res, this, b.i, b.i)
282314
fun div(b: Vec2t<out Number>, res: Vec2i) = div(res, this, b.x.i, b.y.i)
283315

284-
fun div_(bX: Number, bY: Number) = div(this, this, bX.i, bY.i)
285-
infix fun div_(b: Number) = div(this, this, b.i, b.i)
286-
infix fun div_(b: Vec2t<out Number>) = div(this, this, b.x.i, b.y.i)
316+
fun divAssign(bX: Number, bY: Number) = div(this, this, bX.i, bY.i)
317+
infix operator fun divAssign(b: Number) {
318+
div(this, this, b.i, b.i)
319+
}
320+
infix operator fun divAssign(b: Vec2t<out Number>) {
321+
div(this, this, b.x.i, b.y.i)
322+
}
287323

288324

289325
infix operator fun rem(b: Number) = rem(Vec2i(), this, b.i, b.i)
@@ -295,9 +331,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
295331
fun rem(b: Number, res: Vec2i) = rem(res, this, b.i, b.i)
296332
fun rem(b: Vec2t<out Number>, res: Vec2i) = rem(res, this, b.x.i, b.y.i)
297333

298-
fun rem_(bX: Number, bY: Number) = rem(this, this, bX.i, bY.i)
299-
infix fun rem_(b: Number) = rem(this, this, b.i, b.i)
300-
infix fun rem_(b: Vec2t<out Number>) = rem(this, this, b.x.i, b.y.i)
334+
fun remAssign(bX: Number, bY: Number) = rem(this, this, bX.i, bY.i)
335+
infix operator fun remAssign(b: Number) {
336+
rem(this, this, b.i, b.i)
337+
}
338+
infix operator fun remAssign(b: Vec2t<out Number>) {
339+
rem(this, this, b.x.i, b.y.i)
340+
}
301341

302342

303343
// -- Specific bitwise operators --
@@ -310,9 +350,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
310350
@JvmOverloads
311351
fun and(bX: Int, bY: Int, res: Vec2i = Vec2i()) = and(res, this, bX, bY)
312352

313-
infix fun and_(b: Int) = and(this, this, b, b)
314-
infix fun and_(b: Vec2i) = and(this, this, b.x, b.y)
315-
fun and_(bX: Int, bY: Int) = and(this, this, bX, bY)
353+
infix fun andAssign(b: Int) = and(this, this, b, b)
354+
infix fun andAssign(b: Vec2i) = and(this, this, b.x, b.y)
355+
fun andAssign(bX: Int, bY: Int) = and(this, this, bX, bY)
316356

317357

318358
infix fun or(b: Int) = or(Vec2i(), this, b, b)
@@ -323,9 +363,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
323363
@JvmOverloads
324364
fun or(bX: Int, bY: Int, res: Vec2i = Vec2i()) = or(res, this, bX, bY)
325365

326-
infix fun or_(b: Int) = or(this, this, b, b)
327-
infix fun or_(b: Vec2i) = or(this, this, b.x, b.y)
328-
fun or_(bX: Int, bY: Int) = or(this, this, bX, bY)
366+
infix fun orAssign(b: Int) = or(this, this, b, b)
367+
infix fun orAssign(b: Vec2i) = or(this, this, b.x, b.y)
368+
fun orAssign(bX: Int, bY: Int) = or(this, this, bX, bY)
329369

330370

331371
infix fun xor(b: Int) = xor(Vec2i(), this, b, b)
@@ -336,9 +376,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
336376
@JvmOverloads
337377
fun xor(bX: Int, bY: Int, res: Vec2i = Vec2i()) = xor(res, this, bX, bY)
338378

339-
infix fun xor_(b: Int) = xor(this, this, b, b)
340-
infix fun xor_(b: Vec2i) = xor(this, this, b.x, b.y)
341-
fun xor_(bX: Int, bY: Int) = xor(this, this, bX, bY)
379+
infix fun xorAssign(b: Int) = xor(this, this, b, b)
380+
infix fun xorAssign(b: Vec2i) = xor(this, this, b.x, b.y)
381+
fun xorAssign(bX: Int, bY: Int) = xor(this, this, bX, bY)
342382

343383

344384
infix fun shl(b: Int) = shl(Vec2i(), this, b, b)
@@ -349,9 +389,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
349389
@JvmOverloads
350390
fun shl(bX: Int, bY: Int, res: Vec2i = Vec2i()) = shl(res, this, bX, bY)
351391

352-
infix fun shl_(b: Int) = shl(this, this, b, b)
353-
infix fun shl_(b: Vec2i) = shl(this, this, b.x, b.y)
354-
fun shl_(bX: Int, bY: Int) = shl(this, this, bX, bY)
392+
infix fun shlAssign(b: Int) = shl(this, this, b, b)
393+
infix fun shlAssign(b: Vec2i) = shl(this, this, b.x, b.y)
394+
fun shlAssign(bX: Int, bY: Int) = shl(this, this, bX, bY)
355395

356396

357397
infix fun shr(b: Int) = shr(Vec2i(), this, b, b)
@@ -362,9 +402,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
362402
@JvmOverloads
363403
fun shr(bX: Int, bY: Int, res: Vec2i = Vec2i()) = shr(res, this, bX, bY)
364404

365-
infix fun shr_(b: Int) = shr(this, this, b, b)
366-
infix fun shr_(b: Vec2i) = shr(this, this, b.x, b.y)
367-
fun shr_(bX: Int, bY: Int) = shr(this, this, bX, bY)
405+
infix fun shrAssign(b: Int) = shr(this, this, b, b)
406+
infix fun shrAssign(b: Vec2i) = shr(this, this, b.x, b.y)
407+
fun shrAssign(bX: Int, bY: Int) = shr(this, this, bX, bY)
368408

369409

370410
// TODO fill & others
@@ -374,7 +414,7 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
374414
@JvmOverloads
375415
fun inv(res: Vec2i = Vec2i()) = inv(res, this)
376416

377-
fun inv_() = inv(this, this)
417+
fun invAssign() = inv(this, this)
378418

379419

380420
// -- Generic bitwise operators --
@@ -387,9 +427,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
387427
@JvmOverloads
388428
fun and(bX: Number, bY: Number, res: Vec2i = Vec2i()) = and(res, this, bX.i, bY.i)
389429

390-
infix fun and_(b: Number) = and(this, this, b.i, b.i)
391-
infix fun and_(b: Vec2t<out Number>) = and(this, this, b.x.i, b.y.i)
392-
fun and_(bX: Number, bY: Number) = and(this, this, bX.i, bY.i)
430+
infix fun andAssign(b: Number) = and(this, this, b.i, b.i)
431+
infix fun andAssign(b: Vec2t<out Number>) = and(this, this, b.x.i, b.y.i)
432+
fun andAssign(bX: Number, bY: Number) = and(this, this, bX.i, bY.i)
393433

394434

395435
infix fun or(b: Number) = or(Vec2i(), this, b.i, b.i)
@@ -400,9 +440,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
400440
@JvmOverloads
401441
fun or(bX: Number, bY: Number, res: Vec2i = Vec2i()) = or(res, this, bX.i, bY.i)
402442

403-
infix fun or_(b: Number) = or(this, this, b.i, b.i)
404-
infix fun or_(b: Vec2t<out Number>) = or(this, this, b.x.i, b.y.i)
405-
fun or_(bX: Number, bY: Number) = or(this, this, bX.i, bY.i)
443+
infix fun orAssign(b: Number) = or(this, this, b.i, b.i)
444+
infix fun orAssign(b: Vec2t<out Number>) = or(this, this, b.x.i, b.y.i)
445+
fun orAssign(bX: Number, bY: Number) = or(this, this, bX.i, bY.i)
406446

407447

408448
infix fun xor(b: Number) = xor(Vec2i(), this, b.i, b.i)
@@ -413,9 +453,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
413453
@JvmOverloads
414454
fun xor(bX: Number, bY: Number, res: Vec2i = Vec2i()) = xor(res, this, bX.i, bY.i)
415455

416-
infix fun xor_(b: Number) = xor(this, this, b.i, b.i)
417-
infix fun xor_(b: Vec2t<out Number>) = xor(this, this, b.x.i, b.y.i)
418-
fun xor_(bX: Number, bY: Number) = xor(this, this, bX.i, bY.i)
456+
infix fun xorAssign(b: Number) = xor(this, this, b.i, b.i)
457+
infix fun xorAssign(b: Vec2t<out Number>) = xor(this, this, b.x.i, b.y.i)
458+
fun xorAssign(bX: Number, bY: Number) = xor(this, this, bX.i, bY.i)
419459

420460

421461
infix fun shl(b: Number) = shl(Vec2i(), this, b.i, b.i)
@@ -426,9 +466,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
426466
@JvmOverloads
427467
fun shl(bX: Number, bY: Number, res: Vec2i = Vec2i()) = shl(res, this, bX.i, bY.i)
428468

429-
infix fun shl_(b: Number) = shl(this, this, b.i, b.i)
430-
infix fun shl_(b: Vec2t<out Number>) = shl(this, this, b.x.i, b.y.i)
431-
fun shl_(bX: Number, bY: Number) = shl(this, this, bX.i, bY.i)
469+
infix fun shlAssign(b: Number) = shl(this, this, b.i, b.i)
470+
infix fun shlAssign(b: Vec2t<out Number>) = shl(this, this, b.x.i, b.y.i)
471+
fun shlAssign(bX: Number, bY: Number) = shl(this, this, bX.i, bY.i)
432472

433473

434474
infix fun shr(b: Number) = shr(Vec2i(), this, b.i, b.i)
@@ -439,9 +479,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
439479
@JvmOverloads
440480
fun shr(bX: Number, bY: Number, res: Vec2i = Vec2i()) = shr(res, this, bX.i, bY.i)
441481

442-
infix fun shr_(b: Number) = shr(this, this, b.i, b.i)
443-
infix fun shr_(b: Vec2t<out Number>) = shr(this, this, b.x.i, b.y.i)
444-
fun shr_(bX: Number, bY: Number) = shr(this, this, bX.i, bY.i)
482+
infix fun shrAssign(b: Number) = shr(this, this, b.i, b.i)
483+
infix fun shrAssign(b: Vec2t<out Number>) = shr(this, this, b.x.i, b.y.i)
484+
fun shrAssign(bX: Number, bY: Number) = shr(this, this, bX.i, bY.i)
445485

446486

447487
infix fun lessThan(i: Int) = x < i && y < i
@@ -451,6 +491,7 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
451491
infix fun greaterThan(i: Int) = x > i && y > i
452492
infix fun greaterThanEqual(i: Int) = x >= i && y >= i
453493

494+
454495
override fun equals(other: Any?) = other is Vec2i && this[0] == other[0] && this[1] == other[1]
455496
override fun hashCode() = 31 * x.hashCode() + y.hashCode()
456497
}

0 commit comments

Comments
 (0)