Exemplo n.º 1
0
        private static void DuplicateMethodSpecial(CsInterface interfaceType, CsMethod csMethod, CsTypeBase intPtrType)
        {
            bool hasComArrayLike = false;
            foreach(var csParameter in csMethod.Parameters)
            {
                if(csParameter.IsInComArrayLike)
                {
                    hasComArrayLike = true;
                    break;
                }
            }

            // Look for at least one parameter ComArray candidate
            if (hasComArrayLike)
            {
                // Create a new method and transforms all array of ComObject to ComArray<ComObject>
                var newMethod = (CsMethod)csMethod.Clone();
                foreach (var csSubParameter in newMethod.Parameters)
                {
                    if (csSubParameter.IsInComArrayLike)
                        csSubParameter.PublicType = new CsComArray((CsInterface)csSubParameter.PublicType);
                }
                interfaceType.Add(newMethod);
            }

            if(hasComArrayLike || csMethod.RequestRawPtr)
            {
                // Create private method with raw pointers for arrays, with all arrays as pure IntPtr
                // In order to be able to generate method taking single element
                var rawMethod = (CsMethod)csMethod.Clone();
                rawMethod.Visibility = Visibility.Private;
                foreach(var csSubParameter in rawMethod.Parameters)
                {
                    if(csSubParameter.IsArray || csSubParameter.IsComObject || csSubParameter.HasPointer)
                    {
                        csSubParameter.PublicType = intPtrType;
                        csSubParameter.IsArray = false;
                        csSubParameter.Attribute = CsParameterAttribute.In;
                    }
                }
                interfaceType.Add(rawMethod);
            }
        }
Exemplo n.º 2
0
 private static void CreateMethodsForComArrayMethod(CsInterface interfaceType, CsMethod csMethod)
 {
     foreach (var csParameter in csMethod.Parameters)
     {
         // Look for at least one parameter ComArray candidate
         if (csParameter.IsInComArrayLike)
         {
             // Create a new method and transforms all array of ComObject to ComArray<ComObject>
             var newMethod = (CsMethod)csMethod.Clone();
             foreach (var csSubParameter in newMethod.Parameters)
             {
                 if (csSubParameter.IsInComArrayLike)
                     csSubParameter.PublicType = new CsComArray((CsInterface)csSubParameter.PublicType);
             }
             interfaceType.Add(newMethod);
             break;
         }
     }
 }