Ejemplo n.º 1
0
        public void CallAsFunction(int methodNumber, IValue[] arguments, out IValue retValue)
        {
            var result     = ValueFactory.Create();
            int paramCount = NativeApiProxy.GetNParams(_object, methodNumber);

            using (var variant = new NativeApiVariant(paramCount))
            {
                SetDefValues(methodNumber, paramCount, arguments);
                for (int i = 0; i < paramCount; i++)
                {
                    variant.Assign(arguments[i], i);
                }

                NativeApiProxy.CallAsFunc(_object, methodNumber, variant.Ptr,
                                          res => result = NativeApiVariant.Value(res)
                                          );
            }
            retValue = result;
        }
Ejemplo n.º 2
0
        public void CallAsFunction(int methodNumber, IValue[] arguments, out IValue retValue)
        {
            var paramArray = IntPtr.Zero;
            int paramCount = NativeApiProxy.GetNParams(_object, methodNumber);

            if (paramCount > 0)
            {
                paramArray = Marshal.AllocHGlobal(NativeApiVariant.Size * paramCount);
            }
            SetDefValues(methodNumber, paramCount, arguments);
            NativeApiVariant.SetValue(paramArray, arguments, paramCount);
            IValue result = retValue = ValueFactory.Create();
            bool   ok     = NativeApiProxy.CallAsFunc(_object, methodNumber, paramArray,
                                                      variant => result = NativeApiVariant.GetValue(variant)
                                                      );

            NativeApiVariant.GetValue(arguments, paramArray, paramCount);
            NativeApiVariant.Clear(paramArray, paramCount);
            Marshal.FreeHGlobal(paramArray);
            if (ok)
            {
                retValue = result;
            }
        }