void WriteStringSet()
 {
     foreach (var stringValue in StringSet)
     {
         OutStream.WriteLine("\"{0}\"", stringValue);
     }
 }
Example #2
0
        void BuildCPPPrefix()
        {
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// CopyRight (c) Kyungkun Ko");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Author : Generated");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Description : {0} Server service", Group.Name);
            OutStream.WriteLine("// ");
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("");
            OutStream.WriteLine("");
            OutStream.WriteLine("#include \"{0}\"", PreCompiledHeader);
            OutStream.WriteLine("#include \"SFTypedefs.h\"");
            OutStream.WriteLine("#include \"Protocol/SFProtocol.h\"");
            OutStream.WriteLine("#include \"Net/SFMessageEndpoint.h\"");
            OutStream.WriteLine("#include \"Server/BrServer.h\"");
            OutStream.WriteLine("#include \"Server/BrServerUtil.h\"");
            OutStream.WriteLine("#include \"Protocol/{0}\"", OutputHeaderName);
            OutStream.WriteLine("#include \"SvrTrace.h\"");

            NewLine(3);

            // namespace definition
            OpenSection("namespace", PrjPrefix);
        }
        // Build parser class implementation
        void BuildNetPolicyClassParserImpl(string Name, string typeName, Parameter[] parameters)
        {
            if ((typeName == "Cmd") || (typeName == "C2SEvt"))
            {
                OpenSection("Result", string.Format("{0}::{1}{2}( {3} )", PolicyClassName, Name, typeName, ParamInString(parameters)));
            }
            else
            {
                OpenSection("Result", string.Format("{0}::{1}{2}( {3} )", SvrPolicyClassName, Name, typeName, ParamInString(parameters)));
            }

            DefaultHRESULT(); NewLine();

            MatchIndent(); OutStream.WriteLine(" MessageDataPtr pMessage;");
            MatchIndent(); OutStream.WriteLine(" protocolCheckPtr(m_Endpoint);");
            NewLine();

            if (parameters != null && parameters.Length > 0)
            {
                MatchIndent(); OutStream.WriteLine(" pMessage = SF::Message::{0}::{1}{2}::Create(GetSystemHeap(), {3});", Group.Name, Name, typeName, ParamArgument(parameters));
            }
            else
            {
                MatchIndent(); OutStream.WriteLine(" pMessage = SF::Message::{0}::{1}{2}::Create(GetSystemHeap());", Group.Name, Name, typeName);
            }

            MatchIndent(); OutStream.WriteLine(" protocolCheckPtr(*pMessage);");
            NewLine();

            MatchIndent(); OutStream.WriteLine(" return m_Endpoint->Send( pMessage );");
            NewLine();

            CloseSection();
        }
        void BuildClientPolicyCPP()
        {
            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);
                    BuildNetPolicyClassParserImpl(msg.Name, "Cmd", newparams);
                }

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

                    newparams = MakeParameters(MsgType.Evt, msg.Params);
                    BuildNetPolicyClassParserImpl(msg.Name, "C2SEvt", newparams);
                }
            }
        }
Example #5
0
        //public virtual string SvrPolicyClassName { get { return "NetSvrPolicy" + Group.Name; } }


        protected virtual void BuildHPrefix()
        {
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// CopyRight (c) Kyungkun Ko");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Author : Generated");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Description : {0} Service definitions", Group.Name);
            OutStream.WriteLine("// ");
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("");
            OutStream.WriteLine("#pragma once");
            OutStream.WriteLine("");
            OutStream.WriteLine("#include \"SFTypedefs.h\"");
            OutStream.WriteLine("#include \"Protocol/SFProtocol.h\"");
            OutStream.WriteLine("#include \"ServerService/ServerServiceBase.h\"");

            OutStream.WriteLine("#include \"Net/SFNetDef.h\"");
            OutStream.WriteLine("#include \"Protocol/{0}\"", BasePolicyHeaderName);
            NewLine(3);

            // namespace definition
            OpenSection("namespace", "SF");
        }
        protected virtual void BuildHPrefix()
        {
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// CopyRight (c) The Braves");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Author : Generated");
            OutStream.WriteLine("// ");
            OutStream.WriteLine(string.Format("// Description : {0} Message debug definitions", Group.Name));
            OutStream.WriteLine("// ");
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("");
            OutStream.WriteLine("#pragma once");
            OutStream.WriteLine("");
            OutStream.WriteLine("#include \"SFTypedefs.h\"");
            OutStream.WriteLine("#include \"Protocol/SFProtocol.h\"");
            OutStream.WriteLine("#include \"Net/SFNetDef.h\"");
            NewLine(3);


            // namespace definition
            OpenSection("namespace", PrjPrefix);

            OutStream.WriteLine("   class MessageEndpoint;");
            OutStream.WriteLine("   class VariableTable;");
            OutStream.WriteLine("   struct ActorMovement;");

            foreach (var itForward in SF.SystemTypeInfo.CppTypeForwards)
            {
                OutStream.WriteLine("   {0}", itForward);
            }

            NewLine(2);
        }
