📄 mxmldoc.c
字号:
"constant=%p, typedefnode=%p, tree=\"%s\"\n", variable, constant, typedefnode, tree->value.element.name);#endif /* DEBUG */ if (variable) { if (strstr(buffer, "@private@")) { /* * Delete private variables... */ mxmlDelete(variable); } else { description = mxmlNewElement(variable, "description");#ifdef DEBUG fputs(" adding comment to variable...\n", stderr);#endif /* DEBUG */ update_comment(variable, mxmlNewText(description, 0, buffer)); } variable = NULL; } else if (constant) { if (strstr(buffer, "@private@")) { /* * Delete private constants... */ mxmlDelete(constant); } else { description = mxmlNewElement(constant, "description");#ifdef DEBUG fputs(" adding comment to constant...\n", stderr);#endif /* DEBUG */ update_comment(constant, mxmlNewText(description, 0, buffer)); } constant = NULL; } else if (typedefnode) { if (strstr(buffer, "@private@")) { /* * Delete private typedefs... */ mxmlDelete(typedefnode); if (structclass) { mxmlDelete(structclass); structclass = NULL; } if (enumeration) { mxmlDelete(enumeration); enumeration = NULL; } } else { description = mxmlNewElement(typedefnode, "description");#ifdef DEBUG fprintf(stderr, " adding comment to typedef %s...\n", mxmlElementGetAttr(typedefnode, "name"));#endif /* DEBUG */ update_comment(typedefnode, mxmlNewText(description, 0, buffer)); if (structclass) { description = mxmlNewElement(structclass, "description"); update_comment(structclass, mxmlNewText(description, 0, buffer)); } else if (enumeration) { description = mxmlNewElement(enumeration, "description"); update_comment(enumeration, mxmlNewText(description, 0, buffer)); } } typedefnode = NULL; } else if (strcmp(tree->value.element.name, "mxmldoc") && !mxmlFindElement(tree, tree, "description", NULL, NULL, MXML_DESCEND_FIRST)) { description = mxmlNewElement(tree, "description");#ifdef DEBUG fputs(" adding comment to parent...\n", stderr);#endif /* DEBUG */ update_comment(tree, mxmlNewText(description, 0, buffer)); } else mxmlNewText(comment, 0, buffer);#ifdef DEBUG fprintf(stderr, "C comment: <<<< %s >>>\n", buffer);#endif /* DEBUG */ state = STATE_NONE; break; } default : if (ch == ' ' && bufptr == buffer) break; if (bufptr < (buffer + sizeof(buffer) - 1)) *bufptr++ = ch; break; } break; case STATE_CXX_COMMENT : /* Inside a C++ comment */ if (ch == '\n') { state = STATE_NONE; *bufptr = '\0'; if (comment->child != comment->last_child) {#ifdef DEBUG fprintf(stderr, " removing comment %p, last comment %p...\n", comment->child, comment->last_child);#endif /* DEBUG */ mxmlDelete(comment->child);#ifdef DEBUG fprintf(stderr, " new comment %p, last comment %p...\n", comment->child, comment->last_child);#endif /* DEBUG */ } if (variable) { if (strstr(buffer, "@private@")) { /* * Delete private variables... */ mxmlDelete(variable); } else { description = mxmlNewElement(variable, "description");#ifdef DEBUG fputs(" adding comment to variable...\n", stderr);#endif /* DEBUG */ update_comment(variable, mxmlNewText(description, 0, buffer)); } variable = NULL; } else if (constant) { if (strstr(buffer, "@private@")) { /* * Delete private constants... */ mxmlDelete(constant); } else { description = mxmlNewElement(constant, "description");#ifdef DEBUG fputs(" adding comment to constant...\n", stderr);#endif /* DEBUG */ update_comment(constant, mxmlNewText(description, 0, buffer)); } constant = NULL; } else if (typedefnode) { if (strstr(buffer, "@private@")) { /* * Delete private typedefs... */ mxmlDelete(typedefnode); typedefnode = NULL; if (structclass) { mxmlDelete(structclass); structclass = NULL; } if (enumeration) { mxmlDelete(enumeration); enumeration = NULL; } } else { description = mxmlNewElement(typedefnode, "description");#ifdef DEBUG fprintf(stderr, " adding comment to typedef %s...\n", mxmlElementGetAttr(typedefnode, "name"));#endif /* DEBUG */ update_comment(typedefnode, mxmlNewText(description, 0, buffer)); if (structclass) { description = mxmlNewElement(structclass, "description"); update_comment(structclass, mxmlNewText(description, 0, buffer)); } else if (enumeration) { description = mxmlNewElement(enumeration, "description"); update_comment(enumeration, mxmlNewText(description, 0, buffer)); } } } else if (strcmp(tree->value.element.name, "mxmldoc") && !mxmlFindElement(tree, tree, "description", NULL, NULL, MXML_DESCEND_FIRST)) { description = mxmlNewElement(tree, "description");#ifdef DEBUG fputs(" adding comment to parent...\n", stderr);#endif /* DEBUG */ update_comment(tree, mxmlNewText(description, 0, buffer)); } else mxmlNewText(comment, 0, buffer);#ifdef DEBUG fprintf(stderr, "C++ comment: <<<< %s >>>\n", buffer);#endif /* DEBUG */ } else if (ch == ' ' && bufptr == buffer) break; else if (bufptr < (buffer + sizeof(buffer) - 1)) *bufptr++ = ch; break; case STATE_STRING : /* Inside a string constant */ *bufptr++ = ch; if (ch == '\\') *bufptr++ = getc(fp); else if (ch == '\"') { *bufptr = '\0'; if (type) mxmlNewText(type, type->child != NULL, buffer); state = STATE_NONE; } break; case STATE_CHARACTER : /* Inside a character constant */ *bufptr++ = ch; if (ch == '\\') *bufptr++ = getc(fp); else if (ch == '\'') { *bufptr = '\0'; if (type) mxmlNewText(type, type->child != NULL, buffer); state = STATE_NONE; } break; case STATE_IDENTIFIER : /* Inside a keyword or identifier */ if (isalnum(ch) || ch == '_' || ch == '[' || ch == ']' || (ch == ',' && (parens > 1 || (type && !enumeration && !function))) || ch == ':' || ch == '.' || ch == '~') { if (bufptr < (buffer + sizeof(buffer) - 1)) *bufptr++ = ch; } else { ungetc(ch, fp); *bufptr = '\0'; state = STATE_NONE;#ifdef DEBUG fprintf(stderr, " braces=%d, type=%p, type->child=%p, buffer=\"%s\"\n", braces, type, type ? type->child : NULL, buffer);#endif /* DEBUG */ if (!braces) { if (!type || !type->child) { if (!strcmp(tree->value.element.name, "class")) { if (!strcmp(buffer, "public") || !strcmp(buffer, "public:")) { scope = "public";#ifdef DEBUG fputs(" scope = public\n", stderr);#endif /* DEBUG */ break; } else if (!strcmp(buffer, "private") || !strcmp(buffer, "private:")) { scope = "private";#ifdef DEBUG fputs(" scope = private\n", stderr);#endif /* DEBUG */ break; } else if (!strcmp(buffer, "protected") || !strcmp(buffer, "protected:")) { scope = "protected";#ifdef DEBUG fputs(" scope = protected\n", stderr);#endif /* DEBUG */ break; } } } if (!type) type = mxmlNewElement(MXML_NO_PARENT, "type");#ifdef DEBUG fprintf(stderr, " function=%p (%s), type->child=%p, ch='%c', parens=%d\n", function, function ? mxmlElementGetAttr(function, "name") : "null", type->child, ch, parens);#endif /* DEBUG */ if (!function && ch == '(') { if (type->child && !strcmp(type->child->value.text.string, "extern")) { /* * Remove external declarations... */ mxmlDelete(type); type = NULL; break; } if (type->child && !strcmp(type->child->value.text.string, "static") && !strcmp(tree->value.element.name, "mxmldoc")) { /* * Remove static functions... */ mxmlDelete(type); type = NULL; break; } function = mxmlNewElement(MXML_NO_PARENT, "function"); if ((bufptr = strchr(buffer, ':')) != NULL && bufptr[1] == ':') { *bufptr = '\0'; bufptr += 2; if ((fstructclass = mxmlFindElement(tree, tree, "class", "name", buffer, MXML_DESCEND_FIRST)) == NULL) fstructclass = mxmlFindElement(tree, tree, "struct", "name", buffer, MXML_DESCEND_FIRST); } else bufptr = buffer; mxmlElementSetAttr(function, "name", bufptr); if (scope) mxmlElementSetAttr(function, "scope", scope);#ifdef DEBUG fprintf(stderr, "function: %s\n", buffer); fprintf(stderr, " scope = %s\n", scope ? scope : "(null)"); fprintf(stderr, " comment = %p\n", comment); fprintf(stderr, " child = (%p) %s\n", comment->child, comment->child ? comment->child->value.text.string : "(null)"); fprintf(stderr, " last_child = (%p) %s\n", comment->last_child, comment->last_child ? comment->last_child->value.text.string : "(null)");#endif /* DEBUG */ if (type->last_child && strcmp(type->last_child->value.text.string, "void")) { returnvalue = mxmlNewElement(function, "returnvalue"); mxmlAdd(returnvalue, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type); description = mxmlNewElement(returnvalue, "description");#ifdef DEBUG fputs(" adding comment to returnvalue...\n", stderr);#endif /* DEBUG */ update_comment(returnvalue, comment->last_child); mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, comment->last_child); } else mxmlDelete(type); description = mxmlNewElement(function, "description");#ifdef DEBUG fputs(" adding comment to function...\n", stderr);#endif /* DEBUG */ update_comment(function, comment->last_child); mxmlAdd(description, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, comment->last_child); type = NULL; } else if (function && ((ch == ')' && parens == 1) || ch == ',')) { /* * Argument definition... */ if (strcmp(buffer, "void")) { mxmlNewText(type, type->child != NULL && type->last_child->value.text.string[0] != '(' && type->last_child->value.text.string[0] != '*', buffer);#ifdef DEBUG fprintf(stderr, "Argument: <<<< %s >>>\n", buffer);#endif /* DEBUG */ variable = add_variable(function, "argument", type); } else mxmlDelete(type); type = NULL; } else if (type->child && !function && (ch == ';' || ch == ',')) {#ifdef DEBUG fprintf(stderr, " got semicolon, typedefnode=%p, structclass=%p\n", typedefnode, structclass);#endif /* DEBUG */ if (typedefnode || structclass) {#ifdef DEBUG fprintf(stderr, "Typedef/struct/class: <<<< %s >>>>\n", buffer);#endif /* DEBUG */ if (typedefnode) { mxmlElementSetAttr(typedefnode, "name", buffer); sort_node(tree, typedefnode); } if (structclass && !mxmlElementGetAttr(structclass, "name")) {#ifdef DEBUG fprintf(stderr, "setting struct/class name to %s!\n", type->last_child->value.text.string);#endif /* DEBUG */ mxmlElementSetAttr(structclass, "name", buffer); sort_node(tree, structclass); structclass = NULL; } if (typedefnode) mxmlAdd(typedefnode, MXML_ADD_BEFORE, MXML_ADD_TO_PARENT, type); else mxmlDelete(type); type = NULL; typedefnode = NULL; } else if (type->child && !strcmp(type->child->value.text.string, "typedef")) { /* * Simple typedef... */#ifdef DEBUG fprintf(stderr, "Typedef: <<<< %s >>>\n", buffer);#endif /* DEBUG */ typedefnode = mxmlNewElement(MXML_NO_PARENT, "typedef"); mxmlElementSetAttr(typedefnode, "name", buffer); mxmlDelete(type->child); sort_node(tree, typedefnode); if (type->child) type->child->value.text.whitespace = 0; mxmlAdd(typedefnode, MXML_ADD_AFTER, MXML_ADD_TO_PARENT, type); type = NULL; } else if (!parens) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -