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); }
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); } }