Example #7
0
        // Build parser class implementation
        void BuildSendFunctionNativeImplementation(MessageBase baseMsg, string msgTypeName, Parameter[] parameters)
        {
            ParameterMode = TypeUsage.CPP;
            string createParamString = "pConnection->GetHeap()";

            if (parameters.Length > 0)
            {
                createParamString += CallCreateNativeParameterString(TypeUsage.CPPForSharp, "", parameters);
            }


            ParameterMode = TypeUsage.CPPForSharp;

            OpenSection("SFDLL_EXPORT int ",
                        string.Format("{0}( {1} )", NativeFuncName(baseMsg, msgTypeName), ParamInStringNative(parameters)),
                        false);

            MatchIndent(); OutStream.WriteLine("auto pConnection = NativeToObject<Net::Connection>(InNativeConnectionHandle);");
            MatchIndent(); OutStream.WriteLine("if(pConnection == nullptr) return ResultCode::INVALID_POINTER;");

            PrepareSendFunctionParametersCPP("", parameters);

            MatchIndent(); OutStream.WriteLine("MessageDataPtr pMessage = SF::Message::{0}::{1}{2}::Create({3});", Group.Name, baseMsg.Name, msgTypeName, createParamString);
            MatchIndent(); OutStream.WriteLine("if(pMessage == nullptr) return ResultCode::OUT_OF_MEMORY;");
            MatchIndent(); OutStream.WriteLine("auto res = pConnection->Send(pMessage);");
            MatchIndent(); OutStream.WriteLine("return (uint32_t)res;");

            CloseSection();

            NewLine();
        }
        void BuildCPPPrefix()
        {
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// CopyRight (c) The Braves");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Author : Generated");
            OutStream.WriteLine("// ");
            OutStream.WriteLine(string.Format("// Description : {0} Message debug implementations", Group.Name));
            OutStream.WriteLine("// ");
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("");
            OutStream.WriteLine("");
            OutStream.WriteLine(string.Format("#include \"{0}\"", PreCompiledHeader));
            OutStream.WriteLine("#include \"SFTypedefs.h\"");
            OutStream.WriteLine("#include \"Net/SFNetDef.h\"");
            OutStream.WriteLine("#include \"Net/SFMessage.h\"");
            OutStream.WriteLine("#include \"Net/SFMessageEndpoint.h\"");
            OutStream.WriteLine("#include \"Actor/Movement/SFActorMovement.h\"");
            OutStream.WriteLine(string.Format("#include \"Protocol/{0}\"", OutputHeaderName()));
            OutStream.WriteLine(string.Format("#include \"Protocol/{0}\"", MessageClassHeaderName));


            NewLine(3);

            // namespace definition
            OpenSection("namespace", PrjPrefix);
        }
Example #9
0
        // Build parser class implementation
        void BuildAccessPropertyNativeInterface(MessageBase baseMsg, string msgTypeName)
        {
            MatchIndent(); OutStream.WriteLine("[DllImport(NativeDLLName, EntryPoint = \"{0}\", CharSet = CharSet.Auto)]", NativeAccessPropertyName(baseMsg, msgTypeName));
            MatchIndent(); OutStream.WriteLine("static extern int {0}();", NativeAccessPropertyName(baseMsg, msgTypeName));

            NewLine();
        }
