Exemple #1
0
        private static string GetFuncDecl(Specification S, bool declOnly, G25.fgs FGS, G25.Operator op, G25.FloatType FT, bool assign, bool constVal, bool returnByReference)
        {
            StringBuilder SB = new StringBuilder();

            string inlineStr = G25.CG.Shared.Util.GetInlineString(S, (!declOnly) && S.m_inlineOperators, " ");
            string returnTypeName = (FGS.m_returnTypeName.Length > 0) ? FGS.m_returnTypeName : FT.type;
            if (!S.IsFloatType(returnTypeName)) returnTypeName = FT.GetMangledName(S, returnTypeName);
            string arg1typeName = FT.GetMangledName(S, FGS.ArgumentTypeNames[0]);
            string arg2typeName = (FGS.NbArguments > 1) ? FT.GetMangledName(S, FGS.ArgumentTypeNames[1]) : "";

            SB.Append(inlineStr);
            SB.Append(returnTypeName);
            SB.Append(" ");
            if (returnByReference) SB.Append("&");
            SB.Append("operator");
            SB.Append(op.Symbol);
            if (assign) SB.Append("=");
            SB.Append("(");
            if (constVal) SB.Append("const ");
            SB.Append(arg1typeName);
            SB.Append(" &");
            SB.Append(FGS.ArgumentVariableNames[0]);

            if (op.IsBinary())
            {
                SB.Append(", const ");
                SB.Append(arg2typeName);
                SB.Append(" &");
                SB.Append(FGS.ArgumentVariableNames[1]);
            }
            else if ((S.OutputCpp()) && op.IsPostfixUnary())
            { // add a dummy int argument so C++ knows this is a unary postfix op
                SB.Append(", int");
            }

            SB.Append(")");

            return SB.ToString();
        }