[AGENT++] [patch] AgenPro3 codegen with symbolic constants
Claus Klein
claus.klein at arcormail.de
Wed Sep 1 23:16:44 CEST 2010
=== modified file 'agenpro3/templates/agent++v3.5.23/cpp_code.vm'
--- agenpro3/templates/agent++v3.5.23/cpp_code.vm 2010-08-31 12:53:57
+0000
+++ agenpro3/templates/agent++v3.5.23/cpp_code.vm 2010-08-31 16:11:19
+0000
@@ -498,8 +498,8 @@
#end
vb.get_value(v);
if (#foreach ($enum in $syntax.enumsVector)
-#set($v = $enum.longValue)
-#if ($velocityCount > 1) && (v != $v$constSuffix)#else(v != $v
$constSuffix)#end
+#set($v = ${enum.getLabelWithoutHyphen()})
+#if ($velocityCount > 1) && (v != e_$v)#else(v != e_$v)#end
#if ($velocityCount % 2 == 1)
#end
@@ -804,7 +804,7 @@
#if ($s.syntax == "Counter64")
r->get_nth($n)->replace_value(new #genSyntaxCPP($s)(p${pn}hi, p$
{pn}lo));
#else
- r->get_nth($n)->replace_value(new #genSyntaxCPP($s)(p${pn}));
+ r->get_nth(n#genOidNameSuffix($col))->replace_value(new
#genSyntaxCPP($s)(p${pn}));
#end
#end## foreach
}
On 01.09.2010, at 07:08, Claus Klein wrote:
>
> Hi,
>
> to get the following code with symbolic names instead of numeric
> constants, I have changed the template for mib code.
> I think this more readable and it is according our coding rules, no
> magic numbers in code.
>
> ##########################################################
>
> {
> long v;
> vb.get_value(v);
> - if ((v != 1)
> - && (v != 2) && (v != 4)
> - && (v != 6)) return FALSE;
> + if ((v != e_doNothing)
> + && (v != e_activate) && (v != e_export)
> + && (v != e_abort)) return FALSE;
> //--AgentGen BEGIN=svfuaLogMgmtAction::value_ok
> //--AgentGen END
> return TRUE;
> }
>
> ##########################################################
>
> void svfuaOperatingHoursEntry::set_row(MibTableRow* r, unsigned long
> p1)
> {
> - r->get_nth(0)->replace_value(new NS_SNMP Gauge32(p1));
> + r->get_nth(nSvfuaOperatingHoursCount)->replace_value(new NS_SNMP
> Gauge32(p1));
> }
>
> //--AgentGen BEGIN=svfuaOperatingHoursEntry
> //--AgentGen END
>
> ##########################################################
>
> Are there any arguments against this changes?
>
> With regards,
> Claus
>
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/agentpp
More information about the AGENTPP
mailing list