📄 dvgenc.c
字号:
} if(type == REL_HASHED) { dvWrtemp(dvFile, " if(%0%3Get%2Sym(_%3) != utSymNull) {\n" " add%1%2%3ToHashTable(%1, _%3);\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName); } dvWrtemp(dvFile, "}\n\n");}/*-------------------------------------------------------------------------------------------------- Write an append relationship routine for theClass.--------------------------------------------------------------------------------------------------*/static void writeClassAppendFunction( dvClass theClass, dvRelationship relationship){ char *parentName = dvClassGetName(theClass); dvClass childClass = dvRelationshipGetChildClass(relationship); char *childName = dvClassGetName(childClass); dvRelationshipType type = dvRelationshipGetType(relationship); dvWrtemp(dvFile, "/*----------------------------------------------------------------------------------------\n" " Add the %2%3 to the end of the list on the %1.\n" "----------------------------------------------------------------------------------------*/\n" "void %0%1Append%2%3(\n" " %4%1 %1,\n" " %5%3 _%3)\n" "{\n" "#if defined(DD_DEBUG)\n" " if(%1 == %4%1Null) {\n" " utExit(\"Non-existent %1\");\n" " }\n" " if(_%3 == %5%3Null) {\n" " utExit(\"Non-existent %3\");\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); if(dvRelationshipAccessParent(relationship)) { dvWrtemp(dvFile, " if(%0%2Get%4%1(_%2) != %3%1Null) {\n" " utExit(\"Attempting to add %3 to %1 twice\");\n" " }\n", dvPrefix, parentName, childName, dvClassGetPrefix(theClass), dvRelationshipGetParentLabel(relationship)); } dvWrtemp(dvFile, "#endif\n"); if(type == REL_DOUBLY_LINKED || type == REL_HASHED) { dvWrtemp(dvFile, " %0%3SetPrev%1%2%3(_%3, %0%1GetLast%2%3(%1));\n" " if(%0%1GetLast%2%3(%1) != %5%3Null) {\n" " %0%3SetNext%1%2%3(%0%1GetLast%2%3(%1), _%3);\n" " }\n" " %0%1SetLast%2%3(%1, _%3);\n" " %0%3SetNext%1%2%3(_%3, %5%3Null);\n" " if(%0%1GetFirst%2%3(%1) == %5%3Null) {\n" " %0%1SetFirst%2%3(%1, _%3);\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); } else { dvWrtemp(dvFile, " if(%0%1GetLast%2%3(%1) != %5%3Null) {\n" " %0%3SetNext%1%2%3(%0%1GetLast%2%3(%1), _%3);\n" " } else {\n" " %0%1SetFirst%2%3(%1, _%3);\n" " }\n" " %0%1SetLast%2%3(%1, _%3);\n" " %0%3SetNext%1%2%3(_%3, %5%3Null);\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); } if(dvRelationshipAccessParent(relationship)) { dvWrtemp(dvFile, " %0%3Set%2%1(_%3, %1);\n", dvPrefix, parentName, dvRelationshipGetParentLabel(relationship), childName); } if(type == REL_HASHED) { dvWrtemp(dvFile, " if(%0%3Get%2Sym(_%3) != utSymNull) {\n" " add%1%2%3ToHashTable(%1, _%3);\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName); } dvWrtemp(dvFile, "}\n\n");}/*-------------------------------------------------------------------------------------------------- Write an insert after relationship routine for theClass.--------------------------------------------------------------------------------------------------*/static void writeClassInsertAfter( dvClass theClass, dvRelationship relationship){ char *parentName = dvClassGetName(theClass); dvClass childClass = dvRelationshipGetChildClass(relationship); char *childName = dvClassGetName(childClass); dvRelationshipType type = dvRelationshipGetType(relationship); dvWrtemp(dvFile, "/*----------------------------------------------------------------------------------------\n" " Insert the %2%3 to the %1 after the previous %2%3.\n" "----------------------------------------------------------------------------------------*/\n" "void %0%1InsertAfter%2%3(\n" " %4%1 %1,\n" " %5%3 prev%3,\n" " %5%3 _%3)\n" "{\n" " %5%3 next%3 = %0%3GetNext%1%2%3(prev%3);\n" "\n" "#if defined(DD_DEBUG)\n" " if(%1 == %4%1Null) {\n" " utExit(\"Non-existent %1\");\n" " }\n" " if(_%3 == %5%3Null) {\n" " utExit(\"Non-existent %3\");\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); if(dvRelationshipAccessParent(relationship)) { dvWrtemp(dvFile, " if(%0%2Get%4%1(_%2) != %3%1Null) {\n" " utExit(\"Attempting to add %3 to %1 twice\");\n" " }\n", dvPrefix, parentName, childName, dvClassGetPrefix(theClass), dvRelationshipGetParentLabel(relationship)); } dvWrtemp(dvFile, "#endif\n"); dvWrtemp(dvFile, " %0%3SetNext%1%2%3(_%3, next%3);\n" " %0%3SetNext%1%2%3(prev%3, _%3);\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); if(type == REL_DOUBLY_LINKED || type == REL_HASHED) { dvWrtemp(dvFile, " %0%3SetPrev%1%2%3(_%3, prev%3);\n" " if(next%3 != %5%3Null) {\n" " %0%3SetPrev%1%2%3(next%3, _%3);\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); } if(type == REL_TAIL_LINKED || type == REL_DOUBLY_LINKED || type == REL_HASHED) { dvWrtemp(dvFile, " if(%0%1GetLast%2%3(%1) == prev%3) {\n" " %0%1SetLast%2%3(%1, _%3);\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName); } if(dvRelationshipAccessParent(relationship)) { dvWrtemp(dvFile, " %0%3Set%2%1(_%3, %1);\n", dvPrefix, parentName, dvRelationshipGetParentLabel(relationship), childName); } if(type == REL_HASHED) { dvWrtemp(dvFile, " if(%0%3Get%2Sym(_%3) != utSymNull) {\n" " add%1%2%3ToHashTable(%1, _%3);\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName); } dvWrtemp(dvFile, "}\n\n");}/*-------------------------------------------------------------------------------------------------- Write a delete relationship routine for theClass.--------------------------------------------------------------------------------------------------*/static void writeClassRemoveFunction( dvClass theClass, dvRelationship relationship){ char *parentName = dvClassGetName(theClass); dvClass childClass = dvRelationshipGetChildClass(relationship); dvRelationshipType type = dvRelationshipGetType(relationship); char *childName = dvClassGetName(childClass); char *childLabel = dvRelationshipGetChildLabel(relationship); dvWrtemp(dvFile, "/*----------------------------------------------------------------------------------------\n" " Remove the %2%3 from the %1.\n" "----------------------------------------------------------------------------------------*/\n" "void %0%1Remove%2%3(\n" " %4%1 %1,\n" " %5%3 _%3)\n" "{\n" " %5%3 p%3, n%3;\n" "\n", dvPrefix, parentName, childLabel, childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); dvWrtemp(dvFile, "#if defined(DD_DEBUG)\n" " if(_%3 == %5%3Null) {\n" " utExit(\"Non-existent %3\");\n" " }\n", dvPrefix, parentName, childLabel, childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); if(dvRelationshipAccessParent(relationship)) { dvWrtemp(dvFile, " if(%0%3Get%1%2(_%3) != %4%2Null && %0%3Get%1%2(_%3) != %2) {\n" " utExit(\"Delete %3 from non-owning %2\");\n" " }\n", dvPrefix, dvRelationshipGetParentLabel(relationship), parentName, childName, dvClassGetPrefix(theClass)); } if(type == REL_DOUBLY_LINKED || type == REL_HASHED) { dvWrtemp(dvFile, "#endif\n" " n%3 = %0%3GetNext%1%2%3(_%3);\n" " p%3 = %0%3GetPrev%1%2%3(_%3);\n" " if(p%3 != %5%3Null) {\n" " %0%3SetNext%1%2%3(p%3, n%3);\n" " } else if(%0%1GetFirst%2%3(%1) == _%3) {\n" " %0%1SetFirst%2%3(%1, n%3);\n" " }\n" " if(n%3 != %5%3Null) {\n" " %0%3SetPrev%1%2%3(n%3, p%3);\n" " } else if(%0%1GetLast%2%3(%1) == _%3) {\n" " %0%1SetLast%2%3(%1, p%3);\n" " }\n" " %0%3SetNext%1%2%3(_%3, %5%3Null);\n" " %0%3SetPrev%1%2%3(_%3, %5%3Null);\n", dvPrefix, parentName, childLabel, childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); } else { dvWrtemp(dvFile, "#endif\n" " p%3 = %5%3Null;\n" " for(n%3 = %0%1GetFirst%2%3(%1); n%3 != %5%3Null && n%3 != _%3;\n" " n%3 = %0%3GetNext%1%2%3(n%3)) {\n" " p%3 = n%3;\n" " }\n" " if(p%3 != %5%3Null) {\n" " %0%3SetNext%1%2%3(p%3, %0%3GetNext%1%2%3(_%3));\n" " } else {\n" " %0%1SetFirst%2%3(%1, %0%3GetNext%1%2%3(_%3));\n" " }\n" " %0%3SetNext%1%2%3(_%3, %5%3Null);\n", dvPrefix, parentName, childLabel, childName, dvClassGetPrefix(theClass), dvClassGetPrefix(childClass)); if(type == REL_TAIL_LINKED) { dvWrtemp(dvFile, " if(%0%1GetLast%2%3(%1) == _%3) {\n" " %0%1SetLast%2%3(%1, p%3);\n" " }\n", dvPrefix, parentName, childLabel, childName); } } if(dvRelationshipAccessParent(relationship)) { dvWrtemp(dvFile, " %0%3Set%1%2(_%3, %4%2Null);\n", dvPrefix, dvRelationshipGetParentLabel(relationship), parentName, childName, dvClassGetPrefix(theClass)); } if(type == REL_HASHED) { dvWrtemp(dvFile, " if(%0%3Get%2Sym(_%3) != utSymNull) {\n" " remove%1%2%3FromHashTable(%1, _%3);\n" " }\n", dvPrefix, parentName, dvRelationshipGetChildLabel(relationship), childName); } dvWrtemp(dvFile, "}\n\n");}/*-------------------------------------------------------------------------------------------------- Write an array insert relationship routine for theClass.--------------------------------------------------------------------------------------------------*/static void writeClassArrayInsertFunction( dvClass theClass, dvRelationship relationship){ char *parentName = dvClassGetName(theClass); dvClass childClass = dvRelationshipGetChildClass(relationship); char *childName = dvClassGetName(childClass); dvWrtemp(dvFile, "/*----------------------------------------------------------------------------------------\n" " Add the indexed %2%3 to the %1.\n" "----------------------------------------------------------------------------------------*/\n" "void %0%1Insert%2%3(\n" " %4%1 %1,\n" " uint32 x,\n" " %5%3 _%3)\n" "{\n" "#if defined(DD_DEBUG)\n" " if(%1 == %4%1Null) {\n" " utExit(\"Non existent %1\");\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -