wspringer/preon — Issue #9: Add numeric size annotation attribute
Author: olerass
Created: 2012-02-27 18:21:39+00:00
State: open

Currently annotations like BoundString and BoundList only accept a string type size attribute. This is fine for situations where you use Limbo expressions, but it limits the options for producing maintainable code if you want to avoid duplicating data.

Consider the example below. The Test class has one string of 8 bytes. The size may be used elsewhere in the class or outside it, and therefore one would of course not want to spray the number 8 all over. The standard solution is to define a constant and use that everywhere. The problem is that you can't reference the constant from within limbo (i may be wrong?) so you have to define it as a string which forces you to do string->int conversion all over the place - not very practical.

I suggest adding a numeric size attribute to the supporting annotations.

class Test
{
public static final int FIELD_SIZE = 8;

@BoundString(size = FIELD_SIZE)
private String field;
}