Пример #1
0
		protected override bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
		{
			container.AddDeclaration(new VariableDeclaration(
				new VariableType(variableName, LwipDefs.Vt_S32, "*"),
				"(" + new VariableType(null, LwipDefs.Vt_S32, "*") + ")" + sourceName));

			return true;
		}
Пример #2
0
		protected override void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
		{
			container.AddCodeFormat("snmp_encode_truthvalue({0}, /* TODO: put requested bool value here */ 0);", localValueVarName);
			localValueVarUsed = true;
			
			container.AddCode(String.Format("{0} = {1};",
				retLenVarName,
				(!String.IsNullOrWhiteSpace(this.FixedValueLength)) ? this.FixedValueLength : "0"));
		}
Пример #3
0
		protected override void GenerateSetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
		{
			VariableType truthVar = new VariableType("bool_value", LwipDefs.Vt_U8);
			container.Declarations.Add(new VariableDeclaration(truthVar));

			container.AddCodeFormat("snmp_decode_truthvalue({0}, &{1});", localValueVarName, truthVar.Name);
			localValueVarUsed = true;

			container.AddElement(new Comment(String.Format("TODO: store new value contained in '{0}' here", truthVar.Name), singleLine: true)); 
		}
Пример #4
0
		public override void GenerateGetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string retLenVarName)
		{
			container.AddCode(String.Format(
				"{0} = snmp_encode_bits(({1} *){2}, SNMP_MAX_VALUE_SIZE, 0 /* TODO: pass real value here */, {3});",
				retLenVarName, 
				LwipDefs.Vt_U8,
				valueVarName,
				this.bitCount));
			
			valueVarUsed = true;
		}
		protected override void GenerateSetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
		{
			VariableDeclaration objIdLenVar = new VariableDeclaration(
				new VariableType(localValueVarName + "_len", LwipDefs.Vt_U8),
				String.Format("{0} / sizeof({1})", lenVarName, LwipDefs.Vt_U32));
			lenVarUsed = true;

			container.Declarations.Add(objIdLenVar);

			base.GenerateSetMethodCodeCore(container, localValueVarName, ref localValueVarUsed, lenVarName, ref lenVarUsed, retErrVarName);

			container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", objIdLenVar.Type.Name));
		}
Пример #6
0
		protected override bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
		{
			container.AddDeclaration(new VariableDeclaration(
				new VariableType(variableName + "_high", LwipDefs.Vt_U32, "*"),
				"(" + new VariableType(null, LwipDefs.Vt_U32, "*").ToString() + ")" + sourceName));
			container.AddDeclaration(new VariableDeclaration(
				new VariableType(variableName + "_low", LwipDefs.Vt_U32, "*"),
				variableName + "_high + 1"));

			container.AddCode(String.Format("LWIP_UNUSED_ARG({0}_high);", variableName));
			container.AddCode(String.Format("LWIP_UNUSED_ARG({0}_low);", variableName));

			return false;
		}
Пример #7
0
		protected override void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
		{
			if (this.Restrictions.Count > 0)
			{
				StringBuilder ifCond = new StringBuilder();
				foreach (IRestriction restriction in this.Restrictions)
				{
					ifCond.Append(restriction.GetCheckCodeValid(retLenVarName));
					ifCond.Append(" || ");
				}

				ifCond.Length -= 4;
				container.AddElement(new Comment("TODO: take care of len restrictions defined in MIB: " + ifCond, singleLine: true));
			}
			base.GenerateGetMethodCodeCore(container, localValueVarName, ref localValueVarUsed, retLenVarName);
		}
Пример #8
0
		protected override void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
		{
			System.Diagnostics.Trace.Assert(this.Restrictions.Count > 0);

			StringBuilder ifCond = new StringBuilder();
			foreach (IRestriction restriction in this.Restrictions)
			{
				ifCond.Append(restriction.GetCheckCodeValid("*" + localValueVarName));
				ifCond.Append(" || ");

				localValueVarUsed = true;
			}

			ifCond.Length -= 4;

			IfThenElse ite = new IfThenElse(ifCond.ToString());
			ite.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
			container.AddElement(ite);
		}
