Ejemplo n.º 1
0
        public void FinishDeclaration()
        {
            if (registered)
            {
                throw new InvalidOperationException("Native class is already declared and registered");
            }
            registered = true;

            // variable to hold reference to .NET object that creates an instance
            const string variableName = "_SEInstance";

            ObjC.AddVariable(Handle, variableName, new IntPtr(IntPtr.Size), (byte)Math.Log(IntPtr.Size, 2), "@");
            ivar = ObjC.GetVariable(Handle, variableName);

            foreach (IntPtr protocol in protocols)
            {
                if (protocol == IntPtr.Zero)
                {
                    // must not add null protocol, can cause runtime exception with conformsToProtocol check
                    continue;
                }

                ObjC.AddProtocol(Handle, protocol);
            }

            ObjC.RegisterClassPair(Handle);
        }