Exemplo n.º 1
0
        void BuildSvrPolicyCPP()
        {
            Parameter[] newparams;

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildNetPolicyClassParserImpl(msg.Name, "Res", newparams);
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildNetPolicyClassParserImpl(msg.Name, "S2CEvt", newparams);
                }
            }
        }
        // build parser class header
        void BuildGroupStrings()
        {
            StringSet.Add(Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    StringSet.Add(msg.Name);
                    StringSet.Add(msg.Name + "Cmd");
                    StringSet.Add(msg.Name + "Res");

                    if (msg.Cmd != null)
                    {
                        foreach (var parameter in msg.Cmd)
                        {
                            StringSet.Add(parameter.Name);
                            StringSet.Add(parameter.TypeName);
                        }
                    }
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    StringSet.Add(msg.Name);
                    StringSet.Add(msg.Name + "C2SEvt");

                    if (msg.Params != null)
                    {
                        foreach (var parameter in msg.Params)
                        {
                            StringSet.Add(parameter.Name);
                            StringSet.Add(parameter.TypeName);
                        }
                    }
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    StringSet.Add(msg.Name);
                    StringSet.Add(msg.Name + "S2CEvt");

                    if (msg.Params != null)
                    {
                        foreach (var parameter in msg.Params)
                        {
                            StringSet.Add(parameter.Name);
                            StringSet.Add(parameter.TypeName);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        void BuildSendAdapterCPP()
        {
            // Packer interface
            Parameter[] newparams;

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunctionNativeImplementation(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeImplementation(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }

            NewLine();
            NewLine();

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunctionNativeImplementation(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeImplementation(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }
        }
Exemplo n.º 4
0
        void BuildMsgMapImpl()
        {
            NewLine();

            if (AppConfig.GetValue("VariableMapParser", false))
            {
                MatchIndent(); OutStream.WriteLine("extern std::unordered_map<uint32_t,HandleParseMessageTo> {0};", MappingTableName());
            }
            MatchIndent(); OutStream.WriteLine("extern std::unordered_map<uint32_t,HandleParseMessageToMessageBase> {0};", MappingToMessageBaseName());

            NewLine();
            OpenSection("void", string.Format("RegisterParser{0}()", Group.Name));

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildMsgMap(MsgType.Cmd, "Cmd", msg.Name, msg.Cmd);
                    BuildMsgMap(MsgType.Res, "Res", msg.Name, msg.Res);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildMsgMap(MsgType.Evt, "C2SEvt", msg.Name, msg.Params);
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildMsgMap(MsgType.Evt, "S2CEvt", msg.Name, msg.Params);
                }
            }

            CloseSection();
        }
Exemplo n.º 5
0
        protected virtual void BuildServerPolicyH()
        {
            Parameter[] newparams;

            OpenSection("class", string.Format("{0}", SvrPolicyClassName));
            MatchIndent(); OutStream.WriteLine("private:");
            MatchIndent(1); OutStream.WriteLine("SharedPointerT<MessageEndpoint> m_Endpoint;");
            MatchIndent(); OutStream.WriteLine("public:");
            MatchIndent(); OutStream.WriteLine("// Constructor");
            MatchIndent(); OutStream.WriteLine(
                string.Format("{0} ( const SharedPointerT<MessageEndpoint>& pEndpoint ) : m_Endpoint(pEndpoint)", SvrPolicyClassName));
            MatchIndent(); OutStream.WriteLine("{}");
            NewLine();

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    MatchIndent(); OutStream.WriteLine(
                        string.Format("Result {0}Res( {1} );", msg.Name, ParamInString(newparams)));
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    MatchIndent(); OutStream.WriteLine(
                        string.Format("Result {0}S2CEvt( {1} );", msg.Name, ParamInString(newparams)));
                }
            }

            NewLine();

            CloseSection();
        }
Exemplo n.º 6
0
        void BuildMessageParserClassCSharp()
        {
            // Packer interface
            Parameter[] newparams;

            MessageCodeIndex = 0;
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildMessageClass(msg, "Cmd", newparams);

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildMessageClass(msg, "Res", newparams); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildMessageClass(msg, "C2SEvt", newparams); NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildMessageClass(msg, "S2CEvt", newparams); NewLine();
                }

                MessageCodeIndex++;
            }
        }
Exemplo n.º 7
0
        // build parser class header
        void BuildGroupDoc()
        {
            Parameter[] newparams;
            string      strClassName    = string.Format("{0}", Group.Name);
            string      policyClassName = PolicyClassName;

            MatchIndent(); OutStream.WriteLine("# Protocol interface class {0}", policyClassName);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildAPIDoc(msg, MakeParameters(MsgType.Cmd, msg.Cmd), MakeParameters(MsgType.Res, msg.Res));
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildAPIDoc(msg, MsgType.Evt, "C2SEvt", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildAPIDoc(msg, MsgType.Evt, "S2CEvt", newparams);
                    NewLine();
                }
            }
        }
