示例#1
0
        static void OutputClassMethodDefinitions(CodeGen.Formatter output, CodeGen.Interface classData, Dictionary<string, CodeGen.QualifiableType> typeDictionary)
        {
            output.WriteLine("//");
            output.WriteLine("// " + classData.NativeName);
            output.WriteLine("//");
            output.WriteLine();
            foreach (CodeGen.Interface.Method m in classData.Methods)
            {
                if (m.IsOverload) continue;

                output.WriteIndent();
                if (m.ReturnsHResult())
                {
                    output.Write("STDMETHOD(" + m.Name + ")(");
                }
                else
                {
                    output.Write("STDMETHOD_(" + typeDictionary[m.NativeReturnType].NativeName + ", " + m.Name + ")(");
                }
                output.Indent();

                for (int i = 0; i < m.Parameters.Count; i++)
                {
                    output.WriteLine();

                    string parameterString = GetParameterTypeNameIncludingIndirection(m.Parameters[i], typeDictionary) + " " + m.Parameters[i].Name;

                    output.WriteIndent();

                    output.Write(parameterString);

                    if(m.Parameters[i].IsArray)
                    {
                        output.Write(",");
                        output.WriteLine();
                        output.WriteIndent();
                        output.Write("UINT32 " + m.Parameters[i].Name + "Count");
                    }

                    if(i < m.Parameters.Count - 1)
                    {
                        output.Write(",");
                    }
                }

                string constString = m.IsConst ? " const" : "";
                output.Write(")" + constString + " override");
                output.WriteLine();

                output.Unindent();

                output.WriteLine("{");
                output.Indent();

                output.WriteIndent();

                if (m.NativeReturnType != "void")
                {
                    output.Write("return ");
                }
                output.Write(m.Name + "Method.WasCalled(");

                for (int i = 0; i < m.Parameters.Count; i++)
                {
                    output.Write(m.Parameters[i].Name);

                    if(m.Parameters[i].IsArray)
                    {
                        output.Write(", " + m.Parameters[i].Name + "Count");
                    }

                    if (i < m.Parameters.Count - 1) output.Write(", ");
                }

                output.Write(");");
                output.WriteLine();

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