/
PropertyExpressionEngine.cpp
750 lines (584 loc) · 23.5 KB
/
PropertyExpressionEngine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
/***************************************************************************
* Copyright (c) Eivind Kvedalen (eivind@kvedalen.name) 2015 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Base/Interpreter.h>
#include <Base/Writer.h>
#include <Base/Reader.h>
#include "Expression.h"
#include "ExpressionVisitors.h"
#include "PropertyExpressionEngine.h"
#include "PropertyStandard.h"
#include "PropertyUnits.h"
#include <CXX/Objects.hxx>
#include <boost/bind.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
using namespace App;
using namespace Base;
using namespace boost;
class ObjectDeletedExpressionVisitor : public ExpressionVisitor {
public:
ObjectDeletedExpressionVisitor(const App::DocumentObject * _obj)
: obj(_obj)
, found(false)
{
}
/**
* @brief Visit each node in the expression, and if it is a VariableExpression object check if it references obj
* @param node Node to visit
*/
void visit(Expression * node) {
VariableExpression *expr = freecad_dynamic_cast<VariableExpression>(node);
if (expr && expr->getPath().getDocumentObject() == obj)
found = true;
}
bool isFound() const { return found; }
private:
const App::DocumentObject * obj;
bool found;
};
TYPESYSTEM_SOURCE(App::PropertyExpressionEngine , App::Property);
/**
* @brief Construct a new PropertyExpressionEngine object.
*/
PropertyExpressionEngine::PropertyExpressionEngine()
: Property()
, AtomicPropertyChangeInterface()
, running(false)
, validator(0)
{
}
/**
* @brief Destroy the PropertyExpressionEngine object.
*/
PropertyExpressionEngine::~PropertyExpressionEngine()
{
}
/**
* @brief Estimate memory size of this property.
*
* \fixme Should probably return something else than 0.
*
* @return Size of object.
*/
unsigned int PropertyExpressionEngine::getMemSize() const
{
return 0;
}
Property *PropertyExpressionEngine::Copy() const
{
PropertyExpressionEngine * engine = new PropertyExpressionEngine();
for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it)
engine->expressions[it->first] = ExpressionInfo(boost::shared_ptr<Expression>(it->second.expression->copy()), it->second.comment.c_str());
engine->validator = validator;
return engine;
}
void PropertyExpressionEngine::Paste(const Property &from)
{
const PropertyExpressionEngine * fromee = static_cast<const PropertyExpressionEngine*>(&from);
AtomicPropertyChange signaller(*this);
expressions.clear();
for (ExpressionMap::const_iterator it = fromee->expressions.begin(); it != fromee->expressions.end(); ++it) {
expressions[it->first] = ExpressionInfo(boost::shared_ptr<Expression>(it->second.expression->copy()), it->second.comment.c_str());
expressionChanged(it->first);
}
validator = fromee->validator;
}
void PropertyExpressionEngine::Save(Base::Writer &writer) const
{
writer.Stream() << writer.ind() << "<ExpressionEngine count=\"" << expressions.size() <<"\">" << std::endl;
writer.incInd();
for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it) {
writer.Stream() << writer.ind() << "<Expression path=\"" << Property::encodeAttribute(it->first.toString()) <<"\"" <<
" expression=\"" << Property::encodeAttribute(it->second.expression->toString()) << "\"";
if (it->second.comment.size() > 0)
writer.Stream() << " comment=\"" << Property::encodeAttribute(it->second.comment) << "\"";
writer.Stream() << "/>" << std::endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</ExpressionEngine>" << std::endl;
}
void PropertyExpressionEngine::Restore(Base::XMLReader &reader)
{
reader.readElement("ExpressionEngine");
int count = reader.getAttributeAsFloat("count");
restoredExpressions.clear();
for (int i = 0; i < count; ++i) {
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
reader.readElement("Expression");
ObjectIdentifier path = ObjectIdentifier::parse(docObj, reader.getAttribute("path"));
boost::shared_ptr<Expression> expression(ExpressionParser::parse(docObj, reader.getAttribute("expression")));
const char * comment = reader.hasAttribute("comment") ? reader.getAttribute("comment") : 0;
restoredExpressions[path] = ExpressionInfo(expression, comment);
}
reader.readEndElement("ExpressionEngine");
}
/**
* @brief Update graph stucture with given path and expression.
* @param path Path
* @param expression Expression to query for dependencies
* @param nodes Map with nodes of graph
* @param revNodes Reverse map of nodes
* @param edges Edges in graph
*/
void PropertyExpressionEngine::buildGraphStructures(const ObjectIdentifier & path,
const boost::shared_ptr<Expression> expression,
boost::unordered_map<ObjectIdentifier, int> & nodes,
boost::unordered_map<int, ObjectIdentifier> & revNodes,
std::vector<Edge> & edges) const
{
std::set<ObjectIdentifier> deps;
/* Insert target property into nodes structure */
if (nodes.find(path) == nodes.end()) {
int s = nodes.size();
revNodes[s] = path;
nodes[path] = s;
}
else
revNodes[nodes[path]] = path;
/* Get the dependencies for this expression */
expression->getDeps(deps);
/* Insert dependencies into nodes structure */
std::set<ObjectIdentifier>::const_iterator di = deps.begin();
while (di != deps.end()) {
Property * prop = di->getProperty();
if (prop) {
ObjectIdentifier cPath(di->canonicalPath());
if (nodes.find(cPath) == nodes.end()) {
int s = nodes.size();
nodes[cPath] = s;
}
edges.push_back(std::make_pair(nodes[path], nodes[cPath]));
}
++di;
}
}
/**
* @brief Create a canonical object identifier of the given object \a p.
* @param p ObjectIndentifier
* @return New ObjectIdentifier
*/
const ObjectIdentifier PropertyExpressionEngine::canonicalPath(const ObjectIdentifier &p) const
{
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
// Am I owned by a DocumentObject?
if (!docObj)
throw Base::Exception("PropertyExpressionEngine must be owned by a DocumentObject.");
Property * prop = p.getProperty();
// p pointing to a property...?
if (!prop)
throw Base::Exception("Property not found");
// ... in the same container as I?
if (prop->getContainer() != getContainer())
throw Base::Exception("Property does not belong to same container as PropertyExpressionEngine");
// In case someone calls this with p pointing to a PropertyExpressionEngine for some reason
if (prop->isDerivedFrom(PropertyExpressionEngine::classTypeId))
return p;
// Dispatch call to actual canonicalPath implementation
return p.canonicalPath();
}
/**
* @brief Number of expressions managed by this object.
* @return Number of expressions.
*/
size_t PropertyExpressionEngine::numExpressions() const
{
return expressions.size();
}
/**
* @brief Slot called when a document object is renamed.
* @param obj Renamed object
*/
void PropertyExpressionEngine::slotObjectRenamed(const DocumentObject &obj)
{
#ifdef FC_PROPERTYEXPRESSIONENGINE_LOG
std::clog << "Object " << obj.getOldLabel() << " renamed to " << obj.Label.getValue() << std::endl;
#endif
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
/* In a document object, and on undo stack? */
if (!docObj || docObj->getNameInDocument() == 0)
return;
RelabelDocumentObjectExpressionVisitor<PropertyExpressionEngine> v(*this, obj.getOldLabel(), obj.Label.getStrValue());
for (ExpressionMap::iterator it = expressions.begin(); it != expressions.end(); ++it) {
int changed = v.getChanged();
it->second.expression->visit(v);
if (changed != v.getChanged())
expressionChanged(it->first);
}
}
void PropertyExpressionEngine::slotObjectDeleted(const DocumentObject &obj)
{
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
/* In a document object, and on undo stack? */
if (!docObj || docObj->getNameInDocument() == 0)
return;
ObjectDeletedExpressionVisitor v(&obj);
for (ExpressionMap::iterator it = expressions.begin(); it != expressions.end(); ++it) {
it->second.expression->visit(v);
if (v.isFound()) {
touch(); // Touch to force recompute; that will trigger a proper error
return;
}
}
}
void PropertyExpressionEngine::onDocumentRestored()
{
AtomicPropertyChange signaller(*this);
for (ExpressionMap::iterator it = restoredExpressions.begin(); it != restoredExpressions.end(); ++it)
setValue(it->first, it->second.expression, it->second.comment.size() > 0 ? it->second.comment.c_str() : 0);
}
/**
* @brief Get expression for \a path.
* @param path ObjectIndentifier to query for.
* @return Expression for \a path, or empty boost::any if not found.
*/
const boost::any PropertyExpressionEngine::getPathValue(const App::ObjectIdentifier & path) const
{
// Get a canonical path
ObjectIdentifier usePath(canonicalPath(path));
ExpressionMap::const_iterator i = expressions.find(usePath);
if (i != expressions.end())
return i->second;
else
return boost::any();
}
/**
* @brief Set expression with optional comment for \a path.
* @param path Path to update
* @param expr New expression
* @param comment Optional comment.
*/
void PropertyExpressionEngine::setValue(const ObjectIdentifier & path, boost::shared_ptr<Expression> expr, const char *comment)
{
ObjectIdentifier usePath(canonicalPath(path));
const Property * prop = usePath.getProperty();
// Try to access value; it should trigger an exception if it is not supported, or if the path is invalid
prop->getPathValue(usePath);
// Check if the current expression equals the new one and do nothing if so to reduce unneeded computations
ExpressionMap::iterator it = expressions.find(usePath);
if(it != expressions.end() && expr == it->second.expression)
return;
if (expr) {
std::string error = validateExpression(usePath, expr);
if (error.size() > 0)
throw Base::Exception(error.c_str());
AtomicPropertyChange signaller(*this);
expressions[usePath] = ExpressionInfo(expr, comment);
expressionChanged(usePath);
}
else {
AtomicPropertyChange signaller(*this);
expressions.erase(usePath);
expressionChanged(usePath);
}
}
/**
* @brief The cycle_detector struct is used by the boost graph routines to detect cycles in the graph.
*/
struct cycle_detector : public boost::dfs_visitor<> {
cycle_detector( bool& has_cycle, int & src)
: _has_cycle(has_cycle), _src(src) { }
template <class Edge, class Graph>
void back_edge(Edge e, Graph&g) {
_has_cycle = true;
_src = source(e, g);
}
protected:
bool& _has_cycle;
int & _src;
};
/**
* @brief Build a graph of all expressions in \a exprs.
* @param exprs Expressions to use in graph
* @param revNodes Map from int to ObjectIndentifer
* @param g Graph to update
*/
void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs,
boost::unordered_map<int, ObjectIdentifier> & revNodes, DiGraph & g) const
{
boost::unordered_map<ObjectIdentifier, int> nodes;
std::vector<Edge> edges;
// Build data structure for graph
for (ExpressionMap::const_iterator it = exprs.begin(); it != exprs.end(); ++it)
buildGraphStructures(it->first, it->second.expression, nodes, revNodes, edges);
// Create graph
g = DiGraph(revNodes.size());
// Add edges to graph
for (std::vector<Edge>::const_iterator i = edges.begin(); i != edges.end(); ++i)
add_edge(i->first, i->second, g);
// Check for cycles
bool has_cycle = false;
int src = -1;
cycle_detector vis(has_cycle, src);
depth_first_search(g, visitor(vis));
if (has_cycle) {
std::string s = revNodes[src].toString() + " reference creates a cyclic dependency.";
throw Base::Exception(s.c_str());
}
}
/**
* The code below builds a graph for all expressions in the engine, and
* finds any circular dependencies. It also computes the internal evaluation
* order, in case properties depends on each other.
*/
std::vector<App::ObjectIdentifier> PropertyExpressionEngine::computeEvaluationOrder()
{
std::vector<App::ObjectIdentifier> evaluationOrder;
boost::unordered_map<int, ObjectIdentifier> revNodes;
DiGraph g;
buildGraph(expressions, revNodes, g);
/* Compute evaluation order for expressions */
std::vector<int> c;
topological_sort(g, std::back_inserter(c));
for (std::vector<int>::iterator i = c.begin(); i != c.end(); ++i) {
if (revNodes.find(*i) != revNodes.end())
evaluationOrder.push_back(revNodes[*i]);
}
return evaluationOrder;
}
/**
* @brief Compute and update values of all registered experssions.
* @return StdReturn on success.
*/
DocumentObjectExecReturn *App::PropertyExpressionEngine::execute()
{
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
if (!docObj)
throw Base::Exception("PropertyExpressionEngine must be owned by a DocumentObject.");
if (running)
return DocumentObject::StdReturn;
/* Resetter class, to ensure that the "running" variable gets set to false, even if
* an exception is thrown.
*/
class resetter {
public:
resetter(bool & b) : _b(b) { _b = true; }
~resetter() { _b = false; }
private:
bool & _b;
};
resetter r(running);
// Compute evaluation order
std::vector<App::ObjectIdentifier> evaluationOrder = computeEvaluationOrder();
std::vector<ObjectIdentifier>::const_iterator it = evaluationOrder.begin();
#ifdef FC_PROPERTYEXPRESSIONENGINE_LOG
std::clog << "Computing expressions for " << getName() << std::endl;
#endif
/* Evaluate the expressions, and update properties */
while (it != evaluationOrder.end()) {
// Get property to update
Property * prop = it->getProperty();
if (!prop)
throw Base::Exception("Path does not resolve to a property.");
DocumentObject* parent = freecad_dynamic_cast<DocumentObject>(prop->getContainer());
/* Make sure property belongs to the same container as this PropertyExpressionEngine */
if (parent != docObj)
throw Base::Exception("Invalid property owner.");
// Evaluate expression
std::auto_ptr<Expression> e(expressions[*it].expression->eval());
#ifdef FC_PROPERTYEXPRESSIONENGINE_LOG
{
Base::Quantity q;
boost::any value = e->getValueAsAny();
if (value.type() == typeid(Base::Quantity))
q = boost::any_cast<Base::Quantity>(value);
else if (value.type() == typeid(double))
q = boost::any_cast<double>(value);
else {
std::clog << "Unknown return value for expression.";
q = 0;
}
std::clog << "Assigning value " << q.getValue() << " to " << (*it).toString().c_str() << " (" << prop->getName() << ")" << std::endl;
}
#endif
/* Set value of property */
prop->setPathValue(*it, e->getValueAsAny());
++it;
}
return DocumentObject::StdReturn;
}
/**
* @brief Find document objects that the expressions depend on.
* @param docObjs Dependencies
*/
void PropertyExpressionEngine::getDocumentObjectDeps(std::vector<DocumentObject *> &docObjs) const
{
DocumentObject * owner = freecad_dynamic_cast<DocumentObject>(getContainer());
if (owner == 0)
return;
ExpressionMap::const_iterator i = expressions.begin();
while (i != expressions.end()) {
std::set<ObjectIdentifier> deps;
i->second.expression->getDeps(deps);
std::set<ObjectIdentifier>::const_iterator j = deps.begin();
while (j != deps.end()) {
const ObjectIdentifier & p = *j;
DocumentObject* docObj = p.getDocumentObject();
if (docObj && docObj != owner)
docObjs.push_back(docObj);
++j;
}
++i;
}
}
/**
* @brief Determine whether any dependencies of any of the registered expressions have been touched.
* @return True if at least on dependency has been touched.
*/
bool PropertyExpressionEngine::depsAreTouched() const
{
ExpressionMap::const_iterator i = expressions.begin();
while (i != expressions.end()) {
std::set<ObjectIdentifier> deps;
i->second.expression->getDeps(deps);
std::set<ObjectIdentifier>::const_iterator j = deps.begin();
while (j != deps.end()) {
const ObjectIdentifier & p = *j;
Property* prop = p.getProperty();
if (prop && prop->isTouched())
return true;
++j;
}
++i;
}
return false;
}
/**
* @brief Get a map of all registered expressions.
* @return Map of expressions.
*/
boost::unordered_map<const ObjectIdentifier, const PropertyExpressionEngine::ExpressionInfo> PropertyExpressionEngine::getExpressions() const
{
boost::unordered_map<const ObjectIdentifier, const ExpressionInfo> result;
ExpressionMap::const_iterator i = expressions.begin();
while (i != expressions.end()) {
result.insert(std::make_pair(i->first, i->second));
++i;
}
return result;
}
/**
* @brief Validate the given path and expression.
* @param path Object Indentifier for expression.
* @param expr Expression tree.
* @return Empty string on success, error message on failure.
*/
std::string PropertyExpressionEngine::validateExpression(const ObjectIdentifier &path, boost::shared_ptr<const Expression> expr) const
{
std::string error;
ObjectIdentifier usePath(canonicalPath(path));
if (validator) {
error = validator(usePath, expr);
if (error.size() > 0)
return error;
}
// Get dependencies from expression
std::set<App::ObjectIdentifier> exprDeps;
expr->getDeps(exprDeps);
// Get document object
DocumentObject * pathDocObj = usePath.getDocumentObject();
// Check for document object dependecies
for (std::set<App::ObjectIdentifier>::const_iterator j = exprDeps.begin(); j != exprDeps.end(); ++j) {
DocumentObject * docObj = (*j).getDocumentObject();
// Skip internal dependencies;
if (docObj == pathDocObj)
continue;
// Get dependencies for the document object pointed to be *j
std::vector<DocumentObject*> targets;
targets.push_back(docObj);
std::vector<DocumentObject*> deps = (*j).getDocument()->getDependencyList(targets);
for (std::vector<DocumentObject*>::const_iterator i = deps.begin(); i != deps.end(); ++i) {
if (*i == pathDocObj)
return (*j).toString() + " reference creates a cyclic dependency.";
}
}
// Check for internal document object dependencies
// Copy current expressions
ExpressionMap newExpressions = expressions;
// Add expression in question
boost::shared_ptr<Expression> exprClone(expr->copy());
newExpressions[usePath].expression = exprClone;
// Build graph; an exception will be thrown if it is not a DAG
try {
boost::unordered_map<int, ObjectIdentifier> revNodes;
DiGraph g;
buildGraph(newExpressions, revNodes, g);
}
catch (const Base::Exception & e) {
return e.what();
}
return std::string();
}
/**
* @brief Rename paths based on \a paths.
* @param paths Map with current and new object identifier.
*/
void PropertyExpressionEngine::renameExpressions(const std::map<ObjectIdentifier, ObjectIdentifier> & paths)
{
ExpressionMap newExpressions;
std::map<ObjectIdentifier, ObjectIdentifier> canonicalPaths;
/* ensure input map uses canonical paths */
for (std::map<ObjectIdentifier, ObjectIdentifier>::const_iterator i = paths.begin(); i != paths.end(); ++i)
canonicalPaths[canonicalPath(i->first)] = i->second;
for (ExpressionMap::const_iterator i = expressions.begin(); i != expressions.end(); ++i) {
std::map<ObjectIdentifier, ObjectIdentifier>::const_iterator j = canonicalPaths.find(i->first);
// Renamed now?
if (j != canonicalPaths.end())
newExpressions[j->second] = i->second;
else
newExpressions[i->first] = i->second;
}
aboutToSetValue();
expressions = newExpressions;
for (ExpressionMap::const_iterator i = expressions.begin(); i != expressions.end(); ++i)
expressionChanged(i->first);
hasSetValue();
}
/**
* @brief Rename object identifiers in the registered expressions.
* @param paths Map with current and new object identifiers.
*/
void PropertyExpressionEngine::renameObjectIdentifiers(const std::map<ObjectIdentifier, ObjectIdentifier> &paths)
{
for (ExpressionMap::iterator it = expressions.begin(); it != expressions.end(); ++it) {
RenameObjectIdentifierExpressionVisitor<PropertyExpressionEngine> v(*this, paths, it->first);
it->second.expression->visit(v);
}
}
PyObject *PropertyExpressionEngine::getPyObject(void)
{
Py::List list;
for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it) {
Py::Tuple tuple(2);
tuple.setItem(0, Py::String(it->first.toString()));
tuple.setItem(1, Py::String(it->second.expression->toString()));
list.append(tuple);
}
return Py::new_reference_to(list);
}
void PropertyExpressionEngine::setPyObject(PyObject *)
{
throw Base::RuntimeError("Property is read-only");
}