Start investigating swigless csharp
This commit is contained in:
parent
9512abbcfc
commit
f5e95c497c
|
@ -22,4 +22,5 @@ inc/blst_aux.h*
|
||||||
*bindings/python/*_wrap.c
|
*bindings/python/*_wrap.c
|
||||||
*bindings/C#/*_wrap.c
|
*bindings/C#/*_wrap.c
|
||||||
*bindings/C#/*.exe
|
*bindings/C#/*.exe
|
||||||
|
*bindings/C#/*.dll
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
INCLUDE_DIRS = .. ../../min-src ../../inc
|
INCLUDE_DIRS = .. ../../min-src ../../inc
|
||||||
|
|
||||||
test: tests.cs libckzg.so ckzg_swig.cs
|
test: tests.cs ckzg.dll
|
||||||
mcs -langversion:5 -optimize+ tests.cs ckzg_swig.cs -r:System.Numerics.dll
|
mcs tests.cs
|
||||||
mono tests.exe
|
./tests.exe
|
||||||
|
|
||||||
libckzg.so: c_kzg_4844_wrap.c ../../min-src/c_kzg_4844.o ../../lib/libblst.a
|
ckzg.dll: ckzg.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 $@ $^
|
clang -O -Wall -shared ${addprefix -I,${INCLUDE_DIRS}} -o $@ $^
|
||||||
|
|
||||||
c_kzg_4844_wrap.c ckzg_swig.cs: ../c_kzg_4844.swg
|
|
||||||
swig -DSWIGWORDSIZE64 -O -Wall -csharp -outcurrentdir -namespace ckzg -outfile ckzg_swig.cs $<
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "c_kzg_4844.h"
|
||||||
|
|
||||||
|
uint64_t hello(uint64_t a) {
|
||||||
|
printf("Hello World! %lu\n", a);
|
||||||
|
return 42;
|
||||||
|
}
|
|
@ -1,10 +1,17 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ckzg;
|
|
||||||
|
|
||||||
class PoC {
|
class ckzg {
|
||||||
|
[global::System.Runtime.InteropServices.DllImport("ckzg.dll", EntryPoint="hello")]
|
||||||
|
public static extern uint hello(uint a);
|
||||||
|
[global::System.Runtime.InteropServices.DllImport("ckzg.dll", EntryPoint="bytes_to_bls_field_wrap")]
|
||||||
|
public static extern void bytes_to_bls_field(byte[] b);
|
||||||
|
}
|
||||||
|
|
||||||
|
class tests {
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("OK");
|
Console.WriteLine("OK");
|
||||||
|
Console.WriteLine(ckzg.hello(32));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue