From bc89288ca7dc6943fe89ed2795d1e553cecf6edd Mon Sep 17 00:00:00 2001 From: Dankrad Feist Date: Sat, 1 Oct 2022 18:03:52 +0100 Subject: [PATCH] C# interface --- min-bindings/C#/Makefile | 11 +++++++++++ min-bindings/C#/tests.cs | 10 ++++++++++ min-bindings/c_kzg_4844.swg | 4 +++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 min-bindings/C#/Makefile create mode 100644 min-bindings/C#/tests.cs diff --git a/min-bindings/C#/Makefile b/min-bindings/C#/Makefile new file mode 100644 index 0000000..5a8d143 --- /dev/null +++ b/min-bindings/C#/Makefile @@ -0,0 +1,11 @@ +INCLUDE_DIRS = .. ../../min-src ../../inc + +test: tests.cs ckzg.dll.so + mcs -langversion:5 -optimize+ tests.cs ckzg.cs -r:System.Numerics.dll + ./tests.exe + +ckzg.dll.so: c_kzg_4844_wrap.c ../../min-src/c_kzg_4844.o ../../lib/libblst.a + clang -O -Wall -shared -fPIC -Wl,-Bsymbolic -I${INCLUDE_PY} ${addprefix -I,${INCLUDE_DIRS}} -o $@ $^ + +c_kzg_4844_wrap.c ckzg.cs: ../c_kzg_4844.swg + swig -DSWIGWORDSIZE64 -O -Wall -csharp -outcurrentdir -namespace ckzg -outfile ckzg.cs $< diff --git a/min-bindings/C#/tests.cs b/min-bindings/C#/tests.cs new file mode 100644 index 0000000..25d9c24 --- /dev/null +++ b/min-bindings/C#/tests.cs @@ -0,0 +1,10 @@ +using System; +using System.Text; +using ckzg; + +class PoC { + private static void Main(string[] args) + { + Console.WriteLine("OK"); + } +} diff --git a/min-bindings/c_kzg_4844.swg b/min-bindings/c_kzg_4844.swg index a8ed47e..4c061ed 100644 --- a/min-bindings/c_kzg_4844.swg +++ b/min-bindings/c_kzg_4844.swg @@ -77,6 +77,7 @@ %include "../min-src/c_kzg_4844.h" %include "../inc/blst.h" +#if defined(SWIGPYTHON) %pythoncode %{ # Helper functions @@ -120,4 +121,5 @@ def _frompybytes(b): return h bytes.frompybytes = _frompybytes -%} \ No newline at end of file +%} +#endif \ No newline at end of file