List private, protected, and public members of the class separately.

web
Michael R Sweet 20 years ago
parent 465d3e7231
commit 36fc2a366d
  1. 141
      mxmldoc.c
  2. 29
      test/class.cxx

@ -1,5 +1,5 @@
/*
* "$Id: mxmldoc.c,v 1.33 2004/05/01 15:20:05 mike Exp $"
* "$Id: mxmldoc.c,v 1.34 2004/05/01 22:45:34 mike Exp $"
*
* Documentation generator using mini-XML, a small XML-like file parsing
* library.
@ -1717,6 +1717,7 @@ update_comment(mxml_node_t *parent, /* I - Parent node */
static void
write_documentation(mxml_node_t *doc) /* I - XML documentation */
{
int i; /* Looping var */
mxml_node_t *function, /* Current function */
*scut, /* Struct/class/union/typedef */
*arg, /* Current argument */
@ -1725,9 +1726,15 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
const char *name, /* Name of function/type */
*cname, /* Class name */
*defval, /* Default value */
*parent, /* Parent class */
*scope; /* Variable/method scope */
*parent; /* Parent class */
int inscope; /* Variable/method scope */
char prefix; /* Prefix character */
static const char * const scopes[] = /* Scope strings */
{
"private",
"protected",
"public"
};
/*
@ -1820,83 +1827,87 @@ write_documentation(mxml_node_t *doc) /* I - XML documentation */
if ((parent = mxmlElementGetAttr(scut, "parent")) != NULL)
printf(" %s", parent);
puts("\n{");
scope = "";
for (arg = mxmlFindElement(scut, scut, "variable", NULL, NULL,
MXML_DESCEND_FIRST);
arg;
arg = mxmlFindElement(arg, scut, "variable", NULL, NULL,
MXML_NO_DESCEND))
for (i = 0; i < 3; i ++)
{
if (strcmp(scope, mxmlElementGetAttr(arg, "scope")))
{
scope = mxmlElementGetAttr(arg, "scope");
printf(" %s:\n", scope);
}
inscope = 0;
printf(" ");
write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST));
printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
}
for (function = mxmlFindElement(scut, scut, "function", NULL, NULL,
MXML_DESCEND_FIRST);
function;
function = mxmlFindElement(function, scut, "function", NULL, NULL,
MXML_NO_DESCEND))
{
if (strcmp(scope, mxmlElementGetAttr(function, "scope")))
for (arg = mxmlFindElement(scut, scut, "variable", "scope", scopes[i],
MXML_DESCEND_FIRST);
arg;
arg = mxmlFindElement(arg, scut, "variable", "scope", scopes[i],
MXML_NO_DESCEND))
{
scope = mxmlElementGetAttr(function, "scope");
printf(" %s:\n", scope);
}
name = mxmlElementGetAttr(function, "name");
printf(" ");
arg = mxmlFindElement(function, function, "returnvalue", NULL,
NULL, MXML_DESCEND_FIRST);
if (!inscope)
{
inscope = 1;
printf(" %s:\n", scopes[i]);
}
if (arg)
{
printf(" ");
write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST));
putchar(' ');
printf(" %s;\n", mxmlElementGetAttr(arg, "name"));
}
else if (strcmp(cname, name) && strcmp(cname, name + 1))
fputs("void ", stdout);
printf("<a href='#%s.%s'>%s</a>", cname, name, name);
for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
MXML_DESCEND_FIRST), prefix = '(';
arg;
arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
MXML_NO_DESCEND), prefix = ',')
for (function = mxmlFindElement(scut, scut, "function", "scope", scopes[i],
MXML_DESCEND_FIRST);
function;
function = mxmlFindElement(function, scut, "function", "scope", scopes[i],
MXML_NO_DESCEND))
{
type = mxmlFindElement(arg, arg, "type", NULL, NULL,
MXML_DESCEND_FIRST);
if (!inscope)
{
inscope = 1;
printf(" %s:\n", scopes[i]);
}
putchar(prefix);
if (prefix == ',')
putchar(' ');
name = mxmlElementGetAttr(function, "name");
if (type->child)
printf(" ");
arg = mxmlFindElement(function, function, "returnvalue", NULL,
NULL, MXML_DESCEND_FIRST);
if (arg)
{
write_element(doc, type);
write_element(doc, mxmlFindElement(arg, arg, "type", NULL,
NULL, MXML_DESCEND_FIRST));
putchar(' ');
}
fputs(mxmlElementGetAttr(arg, "name"), stdout);
if ((defval = mxmlElementGetAttr(arg, "default")) != NULL)
printf(" %s", defval);
}
else if (strcmp(cname, name) && strcmp(cname, name + 1))
fputs("void ", stdout);
if (prefix == '(')
puts("(void);");
else
puts(");");
printf("<a href='#%s.%s'>%s</a>", cname, name, name);
for (arg = mxmlFindElement(function, function, "argument", NULL, NULL,
MXML_DESCEND_FIRST), prefix = '(';
arg;
arg = mxmlFindElement(arg, function, "argument", NULL, NULL,
MXML_NO_DESCEND), prefix = ',')
{
type = mxmlFindElement(arg, arg, "type", NULL, NULL,
MXML_DESCEND_FIRST);
putchar(prefix);
if (prefix == ',')
putchar(' ');
if (type->child)
{
write_element(doc, type);
putchar(' ');
}
fputs(mxmlElementGetAttr(arg, "name"), stdout);
if ((defval = mxmlElementGetAttr(arg, "default")) != NULL)
printf(" %s", defval);
}
if (prefix == '(')
puts("(void);");
else
puts(");");
}
}
puts("};\n</pre>");
@ -2697,5 +2708,5 @@ ws_cb(mxml_node_t *node, /* I - Element node */
/*
* End of "$Id: mxmldoc.c,v 1.33 2004/05/01 15:20:05 mike Exp $".
* End of "$Id: mxmldoc.c,v 1.34 2004/05/01 22:45:34 mike Exp $".
*/

@ -3,8 +3,6 @@ class foo_c : public bar_c // Foo class derived from bar
float foo; /* Real number */
int bar; /* Integer */
static int global; /* Global integer */
public:
foo_c(float f, int b);
@ -40,11 +38,36 @@ class foo_c : public bar_c // Foo class derived from bar
// 'set_foobar()' - Set foo and optionally bar (should show default args).
void
set_foobar(float f, int b = 0)
set_foobar(float f, // I - Value of foo
int b = 0) // I - Value of bar
{
foo = f;
bar = b;
}
protected:
static int global; /* Global integer */
// 'get_global()' - Get the global integer.
int // O - Integer
get_global()
{
return (global);
}
private:
int barfoo; // Another private integer
public:
// 'get_barfoo()' - Get the barfoo value.
int // O - Barfoo value
get_barfoo()
{
return (barfoo);
}
}
// 'foo_c::foo_c()' - Create a foo_c class.

Loading…
Cancel
Save