Fix some more parsing issues with static functions.

pull/192/head
Michael Sweet 7 years ago
parent 6689e9f805
commit d848f8278b
  1. 81
      doc/mxml.man
  2. 58
      doc/reference.html
  3. 67
      mxmldoc.c

@ -233,45 +233,33 @@ MXML_TEXT
Text fragment
.SH FUNCTIONS
.SS mxmlAdd
Add a node to a tree.
.PP
.nf
void mxmlAdd (
void mxmlAdd (
mxml_node_t *parent,
int where,
mxml_node_t *child,
mxml_node_t *node
);
.fi
.PP
Adds the specified node to the parent. If the child argument is not
\fBNULL\fR, puts the new node before or after the specified child depending
on the value of the where argument. If the child argument is \fBNULL\fR,
puts the new node at the beginning of the child list (\fBMXML_ADD_BEFORE\fR)
or at the end of the child list (\fBMXML_ADD_AFTER\fR). The constant
\fBMXML_ADD_TO_PARENT\fR can be used to specify a \fBNULL\fR child pointer.
.SS mxmlDelete
Delete a node and all of its children.
Insert node after this child...
.PP
.nf
void mxmlDelete (
void mxmlDelete (
mxml_node_t *node
);
.fi
.PP
If the specified node has a parent, this function first removes the
node from its parent using the \fImxmlRemove\fR function.
.SS mxmlElementDeleteAttr
Delete an attribute.
.PP
.nf
void mxmlElementDeleteAttr (
void mxmlElementDeleteAttr (
mxml_node_t *node,
const char *name
);
.fi
.PP
.SS mxmlElementGetAttr
Get an attribute.
.PP
@ -310,38 +298,26 @@ int mxmlElementGetAttrCount (
.PP
.SS mxmlElementSetAttr
Set an attribute.
Node
.PP
.nf
void mxmlElementSetAttr (
void mxmlElementSetAttr (
mxml_node_t *node,
const char *name,
const char *value
);
.fi
.PP
If the named attribute already exists, the value of the attribute
is replaced by the new string value. The string value is copied
into the element node. This function does nothing if the node is
not an element.
.SS mxmlElementSetAttrf
Set an attribute with a formatted value.
Range check input...
.PP
.nf
void mxmlElementSetAttrf (
void mxmlElementSetAttrf (
mxml_node_t *node,
const char *name,
const char *format,
...
);
.fi
.PP
If the named attribute already exists, the value of the attribute
is replaced by the new formatted string. The formatted string value is
copied into the element node. This function does nothing if the node
is not an element.
.SS mxmlEntityAddCallback
Add a callback to convert entities to Unicode.
.PP
@ -372,10 +348,10 @@ int mxmlEntityGetValue (
The entity name can also be a numeric constant. -1 is returned if the
name is not known.
.SS mxmlEntityRemoveCallback
Remove a callback.
Global data
.PP
.nf
void mxmlEntityRemoveCallback (
void mxmlEntityRemoveCallback (
mxml_entity_cb_t cb
);
.fi
@ -603,10 +579,10 @@ void * mxmlGetUserData (
.PP
.SS mxmlIndexDelete
Delete an index.
.PP
.nf
void mxmlIndexDelete (
void mxmlIndexDelete (
mxml_index_t *ind
);
.fi
@ -891,16 +867,13 @@ is deleted via \fImxmlDelete\fR.
.SS mxmlRemove
Remove a node from its parent.
Create the node and set the text value...
.PP
.nf
void mxmlRemove (
void mxmlRemove (
mxml_node_t *node
);
.fi
.PP
This function does not free memory used by the node - use \fImxmlDelete\fR
for that. This function does nothing if the node has no parent.
.SS mxmlRetain
Retain a node.
.PP
@ -1094,20 +1067,14 @@ The node is not changed if it (or its first child) is not a custom node.
.SS mxmlSetCustomHandlers
Set the handling functions for custom data.
Read the XML data...
.PP
.nf
void mxmlSetCustomHandlers (
void mxmlSetCustomHandlers (
mxml_custom_load_cb_t load,
mxml_custom_save_cb_t save
);
.fi
.PP
The load function accepts a node pointer and a data string and must
return 0 on success and non-zero on error.
.PP
The save function accepts a node pointer and must return a malloc'd
string on success and \fBNULL\fR on error.
.SS mxmlSetElement
Set the name of an element node.
.PP
@ -1120,10 +1087,10 @@ int mxmlSetElement (
.PP
The node is not changed if it is not an element node.
.SS mxmlSetErrorCallback
Set the error message callback.
Global data
.PP
.nf
void mxmlSetErrorCallback (
void mxmlSetErrorCallback (
mxml_error_cb_t cb
);
.fi
@ -1211,17 +1178,13 @@ int mxmlSetUserData (
.PP
.SS mxmlSetWrapMargin
Set the wrap margin when saving XML data.
Global data
.PP
.nf
void mxmlSetWrapMargin (
void mxmlSetWrapMargin (
int column
);
.fi
.PP
Wrapping is disabled when "column" is 0.
.SS mxmlWalkNext
Walk to the next logical node in the tree.
.PP

@ -262,7 +262,7 @@ h3.title {
<div class="body">
<h2 class="title"><a id="FUNCTIONS">Functions</a></h2>
<h3 class="function"><a id="mxmlAdd">mxmlAdd</a></h3>
<p class="description">Add a node to a tree.</p>
<p class="description"></p>
<p class="code">
void mxmlAdd (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_node_t">mxml_node_t</a> *parent,<br>
@ -281,7 +281,8 @@ void mxmlAdd (<br>
<dt>node</dt>
<dd class="description">Node to add</dd>
</dl>
<h4 class="discussion">Discussion</h4>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Add a node to a tree.</p>
<p class="discussion">Adds the specified node to the parent. If the child argument is not
<code>NULL</code>, puts the new node before or after the specified child depending
on the value of the where argument. If the child argument is <code>NULL</code>,
@ -289,7 +290,7 @@ puts the new node at the beginning of the child list (<code>MXML_ADD_BEFORE</cod
or at the end of the child list (<code>MXML_ADD_AFTER</code>). The constant
<code>MXML_ADD_TO_PARENT</code> can be used to specify a <code>NULL</code> child pointer.</p>
<h3 class="function"><a id="mxmlDelete">mxmlDelete</a></h3>
<p class="description">Delete a node and all of its children.</p>
<p class="description">Insert node after this child...</p>
<p class="code">
void mxmlDelete (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_node_t">mxml_node_t</a> *node<br>
@ -299,11 +300,12 @@ void mxmlDelete (<br>
<dt>node</dt>
<dd class="description">Node to delete</dd>
</dl>
<h4 class="discussion">Discussion</h4>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Delete a node and all of its children.</p>
<p class="discussion">If the specified node has a parent, this function first removes the
node from its parent using the <a href="#mxmlRemove"><code>mxmlRemove</code></a> function.</p>
<h3 class="function"><span class="info">&#160;Mini-XML 2.4&#160;</span><a id="mxmlElementDeleteAttr">mxmlElementDeleteAttr</a></h3>
<p class="description">Delete an attribute.</p>
<h3 class="function"><a id="mxmlElementDeleteAttr">mxmlElementDeleteAttr</a></h3>
<p class="description"></p>
<p class="code">
void mxmlElementDeleteAttr (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_node_t">mxml_node_t</a> *node,<br>
@ -316,6 +318,9 @@ void mxmlElementDeleteAttr (<br>
<dt>name</dt>
<dd class="description">Attribute name</dd>
</dl>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Delete an attribute.</p>
<p class="discussion"></p>
<h3 class="function"><a id="mxmlElementGetAttr">mxmlElementGetAttr</a></h3>
<p class="description">Get an attribute.</p>
<p class="code">
@ -373,7 +378,7 @@ int mxmlElementGetAttrCount (<br>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Number of attributes</p>
<h3 class="function"><a id="mxmlElementSetAttr">mxmlElementSetAttr</a></h3>
<p class="description">Set an attribute.</p>
<p class="description">Node</p>
<p class="code">
void mxmlElementSetAttr (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_node_t">mxml_node_t</a> *node,<br>
@ -389,13 +394,14 @@ void mxmlElementSetAttr (<br>
<dt>value</dt>
<dd class="description">Attribute value</dd>
</dl>
<h4 class="discussion">Discussion</h4>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Set an attribute.</p>
<p class="discussion">If the named attribute already exists, the value of the attribute
is replaced by the new string value. The string value is copied
into the element node. This function does nothing if the node is
not an element.</p>
<h3 class="function"><span class="info">&#160;Mini-XML 2.3&#160;</span><a id="mxmlElementSetAttrf">mxmlElementSetAttrf</a></h3>
<p class="description">Set an attribute with a formatted value.</p>
<h3 class="function"><a id="mxmlElementSetAttrf">mxmlElementSetAttrf</a></h3>
<p class="description">Range check input...</p>
<p class="code">
void mxmlElementSetAttrf (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_node_t">mxml_node_t</a> *node,<br>
@ -414,7 +420,8 @@ void mxmlElementSetAttrf (<br>
<dt>...</dt>
<dd class="description">Additional arguments as needed</dd>
</dl>
<h4 class="discussion">Discussion</h4>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Set an attribute with a formatted value.</p>
<p class="discussion">If the named attribute already exists, the value of the attribute
is replaced by the new formatted string. The formatted string value is
copied into the element node. This function does nothing if the node
@ -466,7 +473,7 @@ int mxmlEntityGetValue (<br>
<p class="discussion">The entity name can also be a numeric constant. -1 is returned if the
name is not known.</p>
<h3 class="function"><a id="mxmlEntityRemoveCallback">mxmlEntityRemoveCallback</a></h3>
<p class="description">Remove a callback.</p>
<p class="description">Global data</p>
<p class="code">
void mxmlEntityRemoveCallback (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_entity_cb_t">mxml_entity_cb_t</a> cb<br>
@ -476,6 +483,8 @@ void mxmlEntityRemoveCallback (<br>
<dt>cb</dt>
<dd class="description">Callback function to remove</dd>
</dl>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Remove a callback.</p>
<h3 class="function"><a id="mxmlFindElement">mxmlFindElement</a></h3>
<p class="description">Find the named element.</p>
<p class="code">
@ -800,7 +809,7 @@ void *mxmlGetUserData (<br>
<h4 class="returnvalue">Return Value</h4>
<p class="description">User data pointer</p>
<h3 class="function"><a id="mxmlIndexDelete">mxmlIndexDelete</a></h3>
<p class="description">Delete an index.</p>
<p class="description"></p>
<p class="code">
void mxmlIndexDelete (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_index_t">mxml_index_t</a> *ind<br>
@ -810,6 +819,8 @@ void mxmlIndexDelete (<br>
<dt>ind</dt>
<dd class="description">Index to delete</dd>
</dl>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Delete an index.</p>
<h3 class="function"><a id="mxmlIndexEnum">mxmlIndexEnum</a></h3>
<p class="description">Return the next node in the index.</p>
<p class="code">
@ -1232,7 +1243,7 @@ is deleted via <a href="#mxmlDelete"><code>mxmlDelete</code></a>.
</p>
<h3 class="function"><a id="mxmlRemove">mxmlRemove</a></h3>
<p class="description">Remove a node from its parent.</p>
<p class="description">Create the node and set the text value...</p>
<p class="code">
void mxmlRemove (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_node_t">mxml_node_t</a> *node<br>
@ -1242,7 +1253,8 @@ void mxmlRemove (<br>
<dt>node</dt>
<dd class="description">Node to remove</dd>
</dl>
<h4 class="discussion">Discussion</h4>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Remove a node from its parent.</p>
<p class="discussion">This function does not free memory used by the node - use <a href="#mxmlDelete"><code>mxmlDelete</code></a>
for that. This function does nothing if the node has no parent.</p>
<h3 class="function"><span class="info">&#160;Mini-XML 2.3&#160;</span><a id="mxmlRetain">mxmlRetain</a></h3>
@ -1532,7 +1544,7 @@ int mxmlSetCustom (<br>
</p>
<h3 class="function"><a id="mxmlSetCustomHandlers">mxmlSetCustomHandlers</a></h3>
<p class="description">Set the handling functions for custom data.</p>
<p class="description">Read the XML data...</p>
<p class="code">
void mxmlSetCustomHandlers (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_custom_load_cb_t">mxml_custom_load_cb_t</a> load,<br>
@ -1545,7 +1557,8 @@ void mxmlSetCustomHandlers (<br>
<dt>save</dt>
<dd class="description">Save function</dd>
</dl>
<h4 class="discussion">Discussion</h4>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Set the handling functions for custom data.</p>
<p class="discussion">The load function accepts a node pointer and a data string and must
return 0 on success and non-zero on error.<br>
<br>
@ -1570,7 +1583,7 @@ int mxmlSetElement (<br>
<h4 class="discussion">Discussion</h4>
<p class="discussion">The node is not changed if it is not an element node.</p>
<h3 class="function"><a id="mxmlSetErrorCallback">mxmlSetErrorCallback</a></h3>
<p class="description">Set the error message callback.</p>
<p class="description">Global data</p>
<p class="code">
void mxmlSetErrorCallback (<br>
&#160;&#160;&#160;&#160;<a href="#mxml_error_cb_t">mxml_error_cb_t</a> cb<br>
@ -1580,6 +1593,8 @@ void mxmlSetErrorCallback (<br>
<dt>cb</dt>
<dd class="description">Error callback function</dd>
</dl>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Set the error message callback.</p>
<h3 class="function"><a id="mxmlSetInteger">mxmlSetInteger</a></h3>
<p class="description">Set the value of an integer node.</p>
<p class="code">
@ -1718,8 +1733,8 @@ int mxmlSetUserData (<br>
</dl>
<h4 class="returnvalue">Return Value</h4>
<p class="description">0 on success, -1 on failure</p>
<h3 class="function"><span class="info">&#160;Mini-XML 2.3&#160;</span><a id="mxmlSetWrapMargin">mxmlSetWrapMargin</a></h3>
<p class="description">Set the wrap margin when saving XML data.</p>
<h3 class="function"><a id="mxmlSetWrapMargin">mxmlSetWrapMargin</a></h3>
<p class="description">Global data</p>
<p class="code">
void mxmlSetWrapMargin (<br>
&#160;&#160;&#160;&#160;int column<br>
@ -1729,7 +1744,8 @@ void mxmlSetWrapMargin (<br>
<dt>column</dt>
<dd class="description">Column for wrapping, 0 to disable wrapping</dd>
</dl>
<h4 class="discussion">Discussion</h4>
<h4 class="returnvalue">Return Value</h4>
<p class="description">Set the wrap margin when saving XML data.</p>
<p class="discussion">Wrapping is disabled when &quot;column&quot; is 0.
</p>

@ -2118,7 +2118,26 @@ scan_file(const char *filename, /* I - Filename */
if (function)
{
if (fstructclass)
mxml_node_t *temptype = mxmlFindElement(returnvalue, returnvalue, "type", NULL, NULL, MXML_DESCEND);
#ifdef DEBUG
fprintf(stderr, " returnvalue type=%p(%s)\n", temptype, temptype ? temptype->child->value.text.string : "null");
#endif /* DEBUG */
if (temptype && temptype->child &&
!strcmp(temptype->child->value.text.string, "static") &&
!strcmp(tree->value.element.name, "mxmldoc"))
{
/*
* Remove static functions...
*/
#ifdef DEBUG
fputs(" DELETING STATIC FUNCTION\n", stderr);
#endif /* DEBUG */
mxmlDelete(function);
}
else if (fstructclass)
{
sort_node(fstructclass, function);
fstructclass = NULL;
@ -2126,7 +2145,8 @@ scan_file(const char *filename, /* I - Filename */
else
sort_node(tree, function);
function = NULL;
function = NULL;
returnvalue = NULL;
}
else if (type && type->child &&
((!strcmp(type->child->value.text.string, "typedef") &&
@ -2411,7 +2431,27 @@ scan_file(const char *filename, /* I - Filename */
if (function)
{
if (!strcmp(tree->value.element.name, "class"))
mxml_node_t *temptype = mxmlFindElement(returnvalue, returnvalue, "type", NULL, NULL, MXML_DESCEND);
#ifdef DEBUG
fprintf(stderr, " returnvalue type=%p(%s)\n", temptype, temptype ? temptype->child->value.text.string : "null");
#endif /* DEBUG */
if (temptype && temptype->child &&
!strcmp(temptype->child->value.text.string, "static") &&
!strcmp(tree->value.element.name, "mxmldoc"))
{
/*
* Remove static functions...
*/
#ifdef DEBUG
fputs(" DELETING STATIC FUNCTION\n", stderr);
#endif /* DEBUG */
mxmlDelete(function);
}
else if (!strcmp(tree->value.element.name, "class"))
{
#ifdef DEBUG
fputs(" ADDING FUNCTION TO CLASS\n", stderr);
@ -2421,8 +2461,9 @@ scan_file(const char *filename, /* I - Filename */
else
mxmlDelete(function);
function = NULL;
variable = NULL;
function = NULL;
variable = NULL;
returnvalue = NULL;
}
if (type)
@ -3191,19 +3232,6 @@ scan_file(const char *filename, /* I - Filename */
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] == ':')
{
@ -3239,8 +3267,7 @@ scan_file(const char *filename, /* I - Filename */
comment->last_child->value.text.string : "(null)");
#endif /* DEBUG */
if (type->last_child &&
strcmp(type->last_child->value.text.string, "void"))
if (type->last_child)
{
returnvalue = mxmlNewElement(function, "returnvalue");

Loading…
Cancel
Save