Progress
This commit is contained in:
parent
c5082a0f47
commit
c975bdb248
@ -10,6 +10,10 @@ import com.squareup.kotlinpoet.asTypeName
|
|||||||
* on 28-Jul-2020
|
* on 28-Jul-2020
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
val packageName = "debug.test"
|
||||||
|
|
||||||
|
fun withPackageName(name: String) = ClassName(packageName, name)
|
||||||
|
|
||||||
class KotlinFileDefinition(
|
class KotlinFileDefinition(
|
||||||
val name: String,
|
val name: String,
|
||||||
val commonClassList: MutableList<ClassDefinition> = mutableListOf()
|
val commonClassList: MutableList<ClassDefinition> = mutableListOf()
|
||||||
@ -117,6 +121,16 @@ fun funcDef(
|
|||||||
return function
|
return function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun funcDef(
|
||||||
|
name: String,
|
||||||
|
returnType: GeneralTypeDefinition,
|
||||||
|
body: FunctionDefinition.() -> Unit
|
||||||
|
): FunctionDefinition {
|
||||||
|
val function = FunctionDefinition(name, name, name, name, returnType = returnType)
|
||||||
|
function.body()
|
||||||
|
return function
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
object LibSodiumDefinitions {
|
object LibSodiumDefinitions {
|
||||||
val testKotlinFile = fileDef("DebugTest") {
|
val testKotlinFile = fileDef("DebugTest") {
|
||||||
@ -128,22 +142,16 @@ object LibSodiumDefinitions {
|
|||||||
"crypto_hash_sha256_state"
|
"crypto_hash_sha256_state"
|
||||||
)
|
)
|
||||||
+funcDef(
|
+funcDef(
|
||||||
"init",
|
|
||||||
"crypto_hash_sha256_init",
|
|
||||||
"crypto_hash_sha256_init",
|
|
||||||
"crypto_hash_sha256_init",
|
"crypto_hash_sha256_init",
|
||||||
TypeDefinition.INT
|
TypeDefinition.INT
|
||||||
) {
|
) {
|
||||||
+ParameterDefinition("state", CustomTypeDefinition(ClassName.bestGuess("Sha256State")))
|
+ParameterDefinition("state", CustomTypeDefinition((withPackageName("Sha256State"))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+classDef("GenericHash") {
|
+classDef("GenericHash") {
|
||||||
|
|
||||||
+funcDef(
|
+funcDef(
|
||||||
"init",
|
|
||||||
"crypto_generichash_init",
|
|
||||||
"crypto_generichash_init",
|
|
||||||
"crypto_generichash_init",
|
"crypto_generichash_init",
|
||||||
TypeDefinition.INT
|
TypeDefinition.INT
|
||||||
) {
|
) {
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
package debug.test
|
package debug.test
|
||||||
|
|
||||||
import Sha256State
|
|
||||||
import kotlin.Int
|
import kotlin.Int
|
||||||
import kotlin.UByteArray
|
import kotlin.UByteArray
|
||||||
|
|
||||||
expect class Sha256State
|
expect class Sha256State
|
||||||
|
|
||||||
expect class Hashing {
|
expect class Hashing {
|
||||||
fun init(state: Sha256State): Int
|
fun crypto_hash_sha256_init(state: Sha256State): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
expect class GenericHash {
|
expect class GenericHash {
|
||||||
fun init(
|
fun crypto_generichash_init(
|
||||||
state: UByteArray,
|
state: UByteArray,
|
||||||
key: UByteArray,
|
key: UByteArray,
|
||||||
outlen: Int
|
outlen: Int
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package debug.test
|
package debug.test
|
||||||
|
|
||||||
import Sha256State
|
|
||||||
import com.goterl.lazycode.lazysodium.SodiumJava
|
import com.goterl.lazycode.lazysodium.SodiumJava
|
||||||
import com.goterl.lazycode.lazysodium.interfaces.Hash
|
import com.goterl.lazycode.lazysodium.interfaces.Hash
|
||||||
import kotlin.Int
|
import kotlin.Int
|
||||||
@ -11,14 +10,14 @@ val sodium: SodiumJava = SodiumJava()
|
|||||||
actual typealias Sha256State = Hash.State256
|
actual typealias Sha256State = Hash.State256
|
||||||
|
|
||||||
actual class Hashing {
|
actual class Hashing {
|
||||||
actual fun init(state: Sha256State): Int {
|
actual fun crypto_hash_sha256_init(state: Sha256State): Int {
|
||||||
println("Debug")
|
println("Debug")
|
||||||
return sodium.crypto_hash_sha256_init(state)
|
return sodium.crypto_hash_sha256_init(state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actual class GenericHash {
|
actual class GenericHash {
|
||||||
actual fun init(
|
actual fun crypto_generichash_init(
|
||||||
state: UByteArray,
|
state: UByteArray,
|
||||||
key: UByteArray,
|
key: UByteArray,
|
||||||
outlen: Int
|
outlen: Int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user