App: use Python number protocol in Expression

This adds support to do mul/div with matrix and vector, as well as
Python formated string with operator %.
This commit is contained in:
Zheng, Lei
2019-08-25 16:16:32 +08:00
committed by wmayer
parent 1efadc928e
commit 8cbdc3ad5d
9 changed files with 641 additions and 504 deletions

View File

@@ -705,7 +705,7 @@ void Sheet::updateProperty(CellAddress key)
Base::PyGILStateLocker lock;
auto py_expr = freecad_dynamic_cast<PyObjectExpression>(output.get());
if(py_expr)
setObjectProperty(key, py_expr->getPyObject());
setObjectProperty(key, py_expr->getPyValue());
else
setObjectProperty(key, Py::Object());
}

View File

@@ -136,7 +136,7 @@ class SpreadsheetCases(unittest.TestCase):
self.assertEqual(sheet.H2, u'ERR: Quantity::operator <(): quantities need to have same unit to compare')
self.assertEqual(sheet.H3, u'ERR: Quantity::operator >(): quantities need to have same unit to compare')
self.assertEqual(sheet.H4, 4)
self.assertEqual(sheet.H5, u'ERR: Quantity::operator +(): Unit mismatch in minus operation')
self.assertEqual(sheet.H5, u'ERR: Quantity::operator -(): Unit mismatch in minus operation')
self.assertEqual(sheet.H6, u'ERR: Quantity::operator +=(): Unit mismatch in plus operation')
def assertMostlyEqual(self, a, b):