• R/O
  • SSH
  • HTTPS

eircompile: Commit


Commit MetaInfo

Revisión96 (tree)
Tiempo2022-04-13 03:20:44
Autorquiret

Log Message

- transformed the COS nodes to support sub-graph extensions more appropriately

Cambiar Resumen

Diferencia incremental

--- commonlangs/include/commonlangs/cos.h (revision 95)
+++ commonlangs/include/commonlangs/cos.h (revision 96)
@@ -16,7 +16,10 @@
1616 #include <sdk/UniqueIterate.h>
1717 #include <sdk/MultiValueStore.h>
1818 #include <sdk/Set.h>
19+#include <sdk/Map.h>
1920
21+#include <functional> // for std::bind
22+
2023 // Thanks to selector-based nodes we can detach the actual node building from the node logic itself.
2124 // This were a burden because it would require character-based methods that we would not want to lock to character encodings.
2225
@@ -34,6 +37,9 @@
3437 template <typename structType>
3538 using cosCommonSet = eir::Set <structType, CRTHeapAllocator>;
3639
40+template <typename keyType, typename valueType, eir::CompareCompatibleComparator <keyType, keyType> comparatorType = eir::MapDefaultComparator>
41+using cosCommonMap = eir::Map <keyType, valueType, CRTHeapAllocator, comparatorType>;
42+
3743 template <typename structType>
3844 using cosCommonMultiValueStore = eir::MultiValueStore <structType, CRTHeapAllocator>;
3945
@@ -371,8 +377,10 @@
371377 protected:
372378 COSObjectsNode sys;
373379
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 )
376384 {
377385 COSNode *oldnode = fieldRef;
378386
@@ -393,8 +401,18 @@
393401 oldnode_spresent = false;
394402 }
395403
404+ if ( oldnode != nullptr )
405+ {
406+ unset_cb( oldnode );
407+ }
408+
396409 fieldRef = newnode;
397410
411+ if ( newnode != nullptr )
412+ {
413+ set_cb( newnode );
414+ }
415+
398416 COSObjects *sys = this->sys;
399417
400418 if ( newnode && newnode_isold == false )
@@ -411,7 +429,10 @@
411429 }
412430 }
413431
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 )
415436 {
416437 COSNode *oldnode = fieldRef;
417438
@@ -420,8 +441,18 @@
420441
421442 bool newnode_isold = ( newnode && this->IsNodeConnectedTo_Reach( newnode ) );
422443
444+ if ( oldnode != nullptr )
445+ {
446+ unset_cb( oldnode );
447+ }
448+
423449 fieldRef = newnode;
424450
451+ if ( newnode != nullptr )
452+ {
453+ set_cb( newnode );
454+ }
455+
425456 bool oldnode_spresent = ( oldnode && this->IsNodeConnectedTo_Reach( oldnode ) );
426457
427458 COSObjects *sys = this->sys;
@@ -581,7 +612,7 @@
581612 }
582613 }
583614
584-private:
615+protected:
585616 cosCommonVector <COSNode*> statements;
586617 public:
587618 inline void AddStatement( COSNode *node )
@@ -620,6 +651,10 @@
620651 {
621652 return;
622653 }
654+ virtual void OnRemoveStatement( COSNode *node )
655+ {
656+ return;
657+ }
623658 };
624659
625660 struct Operation : public COSNode
@@ -671,12 +706,12 @@
671706 }
672707 }
673708
674-private:
709+protected:
675710 COSNode *op;
676711 public:
677712 inline void SetOperation( COSNode *op )
678713 {
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 ) );
680715
681716 // TODO: improve exception-safety.
682717
@@ -691,6 +726,10 @@
691726 {
692727 return;
693728 }
729+ virtual void OnUnsetOperation( COSNode *n )
730+ {
731+ return;
732+ }
694733 };
695734
696735 struct LogicalNegationOperation : public UnaryOperation
@@ -781,21 +820,23 @@
781820 }
782821 }
783822
784-private:
823+protected:
785824 COSNode *left;
786825 COSNode *right;
787826 public:
788827 inline void SetLeft( COSNode *nleft )
789828 {
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+ );
793833 }
794834 inline void SetRight( COSNode *nright )
795835 {
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+ );
799840 }
800841 inline COSNode* GetLeft( void ) const noexcept
801842 {
@@ -810,10 +851,18 @@
810851 {
811852 return;
812853 }
854+ virtual void OnUnsetLeft( COSNode *left )
855+ {
856+ return;
857+ }
813858 virtual void OnSetRight( COSNode *right )
814859 {
815860 return;
816861 }
862+ virtual void OnUnsetRight( COSNode *right )
863+ {
864+ return;
865+ }
817866 };
818867
819868 struct AddOperation : public BinaryOperation
@@ -1002,15 +1051,16 @@
10021051 }
10031052 }
10041053
1005-private:
1054+protected:
10061055 COSNode *what;
10071056 cosCommonVector <COSNode*> params;
10081057 public:
10091058 inline void SetNode( COSNode *nwhat )
10101059 {
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+ );
10141064 }
10151065 inline COSNode* GetNode( void ) const noexcept
10161066 {
@@ -1052,10 +1102,18 @@
10521102 {
10531103 return;
10541104 }
1105+ virtual void OnUnsetNode( COSNode *n )
1106+ {
1107+ return;
1108+ }
10551109 virtual void OnAddParam( COSNode *n )
10561110 {
10571111 return;
10581112 }
1113+ virtual void OnRemoveParam( COSNode *n )
1114+ {
1115+ return;
1116+ }
10591117 };
10601118 struct ArrayInitOperation : public Operation
10611119 {
@@ -1103,15 +1161,16 @@
11031161 }
11041162 }
11051163
1106-private:
1164+protected:
11071165 COSNode *what;
11081166 cosCommonVector <COSNode*> items;
11091167 public:
11101168 inline void SetNode( COSNode *nwhat )
11111169 {
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+ );
11151174 }
11161175 inline COSNode* GetNode( void ) const noexcept
11171176 {
@@ -1153,10 +1212,18 @@
11531212 {
11541213 return;
11551214 }
1215+ virtual void OnUnsetNode( COSNode *n )
1216+ {
1217+ return;
1218+ }
11561219 virtual void OnAddItem( COSNode *n )
11571220 {
11581221 return;
11591222 }
1223+ virtual void OnRemoveItem( COSNode *n )
1224+ {
1225+ return;
1226+ }
11601227 };
11611228
11621229 struct NewOperation : public Operation
@@ -1205,15 +1272,16 @@
12051272 }
12061273 }
12071274
1208-private:
1275+protected:
12091276 COSNode *type;
12101277 cosCommonVector <COSNode*> params;
12111278 public:
12121279 inline void SetType( COSNode *ntype )
12131280 {
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+ );
12171285 }
12181286 inline COSNode* GetType( void ) const noexcept
12191287 {
@@ -1255,10 +1323,18 @@
12551323 {
12561324 return;
12571325 }
1326+ virtual void OnUnsetType( COSNode *ntype )
1327+ {
1328+ return;
1329+ }
12581330 virtual void OnAddParam( COSNode *nparam )
12591331 {
12601332 return;
12611333 }
1334+ virtual void OnRemoveParam( COSNode *nparam )
1335+ {
1336+ return;
1337+ }
12621338 };
12631339 struct ReplaceOperation : public Operation
12641340 {
@@ -1307,15 +1383,16 @@
13071383 }
13081384 }
13091385
1310-private:
1386+protected:
13111387 COSNode *what;
13121388 COSNode *with;
13131389 public:
13141390 inline void SetWhat( COSNode *nwhat )
13151391 {
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+ );
13191396 }
13201397 inline COSNode* GetWhat( void ) const noexcept
13211398 {
@@ -1323,9 +1400,10 @@
13231400 }
13241401 inline void SetWith( COSNode *nwith )
13251402 {
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+ );
13291407 }
13301408 inline COSNode* GetWith( void ) const noexcept
13311409 {
@@ -1336,10 +1414,18 @@
13361414 {
13371415 return;
13381416 }
1417+ virtual void OnUnsetWhat( COSNode *nwhat )
1418+ {
1419+ return;
1420+ }
13391421 virtual void OnSetWith( COSNode *nwith )
13401422 {
13411423 return;
13421424 }
1425+ virtual void OnUnsetWith( COSNode *nwith )
1426+ {
1427+ return;
1428+ }
13431429 };
13441430 struct DeleteOperation : public UnaryOperation
13451431 {
@@ -1393,15 +1479,16 @@
13931479 }
13941480 }
13951481
1396-private:
1482+protected:
13971483 COSNode *totype;
13981484 COSNode *castobj;
13991485 public:
14001486 inline void SetToType( COSNode *newtotype )
14011487 {
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+ );
14051492 }
14061493 inline COSNode* GetToType( void ) const noexcept
14071494 {
@@ -1409,9 +1496,10 @@
14091496 }
14101497 inline void SetCastObject( COSNode *newcastobj )
14111498 {
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+ );
14151503 }
14161504 inline COSNode* GetCastObject( void ) const noexcept
14171505 {
@@ -1422,10 +1510,18 @@
14221510 {
14231511 return;
14241512 }
1513+ virtual void OnUnsetToType( COSNode *newtotype )
1514+ {
1515+ return;
1516+ }
14251517 virtual void OnSetCastObject( COSNode *newcastobj )
14261518 {
14271519 return;
14281520 }
1521+ virtual void OnUnsetCastObject( COSNode *newcastobj )
1522+ {
1523+ return;
1524+ }
14291525 };
14301526
14311527 struct TemplateInstantiationOperation : public Operation
@@ -1475,15 +1571,16 @@
14751571 }
14761572 }
14771573
1478-private:
1574+protected:
14791575 COSNode *templ;
14801576 cosCommonVector <COSNode*> tparams;
14811577 public:
14821578 inline void SetTemplate( COSNode *newtempl )
14831579 {
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+ );
14871584 }
14881585 inline COSNode* GetTemplate( void ) const noexcept
14891586 {
@@ -1525,10 +1622,18 @@
15251622 {
15261623 return;
15271624 }
1625+ virtual void OnUnsetTemplate( COSNode *newtempl )
1626+ {
1627+ return;
1628+ }
15281629 virtual void OnAddParam( COSNode *newparam )
15291630 {
15301631 return;
15311632 }
1633+ virtual void OnRemoveParam( COSNode *newparam )
1634+ {
1635+ return;
1636+ }
15321637 };
15331638
15341639 struct IfStatement : public COSNode
@@ -1584,7 +1689,7 @@
15841689 }
15851690 }
15861691
1587-private:
1692+protected:
15881693 COSNode *condition;
15891694 COSNode *true_branch;
15901695 COSNode *false_branch;
@@ -1591,9 +1696,10 @@
15911696 public:
15921697 inline void SetCondition( COSNode *newcond )
15931698 {
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+ );
15971703 }
15981704 inline COSNode* GetCondition( void ) const noexcept
15991705 {
@@ -1601,9 +1707,10 @@
16011707 }
16021708 inline void SetTrueBranch( COSNode *newtb )
16031709 {
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+ );
16071714 }
16081715 inline COSNode* GetTrueBranch( void ) const noexcept
16091716 {
@@ -1611,9 +1718,10 @@
16111718 }
16121719 inline void SetFalseBranch( COSNode *newfb )
16131720 {
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+ );
16171725 }
16181726 inline COSNode* GetFalseBranch( void ) const noexcept
16191727 {
@@ -1624,14 +1732,26 @@
16241732 {
16251733 return;
16261734 }
1735+ virtual void OnUnsetCondition( COSNode *newcond )
1736+ {
1737+ return;
1738+ }
16271739 virtual void OnSetTrueBranch( COSNode *newtb )
16281740 {
16291741 return;
16301742 }
1743+ virtual void OnUnsetTrueBranch( COSNode *newtb )
1744+ {
1745+ return;
1746+ }
16311747 virtual void OnSetFalseBranch( COSNode *newfb )
16321748 {
16331749 return;
16341750 }
1751+ virtual void OnUnsetFalseBranch( COSNode *newfb )
1752+ {
1753+ return;
1754+ }
16351755 };
16361756 struct WhileLoopStatement : public COSNode
16371757 {
@@ -1680,15 +1800,16 @@
16801800 }
16811801 }
16821802
1683-private:
1803+protected:
16841804 COSNode *condition;
16851805 COSNode *exec;
16861806 public:
16871807 inline void SetCondition( COSNode *newcond )
16881808 {
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+ );
16921813 }
16931814 inline COSNode* GetCondition( void ) const noexcept
16941815 {
@@ -1696,9 +1817,10 @@
16961817 }
16971818 inline void SetExec( COSNode *newexec )
16981819 {
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+ );
17021824 }
17031825 inline COSNode* GetExec( void ) const noexcept
17041826 {
@@ -1709,10 +1831,18 @@
17091831 {
17101832 return;
17111833 }
1834+ virtual void OnUnsetCondition( COSNode *newcond )
1835+ {
1836+ return;
1837+ }
17121838 virtual void OnSetExec( COSNode *newexec )
17131839 {
17141840 return;
17151841 }
1842+ virtual void OnUnsetExec( COSNode *newexec )
1843+ {
1844+ return;
1845+ }
17161846 };
17171847 struct ForLoopStatement : public COSNode
17181848 {
@@ -1774,7 +1904,7 @@
17741904 }
17751905 }
17761906
1777-private:
1907+protected:
17781908 COSNode *init;
17791909 COSNode *condition;
17801910 COSNode *iteration;
@@ -1782,9 +1912,10 @@
17821912 public:
17831913 inline void SetInit( COSNode *newinit )
17841914 {
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+ );
17881919 }
17891920 inline COSNode* GetInit( void ) const noexcept
17901921 {
@@ -1792,9 +1923,10 @@
17921923 }
17931924 inline void SetCondition( COSNode *newcond )
17941925 {
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+ );
17981930 }
17991931 inline COSNode* GetCondition( void ) const noexcept
18001932 {
@@ -1802,9 +1934,10 @@
18021934 }
18031935 inline void SetIteration( COSNode *newiter )
18041936 {
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+ );
18081941 }
18091942 inline COSNode* GetIteration( void ) const noexcept
18101943 {
@@ -1812,9 +1945,10 @@
18121945 }
18131946 inline void SetExec( COSNode *newexec )
18141947 {
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+ );
18181952 }
18191953 inline COSNode* GetExec( void ) const noexcept
18201954 {
@@ -1825,18 +1959,34 @@
18251959 {
18261960 return;
18271961 }
1962+ virtual void OnUnsetInit( COSNode *newinit )
1963+ {
1964+ return;
1965+ }
18281966 virtual void OnSetCondition( COSNode *newcond )
18291967 {
18301968 return;
18311969 }
1970+ virtual void OnUnsetCondition( COSNode *newcond )
1971+ {
1972+ return;
1973+ }
18321974 virtual void OnSetIteration( COSNode *newiter )
18331975 {
18341976 return;
18351977 }
1978+ virtual void OnUnsetIteration( COSNode *newiter )
1979+ {
1980+ return;
1981+ }
18361982 virtual void OnSetExec( COSNode *newexec )
18371983 {
18381984 return;
18391985 }
1986+ virtual void OnUnsetExec( COSNode *newexec )
1987+ {
1988+ return;
1989+ }
18401990 };
18411991 struct ContinueStatement : public COSNode
18421992 {
@@ -1891,14 +2041,14 @@
18912041 }
18922042 }
18932043
1894-private:
2044+protected:
18952045 COSNode *op;
18962046 public:
18972047 inline void SetNode( COSNode *newop )
18982048 {
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+ );
19022052 }
19032053 inline COSNode* GetNode( void ) const noexcept
19042054 {
@@ -1909,6 +2059,10 @@
19092059 {
19102060 return;
19112061 }
2062+ virtual void OnUnsetNode( COSNode *newop )
2063+ {
2064+ return;
2065+ }
19122066 };
19132067
19142068 // No-op.
@@ -1971,7 +2125,7 @@
19712125 }
19722126 }
19732127
1974-private:
2128+protected:
19752129 COSNode *name;
19762130 COSNode *type;
19772131 COSNode *initializer;
@@ -1978,9 +2132,10 @@
19782132 public:
19792133 inline void SetName( COSNode *newname )
19802134 {
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+ );
19842139 }
19852140 inline COSNode* GetName( void ) const noexcept
19862141 {
@@ -1988,9 +2143,10 @@
19882143 }
19892144 inline void SetType( COSNode *newtype )
19902145 {
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+ );
19942150 }
19952151 inline COSNode* GetType( void ) const noexcept
19962152 {
@@ -1998,9 +2154,10 @@
19982154 }
19992155 inline void SetInitializer( COSNode *newinit )
20002156 {
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+ );
20042161 }
20052162 inline COSNode* GetInitializer( void ) const noexcept
20062163 {
@@ -2011,14 +2168,26 @@
20112168 {
20122169 return;
20132170 }
2171+ virtual void OnUnsetName( COSNode *newname )
2172+ {
2173+ return;
2174+ }
20142175 virtual void OnSetType( COSNode *newtype )
20152176 {
20162177 return;
20172178 }
2179+ virtual void OnUnsetType( COSNode *newtype )
2180+ {
2181+ return;
2182+ }
20182183 virtual void OnSetInitializer( COSNode *newinit )
20192184 {
20202185 return;
20212186 }
2187+ virtual void OnUnsetInitializer( COSNode *newinit )
2188+ {
2189+ return;
2190+ }
20222191 };
20232192 struct MultiDeclarationStatement : public COSNode
20242193 {
@@ -2065,7 +2234,7 @@
20652234 }
20662235 }
20672236
2068-private:
2237+protected:
20692238 cosCommonVector <DeclarationStatement*> decls;
20702239 public:
20712240 inline void AddDeclaration( DeclarationStatement *newdecl )
@@ -2100,10 +2269,14 @@
21002269 return decls.GetCount();
21012270 }
21022271 protected:
2103- virtual void OnAddDeclaration( DeclarationStatement *newdecl )
2272+ virtual void OnAddDeclaration( COSNode *newdecl )
21042273 {
21052274 return;
21062275 }
2276+ virtual void OnRemoveDeclaration( COSNode *newdecl )
2277+ {
2278+ return;
2279+ }
21072280 };
21082281
21092282 struct TypedefStatement : public COSNode
@@ -2153,15 +2326,16 @@
21532326 }
21542327 }
21552328
2156-private:
2329+protected:
21572330 COSNode *srctype;
21582331 COSNode *dsttype;
21592332 public:
21602333 inline void SetSrcType( COSNode *newsrctype )
21612334 {
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+ );
21652339 }
21662340 inline COSNode* GetSrcType( void ) const noexcept
21672341 {
@@ -2169,9 +2343,10 @@
21692343 }
21702344 inline void SetDstType( COSNode *newdsttype )
21712345 {
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+ );
21752350 }
21762351 inline COSNode* GetDstType( void ) const noexcept
21772352 {
@@ -2182,10 +2357,18 @@
21822357 {
21832358 return;
21842359 }
2360+ virtual void OnUnsetSrcType( COSNode *newsrctype )
2361+ {
2362+ return;
2363+ }
21852364 virtual void OnSetDstType( COSNode *newdsttype )
21862365 {
21872366 return;
21882367 }
2368+ virtual void OnUnsetDstType( COSNode *newdsttype )
2369+ {
2370+ return;
2371+ }
21892372 };
21902373 struct MultiTypedefStatement : public COSNode
21912374 {
@@ -2230,7 +2413,7 @@
22302413 }
22312414 }
22322415
2233-private:
2416+protected:
22342417 cosCommonVector <TypedefStatement*> defs;
22352418 public:
22362419 inline void AddTypedef( TypedefStatement *newtypedef )
@@ -2265,10 +2448,14 @@
22652448 return this->defs.GetCount();
22662449 }
22672450 protected:
2268- virtual void OnAddTypedef( TypedefStatement *newtypedef )
2451+ virtual void OnAddTypedef( COSNode *newtypedef )
22692452 {
22702453 return;
22712454 }
2455+ virtual void OnRemoveTypedef( COSNode *newtypedef )
2456+ {
2457+ return;
2458+ }
22722459 };
22732460
22742461 struct BlockStatement : public COSNode
@@ -2311,7 +2498,7 @@
23112498 }
23122499 }
23132500
2314-private:
2501+protected:
23152502 cosCommonVector <COSNode*> statements;
23162503 public:
23172504 inline void AddStatement( COSNode *stmt )
@@ -2350,6 +2537,10 @@
23502537 {
23512538 return;
23522539 }
2540+ virtual void OnRemoveStatement( COSNode *stmt )
2541+ {
2542+ return;
2543+ }
23532544 };
23542545
23552546 struct ThrowStatement : public COSNode
@@ -2396,14 +2587,14 @@
23962587 }
23972588 }
23982589
2399-private:
2590+protected:
24002591 COSNode *op;
24012592 public:
24022593 inline void SetNode( COSNode *newop )
24032594 {
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+ );
24072598 }
24082599 inline COSNode* GetNode( void ) const noexcept
24092600 {
@@ -2414,6 +2605,10 @@
24142605 {
24152606 return;
24162607 }
2608+ virtual void OnUnsetNode( COSNode *newop )
2609+ {
2610+ return;
2611+ }
24172612 };
24182613 struct CatchStatement : public COSNode
24192614 {
@@ -2462,15 +2657,16 @@
24622657 }
24632658 }
24642659
2465-private:
2660+protected:
24662661 COSNode *caught_decl;
24672662 COSNode *catch_body;
24682663 public:
24692664 inline void SetCaughtDecl( COSNode *newcdecl )
24702665 {
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+ );
24742670 }
24752671 inline COSNode* GetCaughtDecl( void ) const noexcept
24762672 {
@@ -2478,9 +2674,10 @@
24782674 }
24792675 inline void SetCatchBody( COSNode *newcbody )
24802676 {
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+ );
24842681 }
24852682 inline COSNode* GetCatchBody( void ) const noexcept
24862683 {
@@ -2491,10 +2688,18 @@
24912688 {
24922689 return;
24932690 }
2691+ virtual void OnUnsetCaughtDecl( COSNode *newcdecl )
2692+ {
2693+ return;
2694+ }
24942695 virtual void OnSetCatchBody( COSNode *newcbody )
24952696 {
24962697 return;
24972698 }
2699+ virtual void OnUnsetCatchBody( COSNode *newcbody )
2700+ {
2701+ return;
2702+ }
24982703 };
24992704 struct TryStatement : public COSNode
25002705 {
@@ -2550,15 +2755,16 @@
25502755 }
25512756 }
25522757
2553-private:
2758+protected:
25542759 COSNode *try_body;
25552760 cosCommonVector <CatchStatement*> errors;
25562761 public:
25572762 inline void SetTryBody( COSNode *newbody )
25582763 {
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+ );
25622768 }
25632769 inline COSNode* GetTryBody( void ) const noexcept
25642770 {
@@ -2600,10 +2806,18 @@
26002806 {
26012807 return;
26022808 }
2603- virtual void OnAddError( CatchStatement *newerror )
2809+ virtual void OnUnsetTryBody( COSNode *newbody )
26042810 {
26052811 return;
26062812 }
2813+ virtual void OnAddError( COSNode *newerror )
2814+ {
2815+ return;
2816+ }
2817+ virtual void OnRemoveError( COSNode *newerror )
2818+ {
2819+ return;
2820+ }
26072821 };
26082822
26092823 struct StructDefinition : public COSNode
@@ -2653,15 +2867,16 @@
26532867 }
26542868 }
26552869
2656-private:
2870+protected:
26572871 COSNode *name;
26582872 COSNode *body;
26592873 public:
26602874 inline void SetName( COSNode *newname )
26612875 {
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+ );
26652880 }
26662881 inline COSNode* GetName( void ) const noexcept
26672882 {
@@ -2669,9 +2884,10 @@
26692884 }
26702885 inline void SetBody( COSNode *newbody )
26712886 {
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+ );
26752891 }
26762892 inline COSNode* GetBody( void ) const noexcept
26772893 {
@@ -2682,10 +2898,18 @@
26822898 {
26832899 return;
26842900 }
2901+ virtual void OnUnsetName( COSNode *newname )
2902+ {
2903+ return;
2904+ }
26852905 virtual void OnSetBody( COSNode *newbody )
26862906 {
26872907 return;
26882908 }
2909+ virtual void OnUnsetBody( COSNode *newbody )
2910+ {
2911+ return;
2912+ }
26892913 };
26902914 struct ConstructorDefinition : public COSNode
26912915 {
@@ -2733,7 +2957,7 @@
27332957 }
27342958 }
27352959
2736-private:
2960+protected:
27372961 cosCommonVector <COSNode*> params;
27382962 COSNode *body;
27392963 public:
@@ -2770,9 +2994,10 @@
27702994 }
27712995 inline void SetBody( COSNode *newbody )
27722996 {
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+ );
27763001 }
27773002 inline COSNode* GetBody( void ) const noexcept
27783003 {
@@ -2783,10 +3008,18 @@
27833008 {
27843009 return;
27853010 }
3011+ virtual void OnRemoveParam( COSNode *newparam )
3012+ {
3013+ return;
3014+ }
27863015 virtual void OnSetBody( COSNode *newbody )
27873016 {
27883017 return;
27893018 }
3019+ virtual void OnUnsetBody( COSNode *newbody )
3020+ {
3021+ return;
3022+ }
27903023 };
27913024 struct DestructorDefinition : public COSNode
27923025 {
@@ -2833,14 +3066,14 @@
28333066 }
28343067 }
28353068
2836-private:
3069+protected:
28373070 COSNode *body;
28383071 public:
28393072 inline void SetBody( COSNode *newbody )
28403073 {
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+ );
28443077 }
28453078 inline COSNode* GetBody( void ) const noexcept
28463079 {
@@ -2851,6 +3084,10 @@
28513084 {
28523085 return;
28533086 }
3087+ virtual void OnUnsetBody( COSNode *newbody )
3088+ {
3089+ return;
3090+ }
28543091 };
28553092
28563093 struct Literal : public COSNode
@@ -3086,9 +3323,9 @@
30863323 public:
30873324 inline void SetSpec( COSNode *newspec )
30883325 {
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+ );
30923329 }
30933330 inline COSNode* GetSpec( void ) const noexcept
30943331 {
@@ -3099,6 +3336,10 @@
30993336 {
31003337 return;
31013338 }
3339+ virtual void OnUnsetSpec( COSNode *newspec )
3340+ {
3341+ return;
3342+ }
31023343 };
31033344 struct PointerTypeSpecifier : public TypeSpecifier
31043345 {
@@ -3151,14 +3392,14 @@
31513392 }
31523393 }
31533394
3154-private:
3395+protected:
31553396 COSNode *array_size_op;
31563397 public:
31573398 inline void SetArraySizeOp( COSNode *newsizeop )
31583399 {
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+ );
31623403 }
31633404 inline COSNode* GetArraySizeOp( void ) const noexcept
31643405 {
@@ -3169,6 +3410,10 @@
31693410 {
31703411 return;
31713412 }
3413+ virtual void OnUnsetArraySizeOp( COSNode *newsizeop )
3414+ {
3415+ return;
3416+ }
31723417 };
31733418
31743419 struct CurlyPack : public COSNode
@@ -3210,7 +3455,7 @@
32103455 }
32113456 }
32123457
3213-private:
3458+protected:
32143459 cosCommonVector <COSNode*> params;
32153460 public:
32163461 inline void AddParam( COSNode *newparam )
@@ -3249,6 +3494,10 @@
32493494 {
32503495 return;
32513496 }
3497+ virtual void OnRemoveParam( COSNode *newparam )
3498+ {
3499+ return;
3500+ }
32523501 };
32533502 struct ArrayDefinition : public COSNode
32543503 {
@@ -3291,7 +3540,7 @@
32913540 }
32923541 }
32933542
3294-private:
3543+protected:
32953544 cosCommonVector <COSNode*> items;
32963545 public:
32973546 inline void AddItem( COSNode *newitem )
@@ -3330,6 +3579,10 @@
33303579 {
33313580 return;
33323581 }
3582+ virtual void OnRemoveItem( COSNode *newitem )
3583+ {
3584+ return;
3585+ }
33333586 };
33343587 struct FuncsigDefinition : public COSNode
33353588 {
@@ -3389,15 +3642,16 @@
33893642 }
33903643 }
33913644
3392-private:
3645+protected:
33933646 COSNode *return_type;
33943647 cosCommonVector <COSNode*> params;
33953648 public:
33963649 inline void SetReturnType( COSNode *newrtype )
33973650 {
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+ );
34013655 }
34023656 inline COSNode* GetReturnType( void ) const noexcept
34033657 {
@@ -3439,10 +3693,18 @@
34393693 {
34403694 return;
34413695 }
3696+ virtual void OnUnsetReturnType( COSNode *newrtype )
3697+ {
3698+ return;
3699+ }
34423700 virtual void OnAddParam( COSNode *newparam )
34433701 {
34443702 return;
34453703 }
3704+ virtual void OnRemoveParam( COSNode *newparam )
3705+ {
3706+ return;
3707+ }
34463708 };
34473709
34483710 struct NamespaceStatement : public COSNode
@@ -3492,15 +3754,16 @@
34923754 }
34933755 }
34943756
3495-private:
3757+protected:
34963758 COSNode *name;
34973759 COSNode *toinclude;
34983760 public:
34993761 inline void SetName( COSNode *newname )
35003762 {
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+ );
35043767 }
35053768 inline COSNode* GetName( void ) const noexcept
35063769 {
@@ -3508,9 +3771,10 @@
35083771 }
35093772 inline void SetToInclude( COSNode *newtoinclude )
35103773 {
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+ );
35143778 }
35153779 inline COSNode* GetToInclude( void ) const noexcept
35163780 {
@@ -3521,10 +3785,18 @@
35213785 {
35223786 return;
35233787 }
3788+ virtual void OnUnsetName( COSNode *newname )
3789+ {
3790+ return;
3791+ }
35243792 virtual void OnSetToInclude( COSNode *newtoinclude )
35253793 {
35263794 return;
35273795 }
3796+ virtual void OnUnsetToInclude( COSNode *newtoinclude )
3797+ {
3798+ return;
3799+ }
35283800 };
35293801 struct UsingNamespaceStatement : public COSNode
35303802 {
@@ -3570,14 +3842,14 @@
35703842 }
35713843 }
35723844
3573-private:
3845+protected:
35743846 COSNode *nsname;
35753847 public:
35763848 inline void SetName( COSNode *newnsname )
35773849 {
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+ );
35813853 }
35823854 inline COSNode* GetName( void ) const noexcept
35833855 {
@@ -3588,6 +3860,10 @@
35883860 {
35893861 return;
35903862 }
3863+ virtual void OnUnsetName( COSNode *newnsname )
3864+ {
3865+ return;
3866+ }
35913867 };
35923868
35933869 struct EnumDefinition : public COSNode
@@ -3695,7 +3971,7 @@
36953971 }
36963972 }
36973973
3698-private:
3974+protected:
36993975 COSNode *name;
37003976 cosCommonVector <item> items;
37013977
@@ -3704,7 +3980,10 @@
37043980 public:
37053981 inline void SetName( COSNode *newname )
37063982 {
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+ );
37083987 }
37093988 inline COSNode* GetName( void ) const noexcept
37103989 {
@@ -3768,10 +4047,22 @@
37684047 }
37694048 }
37704049 protected:
4050+ virtual void OnSetName( COSNode *name )
4051+ {
4052+ return;
4053+ }
4054+ virtual void OnUnsetName( COSNode *name )
4055+ {
4056+ return;
4057+ }
37714058 virtual void OnAddItem( const item& i )
37724059 {
37734060 return;
37744061 }
4062+ virtual void OnRemoveItem( const item& i )
4063+ {
4064+ return;
4065+ }
37754066 };
37764067
37774068 }; // namespace COS
\ No newline at end of file
Show on old repository browser