Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** C# ***
- public struct NimT
- {
- public uint Val1;
- public uint Val2;
- public uint Val2;
- }
- [Dllimport("DllPath", CallingConvention = CallingConvention.Cdecl)]
- public static extern void populateArraySruct(uint length, NimT** ArrayStructs)
- public static unsafe List<NimT> PopulateLstPackNim(int ArrL)
- {
- NimT* PackUArrOut = null;
- List<NimT> RtPackLst = new List<NimT>(ArrL);
- populateArraySruct(ArrL, &PackUArrOut);
- NimT* CurrentPack = PackUArrOut;
- for (int i = 0; i < ArrL; i++, CurrentPack++)
- {
- RtPackLst.Add(new NimT() {Val1 = CurrentPack->Val1, Val2 = CurrentPack->Val2, Val3 = CurrentPack->Val3 });
- }
- return RtPackLst;
- }
- **NIM**
- # feel free to change uint32 to int / int32 i have tried to be more specific in the type convention
- type
- ExportNimTARRAY = seq[ExportNimT]
- ExportNimT = object
- Val1: uint32
- Val2: uint32
- Val3: uint32
- proc populateArraySruct(parSze: int, PackArrINOUT: var ExportNimTARRAY) {.exportc,dynlib.} =
- PackArrINOUT.newSeq(parSze)
- var
- tmp1: uint32
- tmp2: uint32
- tmp3: uint32
- for i, curDataPack in PackArrINOUT.mpairs:
- tmp1 = (uint32 1) * (uint32 i)
- tmp2 = (uint32 10) * (uint32 i)
- tmp3 = (uint32 11) * (uint32 i)
- curDataPack = ExportNimT (Val1:tmp1, Val2: tmp2, Val3: tmp3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement