コード例 #1
0
        public void OutputCode(bool isLast, bool isFlags, Formatter idlFile)
        {
            if (!m_shouldProject)
            {
                return;
            }

            idlFile.WriteIndent();

            //
            // The (int) cast is necessary for values such as "0x80000000" which
            // cannot be stored using a signed int. The default behavior of the
            // MIDL code generation/C++ compilation process is to treat enum
            // values as signed ints.
            //
            idlFile.Write(m_stylizedName);
            idlFile.Write(" = ");

            if (!isFlags)
            {
                idlFile.Write("(int)");
            }

            idlFile.Write(m_valueExpression);

            string suffix = isLast ? "" : ",";

            idlFile.Write(suffix);
            idlFile.WriteLine();
        }
コード例 #2
0
        public static void OutputEffectCpp(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            bool isInputSizeFixed = !EffectHasVariableNumberOfInputs(effect);
            int  inputsCount      = isInputSizeFixed ? effect.Inputs.InputsList.Count : 0;

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine("#include \"" + effect.ClassName + ".h\"");
            output.WriteLine();
            output.WriteLine("namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine(effect.ClassName + "::" + effect.ClassName + "()");
            output.WriteIndent();
            output.WriteLine(": CanvasEffect(CLSID_D2D1"
                             + EffectGenerator.FormatClassName(effect.Properties[0].Value) + ", "
                             + (effect.Properties.Count(p => !p.IsHandCoded) - 4) + ", "
                             + inputsCount + ", "
                             + isInputSizeFixed.ToString().ToLower() + ")");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("// Set default values");

            foreach (var property in effect.Properties)
            {
                WritePropertyInitialization(output, property);
            }
            output.Unindent();
            output.WriteLine("}");
            output.WriteLine();
            foreach (var property in effect.Properties)
            {
                WritePropertyImplementation(effect, output, property);
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("IMPLEMENT_EFFECT_SOURCES_PROPERTY(" + effect.ClassName + ")");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];
                    output.WriteLine("IMPLEMENT_EFFECT_SOURCE_PROPERTY(" + effect.ClassName + ",");
                    output.Indent();
                    output.WriteLine(input.Name + ",");
                    output.WriteLine(i.ToString() + ")");
                    output.Unindent();
                    output.WriteLine();
                }
            }

            output.WriteLine("ActivatableClass(" + effect.ClassName + ");");

            output.Unindent();
            output.WriteLine("}}}}}");
        }
コード例 #3
0
        // Used for code generation.
        public override void OutputCode(Dictionary <string, QualifiableType> typeDictionary, Formatter idlFile)
        {
            idlFile.WriteIndent();
            idlFile.Write("[version(VERSION)");
            if (m_isFlags)
            {
                idlFile.Write(", flags");
            }
            idlFile.Write("]");
            idlFile.WriteLine();

            idlFile.WriteLine("typedef enum " + m_stylizedName);
            idlFile.WriteLine("{");
            idlFile.Indent();

            for (int i = 0; i < m_enumValues.Count; i++)
            {
                bool isLast = i == m_enumValues.Count - 1;
                m_enumValues[i].OutputCode(isLast, m_isFlags, idlFile);
            }
            idlFile.Unindent();
            idlFile.WriteLine("} " + m_stylizedName + ";");
            idlFile.WriteLine();
        }
