Minor interop code changes (dotnet/coreclr#19005)
authorAaron Robinson <arobins@microsoft.com>
Fri, 20 Jul 2018 07:48:07 +0000 (00:48 -0700)
committerJan Kotas <jkotas@microsoft.com>
Fri, 20 Jul 2018 07:48:07 +0000 (00:48 -0700)
* Remove SpecialIsGenericTypeVisibleFromCom() from header file

* Clean up if check resulting from remoting code removal

Commit migrated from https://github.com/dotnet/coreclr/commit/799b2a30a685a739d59a22b26b50e5da8616446f

src/coreclr/src/vm/comcallablewrapper.cpp
src/coreclr/src/vm/comcallablewrapper.h
src/coreclr/src/vm/interoputil.cpp
src/coreclr/src/vm/interoputil.h
src/coreclr/src/vm/stdinterfaces.cpp

index 060519a..15e02a2 100644 (file)
@@ -5524,13 +5524,6 @@ SLOT* ComCallWrapperTemplate::GetVTableSlot(ULONG index)
     RETURN m_rgpIPtr[index];
 }
 
-BOOL ComCallWrapperTemplate::HasInvisibleParent()
-{
-    LIMITED_METHOD_CONTRACT;
-
-    return (m_flags & enum_InvisibleParent);
-}
-
 // Determines whether the template is for a type that cannot be safely marshalled to 
 // an out of proc COM client
 BOOL ComCallWrapperTemplate::IsSafeTypeForMarshalling()
@@ -5652,7 +5645,7 @@ DefaultInterfaceType ComCallWrapperTemplate::GetDefaultInterface(MethodTable **p
     }
 
     *ppDefaultItf = m_pDefaultItf;
-    return (DefaultInterfaceType)(m_flags & enum_DefaultInterfaceType);
+    return (DefaultInterfaceType)(m_flags & enum_DefaultInterfaceTypeMask);
 }
 
 //--------------------------------------------------------------------------
index 152830e..17ef014 100644 (file)
@@ -388,7 +388,6 @@ public:
     ComMethodTable* GetBasicComMT();
     ULONG           GetNumInterfaces();
     SLOT*           GetVTableSlot(ULONG index);
-    BOOL            HasInvisibleParent();
     void            CheckParentComVisibility(BOOL fForIDispatch);
     BOOL            CheckParentComVisibilityNoThrow(BOOL fForIDispatch);
     
@@ -402,6 +401,12 @@ public:
 
     IIDToInterfaceTemplateCache *GetOrCreateIIDToInterfaceTemplateCache();
 
+    BOOL HasInvisibleParent()
+    {
+        LIMITED_METHOD_CONTRACT;
+        return (m_flags & enum_InvisibleParent);
+    }
+
     BOOL SupportsICustomQueryInterface()
     {
         LIMITED_METHOD_CONTRACT;
@@ -465,27 +470,6 @@ public:
     static ComCallWrapperTemplate *CreateTemplateForInterface(MethodTable *pItfMT);
 
 private:
-    
-    enum ComCallWrapperTemplateFlags
-    {
-        // first 3 bits are interpreted as DefaultInterfaceType
-        enum_DefaultInterfaceType             = 0x7,
-        enum_DefaultInterfaceTypeComputed     = 0x10,
-
-        enum_InvisibleParent                  = 0x20,
-        enum_ImplementsICustomQueryInterface  = 0x40,
-        enum_SupportsIInspectable             = 0x80,
-        enum_SupportsIClassX                  = 0x100,
-
-        enum_SupportsVariantInterface         = 0x200, // this is a template for a class that implements an interface with variance
-        enum_RepresentsVariantInterface       = 0x400, // this is a template for an interface with variance
-
-        enum_UseOleAutDispatchImpl            = 0x800, // the class is decorated with IDispatchImplAttribute(CompatibleImpl)
-
-        enum_ImplementsIMarshal               = 0x1000, // the class implements a managed interface with Guid == IID_IMarshal
-
-        enum_IsSafeTypeForMarshalling         = 0x2000, // The class can be safely marshalled out of process via DCOM
-    };
 
     // Hide the constructor
     ComCallWrapperTemplate();
@@ -512,6 +496,27 @@ private:
     MethodTable*                            m_pWinRTRuntimeClass;
     ComMethodTable*                         m_pClassComMT;
     ComMethodTable*                         m_pBasicComMT;
+
+    enum
+    {
+        // first 3 bits are interpreted as DefaultInterfaceType
+        enum_DefaultInterfaceTypeMask         = 0x7,
+        enum_DefaultInterfaceTypeComputed     = 0x10,
+
+        enum_InvisibleParent                  = 0x20,
+        enum_ImplementsICustomQueryInterface  = 0x40,
+        enum_SupportsIInspectable             = 0x80,
+        enum_SupportsIClassX                  = 0x100,
+
+        enum_SupportsVariantInterface         = 0x200, // this is a template for a class that implements an interface with variance
+        enum_RepresentsVariantInterface       = 0x400, // this is a template for an interface with variance
+
+        enum_UseOleAutDispatchImpl            = 0x800, // the class is decorated with IDispatchImplAttribute(CompatibleImpl)
+
+        enum_ImplementsIMarshal               = 0x1000, // the class implements a managed interface with Guid == IID_IMarshal
+
+        enum_IsSafeTypeForMarshalling         = 0x2000, // The class can be safely marshalled out of process via DCOM
+    };
     DWORD                                   m_flags;
     MethodDesc*                             m_pICustomQueryInterfaceGetInterfaceMD;
     Volatile<IIDToInterfaceTemplateCache *> m_pIIDToInterfaceTemplateCache;
index 9caa4a0..09f7d88 100644 (file)
@@ -3716,29 +3716,29 @@ BOOL IsMethodVisibleFromCom(MethodDesc *pMD)
 }
 
 //---------------------------------------------------------------------------
