Esempio n. 1
0
        private static IntPtr DoCreateCif(MethodInfo info)
        {
            IntPtr resultType = Ffi.GetFfiType(info.ReturnType);

            ParameterInfo[] parms   = info.GetParameters();
            int             numArgs = parms.Length;

            PtrArray argTypes = new PtrArray(numArgs + 3);

            argTypes[0] = Ffi.GetFfiType(typeof(NSObject));
            argTypes[1] = Ffi.GetFfiType(typeof(Selector));

            for (int i = 0; i < numArgs; ++i)
            {
                Type type = parms[i].ParameterType;
                argTypes[i + 2] = Ffi.GetFfiType(type);
            }

            argTypes[numArgs + 2] = IntPtr.Zero;

            return(Ffi.AllocCif(resultType, argTypes));                         // note that we don't want to free argTypes
        }
Esempio n. 2
0
            public StackFrame(MethodSignature sig)
            {
                m_returnEncoding = sig.GetReturnEncoding();

                IntPtr resultType = Ffi.GetFfiType(m_returnEncoding);

                m_resultBuffer = Ffi.CreateBuffer(m_returnEncoding);

                int numArgs = sig.GetNumArgs();

                m_argBuffers = new PtrArray(numArgs);
                m_argTypes   = new PtrArray(numArgs + 1);

                for (int i = 0; i < numArgs; ++i)
                {
                    string encoding = sig.GetArgEncoding(i);
                    m_argBuffers[i] = Ffi.CreateBuffer(encoding);
                    m_argTypes[i]   = Ffi.GetFfiType(encoding);
                }

                m_argTypes[numArgs] = IntPtr.Zero;

                m_cif = Ffi.AllocCif(resultType, m_argTypes);
            }