コード例 #4
0
        public static void OutputEffectCpp(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            bool isInputSizeFixed = !EffectHasVariableNumberOfInputs(effect);
            int  inputsCount      = isInputSizeFixed ? effect.Inputs.InputsList.Count : 0;

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine("#include \"" + effect.ClassName + ".h\"");
            output.WriteLine();

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine(effect.ClassName + "::" + effect.ClassName + "(ICanvasDevice* device, ID2D1Effect* effect)");
            output.WriteIndent();
            output.WriteLine(": CanvasEffect(EffectId(), "
                             + (effect.Properties.Count(p => (!p.IsHandCoded && !p.IsHdrAlias)) - 4) + ", "
                             + inputsCount + ", "
                             + isInputSizeFixed.ToString().ToLower() + ", "
                             + "device, effect, static_cast<" + effect.InterfaceName + "*>(this))");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("if (!effect)");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("// Set default values");

            foreach (var property in effect.Properties)
            {
                WritePropertyInitialization(output, property);
            }
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");
            output.WriteLine();
            foreach (var property in effect.Properties)
            {
                WritePropertyImplementation(effect, output, property);
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("IMPLEMENT_EFFECT_SOURCES_PROPERTY(" + effect.ClassName + ")");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];
                    output.WriteLine("IMPLEMENT_EFFECT_SOURCE_PROPERTY(" + effect.ClassName + ",");
                    output.Indent();
                    output.WriteLine(input.Name + ",");
                    output.WriteLine(i.ToString() + ")");
                    output.Unindent();
                    output.WriteLine();
                }
            }

            WritePropertyMapping(effect, output);

            if (effect.Overrides == null || !effect.Overrides.HasStatics)
            {
                output.WriteLine("ActivatableClass(" + effect.ClassName + ");");
            }

            output.Unindent();
            output.WriteLine("}}}}}");

            EndVersionConditional(effect, output);
        }
コード例 #5
0
        public static void OutputEffectIdl(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace Microsoft.Graphics.Canvas.Effects");
            output.WriteLine("{");
            output.Indent();

            // Output all enums specific to this effect
            foreach (var property in effect.Properties)
            {
                if (property.Type == "enum" &&
                    property.EnumFields.Usage == Effects.EnumValues.UsageType.UsedByOneEffect &&
                    property.ShouldProject)
                {
                    OutputEnum(property, output);
                    output.WriteLine();
                }
            }

            output.WriteLine("runtimeclass " + effect.ClassName + ";");
            output.WriteLine();
            output.WriteLine("[version(VERSION), uuid(" + effect.Uuid + "), exclusiveto(" + effect.ClassName + ")]");
            output.WriteLine("interface " + effect.InterfaceName + " : IInspectable");
            output.WriteIndent();
            output.WriteLine("requires ICanvasEffect");
            output.WriteLine("{");
            output.Indent();

            foreach (var property in effect.Properties)
            {
                // Property with type string describes
                // name/author/category/description of effect but not input type
                if (property.Type == "string" || property.IsHidden)
                {
                    continue;
                }

                output.WriteLine("[propget]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([out] UINT32* valueCount, [out, size_is(, *valueCount), retval] " + property.TypeNameIdl + "** valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([out, retval] " + property.TypeNameIdl + "* value);");
                }
                output.WriteLine();

                output.WriteLine("[propput]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] UINT32 valueCount, [in, size_is(valueCount)] " + property.TypeNameIdl + "* valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] " + property.TypeNameIdl + " value);");
                }
                output.WriteLine();
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("[propget]");
                output.WriteLine("HRESULT Sources([out, retval] Windows.Foundation.Collections.IVector<IGRAPHICSEFFECTSOURCE*>** value);");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];

                    output.WriteLine("[propget]");
                    output.WriteLine("HRESULT " + input.Name + "([out, retval] IGRAPHICSEFFECTSOURCE** source);");
                    output.WriteLine();

                    output.WriteLine("[propput]");
                    output.WriteLine("HRESULT " + input.Name + "([in] IGRAPHICSEFFECTSOURCE* source);");
                    output.WriteLine();
                }
            }

            output.Unindent();
            output.WriteLine("};");
            output.WriteLine();

            string statics = "";

            if (effect.Overrides != null && effect.Overrides.HasStatics)
            {
                statics = ", static(" + effect.InterfaceName + "Statics, VERSION)";
            }

            output.WriteLine("[version(VERSION), activatable(VERSION)" + statics + "]");

            output.WriteLine("runtimeclass " + effect.ClassName);
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("[default] interface " + effect.InterfaceName + ";");
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");

            EndVersionConditional(effect, output);
        }
コード例 #6
0
        public static void OutputEffectCpp(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            bool isInputSizeFixed = !EffectHasVariableNumberOfInputs(effect);
            int inputsCount = isInputSizeFixed ? effect.Inputs.InputsList.Count : 0;

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine("#include \"" + effect.ClassName + ".h\"");
            output.WriteLine();

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine(effect.ClassName + "::" + effect.ClassName + "(ICanvasDevice* device, ID2D1Effect* effect)");
            output.WriteIndent();
            output.WriteLine(": CanvasEffect(EffectId(), "
                             + (effect.Properties.Count(p => (!p.IsHandCoded && !p.IsHdrAlias)) - 4) + ", "
                             + inputsCount + ", "
                             + isInputSizeFixed.ToString().ToLower() + ", "
                             + "device, effect, static_cast<" + effect.InterfaceName + "*>(this))");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("if (!effect)");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("// Set default values");

            foreach (var property in effect.Properties)
            {
                WritePropertyInitialization(output, property);
            }
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");
            output.WriteLine();
            foreach (var property in effect.Properties)
            {
                WritePropertyImplementation(effect, output, property);
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("IMPLEMENT_EFFECT_SOURCES_PROPERTY(" + effect.ClassName + ")");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];
                    output.WriteLine("IMPLEMENT_EFFECT_SOURCE_PROPERTY(" + effect.ClassName + ",");
                    output.Indent();
                    output.WriteLine(input.Name + ",");
                    output.WriteLine(i.ToString() + ")");
                    output.Unindent();
                    output.WriteLine();
                }
            }

            WritePropertyMapping(effect, output);

            output.WriteLine("ActivatableClass(" + effect.ClassName + ");");

            output.Unindent();
            output.WriteLine("}}}}}");

            EndVersionConditional(effect, output);
        }
コード例 #7
0
        public static void OutputEffectIdl(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace Microsoft.Graphics.Canvas.Effects");
            output.WriteLine("{");
            output.Indent();

            // Output all enums specific to this effect
            foreach (var property in effect.Properties)
            {
                if (property.Type == "enum" && 
                    property.EnumFields.Usage == Effects.EnumValues.UsageType.UsedByOneEffect && 
                    property.ShouldProject)
                {
                    OutputEnum(property, output);
                    output.WriteLine();
                }
            }

            output.WriteLine("runtimeclass " + effect.ClassName + ";");
            output.WriteLine();
            output.WriteLine("[version(VERSION), uuid(" + effect.Uuid + "), exclusiveto(" + effect.ClassName + ")]");
            output.WriteLine("interface " + effect.InterfaceName + " : IInspectable");
            output.WriteIndent();
            output.WriteLine("requires Microsoft.Graphics.Canvas.ICanvasImage");
            output.WriteLine("{");
            output.Indent();

            foreach (var property in effect.Properties)
            {
                // Property with type string describes 
                // name/author/category/description of effect but not input type
                if (property.Type == "string" || property.IsHidden)
                    continue;

                output.WriteLine("[propget]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([out] UINT32* valueCount, [out, size_is(, *valueCount), retval] " + property.TypeNameIdl + "** valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([out, retval] " + property.TypeNameIdl + "* value);");
                }
                output.WriteLine();

                output.WriteLine("[propput]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] UINT32 valueCount, [in, size_is(valueCount)] " + property.TypeNameIdl + "* valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] " + property.TypeNameIdl + " value);");
                }
                output.WriteLine();
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("[propget]");
                output.WriteLine("HRESULT Sources([out, retval] Windows.Foundation.Collections.IVector<IGRAPHICSEFFECTSOURCE*>** value);");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];

                    output.WriteLine("[propget]");
                    output.WriteLine("HRESULT " + input.Name + "([out, retval] IGRAPHICSEFFECTSOURCE** source);");
                    output.WriteLine();

                    output.WriteLine("[propput]");
                    output.WriteLine("HRESULT " + input.Name + "([in] IGRAPHICSEFFECTSOURCE* source);");
                    output.WriteLine();
                }
            }

            output.Unindent();
            output.WriteLine("};");
            output.WriteLine();

            output.WriteLine("[version(VERSION), activatable(VERSION)]");
            output.WriteLine("runtimeclass " + effect.ClassName);
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("[default] interface " + effect.InterfaceName + ";");
            output.WriteLine("interface IGRAPHICSEFFECT;");
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");

            EndVersionConditional(effect, output);
        }
コード例 #8
0
        public static void OutputEffectCpp(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            bool isInputSizeFixed = !EffectHasVariableNumberOfInputs(effect);
            int  inputsCount      = isInputSizeFixed ? effect.Inputs.InputsList.Count : 0;

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine("#include \"" + effect.ClassName + ".h\"");
            output.WriteLine();

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine(effect.ClassName + "::" + effect.ClassName + "(ICanvasDevice* device, ID2D1Effect* effect)");
            output.WriteIndent();
            output.WriteLine(": CanvasEffect(EffectId(), "
                             + (effect.Properties.Count(p => (!p.IsHandCoded && !p.IsHdrAlias)) - 4) + ", "
                             + inputsCount + ", "
                             + isInputSizeFixed.ToString().ToLower() + ", "
                             + "device, effect, static_cast<" + effect.InterfaceName + "*>(this))");
            output.WriteLine("{");
            output.Indent();

            if (effect.Overrides != null && !string.IsNullOrEmpty(effect.Overrides.IsSupportedCheck))
            {
                output.WriteLine("if (!SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported())");
                output.Indent();
                output.WriteLine("ThrowHR(E_NOTIMPL, Strings::NotSupportedOnThisVersionOfWindows);");
                output.Unindent();
                output.WriteLine();
            }

            output.WriteLine("if (!effect)");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("// Set default values");

            foreach (var property in effect.Properties)
            {
                WritePropertyInitialization(output, property);
            }
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");
            output.WriteLine();
            foreach (var property in effect.Properties)
            {
                WritePropertyImplementation(effect, output, property);
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("IMPLEMENT_EFFECT_SOURCES_PROPERTY(" + effect.ClassName + ")");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];
                    output.WriteLine("IMPLEMENT_EFFECT_SOURCE_PROPERTY(" + effect.ClassName + ",");
                    output.Indent();
                    output.WriteLine(input.Name + ",");
                    output.WriteLine(i.ToString() + ")");
                    output.Unindent();
                    output.WriteLine();
                }
            }

            WritePropertyMapping(effect, output);

            if (HasStatics(effect))
            {
                output.WriteLine("IFACEMETHODIMP " + effect.ClassName + "Factory::ActivateInstance(IInspectable** instance)");
                output.WriteLine("{");
                output.Indent();
                output.WriteLine("return ExceptionBoundary([&]");
                output.WriteLine("{");
                output.Indent();
                output.WriteLine("auto effect = Make<" + effect.ClassName + ">();");
                output.WriteLine("CheckMakeResult(effect);");
                output.WriteLine();
                output.WriteLine("ThrowIfFailed(effect.CopyTo(instance));");
                output.Unindent();
                output.WriteLine("});");
                output.Unindent();
                output.WriteLine("}");
                output.WriteLine();

                if (!string.IsNullOrEmpty(effect.Overrides.IsSupportedCheck))
                {
                    output.WriteLine("IFACEMETHODIMP " + effect.ClassName + "Factory::get_IsSupported(_Out_ boolean* result)");
                    output.WriteLine("{");
                    output.Indent();
                    output.WriteLine("return ExceptionBoundary([&]");
                    output.WriteLine("{");
                    output.Indent();
                    output.WriteLine("CheckInPointer(result);");
                    output.WriteLine("*result = SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported();");
                    output.Unindent();
                    output.WriteLine("});");
                    output.Unindent();
                    output.WriteLine("}");
                    output.WriteLine();
                }

                output.WriteLine("ActivatableClassWithFactory(" + effect.ClassName + ", " + effect.ClassName + "Factory);");
            }
            else
            {
                output.WriteLine("ActivatableClassWithFactory(" + effect.ClassName + ", SimpleAgileActivationFactory<" + effect.ClassName + ">);");
            }

            output.Unindent();
            output.WriteLine("}}}}}");

            EndVersionConditional(effect, output);
        }
