Exemplo n.º 1
0
        internal void PrintH(StreamWriterLevel h, string uniqueID)
        {
            ////print type declaration
            //h.WriteLine("/*");
            //h.WriteLine("Definition of :{0}", m_name);
            //foreach(string line in m_comments)
            //    h.WriteLine("{0}", line);
            //h.WriteLine("*/");

            h.WriteComment(m_comments, 0);

            h.Write("typedef ");
            ((ISCCType)m_type).PrintHTypeDeclaration(m_type.PEREffectiveConstraint, h, uniqueID, "", 0);
            if (!(m_type is IA5StringType))
                h.WriteLine(" {0};", uniqueID);
            h.WriteLine();

            //print
            h.WriteLine("#define {0}_REQUIRED_BYTES_FOR_ENCODING		{1}", uniqueID, m_type.MaxBytesInPER);
            h.WriteLine();
            ((ISCCType)m_type).PrintHConstraintConstant(h, uniqueID);
            h.WriteLine();
            string star = "";
            if (!(m_type is IA5StringType))
                star = "*";
            h.WriteLine("void {0}_Initialize({0}{1} pVal);", uniqueID, star);
            h.WriteLine("flag {0}_IsConstraintValid(const {0}{1} val, int* pErrCode);", uniqueID, star);
            h.WriteLine("flag {0}_Encode(const {0}{1} val, BitStream* pBitStrm, int* pErrCode, flag bCheckConstraints);", uniqueID, star);
            h.WriteLine("flag {0}_Decode({0}{1} pVal, BitStream* pBitStrm, int* pErrCode);", uniqueID, star);
            h.WriteLine();
            h.WriteLine();
        }
Exemplo n.º 2
0
        public static void PrintHTypeDeclaration(SequenceOrSetType pThis, PEREffectiveConstraint cns, StreamWriterLevel h, string typeName, string varName, int lev)
        {
            h.WriteLine("struct {");
            //            h.WriteLine("struct {0} {{", typeName);
            foreach (SequenceOrSetType.Child ch in pThis.m_children.Values)
            {
                h.WriteComment(ch.m_comments, lev + 1);
                h.P(lev + 1);
                ((ISCCType)ch.m_type).PrintHTypeDeclaration(ch.m_type.PEREffectiveConstraint, h,
                    typeName + "_" + C.ID(ch.m_childVarName), C.ID(ch.m_childVarName), lev + 1);
                if (!(ch.m_type is IA5StringType))
                    h.WriteLine(" {0};", C.ID(ch.m_childVarName));
            }
            if (pThis.GetNumberOfOptionalOrDefaultFields() != 0)
            {
                h.P(lev + 1);
                h.WriteLine("struct {");
                foreach (SequenceOrSetType.Child ch in pThis.m_children.Values)
                {
                    if (ch.m_optional || ch.m_defaultValue != null)
                    {
                        h.P(lev + 2);
                        h.WriteLine("unsigned int {0}:1;", C.ID(ch.m_childVarName));
                    }
                }
                h.P(lev + 1);
                h.WriteLine("} exist;");

            }
            h.P(lev);
            h.Write("}");
        }
Exemplo n.º 3
0
        public void PrintHTypeDeclaration(PEREffectiveConstraint cns, StreamWriterLevel h, string typeName, string varName, int lev)
        {
            //            h.WriteLine("struct {0} {{", typeName);
            h.WriteLine("struct {");
            h.P(lev + 1);
            h.WriteLine("enum {");
            //            h.WriteLine("enum {0}_PR {{", typeName);
            h.P(lev + 2);
            h.WriteLine("{0},	/* No components present */", CID_NONE);
            //            h.WriteLine("{0}_NONE,	/* No components present */", typeName);
            int i = 0;
            foreach (ChoiceChild ch in m_children.Values)
            {
                h.P(lev + 2);
                //                h.Write("{0}_{1}", typeName, ch.m_childVarName);
                h.Write("{0}", ch.CID);
                if (i < m_children.Values.Count - 1)
                    h.WriteLine(",");
                else
                    h.WriteLine();
                i++;
            }
            h.P(lev + 1);
            h.WriteLine("} kind;");

            h.P(lev + 1);
            h.WriteLine("union {");
            //            h.WriteLine("union {0}_data {{", typeName);
            foreach (ChoiceChild ch in m_children.Values)
            {
                h.WriteComment(ch.m_comments, lev + 2);

                h.P(lev + 2);
                ((ISCCType)ch.m_type).PrintHTypeDeclaration(ch.m_type.PEREffectiveConstraint, h,
                    typeName + "_" + C.ID(ch.m_childVarName),
                    C.ID(ch.m_childVarName), lev + 1);
                if (!(ch.m_type is IA5StringType))
                    h.WriteLine(" {0};", C.ID(ch.m_childVarName));
            }
            h.P(lev + 1);
            h.WriteLine("} u;");

            h.P(lev);
            h.Write("}");
        }