Beispiel #1
0
        internal static bool IsCompatible(RegistryContext ctx, Command command, CommandParameter param)
        {
            switch (ctx.Class.ToLower())
            {
            case "gl":
                break;

            default:
                return(false);
            }

            if (param.GetImplementationType(ctx, command) != "IntPtr")
            {
                return(false);
            }
            if (Regex.IsMatch(param.Name, "offset"))
            {
                return(false);
            }
            if (param.IsConstant || command.IsGetImplementation(ctx))
            {
                return(true);
            }

            return(false);
        }
		internal static bool IsCompatible(RegistryContext ctx, Command command, CommandParameter param)
		{
			switch (ctx.Class.ToLower()) {
				case "gl":
					break;
				default:
					return (false);
			}

			if (param.GetImplementationType(ctx, command) != "IntPtr")
				return (false);
			if (Regex.IsMatch(param.Name, "offset"))
				return (false);
			if (param.IsConstant || command.IsGetImplementation(ctx))
				return (true);

			return (false);
		}
Beispiel #3
0
        public string GetDelegateTypeAttributes(RegistryContext ctx, Command parentCommand)
        {
            string implementationType = ManagedImplementationType;
            string attribute          = null;

            // String + Length!=null -> [Out] StringBuilder
            if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                attribute = "[Out]";
            }

            return(attribute);
        }
Beispiel #4
0
        public string GetDelegateType(RegistryContext ctx, Command parentCommand)
        {
            string implementationType = ImportType;

            // String + Length!=null -> [Out] StringBuilder
            if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                implementationType = "StringBuilder";
            }

            return(implementationType.Trim());
        }
Beispiel #5
0
        public string GetImplementationTypeAttributes(RegistryContext ctx, Command parentCommand)
        {
            string implementationType = ManagedImplementationType;
            string implementationMod  = GetImplementationTypeModifier(ctx, parentCommand);
            string attribute          = null;

            // String + Length!=null && !IsConst -> [Out] StringBuilder (in Get commands)
            if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                attribute = "[Out]";
            }
            // Array && !IsConst -> [Out] T[] (in Get commands)
            if ((IsConstant == false) && (implementationType.EndsWith("[]")) && ((implementationMod != "out") && (implementationMod != "ref")) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                attribute = "[Out]";
            }

            return(attribute);
        }