Exemplo n.º 8
0
        void BuildMsgMapImpl()
        {
            MatchIndent(); OutStream.WriteLine("extern std::unordered_map<uint32_t,MessageHandlingFunction> {0};", MappingTableName());
            NewLine();

            OpenSection("void", string.Format("RegisterDebugTrace{0}()", Group.Name));

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildMsgMap(MsgType.Cmd, "Cmd", msg.Name, msg.Cmd);
                    BuildMsgMap(MsgType.Res, "Res", msg.Name, msg.Res);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildMsgMap(MsgType.Evt, "C2SEvt", msg.Name, msg.Params);
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildMsgMap(MsgType.Evt, "S2CEvt", msg.Name, msg.Params);
                }
            }

            CloseSection();
        }
Exemplo n.º 9
0
        void BuildMessageParserClassCPP()
        {
            // Packer interface
            Parameter[] newparams;
            m_MessageCodeIndex = 0;
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildMessageIDImpl(msg, MsgType.Cmd, "Cmd");
                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildGetFunctionImpl(msg.Name, "Cmd", newparams);
                    BuildParserImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Cmd", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "Cmd", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "Cmd", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "Cmd", msg.Trace.ToString(), newparams);

                    BuildMessageIDImpl(msg, MsgType.Res, "Res");
                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildGetFunctionImpl(msg.Name, "Res", newparams);
                    BuildParserImpl(msg.Name, "Res", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "Res", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "Res", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Res", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "Res", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "Res", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "Res", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "Res", msg.Trace.ToString(), newparams);
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    BuildMessageIDImpl(msg, MsgType.Evt, "C2SEvt");
                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildGetFunctionImpl(msg.Name, "C2SEvt", newparams);
                    BuildParserImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "C2SEvt", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "C2SEvt", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "C2SEvt", msg.Trace.ToString(), newparams);
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    BuildMessageIDImpl(msg, MsgType.Evt, "S2CEvt");
                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildGetFunctionImpl(msg.Name, "S2CEvt", newparams);
                    BuildParserImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildParserToVariableBuilderImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildParserToMessageBaseImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildCreateImpl(msg.Name, "S2CEvt", newparams, bUseOriginalType: true); NewLine();
                    //BuildOverrideRouteContextImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    //BuildOverrideRouteHopCountImpl(msg.Name, "S2CEvt", newparams); NewLine();
                    BuildMessageTrace(msg.Name, "S2CEvt", msg.Trace.ToString(), newparams);
                }
                m_MessageCodeIndex++;
            }
        }
Exemplo n.º 10
0
        void BuildMessageAdapterClassCSharp()
        {
            // Packer interface
            Parameter[] newparams;

            OpenSection("public class", String.Format("SendMessage{0} : SendMessage", Group.Name));

            BuildClassMember();
            BuildConstructor("SendMessage" + Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunction(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunction(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }

            MatchIndent(); OutStream.WriteLine("#region Native Interfaces ");
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Cmd, msg.Cmd);
                    BuildSendFunctionNativeInterface(msg, "Cmd", newparams);
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupC2SEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// C2S: " + baseMsg.Desc);
                    ProtocolsProtocolGroupC2SEvent msg = baseMsg as ProtocolsProtocolGroupC2SEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeInterface(msg, "C2SEvt", newparams); NewLine();
                    NewLine();
                }
            }
            MatchIndent(); OutStream.WriteLine("#endregion //Native Interfaces ");

            CloseSection();



            OpenSection("public class", String.Format("SendMessageSvr{0} : SendMessage", Group.Name));

            BuildClassMember();
            BuildConstructor("SendMessageSvr" + Group.Name);

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunction(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunction(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }

            MatchIndent(); OutStream.WriteLine("#region Native Interfaces ");

            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    newparams = MakeParameters(MsgType.Res, msg.Res);
                    BuildSendFunctionNativeInterface(msg, "Res", newparams); NewLine();
                    NewLine();
                }

                if (baseMsg is ProtocolsProtocolGroupS2CEvent)
                {
                    MatchIndent(); OutStream.WriteLine("// S2C: " + baseMsg.Desc);
                    ProtocolsProtocolGroupS2CEvent msg = baseMsg as ProtocolsProtocolGroupS2CEvent;

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildSendFunctionNativeInterface(msg, "S2CEvt", newparams); NewLine();
                    NewLine();
                }
            }
            MatchIndent(); OutStream.WriteLine("#endregion //Native Interfaces ");

            CloseSection();
        }