Commit Graph

21 Commits

Author SHA1 Message Date
Mark Roszko 11ff16be4e Switch to scoped enums 2019-12-20 14:11:39 +00:00
Seth Hillbrand 4d2e953f42 Cleanup: Replace C-only deprecated headers
This replaces headers deprecated by C++14 with their equivalent
replacement
2019-12-05 11:03:15 -08:00
John Beard dd17f24c04 Libeval: consistent formatting for NaN
On some platforms like MSVC, NaN prints as "-nan(ind)". This
is a bit needlessly ugly, so print "NaN" on all platforms
consistently.

This fixes a test failure on MSVC.
2019-04-08 16:27:45 +01:00
John Beard 5e705347bb Libeval: Use add_custom_target so grammar.c won't be cleaned
If you use add_custom_command to generate the grammar file,
it can be removed by "make clean". This then means the user will
need to get it back from Git, or regenerate it with Lemon.

Changing to add_custom_command removes the output file
from the clean list. The incantation to rebuild the grammar
remains the same: "make libeval_grammar", and it is still not
required to have lemon installed for a normal build.

Fixes: lp:1809610
* https://bugs.launchpad.net/kicad/+bug/1809610
2019-01-05 07:44:06 -08:00
John Beard 157519d722 Libeval: leading + is a sign, not an operator
Due to (presumably) a different lemon version,
there are some formatting changes in the grammar,
and some manual debug left in has been removed.
2018-12-03 08:39:30 +01:00
John Beard f30f5b3249 Build: Add a CMake target libeval lemon grammar
The libeval grammar can now be rebuilt with "make libeval_grammar".
This is only possible when lemon is installed.

Also a couple of modifications to the lemon grammar to
account for external changes since the grammer was last generated.

Also move the grammar defines into grammar.h - this is how
Lemon produces them, and by manually copying into the target .cpp,
it make automated regeneration impossible.
2018-12-03 08:39:27 +01:00
John Beard 49c723fc83 QA: Add numeric evaluator tests
Remove obsolete and unbuildable common/libeval/main.cpp
test program.
2018-12-03 08:39:21 +01:00
Jeff Young 3024ded91e Improve robustness of numeric evaluation.
It would appear that some platforms process the KILL_FOCUS event
after running TransferDataFromWindow().  This change makes sure
that the evaluation is done no matter the order.

Fixes: lp:1793911
* https://bugs.launchpad.net/kicad/+bug/1793911
2018-10-08 12:59:40 +01:00
Jeff Young d1a679e496 Save original_text before obliterating it.
Fixes: lp:1793911
* https://bugs.launchpad.net/kicad/+bug/1793911
2018-10-07 23:37:16 +01:00
Jeff Young 40f5ca0bf7 Fix copy/paste error in numeric evaluator.
Fixes: lp:1783991
* https://bugs.launchpad.net/kicad/+bug/1783991
2018-07-27 14:58:19 +01:00
Jeff Young 06bf958bf1 UNIT_BINDERize eeschema's plot and text edit dialogs.
(cherry picked from commit 298ea70)
2018-07-17 15:11:26 +01:00
Jeff Young f0f9e4a1cb Kicad-ize the numeric evaluator.
Naming conventions, code formatting, and wxStrings.

(cherry picked from commit 4a0d7a8)
2018-07-17 15:10:01 +01:00
Jeff Young 74acb76e7f Switch UNIT_BINDER and DIALOG_SHIM to local units.
The general idea is to support user-units inheritance.  The
UNIT_BINDER allows wrapped controls to inherit units from their
parent dialog, while KEYWAY_HOLDER and DIALOG_SHIM allow child
KEYWAY_HOLDERs or DIALOG_SHIMs to inherit units from their
parent.

The GetUserUnits() method signature has to move to KEYWAY_HOLDER
rather than KEYWAY_PLAYER (where it makes more sense) as it’s the
only common ancestor of KEYWAY_PLAYER and DIALOG_SHIM.

As long as we'll be using the UNIT_BINDER more widely, it also
makes sense to move evaluation and validation into it.

This commit also provides eeschema’s DIALOG_LABEL_EDITOR and
pcbnew’s DIALOG_TRACK_VIA_PROPERTIES and DIALOG_SET_GRID as
models of how to use the new user-units inheritance, eval, and
validation.

Fixes: lp:593795
* https://bugs.launchpad.net/kicad/+bug/593795

(cherry picked from commit c8bc53e)
2018-07-17 15:09:53 +01:00
Jeff Young 99e659ff54 Coverity fixes. 2018-03-21 23:11:55 +00:00
Maciej Suminski dfd2a8fc48 NumericEvaluator: return false for invalid expressions
Clearing bClError flag in NumericEvaluator::parseOk() made the
expression look valid, even if the flag has been set for a previous
token. Now it is cleared before an expression is parsed and verified
after parser finishes.

Fixes: lp:1756995
* https://bugs.launchpad.net/kicad/+bug/1756995
2018-03-21 17:11:35 +01:00
Maciej Suminski 5f2b8e0409 Change NumericEvaluator::clear() to optionally accept an object to clear 2018-02-27 12:47:32 +01:00
Michael Geselbracht 21f46776c6 Fix decimal point bug, support for more units V2
If ',' is used as decimal separator by the current locale a '.' is also accepted.
Also add support for units "mi", "th" and "in" as described in the documentation of pcbnew.

Fixes: lp:1751315
* https://bugs.launchpad.net/kicad/+bug/1751315
2018-02-25 08:21:23 +01:00
Michael Geselbracht 5d738dcb6d Coverity fix for libeval (CID #169327) 2018-02-15 15:43:12 +01:00
Maciej Suminski 1f70cc8c5f Expression evaluator: increased output precision 2017-11-24 21:16:13 +01:00
Maciej Suminski 9866196130 Expression evaluator: handle locale setting for decimal separator
NumericEvaluator uses the locale settings to determine the decimal
separator character which will be used when parsing expressions.
2017-11-24 21:16:13 +01:00
Michael Geselbracht b5fc6e45cf Numeric expression evaluator 2017-11-24 21:15:40 +01:00