Ejemplo n.º 1
0
        } // end of GenerateCode()

        /// <summary>
        /// Writes code for all 'set' function and various other function (largest coordinate, coordinate extraction, etc)
        /// </summary>
        /// <param name="S"></param>
        /// <param name="plugins"></param>
        /// <param name="cgd"></param>
        protected void GenerateSetFunctions(Specification S, List <CodeGeneratorPlugin> plugins, CG.Shared.CGdata cgd)
        {
            const int NB_SET_CODE = 4;

            // get a temporary cgd for each type of parts code
            CG.Shared.CGdata[] tmpCgd = new G25.CG.Shared.CGdata[]
            { new G25.CG.Shared.CGdata(cgd),
              new G25.CG.Shared.CGdata(cgd),
              new G25.CG.Shared.CGdata(cgd),
              new G25.CG.Shared.CGdata(cgd) };

            // get parts code generators
            G25.CG.CPP.GMV p1 = new G25.CG.CPP.GMV(S, tmpCgd[0]); // [0] = GMV
            G25.CG.CPP.SMV p2 = new G25.CG.CPP.SMV(S, tmpCgd[1]); // [1] = SMV
            G25.CG.CPP.GOM p3 = new G25.CG.CPP.GOM(S, tmpCgd[2]); // [2] = GOM
            G25.CG.CPP.SOM p4 = new G25.CG.CPP.SOM(S, tmpCgd[3]); // [3] = SOM

            // run threads
            System.Threading.Thread[] T = new System.Threading.Thread[NB_SET_CODE];
            T[0] = new Thread(p1.WriteSetFunctions);
            T[1] = new Thread(p2.WriteSetFunctions);
            T[2] = new Thread(p3.WriteSetFunctions);
            T[3] = new Thread(p4.WriteSetFunctions);
            G25.CG.Shared.Threads.StartThreadArray(T);
            G25.CG.Shared.Threads.JoinThreadArray(T);

            // merge declarations and definitions
            for (int i = 0; i < NB_SET_CODE; i++)
            {
                cgd.m_declSB.Append(tmpCgd[i].m_declSB);
                cgd.m_defSB.Append(tmpCgd[i].m_defSB);
                cgd.m_inlineDefSB.Append(tmpCgd[i].m_inlineDefSB);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes code for all 'set' function and various other function (largest coordinate, coordinate extraction, etc)
        /// </summary>
        /// <param name="S"></param>
        /// <param name="plugins"></param>
        /// <param name="cgd"></param>
        protected void GenerateSetFunctions(Specification S, List<CodeGeneratorPlugin> plugins, CG.Shared.CGdata cgd)
        {
            const int NB_SET_CODE = 4;

            // get a temporary cgd for each type of parts code
            CG.Shared.CGdata[] tmpCgd = new G25.CG.Shared.CGdata[]
                {new G25.CG.Shared.CGdata(cgd),
                    new G25.CG.Shared.CGdata(cgd),
                    new G25.CG.Shared.CGdata(cgd),
                    new G25.CG.Shared.CGdata(cgd)
                };

            // get parts code generators
            G25.CG.CPP.GMV p1 = new G25.CG.CPP.GMV(S, tmpCgd[0]); // [0] = GMV
            G25.CG.CPP.SMV p2 = new G25.CG.CPP.SMV(S, tmpCgd[1]); // [1] = SMV
            G25.CG.CPP.GOM p3 = new G25.CG.CPP.GOM(S, tmpCgd[2]); // [2] = GOM
            G25.CG.CPP.SOM p4 = new G25.CG.CPP.SOM(S, tmpCgd[3]); // [3] = SOM

            // run threads
            System.Threading.Thread[] T = new System.Threading.Thread[NB_SET_CODE];
            T[0] = new Thread(p1.WriteSetFunctions);
            T[1] = new Thread(p2.WriteSetFunctions);
            T[2] = new Thread(p3.WriteSetFunctions);
            T[3] = new Thread(p4.WriteSetFunctions);
            G25.CG.Shared.Threads.StartThreadArray(T);
            G25.CG.Shared.Threads.JoinThreadArray(T);

            // merge declarations and definitions
            for (int i = 0; i < NB_SET_CODE; i++)
            {
                cgd.m_declSB.Append(tmpCgd[i].m_declSB);
                cgd.m_defSB.Append(tmpCgd[i].m_defSB);
                cgd.m_inlineDefSB.Append(tmpCgd[i].m_inlineDefSB);
            }
        }