Reformat generated APIs

This commit is contained in:
Iaroslav Postovalov 2021-01-07 18:28:51 +07:00
parent a86987362b
commit f7fc327e8c
No known key found for this signature in database
GPG Key ID: 46E15E4A31B3BCD7
5 changed files with 79 additions and 32 deletions

View File

@ -33,9 +33,8 @@ private fun KtPsiFactory.createMatrixClass(
override fun suggestFeature(vararg features: MatrixFeature): $className =
${className}(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): $kotlinTypeName = ${
fn("gsl_matrixRget", cTypeName)
}(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): $kotlinTypeName =
${fn("gsl_matrixRget", cTypeName)}(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: ${kotlinTypeName}): Unit =
${fn("gsl_matrixRset", cTypeName)}(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -49,9 +48,11 @@ private fun KtPsiFactory.createMatrixClass(
override fun close(): Unit = ${fn("gsl_matrixRfree", cTypeName)}(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is $className) return ${
if (other is $className)
return ${
fn("gsl_matrixRequal", cTypeName)
}(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}"""

View File

@ -38,10 +38,12 @@ private fun KtPsiFactory.createVectorClass(
}
override fun equals(other: Any?): Boolean {
if (other is $className) return ${
if (other is $className)
return ${
fn("gsl_vectorRequal",
cTypeName)
}(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}

View File

@ -15,7 +15,7 @@ internal fun Complex.toGsl(): CValue<gsl_complex> = cValue {
internal class GslComplexMatrix(
override val nativeHandle: CPointer<gsl_matrix_complex>,
features: Set<MatrixFeature> = emptySet(),
scope: DeferScope
scope: DeferScope,
) : GslMatrix<Complex, gsl_matrix_complex>(scope) {
override val rowNum: Int
get() = nativeHandleChecked().pointed.size1.toInt()
@ -43,7 +43,9 @@ internal class GslComplexMatrix(
override fun close(): Unit = gsl_matrix_complex_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslComplexMatrix) return gsl_matrix_complex_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslComplexMatrix)
return gsl_matrix_complex_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -65,7 +67,9 @@ internal class GslComplexVector(override val nativeHandle: CPointer<gsl_vector_c
}
override fun equals(other: Any?): Boolean {
if (other is GslComplexVector) return gsl_vector_complex_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslComplexVector)
return gsl_vector_complex_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}

View File

@ -20,7 +20,8 @@ internal class GslRealMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslRealMatrix =
GslRealMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): Double = gsl_matrix_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): Double =
gsl_matrix_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: Double): Unit =
gsl_matrix_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -34,7 +35,9 @@ internal class GslRealMatrix(
override fun close(): Unit = gsl_matrix_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslRealMatrix) return gsl_matrix_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslRealMatrix)
return gsl_matrix_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -55,7 +58,8 @@ internal class GslFloatMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslFloatMatrix =
GslFloatMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): Float = gsl_matrix_float_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): Float =
gsl_matrix_float_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: Float): Unit =
gsl_matrix_float_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -69,7 +73,9 @@ internal class GslFloatMatrix(
override fun close(): Unit = gsl_matrix_float_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslFloatMatrix) return gsl_matrix_float_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslFloatMatrix)
return gsl_matrix_float_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -90,7 +96,8 @@ internal class GslShortMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslShortMatrix =
GslShortMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): Short = gsl_matrix_short_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): Short =
gsl_matrix_short_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: Short): Unit =
gsl_matrix_short_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -104,7 +111,9 @@ internal class GslShortMatrix(
override fun close(): Unit = gsl_matrix_short_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslShortMatrix) return gsl_matrix_short_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslShortMatrix)
return gsl_matrix_short_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -125,7 +134,8 @@ internal class GslUShortMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslUShortMatrix =
GslUShortMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): UShort = gsl_matrix_ushort_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): UShort =
gsl_matrix_ushort_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: UShort): Unit =
gsl_matrix_ushort_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -139,7 +149,9 @@ internal class GslUShortMatrix(
override fun close(): Unit = gsl_matrix_ushort_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslUShortMatrix) return gsl_matrix_ushort_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslUShortMatrix)
return gsl_matrix_ushort_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -160,7 +172,8 @@ internal class GslLongMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslLongMatrix =
GslLongMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): Long = gsl_matrix_long_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): Long =
gsl_matrix_long_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: Long): Unit =
gsl_matrix_long_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -174,7 +187,9 @@ internal class GslLongMatrix(
override fun close(): Unit = gsl_matrix_long_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslLongMatrix) return gsl_matrix_long_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslLongMatrix)
return gsl_matrix_long_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -195,7 +210,8 @@ internal class GslULongMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslULongMatrix =
GslULongMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): ULong = gsl_matrix_ulong_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): ULong =
gsl_matrix_ulong_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: ULong): Unit =
gsl_matrix_ulong_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -209,7 +225,9 @@ internal class GslULongMatrix(
override fun close(): Unit = gsl_matrix_ulong_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslULongMatrix) return gsl_matrix_ulong_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslULongMatrix)
return gsl_matrix_ulong_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -230,7 +248,8 @@ internal class GslIntMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslIntMatrix =
GslIntMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): Int = gsl_matrix_int_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): Int =
gsl_matrix_int_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: Int): Unit =
gsl_matrix_int_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -244,7 +263,9 @@ internal class GslIntMatrix(
override fun close(): Unit = gsl_matrix_int_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslIntMatrix) return gsl_matrix_int_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslIntMatrix)
return gsl_matrix_int_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}
@ -265,7 +286,8 @@ internal class GslUIntMatrix(
override fun suggestFeature(vararg features: MatrixFeature): GslUIntMatrix =
GslUIntMatrix(nativeHandleChecked(), this.features + features, scope)
override operator fun get(i: Int, j: Int): UInt = gsl_matrix_uint_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun get(i: Int, j: Int): UInt =
gsl_matrix_uint_get(nativeHandleChecked(), i.toULong(), j.toULong())
override operator fun set(i: Int, j: Int, value: UInt): Unit =
gsl_matrix_uint_set(nativeHandleChecked(), i.toULong(), j.toULong(), value)
@ -279,7 +301,9 @@ internal class GslUIntMatrix(
override fun close(): Unit = gsl_matrix_uint_free(nativeHandleChecked())
override fun equals(other: Any?): Boolean {
if (other is GslUIntMatrix) return gsl_matrix_uint_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslUIntMatrix)
return gsl_matrix_uint_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
}

View File

@ -18,7 +18,9 @@ internal class GslRealVector(override val nativeHandle: CPointer<gsl_vector>, sc
}
override fun equals(other: Any?): Boolean {
if (other is GslRealVector) return gsl_vector_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslRealVector)
return gsl_vector_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
@ -40,7 +42,9 @@ internal class GslFloatVector(override val nativeHandle: CPointer<gsl_vector_flo
}
override fun equals(other: Any?): Boolean {
if (other is GslFloatVector) return gsl_vector_float_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslFloatVector)
return gsl_vector_float_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
@ -62,7 +66,9 @@ internal class GslShortVector(override val nativeHandle: CPointer<gsl_vector_sho
}
override fun equals(other: Any?): Boolean {
if (other is GslShortVector) return gsl_vector_short_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslShortVector)
return gsl_vector_short_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
@ -84,7 +90,9 @@ internal class GslUShortVector(override val nativeHandle: CPointer<gsl_vector_us
}
override fun equals(other: Any?): Boolean {
if (other is GslUShortVector) return gsl_vector_ushort_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslUShortVector)
return gsl_vector_ushort_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
@ -106,7 +114,9 @@ internal class GslLongVector(override val nativeHandle: CPointer<gsl_vector_long
}
override fun equals(other: Any?): Boolean {
if (other is GslLongVector) return gsl_vector_long_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslLongVector)
return gsl_vector_long_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
@ -128,7 +138,9 @@ internal class GslULongVector(override val nativeHandle: CPointer<gsl_vector_ulo
}
override fun equals(other: Any?): Boolean {
if (other is GslULongVector) return gsl_vector_ulong_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslULongVector)
return gsl_vector_ulong_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
@ -150,7 +162,9 @@ internal class GslIntVector(override val nativeHandle: CPointer<gsl_vector_int>,
}
override fun equals(other: Any?): Boolean {
if (other is GslIntVector) return gsl_vector_int_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslIntVector)
return gsl_vector_int_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}
@ -172,7 +186,9 @@ internal class GslUIntVector(override val nativeHandle: CPointer<gsl_vector_uint
}
override fun equals(other: Any?): Boolean {
if (other is GslUIntVector) return gsl_vector_uint_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
if (other is GslUIntVector)
return gsl_vector_uint_equal(nativeHandleChecked(), other.nativeHandleChecked()) == 1
return super.equals(other)
}