- transformed the COS nodes to support sub-graph extensions more appropriately
@@ -16,7 +16,10 @@ | ||
16 | 16 | #include <sdk/UniqueIterate.h> |
17 | 17 | #include <sdk/MultiValueStore.h> |
18 | 18 | #include <sdk/Set.h> |
19 | +#include <sdk/Map.h> | |
19 | 20 | |
21 | +#include <functional> // for std::bind | |
22 | + | |
20 | 23 | // Thanks to selector-based nodes we can detach the actual node building from the node logic itself. |
21 | 24 | // This were a burden because it would require character-based methods that we would not want to lock to character encodings. |
22 | 25 |
@@ -34,6 +37,9 @@ | ||
34 | 37 | template <typename structType> |
35 | 38 | using cosCommonSet = eir::Set <structType, CRTHeapAllocator>; |
36 | 39 | |
40 | +template <typename keyType, typename valueType, eir::CompareCompatibleComparator <keyType, keyType> comparatorType = eir::MapDefaultComparator> | |
41 | +using cosCommonMap = eir::Map <keyType, valueType, CRTHeapAllocator, comparatorType>; | |
42 | + | |
37 | 43 | template <typename structType> |
38 | 44 | using cosCommonMultiValueStore = eir::MultiValueStore <structType, CRTHeapAllocator>; |
39 | 45 |
@@ -371,8 +377,10 @@ | ||
371 | 377 | protected: |
372 | 378 | COSObjectsNode sys; |
373 | 379 | |
374 | - template <typename... containerTypes> | |
375 | - AINLINE void TemplateSetEdge( COSNode *newnode, COSNode*& fieldRef, const containerTypes&... others ) | |
380 | + template <typename setCallbackType, typename unsetCallbackType, typename... containerTypes> | |
381 | + requires ( std::is_invocable_r <void, setCallbackType, COSNode*>::value && | |
382 | + std::is_invocable_r <void, unsetCallbackType, COSNode*>::value ) | |
383 | + AINLINE void TemplateSetEdge( COSNode *newnode, COSNode*& fieldRef, setCallbackType&& set_cb, unsetCallbackType&& unset_cb, const containerTypes&... others ) | |
376 | 384 | { |
377 | 385 | COSNode *oldnode = fieldRef; |
378 | 386 |
@@ -393,8 +401,18 @@ | ||
393 | 401 | oldnode_spresent = false; |
394 | 402 | } |
395 | 403 | |
404 | + if ( oldnode != nullptr ) | |
405 | + { | |
406 | + unset_cb( oldnode ); | |
407 | + } | |
408 | + | |
396 | 409 | fieldRef = newnode; |
397 | 410 | |
411 | + if ( newnode != nullptr ) | |
412 | + { | |
413 | + set_cb( newnode ); | |
414 | + } | |
415 | + | |
398 | 416 | COSObjects *sys = this->sys; |
399 | 417 | |
400 | 418 | if ( newnode && newnode_isold == false ) |
@@ -411,7 +429,10 @@ | ||
411 | 429 | } |
412 | 430 | } |
413 | 431 | |
414 | - AINLINE void TemplateSetDynamicEdge( COSNode *newnode, COSNode*& fieldRef ) | |
432 | + template <typename setCallbackType, typename unsetCallbackType> | |
433 | + requires ( std::is_invocable_r <void, setCallbackType, COSNode*>::value && | |
434 | + std::is_invocable_r <void, unsetCallbackType, COSNode*>::value ) | |
435 | + AINLINE void TemplateSetDynamicEdge( COSNode *newnode, COSNode*& fieldRef, setCallbackType&& set_cb, unsetCallbackType unset_cb ) | |
415 | 436 | { |
416 | 437 | COSNode *oldnode = fieldRef; |
417 | 438 |
@@ -420,8 +441,18 @@ | ||
420 | 441 | |
421 | 442 | bool newnode_isold = ( newnode && this->IsNodeConnectedTo_Reach( newnode ) ); |
422 | 443 | |
444 | + if ( oldnode != nullptr ) | |
445 | + { | |
446 | + unset_cb( oldnode ); | |
447 | + } | |
448 | + | |
423 | 449 | fieldRef = newnode; |
424 | 450 | |
451 | + if ( newnode != nullptr ) | |
452 | + { | |
453 | + set_cb( newnode ); | |
454 | + } | |
455 | + | |
425 | 456 | bool oldnode_spresent = ( oldnode && this->IsNodeConnectedTo_Reach( oldnode ) ); |
426 | 457 | |
427 | 458 | COSObjects *sys = this->sys; |
@@ -581,7 +612,7 @@ | ||
581 | 612 | } |
582 | 613 | } |
583 | 614 | |
584 | -private: | |
615 | +protected: | |
585 | 616 | cosCommonVector <COSNode*> statements; |
586 | 617 | public: |
587 | 618 | inline void AddStatement( COSNode *node ) |
@@ -620,6 +651,10 @@ | ||
620 | 651 | { |
621 | 652 | return; |
622 | 653 | } |
654 | + virtual void OnRemoveStatement( COSNode *node ) | |
655 | + { | |
656 | + return; | |
657 | + } | |
623 | 658 | }; |
624 | 659 | |
625 | 660 | struct Operation : public COSNode |
@@ -671,12 +706,12 @@ | ||
671 | 706 | } |
672 | 707 | } |
673 | 708 | |
674 | -private: | |
709 | +protected: | |
675 | 710 | COSNode *op; |
676 | 711 | public: |
677 | 712 | inline void SetOperation( COSNode *op ) |
678 | 713 | { |
679 | - TemplateSetEdge( op, this->op ); | |
714 | + TemplateSetEdge( op, this->op, std::bind( &UnaryOperation::OnSetOperation, this, std::placeholders::_1 ), std::bind( &UnaryOperation::OnUnsetOperation, this, std::placeholders::_1 ) ); | |
680 | 715 | |
681 | 716 | // TODO: improve exception-safety. |
682 | 717 |
@@ -691,6 +726,10 @@ | ||
691 | 726 | { |
692 | 727 | return; |
693 | 728 | } |
729 | + virtual void OnUnsetOperation( COSNode *n ) | |
730 | + { | |
731 | + return; | |
732 | + } | |
694 | 733 | }; |
695 | 734 | |
696 | 735 | struct LogicalNegationOperation : public UnaryOperation |
@@ -781,21 +820,23 @@ | ||
781 | 820 | } |
782 | 821 | } |
783 | 822 | |
784 | -private: | |
823 | +protected: | |
785 | 824 | COSNode *left; |
786 | 825 | COSNode *right; |
787 | 826 | public: |
788 | 827 | inline void SetLeft( COSNode *nleft ) |
789 | 828 | { |
790 | - TemplateSetEdge( nleft, this->left, right ); | |
791 | - | |
792 | - this->OnSetLeft( nleft ); | |
829 | + TemplateSetEdge( nleft, this->left, | |
830 | + std::bind( &BinaryOperation::OnSetLeft, this, std::placeholders::_1 ), std::bind( &BinaryOperation::OnUnsetLeft, this, std::placeholders::_1 ), | |
831 | + right | |
832 | + ); | |
793 | 833 | } |
794 | 834 | inline void SetRight( COSNode *nright ) |
795 | 835 | { |
796 | - TemplateSetEdge( nright, this->right, left ); | |
797 | - | |
798 | - this->OnSetRight( nright ); | |
836 | + TemplateSetEdge( nright, this->right, | |
837 | + std::bind( &BinaryOperation::OnSetRight, this, std::placeholders::_1 ), std::bind( &BinaryOperation::OnUnsetRight, this, std::placeholders::_1 ), | |
838 | + left | |
839 | + ); | |
799 | 840 | } |
800 | 841 | inline COSNode* GetLeft( void ) const noexcept |
801 | 842 | { |
@@ -810,10 +851,18 @@ | ||
810 | 851 | { |
811 | 852 | return; |
812 | 853 | } |
854 | + virtual void OnUnsetLeft( COSNode *left ) | |
855 | + { | |
856 | + return; | |
857 | + } | |
813 | 858 | virtual void OnSetRight( COSNode *right ) |
814 | 859 | { |
815 | 860 | return; |
816 | 861 | } |
862 | + virtual void OnUnsetRight( COSNode *right ) | |
863 | + { | |
864 | + return; | |
865 | + } | |
817 | 866 | }; |
818 | 867 | |
819 | 868 | struct AddOperation : public BinaryOperation |
@@ -1002,15 +1051,16 @@ | ||
1002 | 1051 | } |
1003 | 1052 | } |
1004 | 1053 | |
1005 | -private: | |
1054 | +protected: | |
1006 | 1055 | COSNode *what; |
1007 | 1056 | cosCommonVector <COSNode*> params; |
1008 | 1057 | public: |
1009 | 1058 | inline void SetNode( COSNode *nwhat ) |
1010 | 1059 | { |
1011 | - TemplateSetEdge( nwhat, this->what, params ); | |
1012 | - | |
1013 | - this->OnSetNode( nwhat ); | |
1060 | + TemplateSetEdge( nwhat, this->what, | |
1061 | + std::bind( &FunctionCallOperation::OnSetNode, this, std::placeholders::_1 ), std::bind( &FunctionCallOperation::OnUnsetNode, this, std::placeholders::_1 ), | |
1062 | + params | |
1063 | + ); | |
1014 | 1064 | } |
1015 | 1065 | inline COSNode* GetNode( void ) const noexcept |
1016 | 1066 | { |
@@ -1052,10 +1102,18 @@ | ||
1052 | 1102 | { |
1053 | 1103 | return; |
1054 | 1104 | } |
1105 | + virtual void OnUnsetNode( COSNode *n ) | |
1106 | + { | |
1107 | + return; | |
1108 | + } | |
1055 | 1109 | virtual void OnAddParam( COSNode *n ) |
1056 | 1110 | { |
1057 | 1111 | return; |
1058 | 1112 | } |
1113 | + virtual void OnRemoveParam( COSNode *n ) | |
1114 | + { | |
1115 | + return; | |
1116 | + } | |
1059 | 1117 | }; |
1060 | 1118 | struct ArrayInitOperation : public Operation |
1061 | 1119 | { |
@@ -1103,15 +1161,16 @@ | ||
1103 | 1161 | } |
1104 | 1162 | } |
1105 | 1163 | |
1106 | -private: | |
1164 | +protected: | |
1107 | 1165 | COSNode *what; |
1108 | 1166 | cosCommonVector <COSNode*> items; |
1109 | 1167 | public: |
1110 | 1168 | inline void SetNode( COSNode *nwhat ) |
1111 | 1169 | { |
1112 | - TemplateSetEdge( nwhat, this->what, items ); | |
1113 | - | |
1114 | - this->OnSetNode( nwhat ); | |
1170 | + TemplateSetEdge( nwhat, this->what, | |
1171 | + std::bind( &ArrayInitOperation::OnSetNode, this, std::placeholders::_1 ), std::bind( &ArrayInitOperation::OnUnsetNode, this, std::placeholders::_1 ), | |
1172 | + items | |
1173 | + ); | |
1115 | 1174 | } |
1116 | 1175 | inline COSNode* GetNode( void ) const noexcept |
1117 | 1176 | { |
@@ -1153,10 +1212,18 @@ | ||
1153 | 1212 | { |
1154 | 1213 | return; |
1155 | 1214 | } |
1215 | + virtual void OnUnsetNode( COSNode *n ) | |
1216 | + { | |
1217 | + return; | |
1218 | + } | |
1156 | 1219 | virtual void OnAddItem( COSNode *n ) |
1157 | 1220 | { |
1158 | 1221 | return; |
1159 | 1222 | } |
1223 | + virtual void OnRemoveItem( COSNode *n ) | |
1224 | + { | |
1225 | + return; | |
1226 | + } | |
1160 | 1227 | }; |
1161 | 1228 | |
1162 | 1229 | struct NewOperation : public Operation |
@@ -1205,15 +1272,16 @@ | ||
1205 | 1272 | } |
1206 | 1273 | } |
1207 | 1274 | |
1208 | -private: | |
1275 | +protected: | |
1209 | 1276 | COSNode *type; |
1210 | 1277 | cosCommonVector <COSNode*> params; |
1211 | 1278 | public: |
1212 | 1279 | inline void SetType( COSNode *ntype ) |
1213 | 1280 | { |
1214 | - TemplateSetEdge( ntype, this->type, params ); | |
1215 | - | |
1216 | - this->OnSetType( ntype ); | |
1281 | + TemplateSetEdge( ntype, this->type, | |
1282 | + std::bind( &NewOperation::OnSetType, this, std::placeholders::_1 ), std::bind( &NewOperation::OnUnsetType, this, std::placeholders::_1 ), | |
1283 | + params | |
1284 | + ); | |
1217 | 1285 | } |
1218 | 1286 | inline COSNode* GetType( void ) const noexcept |
1219 | 1287 | { |
@@ -1255,10 +1323,18 @@ | ||
1255 | 1323 | { |
1256 | 1324 | return; |
1257 | 1325 | } |
1326 | + virtual void OnUnsetType( COSNode *ntype ) | |
1327 | + { | |
1328 | + return; | |
1329 | + } | |
1258 | 1330 | virtual void OnAddParam( COSNode *nparam ) |
1259 | 1331 | { |
1260 | 1332 | return; |
1261 | 1333 | } |
1334 | + virtual void OnRemoveParam( COSNode *nparam ) | |
1335 | + { | |
1336 | + return; | |
1337 | + } | |
1262 | 1338 | }; |
1263 | 1339 | struct ReplaceOperation : public Operation |
1264 | 1340 | { |
@@ -1307,15 +1383,16 @@ | ||
1307 | 1383 | } |
1308 | 1384 | } |
1309 | 1385 | |
1310 | -private: | |
1386 | +protected: | |
1311 | 1387 | COSNode *what; |
1312 | 1388 | COSNode *with; |
1313 | 1389 | public: |
1314 | 1390 | inline void SetWhat( COSNode *nwhat ) |
1315 | 1391 | { |
1316 | - TemplateSetEdge( nwhat, this->what, with ); | |
1317 | - | |
1318 | - this->OnSetWhat( nwhat ); | |
1392 | + TemplateSetEdge( nwhat, this->what, | |
1393 | + std::bind( &ReplaceOperation::OnSetWhat, this, std::placeholders::_1 ), std::bind( &ReplaceOperation::OnUnsetWhat, this, std::placeholders::_1 ), | |
1394 | + with | |
1395 | + ); | |
1319 | 1396 | } |
1320 | 1397 | inline COSNode* GetWhat( void ) const noexcept |
1321 | 1398 | { |
@@ -1323,9 +1400,10 @@ | ||
1323 | 1400 | } |
1324 | 1401 | inline void SetWith( COSNode *nwith ) |
1325 | 1402 | { |
1326 | - TemplateSetEdge( nwith, this->with, what ); | |
1327 | - | |
1328 | - this->OnSetWith( nwith ); | |
1403 | + TemplateSetEdge( nwith, this->with, | |
1404 | + std::bind( &ReplaceOperation::OnSetWith, this, std::placeholders::_1 ), std::bind( &ReplaceOperation::OnUnsetWith, this, std::placeholders::_1 ), | |
1405 | + what | |
1406 | + ); | |
1329 | 1407 | } |
1330 | 1408 | inline COSNode* GetWith( void ) const noexcept |
1331 | 1409 | { |
@@ -1336,10 +1414,18 @@ | ||
1336 | 1414 | { |
1337 | 1415 | return; |
1338 | 1416 | } |
1417 | + virtual void OnUnsetWhat( COSNode *nwhat ) | |
1418 | + { | |
1419 | + return; | |
1420 | + } | |
1339 | 1421 | virtual void OnSetWith( COSNode *nwith ) |
1340 | 1422 | { |
1341 | 1423 | return; |
1342 | 1424 | } |
1425 | + virtual void OnUnsetWith( COSNode *nwith ) | |
1426 | + { | |
1427 | + return; | |
1428 | + } | |
1343 | 1429 | }; |
1344 | 1430 | struct DeleteOperation : public UnaryOperation |
1345 | 1431 | { |
@@ -1393,15 +1479,16 @@ | ||
1393 | 1479 | } |
1394 | 1480 | } |
1395 | 1481 | |
1396 | -private: | |
1482 | +protected: | |
1397 | 1483 | COSNode *totype; |
1398 | 1484 | COSNode *castobj; |
1399 | 1485 | public: |
1400 | 1486 | inline void SetToType( COSNode *newtotype ) |
1401 | 1487 | { |
1402 | - TemplateSetEdge( newtotype, this->totype, castobj ); | |
1403 | - | |
1404 | - this->OnSetToType( newtotype ); | |
1488 | + TemplateSetEdge( newtotype, this->totype, | |
1489 | + std::bind( &CastOperation::OnSetToType, this, std::placeholders::_1 ), std::bind( &CastOperation::OnUnsetToType, this, std::placeholders::_1 ), | |
1490 | + castobj | |
1491 | + ); | |
1405 | 1492 | } |
1406 | 1493 | inline COSNode* GetToType( void ) const noexcept |
1407 | 1494 | { |
@@ -1409,9 +1496,10 @@ | ||
1409 | 1496 | } |
1410 | 1497 | inline void SetCastObject( COSNode *newcastobj ) |
1411 | 1498 | { |
1412 | - TemplateSetEdge( newcastobj, this->castobj, totype ); | |
1413 | - | |
1414 | - this->OnSetCastObject( newcastobj ); | |
1499 | + TemplateSetEdge( newcastobj, this->castobj, | |
1500 | + std::bind( &CastOperation::OnSetCastObject, this, std::placeholders::_1 ), std::bind( &CastOperation::OnUnsetCastObject, this, std::placeholders::_1 ), | |
1501 | + totype | |
1502 | + ); | |
1415 | 1503 | } |
1416 | 1504 | inline COSNode* GetCastObject( void ) const noexcept |
1417 | 1505 | { |
@@ -1422,10 +1510,18 @@ | ||
1422 | 1510 | { |
1423 | 1511 | return; |
1424 | 1512 | } |
1513 | + virtual void OnUnsetToType( COSNode *newtotype ) | |
1514 | + { | |
1515 | + return; | |
1516 | + } | |
1425 | 1517 | virtual void OnSetCastObject( COSNode *newcastobj ) |
1426 | 1518 | { |
1427 | 1519 | return; |
1428 | 1520 | } |
1521 | + virtual void OnUnsetCastObject( COSNode *newcastobj ) | |
1522 | + { | |
1523 | + return; | |
1524 | + } | |
1429 | 1525 | }; |
1430 | 1526 | |
1431 | 1527 | struct TemplateInstantiationOperation : public Operation |
@@ -1475,15 +1571,16 @@ | ||
1475 | 1571 | } |
1476 | 1572 | } |
1477 | 1573 | |
1478 | -private: | |
1574 | +protected: | |
1479 | 1575 | COSNode *templ; |
1480 | 1576 | cosCommonVector <COSNode*> tparams; |
1481 | 1577 | public: |
1482 | 1578 | inline void SetTemplate( COSNode *newtempl ) |
1483 | 1579 | { |
1484 | - TemplateSetEdge( newtempl, this->templ, tparams ); | |
1485 | - | |
1486 | - this->OnSetTemplate( newtempl ); | |
1580 | + TemplateSetEdge( newtempl, this->templ, | |
1581 | + std::bind( &TemplateInstantiationOperation::OnSetTemplate, this, std::placeholders::_1 ), std::bind( &TemplateInstantiationOperation::OnUnsetTemplate, this, std::placeholders::_1 ), | |
1582 | + tparams | |
1583 | + ); | |
1487 | 1584 | } |
1488 | 1585 | inline COSNode* GetTemplate( void ) const noexcept |
1489 | 1586 | { |
@@ -1525,10 +1622,18 @@ | ||
1525 | 1622 | { |
1526 | 1623 | return; |
1527 | 1624 | } |
1625 | + virtual void OnUnsetTemplate( COSNode *newtempl ) | |
1626 | + { | |
1627 | + return; | |
1628 | + } | |
1528 | 1629 | virtual void OnAddParam( COSNode *newparam ) |
1529 | 1630 | { |
1530 | 1631 | return; |
1531 | 1632 | } |
1633 | + virtual void OnRemoveParam( COSNode *newparam ) | |
1634 | + { | |
1635 | + return; | |
1636 | + } | |
1532 | 1637 | }; |
1533 | 1638 | |
1534 | 1639 | struct IfStatement : public COSNode |
@@ -1584,7 +1689,7 @@ | ||
1584 | 1689 | } |
1585 | 1690 | } |
1586 | 1691 | |
1587 | -private: | |
1692 | +protected: | |
1588 | 1693 | COSNode *condition; |
1589 | 1694 | COSNode *true_branch; |
1590 | 1695 | COSNode *false_branch; |
@@ -1591,9 +1696,10 @@ | ||
1591 | 1696 | public: |
1592 | 1697 | inline void SetCondition( COSNode *newcond ) |
1593 | 1698 | { |
1594 | - TemplateSetEdge( newcond, this->condition, true_branch, false_branch ); | |
1595 | - | |
1596 | - this->OnSetCondition( newcond ); | |
1699 | + TemplateSetEdge( newcond, this->condition, | |
1700 | + std::bind( &IfStatement::OnSetCondition, this, std::placeholders::_1 ), std::bind( &IfStatement::OnUnsetCondition, this, std::placeholders::_1 ), | |
1701 | + true_branch, false_branch | |
1702 | + ); | |
1597 | 1703 | } |
1598 | 1704 | inline COSNode* GetCondition( void ) const noexcept |
1599 | 1705 | { |
@@ -1601,9 +1707,10 @@ | ||
1601 | 1707 | } |
1602 | 1708 | inline void SetTrueBranch( COSNode *newtb ) |
1603 | 1709 | { |
1604 | - TemplateSetEdge( newtb, this->true_branch, condition, false_branch ); | |
1605 | - | |
1606 | - this->OnSetTrueBranch( newtb ); | |
1710 | + TemplateSetEdge( newtb, this->true_branch, | |
1711 | + std::bind( &IfStatement::OnSetTrueBranch, this, std::placeholders::_1 ), std::bind( &IfStatement::OnUnsetTrueBranch, this, std::placeholders::_1 ), | |
1712 | + condition, false_branch | |
1713 | + ); | |
1607 | 1714 | } |
1608 | 1715 | inline COSNode* GetTrueBranch( void ) const noexcept |
1609 | 1716 | { |
@@ -1611,9 +1718,10 @@ | ||
1611 | 1718 | } |
1612 | 1719 | inline void SetFalseBranch( COSNode *newfb ) |
1613 | 1720 | { |
1614 | - TemplateSetEdge( newfb, this->false_branch, condition, true_branch ); | |
1615 | - | |
1616 | - this->OnSetFalseBranch( newfb ); | |
1721 | + TemplateSetEdge( newfb, this->false_branch, | |
1722 | + std::bind( &IfStatement::OnSetFalseBranch, this, std::placeholders::_1 ), std::bind( &IfStatement::OnUnsetFalseBranch, this, std::placeholders::_1 ), | |
1723 | + condition, true_branch | |
1724 | + ); | |
1617 | 1725 | } |
1618 | 1726 | inline COSNode* GetFalseBranch( void ) const noexcept |
1619 | 1727 | { |
@@ -1624,14 +1732,26 @@ | ||
1624 | 1732 | { |
1625 | 1733 | return; |
1626 | 1734 | } |
1735 | + virtual void OnUnsetCondition( COSNode *newcond ) | |
1736 | + { | |
1737 | + return; | |
1738 | + } | |
1627 | 1739 | virtual void OnSetTrueBranch( COSNode *newtb ) |
1628 | 1740 | { |
1629 | 1741 | return; |
1630 | 1742 | } |
1743 | + virtual void OnUnsetTrueBranch( COSNode *newtb ) | |
1744 | + { | |
1745 | + return; | |
1746 | + } | |
1631 | 1747 | virtual void OnSetFalseBranch( COSNode *newfb ) |
1632 | 1748 | { |
1633 | 1749 | return; |
1634 | 1750 | } |
1751 | + virtual void OnUnsetFalseBranch( COSNode *newfb ) | |
1752 | + { | |
1753 | + return; | |
1754 | + } | |
1635 | 1755 | }; |
1636 | 1756 | struct WhileLoopStatement : public COSNode |
1637 | 1757 | { |
@@ -1680,15 +1800,16 @@ | ||
1680 | 1800 | } |
1681 | 1801 | } |
1682 | 1802 | |
1683 | -private: | |
1803 | +protected: | |
1684 | 1804 | COSNode *condition; |
1685 | 1805 | COSNode *exec; |
1686 | 1806 | public: |
1687 | 1807 | inline void SetCondition( COSNode *newcond ) |
1688 | 1808 | { |
1689 | - TemplateSetEdge( newcond, this->condition, exec ); | |
1690 | - | |
1691 | - this->OnSetCondition( newcond ); | |
1809 | + TemplateSetEdge( newcond, this->condition, | |
1810 | + std::bind( &WhileLoopStatement::OnSetCondition, this, std::placeholders::_1 ), std::bind( &WhileLoopStatement::OnUnsetCondition, this, std::placeholders::_1 ), | |
1811 | + exec | |
1812 | + ); | |
1692 | 1813 | } |
1693 | 1814 | inline COSNode* GetCondition( void ) const noexcept |
1694 | 1815 | { |
@@ -1696,9 +1817,10 @@ | ||
1696 | 1817 | } |
1697 | 1818 | inline void SetExec( COSNode *newexec ) |
1698 | 1819 | { |
1699 | - TemplateSetEdge( newexec, this->exec, condition ); | |
1700 | - | |
1701 | - this->OnSetExec( newexec ); | |
1820 | + TemplateSetEdge( newexec, this->exec, | |
1821 | + std::bind( &WhileLoopStatement::OnSetExec, this, std::placeholders::_1 ), std::bind( &WhileLoopStatement::OnUnsetExec, this, std::placeholders::_1 ), | |
1822 | + condition | |
1823 | + ); | |
1702 | 1824 | } |
1703 | 1825 | inline COSNode* GetExec( void ) const noexcept |
1704 | 1826 | { |
@@ -1709,10 +1831,18 @@ | ||
1709 | 1831 | { |
1710 | 1832 | return; |
1711 | 1833 | } |
1834 | + virtual void OnUnsetCondition( COSNode *newcond ) | |
1835 | + { | |
1836 | + return; | |
1837 | + } | |
1712 | 1838 | virtual void OnSetExec( COSNode *newexec ) |
1713 | 1839 | { |
1714 | 1840 | return; |
1715 | 1841 | } |
1842 | + virtual void OnUnsetExec( COSNode *newexec ) | |
1843 | + { | |
1844 | + return; | |
1845 | + } | |
1716 | 1846 | }; |
1717 | 1847 | struct ForLoopStatement : public COSNode |
1718 | 1848 | { |
@@ -1774,7 +1904,7 @@ | ||
1774 | 1904 | } |
1775 | 1905 | } |
1776 | 1906 | |
1777 | -private: | |
1907 | +protected: | |
1778 | 1908 | COSNode *init; |
1779 | 1909 | COSNode *condition; |
1780 | 1910 | COSNode *iteration; |
@@ -1782,9 +1912,10 @@ | ||
1782 | 1912 | public: |
1783 | 1913 | inline void SetInit( COSNode *newinit ) |
1784 | 1914 | { |
1785 | - TemplateSetEdge( newinit, this->init, condition, iteration, exec ); | |
1786 | - | |
1787 | - this->OnSetInit( newinit ); | |
1915 | + TemplateSetEdge( newinit, this->init, | |
1916 | + std::bind( &ForLoopStatement::OnSetInit, this, std::placeholders::_1 ), std::bind( &ForLoopStatement::OnUnsetInit, this, std::placeholders::_1 ), | |
1917 | + condition, iteration, exec | |
1918 | + ); | |
1788 | 1919 | } |
1789 | 1920 | inline COSNode* GetInit( void ) const noexcept |
1790 | 1921 | { |
@@ -1792,9 +1923,10 @@ | ||
1792 | 1923 | } |
1793 | 1924 | inline void SetCondition( COSNode *newcond ) |
1794 | 1925 | { |
1795 | - TemplateSetEdge( newcond, this->condition, init, iteration, exec ); | |
1796 | - | |
1797 | - this->OnSetCondition( newcond ); | |
1926 | + TemplateSetEdge( newcond, this->condition, | |
1927 | + std::bind( &ForLoopStatement::OnSetCondition, this, std::placeholders::_1 ), std::bind( &ForLoopStatement::OnUnsetCondition, this, std::placeholders::_1 ), | |
1928 | + init, iteration, exec | |
1929 | + ); | |
1798 | 1930 | } |
1799 | 1931 | inline COSNode* GetCondition( void ) const noexcept |
1800 | 1932 | { |
@@ -1802,9 +1934,10 @@ | ||
1802 | 1934 | } |
1803 | 1935 | inline void SetIteration( COSNode *newiter ) |
1804 | 1936 | { |
1805 | - TemplateSetEdge( newiter, this->iteration, init, condition, exec ); | |
1806 | - | |
1807 | - this->OnSetIteration( newiter ); | |
1937 | + TemplateSetEdge( newiter, this->iteration, | |
1938 | + std::bind( &ForLoopStatement::OnSetIteration, this, std::placeholders::_1 ), std::bind( &ForLoopStatement::OnUnsetIteration, this, std::placeholders::_1 ), | |
1939 | + init, condition, exec | |
1940 | + ); | |
1808 | 1941 | } |
1809 | 1942 | inline COSNode* GetIteration( void ) const noexcept |
1810 | 1943 | { |
@@ -1812,9 +1945,10 @@ | ||
1812 | 1945 | } |
1813 | 1946 | inline void SetExec( COSNode *newexec ) |
1814 | 1947 | { |
1815 | - TemplateSetEdge( newexec, this->exec, init, condition, iteration ); | |
1816 | - | |
1817 | - this->OnSetExec( newexec ); | |
1948 | + TemplateSetEdge( newexec, this->exec, | |
1949 | + std::bind( &ForLoopStatement::OnSetExec, this, std::placeholders::_1 ), std::bind( &ForLoopStatement::OnUnsetExec, this, std::placeholders::_1 ), | |
1950 | + init, condition, iteration | |
1951 | + ); | |
1818 | 1952 | } |
1819 | 1953 | inline COSNode* GetExec( void ) const noexcept |
1820 | 1954 | { |
@@ -1825,18 +1959,34 @@ | ||
1825 | 1959 | { |
1826 | 1960 | return; |
1827 | 1961 | } |
1962 | + virtual void OnUnsetInit( COSNode *newinit ) | |
1963 | + { | |
1964 | + return; | |
1965 | + } | |
1828 | 1966 | virtual void OnSetCondition( COSNode *newcond ) |
1829 | 1967 | { |
1830 | 1968 | return; |
1831 | 1969 | } |
1970 | + virtual void OnUnsetCondition( COSNode *newcond ) | |
1971 | + { | |
1972 | + return; | |
1973 | + } | |
1832 | 1974 | virtual void OnSetIteration( COSNode *newiter ) |
1833 | 1975 | { |
1834 | 1976 | return; |
1835 | 1977 | } |
1978 | + virtual void OnUnsetIteration( COSNode *newiter ) | |
1979 | + { | |
1980 | + return; | |
1981 | + } | |
1836 | 1982 | virtual void OnSetExec( COSNode *newexec ) |
1837 | 1983 | { |
1838 | 1984 | return; |
1839 | 1985 | } |
1986 | + virtual void OnUnsetExec( COSNode *newexec ) | |
1987 | + { | |
1988 | + return; | |
1989 | + } | |
1840 | 1990 | }; |
1841 | 1991 | struct ContinueStatement : public COSNode |
1842 | 1992 | { |
@@ -1891,14 +2041,14 @@ | ||
1891 | 2041 | } |
1892 | 2042 | } |
1893 | 2043 | |
1894 | -private: | |
2044 | +protected: | |
1895 | 2045 | COSNode *op; |
1896 | 2046 | public: |
1897 | 2047 | inline void SetNode( COSNode *newop ) |
1898 | 2048 | { |
1899 | - TemplateSetEdge( newop, this->op ); | |
1900 | - | |
1901 | - this->OnSetNode( newop ); | |
2049 | + TemplateSetEdge( newop, this->op, | |
2050 | + std::bind( &ReturnStatement::OnSetNode, this, std::placeholders::_1 ), std::bind( &ReturnStatement::OnUnsetNode, this, std::placeholders::_1 ) | |
2051 | + ); | |
1902 | 2052 | } |
1903 | 2053 | inline COSNode* GetNode( void ) const noexcept |
1904 | 2054 | { |
@@ -1909,6 +2059,10 @@ | ||
1909 | 2059 | { |
1910 | 2060 | return; |
1911 | 2061 | } |
2062 | + virtual void OnUnsetNode( COSNode *newop ) | |
2063 | + { | |
2064 | + return; | |
2065 | + } | |
1912 | 2066 | }; |
1913 | 2067 | |
1914 | 2068 | // No-op. |
@@ -1971,7 +2125,7 @@ | ||
1971 | 2125 | } |
1972 | 2126 | } |
1973 | 2127 | |
1974 | -private: | |
2128 | +protected: | |
1975 | 2129 | COSNode *name; |
1976 | 2130 | COSNode *type; |
1977 | 2131 | COSNode *initializer; |
@@ -1978,9 +2132,10 @@ | ||
1978 | 2132 | public: |
1979 | 2133 | inline void SetName( COSNode *newname ) |
1980 | 2134 | { |
1981 | - TemplateSetEdge( newname, this->name, type, initializer ); | |
1982 | - | |
1983 | - this->OnSetName( newname ); | |
2135 | + TemplateSetEdge( newname, this->name, | |
2136 | + std::bind( &DeclarationStatement::OnSetName, this, std::placeholders::_1 ), std::bind( &DeclarationStatement::OnUnsetName, this, std::placeholders::_1 ), | |
2137 | + type, initializer | |
2138 | + ); | |
1984 | 2139 | } |
1985 | 2140 | inline COSNode* GetName( void ) const noexcept |
1986 | 2141 | { |
@@ -1988,9 +2143,10 @@ | ||
1988 | 2143 | } |
1989 | 2144 | inline void SetType( COSNode *newtype ) |
1990 | 2145 | { |
1991 | - TemplateSetEdge( newtype, this->type, name, initializer ); | |
1992 | - | |
1993 | - this->OnSetType( newtype ); | |
2146 | + TemplateSetEdge( newtype, this->type, | |
2147 | + std::bind( &DeclarationStatement::OnSetType, this, std::placeholders::_1 ), std::bind( &DeclarationStatement::OnUnsetType, this, std::placeholders::_1 ), | |
2148 | + name, initializer | |
2149 | + ); | |
1994 | 2150 | } |
1995 | 2151 | inline COSNode* GetType( void ) const noexcept |
1996 | 2152 | { |
@@ -1998,9 +2154,10 @@ | ||
1998 | 2154 | } |
1999 | 2155 | inline void SetInitializer( COSNode *newinit ) |
2000 | 2156 | { |
2001 | - TemplateSetEdge( newinit, this->initializer, name, type ); | |
2002 | - | |
2003 | - this->OnSetInitializer( newinit ); | |
2157 | + TemplateSetEdge( newinit, this->initializer, | |
2158 | + std::bind( &DeclarationStatement::OnSetInitializer, this, std::placeholders::_1 ), std::bind( &DeclarationStatement::OnUnsetInitializer, this, std::placeholders::_1 ), | |
2159 | + name, type | |
2160 | + ); | |
2004 | 2161 | } |
2005 | 2162 | inline COSNode* GetInitializer( void ) const noexcept |
2006 | 2163 | { |
@@ -2011,14 +2168,26 @@ | ||
2011 | 2168 | { |
2012 | 2169 | return; |
2013 | 2170 | } |
2171 | + virtual void OnUnsetName( COSNode *newname ) | |
2172 | + { | |
2173 | + return; | |
2174 | + } | |
2014 | 2175 | virtual void OnSetType( COSNode *newtype ) |
2015 | 2176 | { |
2016 | 2177 | return; |
2017 | 2178 | } |
2179 | + virtual void OnUnsetType( COSNode *newtype ) | |
2180 | + { | |
2181 | + return; | |
2182 | + } | |
2018 | 2183 | virtual void OnSetInitializer( COSNode *newinit ) |
2019 | 2184 | { |
2020 | 2185 | return; |
2021 | 2186 | } |
2187 | + virtual void OnUnsetInitializer( COSNode *newinit ) | |
2188 | + { | |
2189 | + return; | |
2190 | + } | |
2022 | 2191 | }; |
2023 | 2192 | struct MultiDeclarationStatement : public COSNode |
2024 | 2193 | { |
@@ -2065,7 +2234,7 @@ | ||
2065 | 2234 | } |
2066 | 2235 | } |
2067 | 2236 | |
2068 | -private: | |
2237 | +protected: | |
2069 | 2238 | cosCommonVector <DeclarationStatement*> decls; |
2070 | 2239 | public: |
2071 | 2240 | inline void AddDeclaration( DeclarationStatement *newdecl ) |
@@ -2100,10 +2269,14 @@ | ||
2100 | 2269 | return decls.GetCount(); |
2101 | 2270 | } |
2102 | 2271 | protected: |
2103 | - virtual void OnAddDeclaration( DeclarationStatement *newdecl ) | |
2272 | + virtual void OnAddDeclaration( COSNode *newdecl ) | |
2104 | 2273 | { |
2105 | 2274 | return; |
2106 | 2275 | } |
2276 | + virtual void OnRemoveDeclaration( COSNode *newdecl ) | |
2277 | + { | |
2278 | + return; | |
2279 | + } | |
2107 | 2280 | }; |
2108 | 2281 | |
2109 | 2282 | struct TypedefStatement : public COSNode |
@@ -2153,15 +2326,16 @@ | ||
2153 | 2326 | } |
2154 | 2327 | } |
2155 | 2328 | |
2156 | -private: | |
2329 | +protected: | |
2157 | 2330 | COSNode *srctype; |
2158 | 2331 | COSNode *dsttype; |
2159 | 2332 | public: |
2160 | 2333 | inline void SetSrcType( COSNode *newsrctype ) |
2161 | 2334 | { |
2162 | - TemplateSetEdge( newsrctype, this->srctype, dsttype ); | |
2163 | - | |
2164 | - this->OnSetSrcType( newsrctype ); | |
2335 | + TemplateSetEdge( newsrctype, this->srctype, | |
2336 | + std::bind( &TypedefStatement::OnSetSrcType, this, std::placeholders::_1 ), std::bind( &TypedefStatement::OnUnsetSrcType, this, std::placeholders::_1 ), | |
2337 | + dsttype | |
2338 | + ); | |
2165 | 2339 | } |
2166 | 2340 | inline COSNode* GetSrcType( void ) const noexcept |
2167 | 2341 | { |
@@ -2169,9 +2343,10 @@ | ||
2169 | 2343 | } |
2170 | 2344 | inline void SetDstType( COSNode *newdsttype ) |
2171 | 2345 | { |
2172 | - TemplateSetEdge( newdsttype, this->dsttype, srctype ); | |
2173 | - | |
2174 | - this->OnSetDstType( newdsttype ); | |
2346 | + TemplateSetEdge( newdsttype, this->dsttype, | |
2347 | + std::bind( &TypedefStatement::OnSetDstType, this, std::placeholders::_1 ), std::bind( &TypedefStatement::OnUnsetDstType, this, std::placeholders::_1 ), | |
2348 | + srctype | |
2349 | + ); | |
2175 | 2350 | } |
2176 | 2351 | inline COSNode* GetDstType( void ) const noexcept |
2177 | 2352 | { |
@@ -2182,10 +2357,18 @@ | ||
2182 | 2357 | { |
2183 | 2358 | return; |
2184 | 2359 | } |
2360 | + virtual void OnUnsetSrcType( COSNode *newsrctype ) | |
2361 | + { | |
2362 | + return; | |
2363 | + } | |
2185 | 2364 | virtual void OnSetDstType( COSNode *newdsttype ) |
2186 | 2365 | { |
2187 | 2366 | return; |
2188 | 2367 | } |
2368 | + virtual void OnUnsetDstType( COSNode *newdsttype ) | |
2369 | + { | |
2370 | + return; | |
2371 | + } | |
2189 | 2372 | }; |
2190 | 2373 | struct MultiTypedefStatement : public COSNode |
2191 | 2374 | { |
@@ -2230,7 +2413,7 @@ | ||
2230 | 2413 | } |
2231 | 2414 | } |
2232 | 2415 | |
2233 | -private: | |
2416 | +protected: | |
2234 | 2417 | cosCommonVector <TypedefStatement*> defs; |
2235 | 2418 | public: |
2236 | 2419 | inline void AddTypedef( TypedefStatement *newtypedef ) |
@@ -2265,10 +2448,14 @@ | ||
2265 | 2448 | return this->defs.GetCount(); |
2266 | 2449 | } |
2267 | 2450 | protected: |
2268 | - virtual void OnAddTypedef( TypedefStatement *newtypedef ) | |
2451 | + virtual void OnAddTypedef( COSNode *newtypedef ) | |
2269 | 2452 | { |
2270 | 2453 | return; |
2271 | 2454 | } |
2455 | + virtual void OnRemoveTypedef( COSNode *newtypedef ) | |
2456 | + { | |
2457 | + return; | |
2458 | + } | |
2272 | 2459 | }; |
2273 | 2460 | |
2274 | 2461 | struct BlockStatement : public COSNode |
@@ -2311,7 +2498,7 @@ | ||
2311 | 2498 | } |
2312 | 2499 | } |
2313 | 2500 | |
2314 | -private: | |
2501 | +protected: | |
2315 | 2502 | cosCommonVector <COSNode*> statements; |
2316 | 2503 | public: |
2317 | 2504 | inline void AddStatement( COSNode *stmt ) |
@@ -2350,6 +2537,10 @@ | ||
2350 | 2537 | { |
2351 | 2538 | return; |
2352 | 2539 | } |
2540 | + virtual void OnRemoveStatement( COSNode *stmt ) | |
2541 | + { | |
2542 | + return; | |
2543 | + } | |
2353 | 2544 | }; |
2354 | 2545 | |
2355 | 2546 | struct ThrowStatement : public COSNode |
@@ -2396,14 +2587,14 @@ | ||
2396 | 2587 | } |
2397 | 2588 | } |
2398 | 2589 | |
2399 | -private: | |
2590 | +protected: | |
2400 | 2591 | COSNode *op; |
2401 | 2592 | public: |
2402 | 2593 | inline void SetNode( COSNode *newop ) |
2403 | 2594 | { |
2404 | - TemplateSetEdge( newop, this->op ); | |
2405 | - | |
2406 | - this->OnSetNode( newop ); | |
2595 | + TemplateSetEdge( newop, this->op, | |
2596 | + std::bind( &ThrowStatement::OnSetNode, this, std::placeholders::_1 ), std::bind( &ThrowStatement::OnUnsetNode, this, std::placeholders::_1 ) | |
2597 | + ); | |
2407 | 2598 | } |
2408 | 2599 | inline COSNode* GetNode( void ) const noexcept |
2409 | 2600 | { |
@@ -2414,6 +2605,10 @@ | ||
2414 | 2605 | { |
2415 | 2606 | return; |
2416 | 2607 | } |
2608 | + virtual void OnUnsetNode( COSNode *newop ) | |
2609 | + { | |
2610 | + return; | |
2611 | + } | |
2417 | 2612 | }; |
2418 | 2613 | struct CatchStatement : public COSNode |
2419 | 2614 | { |
@@ -2462,15 +2657,16 @@ | ||
2462 | 2657 | } |
2463 | 2658 | } |
2464 | 2659 | |
2465 | -private: | |
2660 | +protected: | |
2466 | 2661 | COSNode *caught_decl; |
2467 | 2662 | COSNode *catch_body; |
2468 | 2663 | public: |
2469 | 2664 | inline void SetCaughtDecl( COSNode *newcdecl ) |
2470 | 2665 | { |
2471 | - TemplateSetEdge( newcdecl, this->caught_decl, catch_body ); | |
2472 | - | |
2473 | - this->OnSetCaughtDecl( newcdecl ); | |
2666 | + TemplateSetEdge( newcdecl, this->caught_decl, | |
2667 | + std::bind( &CatchStatement::OnSetCaughtDecl, this, std::placeholders::_1 ), std::bind( &CatchStatement::OnUnsetCaughtDecl, this, std::placeholders::_1 ), | |
2668 | + catch_body | |
2669 | + ); | |
2474 | 2670 | } |
2475 | 2671 | inline COSNode* GetCaughtDecl( void ) const noexcept |
2476 | 2672 | { |
@@ -2478,9 +2674,10 @@ | ||
2478 | 2674 | } |
2479 | 2675 | inline void SetCatchBody( COSNode *newcbody ) |
2480 | 2676 | { |
2481 | - TemplateSetEdge( newcbody, this->catch_body, caught_decl ); | |
2482 | - | |
2483 | - this->OnSetCatchBody( newcbody ); | |
2677 | + TemplateSetEdge( newcbody, this->catch_body, | |
2678 | + std::bind( &CatchStatement::OnSetCatchBody, this, std::placeholders::_1 ), std::bind( &CatchStatement::OnUnsetCatchBody, this, std::placeholders::_1 ), | |
2679 | + caught_decl | |
2680 | + ); | |
2484 | 2681 | } |
2485 | 2682 | inline COSNode* GetCatchBody( void ) const noexcept |
2486 | 2683 | { |
@@ -2491,10 +2688,18 @@ | ||
2491 | 2688 | { |
2492 | 2689 | return; |
2493 | 2690 | } |
2691 | + virtual void OnUnsetCaughtDecl( COSNode *newcdecl ) | |
2692 | + { | |
2693 | + return; | |
2694 | + } | |
2494 | 2695 | virtual void OnSetCatchBody( COSNode *newcbody ) |
2495 | 2696 | { |
2496 | 2697 | return; |
2497 | 2698 | } |
2699 | + virtual void OnUnsetCatchBody( COSNode *newcbody ) | |
2700 | + { | |
2701 | + return; | |
2702 | + } | |
2498 | 2703 | }; |
2499 | 2704 | struct TryStatement : public COSNode |
2500 | 2705 | { |
@@ -2550,15 +2755,16 @@ | ||
2550 | 2755 | } |
2551 | 2756 | } |
2552 | 2757 | |
2553 | -private: | |
2758 | +protected: | |
2554 | 2759 | COSNode *try_body; |
2555 | 2760 | cosCommonVector <CatchStatement*> errors; |
2556 | 2761 | public: |
2557 | 2762 | inline void SetTryBody( COSNode *newbody ) |
2558 | 2763 | { |
2559 | - TemplateSetEdge( newbody, this->try_body, errors ); | |
2560 | - | |
2561 | - this->OnSetTryBody( newbody ); | |
2764 | + TemplateSetEdge( newbody, this->try_body, | |
2765 | + std::bind( &TryStatement::OnSetTryBody, this, std::placeholders::_1 ), std::bind( &TryStatement::OnUnsetTryBody, this, std::placeholders::_1 ), | |
2766 | + errors | |
2767 | + ); | |
2562 | 2768 | } |
2563 | 2769 | inline COSNode* GetTryBody( void ) const noexcept |
2564 | 2770 | { |
@@ -2600,10 +2806,18 @@ | ||
2600 | 2806 | { |
2601 | 2807 | return; |
2602 | 2808 | } |
2603 | - virtual void OnAddError( CatchStatement *newerror ) | |
2809 | + virtual void OnUnsetTryBody( COSNode *newbody ) | |
2604 | 2810 | { |
2605 | 2811 | return; |
2606 | 2812 | } |
2813 | + virtual void OnAddError( COSNode *newerror ) | |
2814 | + { | |
2815 | + return; | |
2816 | + } | |
2817 | + virtual void OnRemoveError( COSNode *newerror ) | |
2818 | + { | |
2819 | + return; | |
2820 | + } | |
2607 | 2821 | }; |
2608 | 2822 | |
2609 | 2823 | struct StructDefinition : public COSNode |
@@ -2653,15 +2867,16 @@ | ||
2653 | 2867 | } |
2654 | 2868 | } |
2655 | 2869 | |
2656 | -private: | |
2870 | +protected: | |
2657 | 2871 | COSNode *name; |
2658 | 2872 | COSNode *body; |
2659 | 2873 | public: |
2660 | 2874 | inline void SetName( COSNode *newname ) |
2661 | 2875 | { |
2662 | - TemplateSetEdge( newname, this->name, body ); | |
2663 | - | |
2664 | - this->OnSetName( newname ); | |
2876 | + TemplateSetEdge( newname, this->name, | |
2877 | + std::bind( &StructDefinition::OnSetName, this, std::placeholders::_1 ), std::bind( &StructDefinition::OnUnsetName, this, std::placeholders::_1 ), | |
2878 | + body | |
2879 | + ); | |
2665 | 2880 | } |
2666 | 2881 | inline COSNode* GetName( void ) const noexcept |
2667 | 2882 | { |
@@ -2669,9 +2884,10 @@ | ||
2669 | 2884 | } |
2670 | 2885 | inline void SetBody( COSNode *newbody ) |
2671 | 2886 | { |
2672 | - TemplateSetEdge( newbody, this->body, name ); | |
2673 | - | |
2674 | - this->OnSetBody( newbody ); | |
2887 | + TemplateSetEdge( newbody, this->body, | |
2888 | + std::bind( &StructDefinition::OnSetBody, this, std::placeholders::_1 ), std::bind( &StructDefinition::OnUnsetBody, this, std::placeholders::_1 ), | |
2889 | + name | |
2890 | + ); | |
2675 | 2891 | } |
2676 | 2892 | inline COSNode* GetBody( void ) const noexcept |
2677 | 2893 | { |
@@ -2682,10 +2898,18 @@ | ||
2682 | 2898 | { |
2683 | 2899 | return; |
2684 | 2900 | } |
2901 | + virtual void OnUnsetName( COSNode *newname ) | |
2902 | + { | |
2903 | + return; | |
2904 | + } | |
2685 | 2905 | virtual void OnSetBody( COSNode *newbody ) |
2686 | 2906 | { |
2687 | 2907 | return; |
2688 | 2908 | } |
2909 | + virtual void OnUnsetBody( COSNode *newbody ) | |
2910 | + { | |
2911 | + return; | |
2912 | + } | |
2689 | 2913 | }; |
2690 | 2914 | struct ConstructorDefinition : public COSNode |
2691 | 2915 | { |
@@ -2733,7 +2957,7 @@ | ||
2733 | 2957 | } |
2734 | 2958 | } |
2735 | 2959 | |
2736 | -private: | |
2960 | +protected: | |
2737 | 2961 | cosCommonVector <COSNode*> params; |
2738 | 2962 | COSNode *body; |
2739 | 2963 | public: |
@@ -2770,9 +2994,10 @@ | ||
2770 | 2994 | } |
2771 | 2995 | inline void SetBody( COSNode *newbody ) |
2772 | 2996 | { |
2773 | - TemplateSetEdge( newbody, this->body, params ); | |
2774 | - | |
2775 | - this->OnSetBody( newbody ); | |
2997 | + TemplateSetEdge( newbody, this->body, | |
2998 | + std::bind( &ConstructorDefinition::OnSetBody, this, std::placeholders::_1 ), std::bind( &ConstructorDefinition::OnUnsetBody, this, std::placeholders::_1 ), | |
2999 | + params | |
3000 | + ); | |
2776 | 3001 | } |
2777 | 3002 | inline COSNode* GetBody( void ) const noexcept |
2778 | 3003 | { |
@@ -2783,10 +3008,18 @@ | ||
2783 | 3008 | { |
2784 | 3009 | return; |
2785 | 3010 | } |
3011 | + virtual void OnRemoveParam( COSNode *newparam ) | |
3012 | + { | |
3013 | + return; | |
3014 | + } | |
2786 | 3015 | virtual void OnSetBody( COSNode *newbody ) |
2787 | 3016 | { |
2788 | 3017 | return; |
2789 | 3018 | } |
3019 | + virtual void OnUnsetBody( COSNode *newbody ) | |
3020 | + { | |
3021 | + return; | |
3022 | + } | |
2790 | 3023 | }; |
2791 | 3024 | struct DestructorDefinition : public COSNode |
2792 | 3025 | { |
@@ -2833,14 +3066,14 @@ | ||
2833 | 3066 | } |
2834 | 3067 | } |
2835 | 3068 | |
2836 | -private: | |
3069 | +protected: | |
2837 | 3070 | COSNode *body; |
2838 | 3071 | public: |
2839 | 3072 | inline void SetBody( COSNode *newbody ) |
2840 | 3073 | { |
2841 | - TemplateSetEdge( newbody, this->body ); | |
2842 | - | |
2843 | - this->OnSetBody( newbody ); | |
3074 | + TemplateSetEdge( newbody, this->body, | |
3075 | + std::bind( &DestructorDefinition::OnSetBody, this, std::placeholders::_1 ), std::bind( &DestructorDefinition::OnUnsetBody, this, std::placeholders::_1 ) | |
3076 | + ); | |
2844 | 3077 | } |
2845 | 3078 | inline COSNode* GetBody( void ) const noexcept |
2846 | 3079 | { |
@@ -2851,6 +3084,10 @@ | ||
2851 | 3084 | { |
2852 | 3085 | return; |
2853 | 3086 | } |
3087 | + virtual void OnUnsetBody( COSNode *newbody ) | |
3088 | + { | |
3089 | + return; | |
3090 | + } | |
2854 | 3091 | }; |
2855 | 3092 | |
2856 | 3093 | struct Literal : public COSNode |
@@ -3086,9 +3323,9 @@ | ||
3086 | 3323 | public: |
3087 | 3324 | inline void SetSpec( COSNode *newspec ) |
3088 | 3325 | { |
3089 | - TemplateSetDynamicEdge( newspec, this->spec ); | |
3090 | - | |
3091 | - this->OnSetSpec( newspec ); | |
3326 | + TemplateSetDynamicEdge( newspec, this->spec, | |
3327 | + std::bind( &TypeSpecifier::OnSetSpec, this, std::placeholders::_1 ), std::bind( &TypeSpecifier::OnUnsetSpec, this, std::placeholders::_1 ) | |
3328 | + ); | |
3092 | 3329 | } |
3093 | 3330 | inline COSNode* GetSpec( void ) const noexcept |
3094 | 3331 | { |
@@ -3099,6 +3336,10 @@ | ||
3099 | 3336 | { |
3100 | 3337 | return; |
3101 | 3338 | } |
3339 | + virtual void OnUnsetSpec( COSNode *newspec ) | |
3340 | + { | |
3341 | + return; | |
3342 | + } | |
3102 | 3343 | }; |
3103 | 3344 | struct PointerTypeSpecifier : public TypeSpecifier |
3104 | 3345 | { |
@@ -3151,14 +3392,14 @@ | ||
3151 | 3392 | } |
3152 | 3393 | } |
3153 | 3394 | |
3154 | -private: | |
3395 | +protected: | |
3155 | 3396 | COSNode *array_size_op; |
3156 | 3397 | public: |
3157 | 3398 | inline void SetArraySizeOp( COSNode *newsizeop ) |
3158 | 3399 | { |
3159 | - TemplateSetDynamicEdge( newsizeop, this->array_size_op ); | |
3160 | - | |
3161 | - this->OnSetArraySizeOp( newsizeop ); | |
3400 | + TemplateSetDynamicEdge( newsizeop, this->array_size_op, | |
3401 | + std::bind( &ArrayTypeSpecifier::OnSetArraySizeOp, this, std::placeholders::_1 ), std::bind( &ArrayTypeSpecifier::OnUnsetArraySizeOp, this, std::placeholders::_1 ) | |
3402 | + ); | |
3162 | 3403 | } |
3163 | 3404 | inline COSNode* GetArraySizeOp( void ) const noexcept |
3164 | 3405 | { |
@@ -3169,6 +3410,10 @@ | ||
3169 | 3410 | { |
3170 | 3411 | return; |
3171 | 3412 | } |
3413 | + virtual void OnUnsetArraySizeOp( COSNode *newsizeop ) | |
3414 | + { | |
3415 | + return; | |
3416 | + } | |
3172 | 3417 | }; |
3173 | 3418 | |
3174 | 3419 | struct CurlyPack : public COSNode |
@@ -3210,7 +3455,7 @@ | ||
3210 | 3455 | } |
3211 | 3456 | } |
3212 | 3457 | |
3213 | -private: | |
3458 | +protected: | |
3214 | 3459 | cosCommonVector <COSNode*> params; |
3215 | 3460 | public: |
3216 | 3461 | inline void AddParam( COSNode *newparam ) |
@@ -3249,6 +3494,10 @@ | ||
3249 | 3494 | { |
3250 | 3495 | return; |
3251 | 3496 | } |
3497 | + virtual void OnRemoveParam( COSNode *newparam ) | |
3498 | + { | |
3499 | + return; | |
3500 | + } | |
3252 | 3501 | }; |
3253 | 3502 | struct ArrayDefinition : public COSNode |
3254 | 3503 | { |
@@ -3291,7 +3540,7 @@ | ||
3291 | 3540 | } |
3292 | 3541 | } |
3293 | 3542 | |
3294 | -private: | |
3543 | +protected: | |
3295 | 3544 | cosCommonVector <COSNode*> items; |
3296 | 3545 | public: |
3297 | 3546 | inline void AddItem( COSNode *newitem ) |
@@ -3330,6 +3579,10 @@ | ||
3330 | 3579 | { |
3331 | 3580 | return; |
3332 | 3581 | } |
3582 | + virtual void OnRemoveItem( COSNode *newitem ) | |
3583 | + { | |
3584 | + return; | |
3585 | + } | |
3333 | 3586 | }; |
3334 | 3587 | struct FuncsigDefinition : public COSNode |
3335 | 3588 | { |
@@ -3389,15 +3642,16 @@ | ||
3389 | 3642 | } |
3390 | 3643 | } |
3391 | 3644 | |
3392 | -private: | |
3645 | +protected: | |
3393 | 3646 | COSNode *return_type; |
3394 | 3647 | cosCommonVector <COSNode*> params; |
3395 | 3648 | public: |
3396 | 3649 | inline void SetReturnType( COSNode *newrtype ) |
3397 | 3650 | { |
3398 | - TemplateSetEdge( newrtype, this->return_type, params ); | |
3399 | - | |
3400 | - this->OnSetReturnType( newrtype ); | |
3651 | + TemplateSetEdge( newrtype, this->return_type, | |
3652 | + std::bind( &FuncsigDefinition::OnSetReturnType, this, std::placeholders::_1 ), std::bind( &FuncsigDefinition::OnUnsetReturnType, this, std::placeholders::_1 ), | |
3653 | + params | |
3654 | + ); | |
3401 | 3655 | } |
3402 | 3656 | inline COSNode* GetReturnType( void ) const noexcept |
3403 | 3657 | { |
@@ -3439,10 +3693,18 @@ | ||
3439 | 3693 | { |
3440 | 3694 | return; |
3441 | 3695 | } |
3696 | + virtual void OnUnsetReturnType( COSNode *newrtype ) | |
3697 | + { | |
3698 | + return; | |
3699 | + } | |
3442 | 3700 | virtual void OnAddParam( COSNode *newparam ) |
3443 | 3701 | { |
3444 | 3702 | return; |
3445 | 3703 | } |
3704 | + virtual void OnRemoveParam( COSNode *newparam ) | |
3705 | + { | |
3706 | + return; | |
3707 | + } | |
3446 | 3708 | }; |
3447 | 3709 | |
3448 | 3710 | struct NamespaceStatement : public COSNode |
@@ -3492,15 +3754,16 @@ | ||
3492 | 3754 | } |
3493 | 3755 | } |
3494 | 3756 | |
3495 | -private: | |
3757 | +protected: | |
3496 | 3758 | COSNode *name; |
3497 | 3759 | COSNode *toinclude; |
3498 | 3760 | public: |
3499 | 3761 | inline void SetName( COSNode *newname ) |
3500 | 3762 | { |
3501 | - TemplateSetEdge( newname, this->name, toinclude ); | |
3502 | - | |
3503 | - this->OnSetName( newname ); | |
3763 | + TemplateSetEdge( newname, this->name, | |
3764 | + std::bind( &NamespaceStatement::OnSetName, this, std::placeholders::_1 ), std::bind( &NamespaceStatement::OnUnsetName, this, std::placeholders::_1 ), | |
3765 | + toinclude | |
3766 | + ); | |
3504 | 3767 | } |
3505 | 3768 | inline COSNode* GetName( void ) const noexcept |
3506 | 3769 | { |
@@ -3508,9 +3771,10 @@ | ||
3508 | 3771 | } |
3509 | 3772 | inline void SetToInclude( COSNode *newtoinclude ) |
3510 | 3773 | { |
3511 | - TemplateSetEdge( newtoinclude, this->toinclude, name ); | |
3512 | - | |
3513 | - this->OnSetToInclude( newtoinclude ); | |
3774 | + TemplateSetEdge( newtoinclude, this->toinclude, | |
3775 | + std::bind( &NamespaceStatement::OnSetToInclude, this, std::placeholders::_1 ), std::bind( &NamespaceStatement::OnUnsetToInclude, this, std::placeholders::_1 ), | |
3776 | + name | |
3777 | + ); | |
3514 | 3778 | } |
3515 | 3779 | inline COSNode* GetToInclude( void ) const noexcept |
3516 | 3780 | { |
@@ -3521,10 +3785,18 @@ | ||
3521 | 3785 | { |
3522 | 3786 | return; |
3523 | 3787 | } |
3788 | + virtual void OnUnsetName( COSNode *newname ) | |
3789 | + { | |
3790 | + return; | |
3791 | + } | |
3524 | 3792 | virtual void OnSetToInclude( COSNode *newtoinclude ) |
3525 | 3793 | { |
3526 | 3794 | return; |
3527 | 3795 | } |
3796 | + virtual void OnUnsetToInclude( COSNode *newtoinclude ) | |
3797 | + { | |
3798 | + return; | |
3799 | + } | |
3528 | 3800 | }; |
3529 | 3801 | struct UsingNamespaceStatement : public COSNode |
3530 | 3802 | { |
@@ -3570,14 +3842,14 @@ | ||
3570 | 3842 | } |
3571 | 3843 | } |
3572 | 3844 | |
3573 | -private: | |
3845 | +protected: | |
3574 | 3846 | COSNode *nsname; |
3575 | 3847 | public: |
3576 | 3848 | inline void SetName( COSNode *newnsname ) |
3577 | 3849 | { |
3578 | - TemplateSetEdge( newnsname, this->nsname ); | |
3579 | - | |
3580 | - this->OnSetName( newnsname ); | |
3850 | + TemplateSetEdge( newnsname, this->nsname, | |
3851 | + std::bind( &UsingNamespaceStatement::OnSetName, this, std::placeholders::_1 ), std::bind( &UsingNamespaceStatement::OnUnsetName, this, std::placeholders::_1 ) | |
3852 | + ); | |
3581 | 3853 | } |
3582 | 3854 | inline COSNode* GetName( void ) const noexcept |
3583 | 3855 | { |
@@ -3588,6 +3860,10 @@ | ||
3588 | 3860 | { |
3589 | 3861 | return; |
3590 | 3862 | } |
3863 | + virtual void OnUnsetName( COSNode *newnsname ) | |
3864 | + { | |
3865 | + return; | |
3866 | + } | |
3591 | 3867 | }; |
3592 | 3868 | |
3593 | 3869 | struct EnumDefinition : public COSNode |
@@ -3695,7 +3971,7 @@ | ||
3695 | 3971 | } |
3696 | 3972 | } |
3697 | 3973 | |
3698 | -private: | |
3974 | +protected: | |
3699 | 3975 | COSNode *name; |
3700 | 3976 | cosCommonVector <item> items; |
3701 | 3977 |
@@ -3704,7 +3980,10 @@ | ||
3704 | 3980 | public: |
3705 | 3981 | inline void SetName( COSNode *newname ) |
3706 | 3982 | { |
3707 | - TemplateSetEdge( newname, this->name, itemrefs ); | |
3983 | + TemplateSetEdge( newname, this->name, | |
3984 | + std::bind( &EnumDefinition::OnSetName, this, std::placeholders::_1 ), std::bind( &EnumDefinition::OnUnsetName, this, std::placeholders::_1 ), | |
3985 | + itemrefs | |
3986 | + ); | |
3708 | 3987 | } |
3709 | 3988 | inline COSNode* GetName( void ) const noexcept |
3710 | 3989 | { |
@@ -3768,10 +4047,22 @@ | ||
3768 | 4047 | } |
3769 | 4048 | } |
3770 | 4049 | protected: |
4050 | + virtual void OnSetName( COSNode *name ) | |
4051 | + { | |
4052 | + return; | |
4053 | + } | |
4054 | + virtual void OnUnsetName( COSNode *name ) | |
4055 | + { | |
4056 | + return; | |
4057 | + } | |
3771 | 4058 | virtual void OnAddItem( const item& i ) |
3772 | 4059 | { |
3773 | 4060 | return; |
3774 | 4061 | } |
4062 | + virtual void OnRemoveItem( const item& i ) | |
4063 | + { | |
4064 | + return; | |
4065 | + } | |
3775 | 4066 | }; |
3776 | 4067 | |
3777 | 4068 | }; // namespace COS |
\ No newline at end of file |