public object Call(params object[] args) { var length = args.Length; var mValues = new MValueConst[length]; core.CreateMValues(mValues, args); var argsPointers = Marshal.AllocHGlobal(length * IntPtr.Size); for (var i = 0; i < length; i++) { Marshal.WriteIntPtr(argsPointers, mValues[i].nativePointer); } var result = function(argsPointers, length); for (var i = 0; i < length; i++) { mValues[i].Dispose(); } Marshal.FreeHGlobal(argsPointers); var resultMValue = new MValueConst(core, result); var resultObj = resultMValue.ToObject(); resultMValue.Dispose(); return(resultObj); }
public void ToMValue(out MValueConst mValue) { var size = (ulong)Values.Count; var mValues = new MValueConst[size]; core.CreateMValues(mValues, Values.ToArray()); core.CreateMValueList(out mValue, mValues, size); for (ulong i = 0; i < size; i++) { mValues[i].Dispose(); } }