示例#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);
            }
        }
示例#2
0
        public CsMethod CreateInterfaceArrayOverload(CsMethod original)
        {
            // Create a new method and transforms all array of CppObject to InterfaceArray<CppObject>
            var newMethod = (CsMethod)original.Clone();

            foreach (var csSubParameter in newMethod.Parameters)
            {
                if (csSubParameter.IsInInterfaceArrayLike)
                {
                    csSubParameter.PublicType  = new CsInterfaceArray((CsInterface)csSubParameter.PublicType, globalNamespace.GetTypeName(WellKnownName.InterfaceArray));
                    csSubParameter.MarshalType = typeRegistry.ImportType(typeof(IntPtr));
                }
            }
            return(newMethod);
        }
示例#3
0
        public CsMethod CreateRawPtrOverload(CsMethod original)
        {
            // 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)original.Clone();

            rawMethod.Visibility = Visibility.Private;
            foreach (var csSubParameter in rawMethod.PublicParameters)
            {
                if (csSubParameter.IsArray || csSubParameter.IsInterface || csSubParameter.HasPointer)
                {
                    csSubParameter.PublicType = csSubParameter.MarshalType = TypeRegistry.IntPtr;
                    csSubParameter.IsArray    = false;
                    csSubParameter.Attribute  = CsParameterAttribute.In;
                }
            }
            return(rawMethod);
        }
示例#4
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;
         }
     }
 }