コード例 #9
0
ファイル: OutputEffectType.cs プロジェクト: clarkezone/Win2D
        public static void OutputEffectCpp(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            bool isInputSizeFixed = !EffectHasVariableNumberOfInputs(effect);
            int inputsCount = isInputSizeFixed ? effect.Inputs.InputsList.Count : 0;

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine("#include \"" + effect.ClassName + ".h\"");
            output.WriteLine();

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine(effect.ClassName + "::" + effect.ClassName + "(ICanvasDevice* device, ID2D1Effect* effect)");
            output.WriteIndent();
            output.WriteLine(": CanvasEffect(EffectId(), "
                             + (effect.Properties.Count(p => (!p.IsHandCoded && !p.IsHdrAlias)) - 4) + ", "
                             + inputsCount + ", "
                             + isInputSizeFixed.ToString().ToLower() + ", "
                             + "device, effect, static_cast<" + effect.InterfaceName + "*>(this))");
            output.WriteLine("{");
            output.Indent();

            if (effect.Overrides != null && !string.IsNullOrEmpty(effect.Overrides.IsSupportedCheck))
            {
                output.WriteLine("if (!SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported())");
                output.Indent();
                output.WriteLine("ThrowHR(E_NOTIMPL, Strings::NotSupportedOnThisVersionOfWindows);");
                output.Unindent();
                output.WriteLine();
            }
            
            output.WriteLine("if (!effect)");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("// Set default values");

            foreach (var property in effect.Properties)
            {
                WritePropertyInitialization(output, property);
            }
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");
            output.WriteLine();
            foreach (var property in effect.Properties)
            {
                WritePropertyImplementation(effect, output, property);
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("IMPLEMENT_EFFECT_SOURCES_PROPERTY(" + effect.ClassName + ")");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];
                    output.WriteLine("IMPLEMENT_EFFECT_SOURCE_PROPERTY(" + effect.ClassName + ",");
                    output.Indent();
                    output.WriteLine(input.Name + ",");
                    output.WriteLine(i.ToString() + ")");
                    output.Unindent();
                    output.WriteLine();
                }
            }

            WritePropertyMapping(effect, output);

            if (HasStatics(effect))
            {
                output.WriteLine("IFACEMETHODIMP " + effect.ClassName + "Factory::ActivateInstance(IInspectable** instance)");
                output.WriteLine("{");
                output.Indent();
                output.WriteLine("return ExceptionBoundary([&]");
                output.WriteLine("{");
                output.Indent();
                output.WriteLine("auto effect = Make<" + effect.ClassName + ">();");
                output.WriteLine("CheckMakeResult(effect);");
                output.WriteLine();
                output.WriteLine("ThrowIfFailed(effect.CopyTo(instance));");
                output.Unindent();
                output.WriteLine("});");
                output.Unindent();
                output.WriteLine("}");
                output.WriteLine();

                if (!string.IsNullOrEmpty(effect.Overrides.IsSupportedCheck))
                {
                    output.WriteLine("IFACEMETHODIMP " + effect.ClassName + "Factory::get_IsSupported(_Out_ boolean* result)");
                    output.WriteLine("{");
                    output.Indent();
                    output.WriteLine("return ExceptionBoundary([&]");
                    output.WriteLine("{");
                    output.Indent();
                    output.WriteLine("CheckInPointer(result);");
                    output.WriteLine("*result = SharedDeviceState::GetInstance()->Is" + effect.Overrides.IsSupportedCheck + "Supported();");
                    output.Unindent();
                    output.WriteLine("});");
                    output.Unindent();
                    output.WriteLine("}");
                    output.WriteLine();
                }

                output.WriteLine("ActivatableClassWithFactory(" + effect.ClassName + ", " + effect.ClassName + "Factory);");
            }
            else
            {
                output.WriteLine("ActivatableClassWithFactory(" + effect.ClassName + ", SimpleAgileActivationFactory<" + effect.ClassName + ">);");
            }

            output.Unindent();
            output.WriteLine("}}}}}");

            EndVersionConditional(effect, output);
        }
