Beispiel #1
0
        public CppTypeInfo(CppLibrary lib, string typeName, Type interfaceType, Type nativeLayout, Type /*?*/ wrapperType)
            : this()
        {
            Library  = lib;
            TypeName = typeName;

            InterfaceType = interfaceType;
            NativeLayout  = nativeLayout;
            WrapperType   = wrapperType;

            virtual_methods = new List <PInvokeSignature> (Library.Abi.GetVirtualMethodSlots(this, interfaceType));
            VirtualMethods  = new ReadOnlyCollection <PInvokeSignature> (virtual_methods);

            vt_delegate_types   = new LazyGeneratedList <Type> (virtual_methods.Count, i => DelegateTypeCache.GetDelegateType(virtual_methods [i]));
            VTableDelegateTypes = new ReadOnlyCollection <Type> (vt_delegate_types);

            vt_overrides    = new LazyGeneratedList <Delegate> (virtual_methods.Count, i => Library.Abi.GetManagedOverrideTrampoline(this, i));
            VTableOverrides = new ReadOnlyCollection <Delegate> (vt_overrides);

            vtable_index_adjustments = new List <int> (virtual_methods.Count);

            if (nativeLayout != null)
            {
                native_size_without_padding = nativeLayout.GetFields().Any()? Marshal.SizeOf(nativeLayout) : 0;
            }
        }