-// This method determines if a type is visible from COM or not based on 
+// This method determines if a type is visible from COM or not based on
 // its visibility. This version of the method works with a type handle.
 // This version will ignore a type's generic attributes.
 //
 // This API should *never* be called directly!!!
-BOOL SpecialIsGenericTypeVisibleFromCom(TypeHandle hndType)
+static BOOL SpecialIsGenericTypeVisibleFromCom(TypeHandle hndType)
 {
     CONTRACTL
     {
         NOTHROW;
         GC_NOTRIGGER;
         MODE_ANY;
-        PRECONDITION(!hndType.IsNull());        
+        PRECONDITION(!hndType.IsNull());
     }
     CONTRACTL_END;
-    
+
     DWORD                   dwFlags;
     mdTypeDef               tdEnclosingType;
     HRESULT                 hr;
     const BYTE *            pVal;
     ULONG                   cbVal;
-    MethodTable *           pMT = hndType.GetMethodTable(); 
-    _ASSERTE(pMT);    
+    MethodTable *           pMT = hndType.GetMethodTable();
+    _ASSERTE(pMT);
 
     mdTypeDef               mdType = pMT->GetCl();
     IMDInternalImport *     pInternalImport = pMT->GetMDImport();
@@ -3755,14 +3755,14 @@ BOOL SpecialIsGenericTypeVisibleFromCom(TypeHandle hndType)
     // If the type is an array, then it is not visible from COM.
     if (pMT->IsArray())
         return FALSE;
-    
+
     // Retrieve the flags for the current type.
     tdEnclosingType = mdType;
     if (FAILED(pInternalImport->GetTypeDefProps(tdEnclosingType, &dwFlags, 0)))
     {
         return FALSE;
     }
-    
+
     // Handle nested types.
     while (IsTdNestedPublic(dwFlags))
     {
@@ -3771,14 +3771,14 @@ BOOL SpecialIsGenericTypeVisibleFromCom(TypeHandle hndType)
         {
             return FALSE;
         }
-        
+
         // Retrieve the flags for the enclosing type.
         if (FAILED(pInternalImport->GetTypeDefProps(tdEnclosingType, &dwFlags, 0)))
         {
             return FALSE;
         }
     }
-    
+
     // If the outermost type is not visible then the specified type is not visible.
     if (!IsTdPublic(dwFlags))
         return FALSE;
@@ -3817,7 +3817,6 @@ BOOL SpecialIsGenericTypeVisibleFromCom(TypeHandle hndType)
     return TRUE;
 }
 
-
 //---------------------------------------------------------------------------
 // This method determines if a type is visible from COM or not based on
 // its visibility. This version of the method works with a type handle.
index a689624..f290ba2 100644 (file)
@@ -357,14 +357,6 @@ BOOL IsMethodVisibleFromCom(MethodDesc *pMD);
 //---------------------------------------------------------------------------
 // This method determines if a type is visible from COM or not based on 
 // its visibility. This version of the method works with a type handle.
-// This version will ignore a type's generic attributes.
-//
-// This API should *never* be called directly!!!
-BOOL SpecialIsGenericTypeVisibleFromCom(TypeHandle hndType);
-
-//---------------------------------------------------------------------------
-// This method determines if a type is visible from COM or not based on 
-// its visibility. This version of the method works with a type handle.
 BOOL IsTypeVisibleFromCom(TypeHandle hndType);
 
 //---------------------------------------------------------------------------
index fa2d2a7..5726df9 100644 (file)
@@ -239,12 +239,7 @@ Unknown_QueryInterface_Internal(ComCallWrapper* pWrap, IUnknown* pUnk, REFIID ri
         // If we haven't found the IP or if we haven't looked yet (because we aren't
         // being aggregated), now look on the managed object to see if it supports the interface.
         if (pDestItf == NULL)
-        {
             pDestItf = ComCallWrapper::GetComIPFromCCW(pWrap, riid, NULL, GetComIPFromCCW::CheckVisibility);
-            if (pDestItf == NULL)
-            {
-            }
-        }
 
 ErrExit:
         // If we succeeded in obtaining the requested IP then return S_OK.