コード例 #10
0
ファイル: OutputEffectType.cs プロジェクト: clarkezone/Win2D
        public static void OutputEffectIdl(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            OutputVersionConditional(effect, output);

            output.WriteLine("namespace Microsoft.Graphics.Canvas.Effects");
            output.WriteLine("{");
            output.Indent();

            // Output all enums specific to this effect
            foreach (var property in effect.Properties)
            {
                if (property.Type == "enum" && 
                    property.EnumFields.Usage == Effects.EnumValues.UsageType.UsedByOneEffect && 
                    property.ShouldProject)
                {
                    OutputEnum(property, output);
                    output.WriteLine();
                }
            }

            output.WriteLine("runtimeclass " + effect.ClassName + ";");
            output.WriteLine();
            output.WriteLine("[version(VERSION), uuid(" + effect.Uuid + "), exclusiveto(" + effect.ClassName + ")]");
            output.WriteLine("interface " + effect.InterfaceName + " : IInspectable");
            output.WriteIndent();
            output.WriteLine("requires ICanvasEffect");
            output.WriteLine("{");
            output.Indent();

            foreach (var property in effect.Properties)
            {
                // Property with type string describes 
                // name/author/category/description of effect but not input type
                if (property.Type == "string" || property.IsHidden)
                    continue;

                output.WriteLine("[propget]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([out] UINT32* valueCount, [out, size_is(, *valueCount), retval] " + property.TypeNameIdl + "** valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([out, retval] " + property.TypeNameIdl + "* value);");
                }
                output.WriteLine();

                output.WriteLine("[propput]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] UINT32 valueCount, [in, size_is(valueCount)] " + property.TypeNameIdl + "* valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] " + property.TypeNameIdl + " value);");
                }
                output.WriteLine();
            }

            if (EffectHasVariableNumberOfInputs(effect))
            {
                output.WriteLine("[propget]");
                output.WriteLine("HRESULT Sources([out, retval] Windows.Foundation.Collections.IVector<IGRAPHICSEFFECTSOURCE*>** value);");
                output.WriteLine();
            }
            else
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];

                    output.WriteLine("[propget]");
                    output.WriteLine("HRESULT " + input.Name + "([out, retval] IGRAPHICSEFFECTSOURCE** source);");
                    output.WriteLine();

                    output.WriteLine("[propput]");
                    output.WriteLine("HRESULT " + input.Name + "([in] IGRAPHICSEFFECTSOURCE* source);");
                    output.WriteLine();
                }
            }

            output.Unindent();
            output.WriteLine("};");
            output.WriteLine();

            string staticAttribute = "";

            if (HasStatics(effect))
            {
                string staticsInterfaceName = effect.InterfaceName + "Statics";
                string staticsUuid = EffectGenerator.GenerateUuid(staticsInterfaceName);

                staticAttribute = ", static(" + staticsInterfaceName + ", VERSION)";

                output.WriteLine("[version(VERSION), uuid(" + staticsUuid + "), exclusiveto(" + effect.ClassName + ")]");
                output.WriteLine("interface " + staticsInterfaceName + " : IInspectable");
                output.WriteLine("{");
                output.Indent();

                foreach (var customIdl in effect.Overrides.CustomStaticMethodIdl)
                {
                    output.WriteLine(customIdl.Trim());
                }

                if (!string.IsNullOrEmpty(effect.Overrides.IsSupportedCheck))
                {
                    output.WriteLine("[propget] HRESULT IsSupported([out, retval] boolean* value);");
                }

                output.Unindent();
                output.WriteLine("}");
                output.WriteLine();
            }
            
            output.WriteLine("[STANDARD_ATTRIBUTES, activatable(VERSION)" + staticAttribute + "]");

            output.WriteLine("runtimeclass " + effect.ClassName);
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("[default] interface " + effect.InterfaceName + ";");
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");

            EndVersionConditional(effect, output);
        }
