SHOW:
|
|
- or go back to the newest paste.
| 1 | *** C# *** | |
| 2 | ||
| 3 | public struct NimT | |
| 4 | {
| |
| 5 | public uint Val1; | |
| 6 | public uint Val2; | |
| 7 | public uint Val2; | |
| 8 | } | |
| 9 | ||
| 10 | [Dllimport("DllPath", CallingConvention = CallingConvention.Cdecl)]
| |
| 11 | public static extern void populateArraySruct(uint length, NimT** ArrayStructs) | |
| 12 | ||
| 13 | ||
| 14 | public static unsafe List<NimT> PopulateLstPackNim(int ArrL) | |
| 15 | {
| |
| 16 | NimT* PackUArrOut = null; | |
| 17 | List<NimT> RtPackLst = new List<NimT>(ArrL); | |
| 18 | populateArraySruct(ArrL, &PackUArrOut); | |
| 19 | NimT* CurrentPack = PackUArrOut; | |
| 20 | for (int i = 0; i < ArrL; i++, CurrentPack++) | |
| 21 | {
| |
| 22 | RtPackLst.Add(new NimT() {Val1 = CurrentPack->Val1, Val2 = CurrentPack->Val2, Val3 = CurrentPack->Val3 });
| |
| 23 | } | |
| 24 | return RtPackLst; | |
| 25 | } | |
| 26 | ||
| 27 | ||
| 28 | **NIM** | |
| 29 | # feel free to change uint32 to int / int32 i have tried to be more specific in the type convention | |
| 30 | ||
| 31 | type | |
| 32 | ExportNimTARRAY = seq[ExportNimT] | |
| 33 | ExportNimT = object | |
| 34 | Val1: uint32 | |
| 35 | Val2: uint32 | |
| 36 | Val3: uint32 | |
| 37 | ||
| 38 | proc populateArraySruct(parSze: int, PackArrINOUT: var ExportNimTARRAY) {.exportc,dynlib.} =
| |
| 39 | PackArrINOUT.newSeq(parSze) | |
| 40 | var | |
| 41 | tmp1: uint32 | |
| 42 | tmp2: uint32 | |
| 43 | tmp3: uint32 | |
| 44 | for i, curDataPack in PackArrINOUT.mpairs: | |
| 45 | tmp1 = (uint32 1) * (uint32 i) | |
| 46 | tmp2 = (uint32 10) * (uint32 i) | |
| 47 | tmp3 = (uint32 11) * (uint32 i) | |
| 48 | curDataPack = ExportNimT (Val1:tmp1, Val2: tmp2, Val3: tmp3) |