示例#1
0
        /// <summary>
        /// Creates a member entry for a member specified in the IDL. A SinTDType object of respective type is
        /// retrieved from the SinTD or created for map or array typed members. Registers the member to the
        /// struct's members under the name given in the IDL
        /// </summary>
        /// <param name="memberDefinition">IDL entry defining type and name of the member</param>
        /// <param name="createdStruct">Struct that is created during the currrent parsing process</param>
        internal void createSinTDTypeForMember(string memberDefinition, SinTDStruct createdStruct)
        {
            if (!memberDefinition.Contains(';'))
            {
                return;
            }

            // Removes semicolon and comments at the end of line
            memberDefinition = memberDefinition.Trim().Split(';')[0];

            // TODO:
            // Consider additional spaces that may occur after comma of map definitions
            string[] memberComponents;
            string   memberType;
            string   memberName;

            if (!(memberDefinition.Contains("array") || memberDefinition.Contains("map")))
            {
                memberComponents = memberDefinition.Split(' ');
                memberType       = memberComponents[0];
                memberName       = memberComponents[1];
            }
            else
            {
                memberDefinition = Regex.Replace(memberDefinition, @"\s+", "");
                int closingBracket = memberDefinition.IndexOf('>') + 1;
                memberType = memberDefinition.Substring(0, closingBracket);
                memberName = memberDefinition.Substring(closingBracket, memberDefinition.Length - closingBracket);
            }

            SinTDType typeObject = getTypeForMember(memberType);

            createdStruct.members.Add(memberName, typeObject);
        }
示例#2
0
        /// <summary>
        /// Creates a member entry for a member specified in the IDL. A SinTDType object of respective type is
        /// retrieved from the SinTD or created for map or array typed members. Registers the member to the
        /// struct's members under the name given in the IDL
        /// </summary>
        /// <param name="memberDefinition">IDL entry defining type and name of the member</param>
        /// <param name="createdStruct">Struct that is created during the currrent parsing process</param>
        internal void createSinTDTypeForMember(string memberDefinition, SinTDStruct createdStruct)
        {
            if (!memberDefinition.Contains(';'))
                return;

            // Removes semicolon and comments at the end of line
            memberDefinition = memberDefinition.Trim().Split(';')[0];

            // TODO:
            // Consider additional spaces that may occur after comma of map definitions
            string[] memberComponents;
            string memberType;
            string memberName;

            if (!(memberDefinition.Contains("array") || memberDefinition.Contains("map")))
            {
                memberComponents = memberDefinition.Split(' ');
                memberType = memberComponents[0];
                memberName = memberComponents[1];
            }
            else
            {
                memberDefinition = Regex.Replace(memberDefinition, @"\s+", "");
                int closingBracket = memberDefinition.IndexOf('>') + 1;
                memberType = memberDefinition.Substring(0, closingBracket);
                memberName = memberDefinition.Substring(closingBracket, memberDefinition.Length - closingBracket);
            }

            SinTDType typeObject = getTypeForMember(memberType);

            createdStruct.members.Add(memberName, typeObject);
        }
示例#3
0
        /// <summary>
        /// When IDL parser parses a line initiating a struct definition, struct parser creates a new struct object
        /// with the name given in the IDL. Member definitions parsed afterwards are added to this struct until
        /// parsing the struct has finished
        /// </summary>
        /// <param name="structDefinition">Line from IDL defining name of the struct</param>
        internal void startStructParsing(string structDefinition)
        {
            Regex  nameRegEx = new Regex("struct ([A-Za-z0-9_]*) [{}._<,>; ]*");
            Match  nameMatch = nameRegEx.Match(structDefinition);
            string name      = nameMatch.Groups[1].Value;

            currentlyParsedStruct = new SinTDStruct(name);
        }
示例#4
0
 /// <summary>
 /// When IDL parser parses a line initiating a struct definition, struct parser creates a new struct object
 /// with the name given in the IDL. Member definitions parsed afterwards are added to this struct until
 /// parsing the struct has finished
 /// </summary>
 /// <param name="structDefinition">Line from IDL defining name of the struct</param>
 internal void startStructParsing(string structDefinition)
 {
     Regex nameRegEx = new Regex("struct ([A-Za-z0-9_]*) [{}._<,>; ]*");
     Match nameMatch = nameRegEx.Match(structDefinition);
     string name = nameMatch.Groups[1].Value;
     currentlyParsedStruct = new SinTDStruct(name);
 }
示例#5
0
        public void TestSetUp()
        {
            i32 = SinTDInstance.GetSinTDType("i32");
            SinTDString = SinTDInstance.GetSinTDType("string");
            SinTDBool = SinTDInstance.GetSinTDType("boolean");

            intStruct = new SinTDStruct("intStruct");
            intStruct.members["x"] = i32;
            intStruct.members["y"] = i32;

            aStruct = new SinTDStruct("arrayStruct");
            aStruct.members.Add("arr", new SinTDArray(i32));
            SinTDInstance.RegisterType(aStruct);

            mStruct = new SinTDStruct("mapStruct");
            mStruct.members.Add("map", new SinTDMap(SinTDString, SinTDBool));
            SinTDInstance.RegisterType(mStruct);

            sStruct = new SinTDStruct("structStruct");
            sStruct.members.Add("child", intStruct);
            SinTDInstance.RegisterType(sStruct);

            SinTDInstance = new SinTD();
        }
示例#6
0
        public void Setup()
        {
            SinTDInstance = new SinTD();
            SinTDInstance.SINFONIServices = new ServiceRegistry();

            i32 = SinTDInstance.GetSinTDType("i32");
            SinTD_string = SinTDInstance.GetSinTDType("string");

            intStruct = new SinTDStruct("intStruct");
            intStruct.members["x"] = i32;
            intStruct.members["y"] = i32;

            serviceFunction = new ServiceFunctionDescription("function", new SinTDType("void"));
            serviceFunction.Parameters.Add("intParameter", i32);
            serviceFunction.Parameters.Add("stringParameter", SinTD_string);

            service = new SINFONIService("service");
            service.serviceFunctions.Add("function", serviceFunction);

            SinTDInstance.SINFONIServices.services.Add("service", service);
            connection = new TestConnection();
            connection.SinTD = SinTDInstance;
        }