コード例 #11
0
ファイル: OutputEffectType.cs プロジェクト: chenbk85/Win2D
        public static void OutputEffectIdl(Effects.Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            output.WriteLine("namespace Microsoft.Graphics.Canvas.Effects");
            output.WriteLine("{");
            output.Indent();

            // Output all enums specific to this effect
            foreach (var property in effect.Properties)
            {
                if (property.Type == "enum" &&
                    property.EnumFields.Usage == Effects.EnumValues.UsageType.UsedByOneEffect &&
                    property.ShouldProject)
                {
                    OutputEnum(property, output);
                    output.WriteLine();
                }
            }

            output.WriteLine("runtimeclass " + effect.ClassName + ";");
            output.WriteLine();
            output.WriteLine("[version(VERSION), uuid(" + effect.Uuid + "), exclusiveto(" + effect.ClassName + ")]");
            output.WriteLine("interface " + effect.InterfaceName + " : IInspectable");
            output.WriteIndent();
            output.WriteLine("requires Microsoft.Graphics.Canvas.ICanvasImage");
            output.WriteLine("{");
            output.Indent();

            foreach (var property in effect.Properties)
            {
                // Property with type string describes
                // name/author/category/description of effect but not input type
                if (property.Type == "string" || property.IsHidden)
                {
                    continue;
                }

                output.WriteLine("[propget]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([out] UINT32* valueCount, [out, size_is(, *valueCount), retval] " + property.TypeNameIdl + "** valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([out, retval] " + property.TypeNameIdl + "* value);");
                }
                output.WriteLine();

                output.WriteLine("[propput]");
                if (property.IsArray)
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] UINT32 valueCount, [in, size_is(valueCount)] " + property.TypeNameIdl + "* valueElements);");
                }
                else
                {
                    output.WriteLine("HRESULT " + property.Name + "([in] " + property.TypeNameIdl + " value);");
                }
                output.WriteLine();
            }

            // Check if inputs specify maximum attribute in xml and if it is marked as unlimited
            if (!(effect.Inputs.Maximum != null && effect.Inputs.Maximum == "0xFFFFFFFF"))
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];

                    output.WriteLine("[propget]");
                    output.WriteLine("HRESULT " + input.Name + "([out, retval] IEffectInput** input);");
                    output.WriteLine();

                    output.WriteLine("[propput]");
                    output.WriteLine("HRESULT " + input.Name + "([in] IEffectInput* input);");
                    output.WriteLine();
                }
            }

            output.Unindent();
            output.WriteLine("};");
            output.WriteLine();

            output.WriteLine("[version(VERSION), activatable(VERSION)]");
            output.WriteLine("runtimeclass " + effect.ClassName);
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("[default] interface " + effect.InterfaceName + ";");
            output.WriteLine("interface IEffect;");
            output.Unindent();
            output.WriteLine("}");
            output.Unindent();
            output.WriteLine("}");
        }
