Closed GoogleCodeExporter closed 9 years ago
This is an API-breaking change. We will change the String-type default values
to integer and hex values. The options for defining defaults (integer, hex,
maybe more in future) are provided as part of the IDL syntax only. IN the model
API there will be just an integer constant without additional information about
how it has been specified in the IDL.
In order to avoid additional work in downstream generators, we won't provide a
deprecation phase. This will require downstream tools to adapt to this change
exactly once.
Original comment by klaus.birken@gmail.com
on 28 Aug 2013 at 9:55
for code generation it would make sense to have the number system used for
constant definition available from the model. Goal is to enable code generators
or transformations to put numbers in exactly the same way to their output as it
was specified in Franca, e.g. hexadecimal, decimal, binary or octal.
Original comment by manfred....@bmw.de
on 28 Aug 2013 at 1:28
Original comment by klaus.birken@gmail.com
on 19 Feb 2014 at 10:33
Finished implementation by commit 5ea396c on develop.
We decided in favor of a deprecation phase, i.e., string values are still
supported, but will be marked with deprecation warnings by the validator. This
allows a smooth transition for existing fidl files. The deprecation phase will
end with release 0.9.1 or later (not defined yet).
We extended the requirements a bit: It is possible to use arbitrary expressions
to define an enumerator value. The same syntax can be used as for initializer
expressions of constant definitions. This is a quite powerful feature. However,
it is currently not possible to define one enumerator's value by means of
another enumerator, because there is no implicit conversion from enum types to
integer types.
Hint for code generator developers: This change breaks your API. There are two
helper functions which should be used to determine the value of an enumerator,
both in class org.franca.core.utils.ExpressionEvaluator:
- evaluateInteger() can be used for evaluating an e.value. If the deprecated
string syntax is used for the enumerator's value, this function will return null
- evaluateIntegerOrParseString() can also be used for evaluating an e.value.
This supports the deprecated string syntax, including strings which represent
hex numbers (e.g., "0xAB).
Regarding comment #2: If the code generator wants to generate code exactly as
specified in Franca (and not evaluated to an atomic constant), the evaluator
shouldn't be used, but the expression has to be parsed instead. But this might
be tricky (look at the implementation of ExpressionEvaluator to get an
impression). In that case, it might be a good solution to fall back to the
evaluator if the expression is beyond a defined complexity.
Current scope restriction: Hex numbers cannot be used in the enumerator value
expressions yet. Support of hex values is a separate issue which will be
supported in any kind of Franca expression.
Original comment by klaus.birken@gmail.com
on 21 Feb 2014 at 9:38
Original comment by klaus.birken@gmail.com
on 21 Feb 2014 at 9:38
Integrated to master.
Original comment by klaus.birken@gmail.com
on 4 Mar 2014 at 12:17
Original comment by klaus.birken@gmail.com
on 25 Jan 2015 at 12:29
Original issue reported on code.google.com by
manfred....@bmw.de
on 2 Jul 2013 at 3:25