Example #10
0
        void BuildMessageIDAccessCPP()
        {
            // Packer interface
            foreach (MessageBase baseMsg in Group.Items)
            {
                if (baseMsg is ProtocolsProtocolGroupCommand)
                {
                    MatchIndent(); OutStream.WriteLine("// Cmd: " + baseMsg.Desc);
                    ProtocolsProtocolGroupCommand msg = baseMsg as ProtocolsProtocolGroupCommand;

                    BuildAccessPropertyNativeImplementation(msg, "Cmd"); NewLine();
                    BuildAccessPropertyNativeImplementation(msg, "Res"); NewLine();
                }

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

                    BuildAccessPropertyNativeImplementation(msg, "C2SEvt"); NewLine();
                }

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

                    BuildAccessPropertyNativeImplementation(msg, "S2CEvt"); NewLine();
                }
            }

            NewLine();
            NewLine();
        }
Example #11
0
        void BuildPrefix()
        {
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// CopyRight (c) 2016 Kyungkun Ko");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Author : Generated");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Description : {0} Message implementations", Group.Name);
            OutStream.WriteLine("// ");
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("");
            OutStream.WriteLine("");
            OutStream.WriteLine("using System;");
            OutStream.WriteLine("using System.Diagnostics;");
            OutStream.WriteLine("using SF;");
            OutStream.WriteLine("using SF.Message;");
            OutStream.WriteLine("using SF.Net;");
            OutStream.WriteLine("#if ANDROID");
            OutStream.WriteLine("using Preserve = Android.Runtime.PreserveAttribute;");
            OutStream.WriteLine("#elif IOS");
            OutStream.WriteLine("using Preserve = Foundation.PreserveAttribute;");
            OutStream.WriteLine("#else");
            OutStream.WriteLine("using Preserve = MonoGame.Framework.PreserveAttribute;");
            OutStream.WriteLine("#endif");

            NewLine(3);

            // namespace definition
            OpenSection("namespace", PrjPrefix + "." + BuilderNamespace, false);
            OpenSection("namespace", Group.Name, false);
        }
Example #12
0
        // Build parser class implementation
        void BuildBuilderImpl(Parameter[] parameters)
        {
            OpenSection("static public void ", string.Format("BuildMessageBuffer( BinaryMemoryWriter binaryWriter, ref MessageHeader header {0} {1} )", parameters.Length > 0 ? "," : "", ParamInString("", parameters)), false);

            MatchIndent(); OutStream.WriteLine("var binWriter = (PacketMemoryWriter)binaryWriter;");

            BuildParamSize(parameters, "__uiMessageSize");
            NewLine();

            MatchIndent(); OutStream.WriteLine("BRDebug.Assert((binWriter.Capacity - binWriter.Position) >= __uiMessageSize);");
            NewLine();
            MatchIndent(); OutStream.WriteLine("header.Length = (uint)__uiMessageSize;");
            //MatchIndent(); OutStream.WriteLine("header.Write(binWriter);");

            foreach (Parameter param in parameters)
            {
                if (param.IsArray)
                {
                    //MatchIndent(); OutStream.WriteLine("binWriter.Write((UInt16)In{0}.Length);", param.Name);
                }

                string refString = "";
                if (IsStruct(param))
                {
                    refString = "ref";
                }

                MatchIndent(); OutStream.WriteLine("binWriter.Write({0} In{1});", refString, param.Name);
            }

            NewLine();

            CloseSection();
        }
Example #13
0
 private void ProcessWeightsFile(string value)
 {
     if (taskSearchCurrentlyExecuting != null)
     {
         OutStream.WriteLine("Cannot change weights while search is running.");
     }
     else
     {
         if (value == null || value == "")
         {
             OutStream.WriteLine("Network file name expected");
         }
         else
         {
             if (EvaluatorDef != null && EvaluatorDef.Nets[0].Net.NetworkID.ToLower() == value.ToLower())
             {
                 OutStream.WriteLine($"Specified network file is already {value}");
             }
             else if (CeresEngine != null)
             {
                 OutStream.WriteLine("Implementation limitation: cannot modify weights file after initialization");
             }
             else
             {
                 NetworkSpec = new NNNetSpecificationString(value);
                 CreateEvaluator();
             }
         }
     }
 }
Example #14
0
        // Builder parameters size
        public void BuildParamSize(Parameter[] parameters, string strSizeVarName)
        {
            // size calculation
            MatchIndent();
            OutStream.Write(string.Format("int {0} = sizeof(UInt64)*2 ", strSizeVarName));

            if (parameters != null)
            {
                foreach (Parameter param in parameters)
                {
                    NewLine(); MatchIndent(1);
                    var typeInfo = SystemTypeInfo.GetParameterInfo(param);
                    if (typeInfo.IsString)
                    {
                        OutStream.Write("+ binWriter.StringEncoder.GetByteCount({0}) + 1 + 2", InParamName(param.Name));
                    }
                    else
                    {
                        if (param.IsArray)
                        {
                            OutStream.Write("+ Marshal.SizeOf({0})*({1}.Length) + sizeof(UInt16)", typeInfo.CSharpTypeName, InParamName(param.Name));
                        }
                        else
                        {
                            OutStream.Write("+ Marshal.SizeOf({0})", typeInfo.CSharpTypeName);
                        }
                    }
                }
            }

            OutStream.WriteLine(";");
        }
Example #15
0
        // Builder parameter string
        public void PrepareSendFunctionParametersCPP(string strPrefix, Parameter[] parameter)
        {
            TypeUsage from = TypeUsage.CPPForSharp;
            TypeUsage to   = ParameterMode;

            if (parameter == null)
            {
                return;
            }

            foreach (Parameter param in parameter)
            {
                string paramElementTypeName = SystemTypeInfo.ElementTypeNameFor(from, param);
                string paramTypeNameOnly    = SystemTypeInfo.TypeNameOnlyFor(from, param);
                string paramTypeFrom        = SystemTypeInfo.TypeNameFor(from, param);
                string paramTypeTo          = SystemTypeInfo.TypeNameFor(to, param);
                var    typeInfo             = SystemTypeInfo.GetParameterInfo(param);
                //Type scharpType = SystemTypeInfo.ToCSharpType(param.Type);
                bool paramTypeEquality = paramTypeFrom == paramTypeTo;

                //bool bIsStruct = IsStruct(param.Type);

                // Disable native conversion
                if (param.IsArray) // string type
                {
                    if (IsStrType(param))
                    {
                        string varName = string.Format("{0}{1}", strPrefix, InParamName(param.Name));
                        MatchIndent(); OutStream.WriteLine("auto& {0}Array_ = *NativeToObject<SF::ArrayObject<const char*>>({0});", varName);
                    }
                }
            }
        }
Example #16
0
        void BuildCPPPrefix(string HeaderName)
        {
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// CopyRight (c) StormForge");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Author : Generated");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Description : {0} Message parser implementations", Group.Name);
            OutStream.WriteLine("// ");
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("");
            OutStream.WriteLine("");
            OutStream.WriteLine("#include \"{0}\"", PreCompiledHeader);
            OutStream.WriteLine("#include \"Protocol/SFProtocol.h\"");
            OutStream.WriteLine("#include \"Util/SFToString.h\"");
            OutStream.WriteLine("#include \"Net/SFNetToString.h\"");
            OutStream.WriteLine("#include \"Container/SFArray.h\"");
            OutStream.WriteLine("#include \"Protocol/SFProtocolHelper.h\"");
            OutStream.WriteLine("#include \"Protocol/{0}\"", HeaderName);

            NewLine(3);

            // namespace definition
            OpenSection("namespace", PrjPrefix);
            OpenSection("namespace", BuilderNamespace);
            OpenSection("namespace", Group.Name);
        }
        void BuildCPPPrefix()
        {
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// CopyRight (c) 2017 Kyungkun Ko");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Author : Generated");
            OutStream.WriteLine("// ");
            OutStream.WriteLine("// Description : {0} Message parsing implementations", Group.Name);
            OutStream.WriteLine("// ");
            OutStream.WriteLine("////////////////////////////////////////////////////////////////////////////////");
            OutStream.WriteLine("");
            OutStream.WriteLine("");
            OutStream.WriteLine("#include \"{0}\"", PreCompiledHeader);
            OutStream.WriteLine("#include \"SFTypedefs.h\"");
            OutStream.WriteLine("#include \"Protocol/SFProtocol.h\"");
            OutStream.WriteLine("#include \"Net/SFNetDef.h\"");
            OutStream.WriteLine("#include \"Protocol/{0}\"", OutputHeaderName());
            OutStream.WriteLine("#include \"Protocol/{0}MsgClass.h\"", Group.Name);
            NewLine(3);

            // namespace definition
            OpenSection("namespace", PrjPrefix);
            OpenSection("namespace", "Protocol");
        }