Пример #9
0
		public override void GenerateTestMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
		{
			if (this.Restrictions.Count > 0)
			{
				const string bitVarName = "bits";

				container.Declarations.Add(new VariableDeclaration(new VariableType(bitVarName, LwipDefs.Vt_U32)));

				IfThenElse ite = new IfThenElse(String.Format(
					"snmp_decode_bits(({0} *){1}, {2}, &{3}) == ERR_OK",
					LwipDefs.Vt_U8,
					valueVarName,
					lenVarName,
					bitVarName));

				valueVarUsed = true;
				lenVarUsed = true;

				StringBuilder innerIfCond = new StringBuilder();
				foreach (IRestriction restriction in this.Restrictions)
				{
					innerIfCond.Append(restriction.GetCheckCodeValid(bitVarName));
					innerIfCond.Append(" || ");
				}

				innerIfCond.Length -= 4;

				IfThenElse innerIte = new IfThenElse(innerIfCond.ToString());
				innerIte.AddCode(String.Format("{0} = {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok));
				ite.AddElement(innerIte);
				container.AddElement(ite);
			}
			else
			{
				base.GenerateTestMethodCode(container, valueVarName, ref valueVarUsed, lenVarName, ref lenVarUsed, retErrVarName);
			}
		}
Пример #10
0
 protected virtual void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
 {
     container.AddElement(new Comment(String.Format("TODO: test new value here:\nif (*{0} == ) {1} = {2};", localValueVarName, retErrVarName, LwipDefs.Def_ErrorCode_Ok)));
 }
Пример #11
0
 protected virtual void GenerateSetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
 {
     container.AddElement(new Comment(String.Format("TODO: store new value contained in '*{0}' here", localValueVarName), singleLine: true));
 }
Пример #12
0
 protected virtual void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
 {
     container.AddElement(new Comment(String.Format("TODO: put requested value to '*{0}' here", localValueVarName), singleLine: true));
     container.AddCodeFormat("{0} = {1};",
         retLenVarName,
         (!String.IsNullOrWhiteSpace(this.FixedValueLength)) ? this.FixedValueLength : "0");
 }
Пример #13
0
        public virtual void GenerateTestMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
        {
            if (this.Restrictions.Count > 0)
            {
                bool localVarUsed;
                if (GenerateValueDeclaration(container, LocalValueName, valueVarName))
                {
                    valueVarUsed = true;
                    localVarUsed = false;
                }
                else
                {
                    localVarUsed = true;  // do not generate UNUSED_ARG code
                }

                if (!String.IsNullOrWhiteSpace(this.FixedValueLength))
                {
                    // check for fixed value
                    container.AddCodeFormat("LWIP_ASSERT(\"Invalid length for datatype\", ({0} == {1}));", lenVarName, this.FixedValueLength);
                    lenVarUsed = true;
                }

                GenerateTestMethodCodeCore(container, LocalValueName, ref localVarUsed, lenVarName, ref lenVarUsed, retErrVarName);

                if (!localVarUsed)
                {
                    container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", LocalValueName));
                }
            }
            else
            {
                container.AddCodeFormat("{0} == {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok);
            }
        }
Пример #14
0
        public virtual void GenerateSetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
        {
            bool localVarUsed;
            if (GenerateValueDeclaration(container, LocalValueName, valueVarName))
            {
                valueVarUsed = true;
                localVarUsed = false;
            }
            else
            {
                localVarUsed = true; // do not generate UNUSED_ARG code
            }

            GenerateSetMethodCodeCore(container, LocalValueName, ref localVarUsed, lenVarName, ref lenVarUsed, retErrVarName);

            if (!localVarUsed)
            {
                container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", LocalValueName));
            }
        }
Пример #15
0
        public virtual void GenerateGetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string retLenVarName)
        {
            bool localValueVarUsed;
            if (GenerateValueDeclaration(container, LocalValueName, valueVarName))
            {
                valueVarUsed = true;
                localValueVarUsed = false;
            }
            else
            {
                localValueVarUsed = true;  // do not generate UNUSED_ARG code
            }

            if (this.FixedValueLength == null)
            {
                // check that value with variable length fits into buffer
                container.AddElement(new Comment(String.Format("TODO: take care that value with variable length fits into buffer: ({0} <= SNMP_MAX_VALUE_SIZE)", retLenVarName), singleLine: true));
            }

            GenerateGetMethodCodeCore(container, LocalValueName, ref localValueVarUsed, retLenVarName);
            if (!localValueVarUsed)
            {
                container.AddCode(String.Format("LWIP_UNUSED_ARG({0});", LocalValueName));
            }
        }
Пример #16
0
		public override void GenerateSetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
		{
			const string bitVarName = "bits";

			container.Declarations.Add(new VariableDeclaration(new VariableType(bitVarName, LwipDefs.Vt_U32)));

			IfThenElse ite = new IfThenElse(String.Format(
				"snmp_decode_bits(({0} *){1}, {2}, &{3}) == ERR_OK",
				LwipDefs.Vt_U8,
				valueVarName,
				lenVarName,
				bitVarName));

			valueVarUsed = true;
			lenVarUsed = true;

			ite.AddElement(new Comment(String.Format("TODO: store new value contained in '{0}' here", bitVarName), singleLine: true));

			container.AddElement(ite);
		}
		protected override void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
		{
			container.AddElement(new Comment(String.Format("TODO: put requested value to '*{0}' here. '{0}' has to be interpreted as {1}[]", localValueVarName, LwipDefs.Vt_U32), singleLine: true));
			container.AddElement(EmptyLine.SingleLine);
			container.AddCode(String.Format("{0} = 0; // TODO: return real value length here (should be 'numOfElements * sizeof({1})')", retLenVarName, LwipDefs.Vt_U32));
		}