Beispiel #6
0
        public string GetImplementationTypeModifier(RegistryContext ctx, Command parentCommand)
        {
            string implementationType = ManagedImplementationType;

            // Type[] + Length=1 -> out Type
            if ((IsConstant == false) && implementationType.EndsWith("[]") && (Length == "1") && (parentCommand.IsGetImplementation(ctx)))
            {
                return("out");
            }
            // Type[] + Length=1 -> out Type
            if ((IsConstant == false) && implementationType.EndsWith("[]") && (Length == "1") && ((parentCommand.Flags & CommandFlags.OutParam) != 0))
            {
                return("out");
            }

            return(null);
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="parentCommand"></param>
        /// <returns></returns>
        /// <remarks>
        /// <para>
        /// In the generale case, the implementation type corresponds to <see cref="ManagedImplementationType"/>.
        /// </para>
        /// <para>
        /// In the case the implementation type is a managed array, but the specification assert a length equals to
        /// 1, and <paramref name="parentCommand"/> is a "Get" implementation, the implementation type is converted
        /// to a basic type, with an "out" modifier.
        /// </para>
        /// </remarks>
        public virtual string GetImplementationType(RegistryContext ctx, Command parentCommand)
        {
            string implementationType = ManagedImplementationType;

            // Type[] + Length=1 -> out Type
            if ((IsConstant == false) && implementationType.EndsWith("[]") && (Length == "1") && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                implementationType = implementationType.Substring(0, implementationType.Length - 2);
            }
            // String + Length!=null && !IsConst -> [Out] StringBuilder (in Get commands)
            if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                implementationType = "StringBuilder";
            }

            return(implementationType);
        }
		public string GetDelegateTypeAttributes(RegistryContext ctx, Command parentCommand)
		{
			string implementationType = ManagedImplementationType;
			string attribute = null;

			// String + Length!=null -> [Out] StringBuilder
			if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
				attribute = "[Out]";

			return (attribute);
		}
		public string GetImplementationTypeAttributes(RegistryContext ctx, Command parentCommand)
		{
			string implementationType = ManagedImplementationType;
			string implementationMod = GetImplementationTypeModifier(ctx, parentCommand);
			string attribute = null;

			// String + Length!=null && !IsConst -> [Out] StringBuilder (in Get commands)
			if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
				attribute = "[Out]";
			// Array && !IsConst -> [Out] T[] (in Get commands)
			if ((IsConstant == false) && (implementationType.EndsWith("[]")) && ((implementationMod != "out") && (implementationMod != "ref")) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
				attribute = "[Out]";

			return (attribute);
		}
Beispiel #10
0
		public string GetDelegateType(RegistryContext ctx, Command parentCommand)
		{
			string implementationType = ImportType;

			// String + Length!=null -> [Out] StringBuilder
			if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
				implementationType = "StringBuilder";

			return (implementationType.Trim());
		}
Beispiel #11
0
		public string GetImplementationTypeModifier(RegistryContext ctx, Command parentCommand)
		{
			string implementationType = ManagedImplementationType;

			// Type[] + Length=1 -> out Type
			if ((IsConstant == false) && implementationType.EndsWith("[]") && (Length == "1") && (parentCommand.IsGetImplementation(ctx)))
				return ("out");
			// Type[] + Length=1 -> out Type
			if ((IsConstant == false) && implementationType.EndsWith("[]") && (Length == "1") && ((parentCommand.Flags & CommandFlags.OutParam) != 0))
				return ("out");

			return (null);
		}
Beispiel #12
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="ctx"></param>
		/// <param name="parentCommand"></param>
		/// <returns></returns>
		/// <remarks>
		/// <para>
		/// In the generale case, the implementation type corresponds to <see cref="ManagedImplementationType"/>.
		/// </para>
		/// <para>
		/// In the case the implementation type is a managed array, but the specification assert a length equals to
		/// 1, and <paramref name="parentCommand"/> is a "Get" implementation, the implementation type is converted
		/// to a basic type, with an "out" modifier.
		/// </para>
		/// <para>
		/// 
		/// </para>
		/// </remarks>
		public string GetImplementationType(RegistryContext ctx, Command parentCommand)
		{
			string implementationType = ManagedImplementationType;

			// Type[] + Length=1 -> out Type
			if ((IsConstant == false) && implementationType.EndsWith("[]") && (Length == "1") && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
				implementationType = implementationType.Substring(0, implementationType.Length - 2);
			// String + Length!=null && !IsConst -> [Out] StringBuilder (in Get commands)
			if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
				implementationType = "StringBuilder";

			return (implementationType);
		}
        public string GetDelegateTypeAttributes(RegistryContext ctx, Command parentCommand)
        {
            string implementationType = GetManagedImplementationType(parentCommand);
            string attribute          = null;

            // String + Length!=null -> [Out] StringBuilder
            if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                attribute = "[Out]";
            }

            switch (SpecificationType)
            {
            case "GLboolean":                                   // bool
                attribute = (attribute ?? String.Empty) + "[MarshalAs(UnmanagedType.I1)]";
                break;
                // Note: MarshalAsAttribute not applicable to bool*!
                //case "GLboolean*":		// bool[]
                //	attribute = (attribute ?? String.Empty) + "[MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1)]";
                //	break;
            }

            return(attribute);
        }
        public string GetDelegateType(RegistryContext ctx, Command parentCommand)
        {
            string modifier           = CommandFlagsDatabase.GetCommandArgumentModifier(parentCommand, this);
            string implementationType = GetImportType(parentCommand);

            // String + Length!=null -> [Out] StringBuilder
            if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                implementationType = "StringBuilder";
            }
            // Support 'ref' argument
            if ((modifier == "ref" || modifier == "out") && implementationType.EndsWith("*"))
            {
                implementationType = modifier + " " + implementationType.Substring(0, implementationType.Length - 1);
            }

            return(implementationType.Trim());
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="parentCommand"></param>
        /// <returns></returns>
        /// <remarks>
        /// <para>
        /// In the generale case, the implementation type corresponds to <see cref="ManagedImplementationType"/>.
        /// </para>
        /// <para>
        /// In the case the implementation type is a managed array, but the specification assert a length equals to
        /// 1, and <paramref name="parentCommand"/> is a "Get" implementation, the implementation type is converted
        /// to a basic type, with an "out" modifier.
        /// </para>
        /// </remarks>
        public virtual string GetImplementationType(RegistryContext ctx, Command parentCommand)
        {
            string modifier           = CommandFlagsDatabase.GetCommandArgumentModifier(parentCommand, this);
            string implementationType = GetManagedImplementationType(parentCommand);

            // Type[] + Length=1 -> out Type
            if ((IsConstant == false) && implementationType.EndsWith("[]") && (Length == "1") && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                implementationType = implementationType.Substring(0, implementationType.Length - 2);
            }
            // String + Length!=null && !IsConst -> [Out] StringBuilder (in Get commands)
            if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0))))
            {
                implementationType = "StringBuilder";
            }
            // Support 'ref' argument
            if ((modifier == "ref" || modifier == "out") && implementationType.EndsWith("[]"))
            {
                implementationType = modifier + " " + implementationType.Substring(0, implementationType.Length - 2);
            }

            return(implementationType);
        }