From 04390adae5788adeeeb22edfcc6222cf86cbe348 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Tue, 1 Mar 2022 09:11:52 -0600 Subject: [PATCH] [wip] wrappers for full leopard api Needs to be proved out by doing a port of leopard's benchmark tool to Nim, i.e. there are still some questions re: parameter types --- dagger/leopard.nim | 29 ++++++++++++++++++++++++++++- tests/dagger/testleopard.nim | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dagger/leopard.nim b/dagger/leopard.nim index 66960c5f..2fa791de 100644 --- a/dagger/leopard.nim +++ b/dagger/leopard.nim @@ -1,5 +1,32 @@ -const header = "leopard.h" +type + LeopardResult* {.pure.} = enum + Leopard_CallInitialize = -7.cint + Leopard_Platform = -6.cint + Leopard_InvalidInput = -5.cint + Leopard_InvalidCounts = -4.cint + Leopard_InvalidSize = -3.cint + Leopard_TooMuchData = -2.cint + Leopard_NeedMoreData = -1.cint + Leopard_Success = 0.cint + +const + header = "leopard.h" {.pragma: leo, cdecl, header: header, importCpp.} proc leo_init*(): cint {.leo.} + +func leo_result_string*(res: LeopardResult): cstring {.leo.} + +func leo_encode_work_count*(original_count, recovery_count: cuint): cuint + {.leo.} + +proc leo_encode*(buffer_bytes: uint64, original_count, recovery_count, + work_count: cuint, original_data, work_data: pointer): LeopardResult {.leo.} + +func leo_decode_work_count*(original_count, recovery_count: cuint): cuint + {.leo.} + +proc leo_decode*(buffer_bytes: uint64, original_count, recovery_count, + work_count: cuint, original_data, recovery_data, work_data: pointer): + LeopardResult {.leo.} diff --git a/tests/dagger/testleopard.nim b/tests/dagger/testleopard.nim index d1fda3da..9d5f4f12 100644 --- a/tests/dagger/testleopard.nim +++ b/tests/dagger/testleopard.nim @@ -2,4 +2,5 @@ import pkg/dagger/leopard let lin = leo_init() +echo "" echo "leo_init() return code: " & $lin