Example #18
0
        // Build parser class implementation
        void BuildBuilderSelfImpl(Parameter[] parameters)
        {
            OpenSection("public override void", "BuildMessageBuffer(BinaryMemoryWriter binWriter)", false);

            MatchIndent(); OutStream.WriteLine("BuildMessageBuffer( binWriter, ref Header {0} {1} );", parameters.Length > 0 ? "," : "", ParamMemberString(parameters));

            CloseSection();
        }
 void BuildIMessageDebugH()
 {
     NewLine();
     MatchIndent(); OutStream.WriteLine("///////////////////////////////////////////////////////////////");
     MatchIndent(); OutStream.WriteLine("// {0} parsing register function ", Group.Name);
     NewLine();
     MatchIndent(); OutStream.WriteLine("void RegisterParser{0}();", Group.Name);
     NewLine();
 }
Example #20
0
 void BuildIMessageDebugH()
 {
     NewLine();
     MatchIndent(); OutStream.WriteLine("///////////////////////////////////////////////////////////////");
     MatchIndent(); OutStream.WriteLine("// {0} Debug output function ", Group.Name);
     NewLine();
     MatchIndent(); OutStream.WriteLine("void RegisterDebugTrace{0}();", Group.Name);
     NewLine();
 }
Example #21
0
        // Source timestamp file for make file
        void BuildTimeStamp()
        {
            // write parser class cpp
            OpenOutFile("Protocol" + Group.Name + ".h");

            OutStream.WriteLine("Build:" + DateTime.Now);

            CloseOutFile();
        }
Example #22
0
        public void PrepareCallNative(Parameter[] parameter)
        {
            string strPrefix = "";

            if (parameter == null)
            {
                return;
            }


            // 1. Prepare local variables;
            foreach (Parameter param in parameter)
            {
                var typeInfo = SystemTypeInfo.GetParameterInfo(param);
                //Type csharpType = SystemTypeInfo.ToCSharpType(param.Type);

                bool IsArray = param.IsArray | typeInfo.IsCSharpArray;

                if (IsArray) // array
                {
                    // Nothing for now
                }
                else if (IsStrType(param)) // string type
                {
                    // Nothing for now
                }
                else if (IsVariableSizeType(param))
                {
                    MatchIndent(); OutStream.WriteLine("var {0}{1}_ = {0}{1}.ToByteArray();", strPrefix, InParamName(param.Name));
                }
            }

            //2. Prepare pinned variables or something with using statement
            foreach (Parameter param in parameter)
            {
                var typeInfo = SystemTypeInfo.GetParameterInfo(param);
                //Type csharpType = SystemTypeInfo.ToCSharpType(param.Type);

                bool IsArray = param.IsArray | typeInfo.IsCSharpArray;

                if (IsArray)              // array
                {
                    if (IsStrType(param)) // string type
                    {
                        MatchIndent(); OutStream.WriteLine("using (var {0}{1}Array = new ArrayObjectString({0}{1}))", strPrefix, InParamName(param.Name));
                    }
                }
                else if (IsStrType(param)) // string type
                {
                    // Nothing for now
                }
                else if (IsVariableSizeType(param))
                {
                    MatchIndent(); OutStream.WriteLine("using (var {0}{1}_PinnedPtr_ = new PinnedByteBuffer({0}{1}_))", strPrefix, InParamName(param.Name));
                }
            }
        }
Example #23
0
 // Build parser class implementation
 void BuildSendFunctionNativeInterface(MessageBase baseMsg, string msgTypeName, Parameter[] parameters)
 {
     IsCSharpNative = true;
     ParameterMode  = TypeUsage.CSharpNative;
     MatchIndent(); OutStream.WriteLine("[DllImport(NativeDLLName, EntryPoint = \"{0}\", CharSet = CharSet.Ansi)]", NativeFuncName(baseMsg, msgTypeName));
     //MatchIndent(); OutStream.WriteLine("[return: MarshalAs(UnmanagedType.I1)]");
     MatchIndent(); OutStream.WriteLine("static extern int {0}({1} );", NativeFuncName(baseMsg, msgTypeName), ParamInStringNative(parameters));
     IsCSharpNative = false;
     NewLine();
 }
Example #24
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();
                }
            }
        }