コード例 #12
0
ファイル: OutputEffectType.cs プロジェクト: nicecai/Win2D
        public static void OutputEffectCpp(Effect effect, Formatter output)
        {
            OutputDataTypes.OutputLeadingComment(output);

            bool isInputSizeFixed = true;

            if (effect.Inputs.Maximum != null && effect.Inputs.Maximum == "0xFFFFFFFF")
            {
                isInputSizeFixed = false;
            }

            output.WriteLine("#include \"pch.h\"");
            output.WriteLine("#include \"..\\CanvasEffect.h\"");
            output.WriteLine("#include \"" + effect.ClassName + ".h\"");
            output.WriteLine();
            output.WriteLine("namespace ABI { namespace Microsoft { namespace Graphics { namespace Canvas { namespace Effects");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine(effect.ClassName + "::" + effect.ClassName + "()");
            output.WriteIndent();
            int inputsCoutn = effect.Inputs.InputsList.Count;

            if (effect.Inputs.Maximum != null && effect.Inputs.Maximum == "0xFFFFFFFF")
            {
                inputsCoutn = 0;
            }
            output.WriteLine(": CanvasEffect(CLSID_D2D1"
                             + effect.Properties[0].Value.Replace(" ", "") + ", "
                             + (effect.Properties.Count - 4) + ", "
                             + inputsCoutn + ", "
                             + isInputSizeFixed.ToString().ToLower() + ")");
            output.WriteLine("{");
            output.Indent();
            output.WriteLine("// Set default values");

            foreach (var property in effect.Properties)
            {
                // Property with type string describes
                // name/author/category/description of effect but not input type
                if (property.Type == "string")
                {
                    continue;
                }

                string defaultValue = property.Properties.Find(internalProperty => internalProperty.Name == "Default").Value;

                if (property.Type == "enum")
                {
                    string d2dDefaultEnum = property.EnumFields.NativeEnum.Enums[Int32.Parse(defaultValue)];
                    output.WriteLine("SetProperty(" + property.NativePropertyName + ", static_cast<uint32_t>(" + d2dDefaultEnum + "), true);");
                }
                else if (property.Type.StartsWith("matrix"))
                {
                    output.WriteLine(property.TypeNameCpp + " default" + property.Name + " = { " + FixSpacing(defaultValue.Substring(1, defaultValue.Length - 2)) + " };");
                    output.WriteLine("SetProperty(" + property.NativePropertyName + ", " + " default" + property.Name + ", true);");
                }
                else
                {
                    string typeExtension = "";
                    if (property.Type == "float")
                    {
                        typeExtension = "f";
                    }
                    output.WriteLine("SetProperty(" + property.NativePropertyName + ", " + defaultValue + typeExtension + ", true);");
                }
            }
            output.Unindent();
            output.WriteLine("}");
            output.WriteLine();
            foreach (var property in effect.Properties)
            {
                // Property with type string describes
                // name/author/category/description of effect but not input type
                if (property.Type == "string")
                {
                    continue;
                }

                bool isValidation = false;
                if (property.Properties.Find(internalProperty => internalProperty.Name == "Min") != null)
                {
                    isValidation = true;
                }

                bool isWithUnsupported = false;
                if (property.ExcludedEnumIndexes != null && property.ExcludedEnumIndexes.Count != 0)
                {
                    isWithUnsupported = true;
                }

                if (property.Type == "enum" && !isWithUnsupported)
                {
                    output.WriteLine("IMPLEMENT_ENUM_PROPERTY(" + effect.ClassName + ",");
                }
                else if (isValidation)
                {
                    output.WriteLine("IMPLEMENT_PROPERTY_WITH_VALIDATION(" + effect.ClassName + ",");
                }
                else if (isWithUnsupported)
                {
                    output.WriteLine("IMPLEMENT_ENUM_PROPERTY_WITH_UNSUPPORTED(" + effect.ClassName + ",");
                }
                else
                {
                    output.WriteLine("IMPLEMENT_PROPERTY(" + effect.ClassName + ",");
                }

                output.Indent();
                output.WriteLine(property.Name + ",");
                output.WriteLine(property.TypeNameCpp + ",");

                if (isValidation)
                {
                    output.WriteLine(property.NativePropertyName + ",");
                    output.WriteLine(property.Properties.Find(internalProperty => internalProperty.Name == "Min").Value + ",");
                    output.WriteLine(property.Properties.Find(internalProperty => internalProperty.Name == "Max").Value + ")");
                }
                else if (isWithUnsupported)
                {
                    output.WriteLine(property.NativePropertyName + ",");
                    var last = property.ExcludedEnumIndexes.Last();
                    foreach (var index in property.ExcludedEnumIndexes)
                    {
                        if (index == last)
                        {
                            output.WriteLine(index + "U)");
                        }
                        else
                        {
                            output.WriteLine(index + "U,");
                        }
                    }
                }
                else
                {
                    output.WriteLine(property.NativePropertyName + ")");
                }

                output.Unindent();
                output.WriteLine();
            }

            if (!(effect.Inputs.Maximum != null && effect.Inputs.Maximum == "0xFFFFFFFF"))
            {
                for (int i = 0; i < effect.Inputs.InputsList.Count; ++i)
                {
                    var input = effect.Inputs.InputsList[i];
                    output.WriteLine("IMPLEMENT_INPUT_PROPERTY(" + effect.ClassName + ",");
                    output.Indent();
                    output.WriteLine(input.Name + ",");
                    output.WriteLine(i.ToString() + ")");
                    output.Unindent();
                    output.WriteLine();
                }
            }

            output.WriteLine("ActivatableClass(" + effect.ClassName + ");");

            output.Unindent();
            output.WriteLine("}}}}}");
        }