34 using System.Collections.Generic;
45 private readonly List<IRestriction> restrictions =
new List<IRestriction>();
47 private bool useExternalMethods =
false;
48 private string externalGetMethod;
49 private string externalTestMethod;
50 private string externalSetMethod;
60 get {
return this.
Name +
"_scalar"; }
65 get {
return this.dataType; }
66 set { this.dataType = value; }
71 get {
return this.restrictions; }
76 get {
return this.accessMode; }
77 set { this.accessMode = value; }
95 get {
return this.useExternalMethods; }
96 set { this.useExternalMethods = value; }
101 get {
return this.externalGetMethod; }
102 set { this.externalGetMethod = value; }
106 get {
return this.externalTestMethod; }
107 set { this.externalTestMethod = value; }
111 get {
return this.externalSetMethod; }
112 set { this.externalSetMethod = value; }
117 string getMethodName;
118 string testMethodName;
119 string setMethodName;
121 if (this.useExternalMethods)
123 getMethodName = this.externalGetMethod;
124 testMethodName = this.externalTestMethod;
125 setMethodName = this.externalSetMethod;
129 getMethodName = LwipDefs.Null;
130 testMethodName = LwipDefs.Null;
131 setMethodName = LwipDefs.Null;
142 getMethodName = getMethod.
Name;
145 returnValue.
Type.
Name =
"value_len";
149 bool valueVarUsed =
false;
167 if (this.restrictions.Count > 0)
177 testMethodName = testMethod.
Name;
184 valueVarUsed =
false;
205 testMethodName = LwipDefs.FnctName_SetTest_Ok;
217 setMethodName = setMethod.
Name;
224 valueVarUsed =
false;
245 string nodeInitialization;
248 nodeInitialization = String.Format(
"SNMP_SCALAR_CREATE_NODE_READONLY({0}, {1}, {2})",
250 LwipDefs.GetAsn1DefForSnmpDataType(
this.dataType),
255 nodeInitialization = String.Format(
"SNMP_SCALAR_CREATE_NODE({0}, {1}, {2}, {3}, {4}, {5})",
257 LwipDefs.GetLwipDefForSnmpAccessMode(
this.accessMode),
258 LwipDefs.GetAsn1DefForSnmpDataType(this.dataType),
266 nodeInitialization, isStatic:
true));
271 bool localValueVarUsed;
275 localValueVarUsed =
false;
279 localValueVarUsed =
true;
285 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));
289 if (!localValueVarUsed)
291 container.
AddCode(String.Format(
"LWIP_UNUSED_ARG({0});", LocalValueName));
297 container.
AddElement(
new Comment(String.Format(
"TODO: put requested value to '*{0}' here", localValueVarName), singleLine:
true));
300 (!String.IsNullOrWhiteSpace(
this.FixedValueLength)) ? this.
FixedValueLength :
"0");
311 localVarUsed =
false;
318 if (!String.IsNullOrWhiteSpace(
this.FixedValueLength))
329 container.
AddCode(String.Format(
"LWIP_UNUSED_ARG({0});", LocalValueName));
334 container.
AddCodeFormat(
"{0} == {1};", retErrVarName, LwipDefs.Def_ErrorCode_Ok);
340 container.
AddElement(
new Comment(String.Format(
"TODO: test new value here:\nif (*{0} == ) {1} = {2};", localValueVarName, retErrVarName, LwipDefs.Def_ErrorCode_Ok)));
349 localVarUsed =
false;
360 container.
AddCode(String.Format(
"LWIP_UNUSED_ARG({0});", LocalValueName));
366 container.
AddElement(
new Comment(String.Format(
"TODO: store new value contained in '*{0}' here", localValueVarName), singleLine:
true));
374 "(" +
new VariableType(null, LwipDefs.Vt_U8,
"*") +
")" + sourceName));
virtual void GenerateTestMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
List< IRestriction > Restrictions
Code AddCodeFormat(string codeFormat, params object[] args)
virtual int OidRepresentationLen
If scalar is used as a table index its value becomes part of the OID. This value returns how many OID...
CodeElement AddDeclaration(CodeElement declaration)
static Function FromDeclaration(FunctionDeclaration decl)
virtual void GenerateSetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
Code AddCode(string code)
virtual bool GenerateValueDeclaration(CodeContainerBase container, string variableName, string sourceName)
const string LocalValueName
string ExternalTestMethod
static SnmpScalarNode CreateFromDatatype(SnmpDataType dataType, SnmpTreeNode parentNode)
List< CodeElement > Implementation
override string FullNodeName
List< CodeElement > Declarations
SnmpAccessMode AccessMode
override void GenerateCode(MibCFile mibFile)
virtual string FixedValueLength
virtual void GenerateGetMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string retLenVarName)
List< VariableType > Parameter
virtual void GenerateTestMethodCode(CodeContainerBase container, string valueVarName, ref bool valueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)
SnmpScalarNode(SnmpTreeNode parentNode)
CodeElement AddElement(CodeElement element)
List< CodeElement > Declarations
virtual void GenerateGetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string retLenVarName)
List< VariableType > Parameter
virtual void GenerateSetMethodCodeCore(CodeContainerBase container, string localValueVarName, ref bool localValueVarUsed, string lenVarName, ref bool lenVarUsed, string retErrVarName)