SHOW:
|
|
- or go back to the newest paste.
| 1 | *** C# *** | |
| 2 | ||
| 3 | public struct NimT | |
| 4 | {
| |
| 5 | - | public int intVal1; |
| 5 | + | public uint Val1; |
| 6 | - | public int intVal2; |
| 6 | + | public uint Val2; |
| 7 | public uint Val2; | |
| 8 | } | |
| 9 | - | [Dllimport(...)] |
| 9 | + | |
| 10 | - | populateArraySruct(int length, NimT** ArrayStructs) |
| 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 | - | GetPacksPtrNimMe2(ArrL, &PackUArrOut); |
| 17 | + | |
| 18 | populateArraySruct(ArrL, &PackUArrOut); | |
| 19 | NimT* CurrentPack = PackUArrOut; | |
| 20 | for (int i = 0; i < ArrL; i++, CurrentPack++) | |
| 21 | - | RtPackLst.Add(new NimT() {intVal1 = CurrentPack->intVal1, intVal2 = CurrentPack->intVal2 });
|
| 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 | - | intVal1: int32 |
| 33 | + | |
| 34 | - | intVal2: int32 |
| 34 | + | Val1: uint32 |
| 35 | Val2: uint32 | |
| 36 | - | proc GetPacksPtrNimMe2(parSze: int, PackArrINOUT: var ExportNimTARRAY) {.exportc,dynlib.} =
|
| 36 | + | |
| 37 | proc populateArraySruct(parSze: int, PackArrINOUT: var ExportNimTARRAY) {.exportc,dynlib.} =
| |
| 38 | PackArrINOUT.newSeq(parSze) | |
| 39 | - | tmp1: int32 |
| 39 | + | |
| 40 | - | tmp2: int32 |
| 40 | + | tmp1: uint32 |
| 41 | tmp2: uint32 | |
| 42 | - | tmp1 = 10 * int32 i |
| 42 | + | tmp3: uint32 |
| 43 | - | tmp2 = int32 i |
| 43 | + | |
| 44 | - | curDataPack = ExportNimT (intVal1:tmp1, intVal2: tmp2) |
| 44 | + | tmp1 = (uint32 1) * (uint32 i) |
| 45 | tmp2 = (uint32 10) * (uint32 i) | |
| 46 | tmp3 = (uint32 11) * (uint32 i) | |
| 47 | curDataPack = ExportNimT (Val1:tmp1, Val2: tmp2, Val3: tmp3) |