Example #25
0
        void BuildMsgMap(MsgType type, string typeString, string Name, Parameter[] inparam)
        {
            Parameter[] newparams;

            newparams = MakeParameters(type, inparam);
            string strMsgClass = string.Format("{0}::{1}", Group.Name, MsgClassName(Name, typeString));
            string strKey      = string.Format("Message::{0}::MID.IDSeq.MsgID", strMsgClass);
            string strFunction = string.Format("Message::{0}::TraceOut", strMsgClass);

            MatchIndent(); OutStream.WriteLine("{0}.insert(std::make_pair({1},&{2}));", MappingTableName(), strKey, strFunction);
        }
Example #26
0
        // Build parser class implementation
        void BuildAccessPropertyNativeImplementation(MessageBase baseMsg, string msgTypeName)
        {
            OpenSection("SFDLL_EXPORT int ",
                        string.Format("{0}()", NativeAccessPropertyName(baseMsg, msgTypeName)),
                        false);

            MatchIndent(); OutStream.WriteLine("return {0};", NativeMessagIDName(baseMsg, msgTypeName));

            CloseSection();

            NewLine();
        }
Example #27
0
 void BuildClassMember()
 {
     NewLine();
     MatchIndent(); OutStream.WriteLine("const string NativeDLLName = ");
     MatchIndent(); OutStream.WriteLine("#if UNITY_IOS");
     MatchIndent(); OutStream.WriteLine("    \"__Internal\";");
     MatchIndent(); OutStream.WriteLine("#else");
     MatchIndent(); OutStream.WriteLine("    \"{0}\";", DLL_NAME);
     MatchIndent(); OutStream.WriteLine("#endif");
     //MatchIndent(); OutStream.WriteLine("SF.SFConnection m_Connection;");
     //MatchIndent(); OutStream.WriteLine("public SF.SFConnection Connection { get { return m_Connection; } }");
     NewLine();
 }
Example #28
0
        public void Run()
        {
            OutStream.WriteLine("Initializing Anima");
            plugMan.LoadAndRunPlugins();
            OutStream.WriteLine("Plugin manager complete");
            string input;

            do
            {
                input = InStream.ReadLine();
            } while (input != "quit");
            plugMan.ClosePlugins();
        }
Example #29
0
        // Message trace
        void BuildMessageTrace(string Name, string typeName, string traceChannel, Parameter[] parameters)
        {
            OpenSection("public override void", "TraceOut(string Prefix)", false);

            string strTrace       = "\"{{0}}:" + Name + typeName + ": ";
            string strTraceMember = "Prefix";
            int    ParamCount     = 1;

            if (parameters != null)
            {
                foreach (Parameter param in parameters)
                {
                    switch (param.TypeName)
                    {
                    case "String":
                    {
                        strTrace       += string.Format(", {0}:{{{1}}}", param.Name, ParamCount++);
                        strTraceMember += string.Format(", {0}", param.Name);
                    } break;

                    default:
                        if (param.IsArray)
                        {
                            strTrace       += string.Format(", {0}:{{{1}}}", param.Name, ParamCount++);
                            strTraceMember += string.Format(", {0}.ToString()", param.Name);
                        }
                        else
                        {
                            if (param.TypeName == "Result")
                            {
                                strTrace       += string.Format(", {0}:{{{1}}}", param.Name, ParamCount++);
                                strTraceMember += string.Format(", {0}.ToString()", param.Name);
                            }
                            else
                            {
                                strTrace       += string.Format(", {0}:{{{1}}}", param.Name, ParamCount++);
                                strTraceMember += string.Format(", {0}.ToString()", param.Name);
                            }
                        }
                        break;
                    }
                }
            }

            MatchIndent(); OutStream.WriteLine("Debug.Print({0},", strTrace + "\"");
            MatchIndent(7); OutStream.WriteLine("\t{0}); ", strTraceMember);

            CloseSection();

            NewLine();
        }
Example #30
0
        void BuildCPP()
        {
            OpenOutFile(OutputCPPName());

            BuildCPPPrefix();

            MatchIndent(); OutStream.WriteLine("///////////////////////////////////////////////////////////////");
            MatchIndent(); OutStream.WriteLine("// {0} Debug trace mapping", Group.Name);
            BuildMsgMapImpl();

            NewLine(2);

            CloseOutFile();
        }