diff --git a/doc/mxml.man b/doc/mxml.man index 40237ac..75a7691 100644 --- a/doc/mxml.man +++ b/doc/mxml.man @@ -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 diff --git a/doc/reference.html b/doc/reference.html index dd00925..11766aa 100644 --- a/doc/reference.html +++ b/doc/reference.html @@ -262,7 +262,7 @@ h3.title {

Functions

mxmlAdd

-

Add a node to a tree.

+

void mxmlAdd (
    mxml_node_t *parent,
@@ -281,7 +281,8 @@ void mxmlAdd (

node
Node to add
-

Discussion

+

Return Value

+

Add a node to a tree.

Adds the specified node to the parent. If the child argument is not NULL, puts the new node before or after the specified child depending on the value of the where argument. If the child argument is NULL, @@ -289,7 +290,7 @@ puts the new node at the beginning of the child list (MXML_ADD_BEFOREMXML_ADD_AFTER). The constant MXML_ADD_TO_PARENT can be used to specify a NULL child pointer.

mxmlDelete

-

Delete a node and all of its children.

+

Insert node after this child...

void mxmlDelete (
    mxml_node_t *node
@@ -299,11 +300,12 @@ void mxmlDelete (

node
Node to delete
-

Discussion

+

Return Value

+

Delete a node and all of its children.

If the specified node has a parent, this function first removes the node from its parent using the mxmlRemove function.

-

 Mini-XML 2.4 mxmlElementDeleteAttr

-

Delete an attribute.

+

mxmlElementDeleteAttr

+

void mxmlElementDeleteAttr (
    mxml_node_t *node,
@@ -316,6 +318,9 @@ void mxmlElementDeleteAttr (

name
Attribute name
+

Return Value

+

Delete an attribute.

+

mxmlElementGetAttr

Get an attribute.

@@ -373,7 +378,7 @@ int mxmlElementGetAttrCount (

Return Value

Number of attributes

mxmlElementSetAttr

-

Set an attribute.

+

Node

void mxmlElementSetAttr (
    mxml_node_t *node,
@@ -389,13 +394,14 @@ void mxmlElementSetAttr (

value
Attribute value
-

Discussion

+

Return Value

+

Set an attribute.

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.

-

 Mini-XML 2.3 mxmlElementSetAttrf

-

Set an attribute with a formatted value.

+

mxmlElementSetAttrf

+

Range check input...

void mxmlElementSetAttrf (
    mxml_node_t *node,
@@ -414,7 +420,8 @@ void mxmlElementSetAttrf (

...
Additional arguments as needed
-

Discussion

+

Return Value

+

Set an attribute with a formatted value.

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 (

The entity name can also be a numeric constant. -1 is returned if the name is not known.

mxmlEntityRemoveCallback

-

Remove a callback.

+

Global data

void mxmlEntityRemoveCallback (
    mxml_entity_cb_t cb
@@ -476,6 +483,8 @@ void mxmlEntityRemoveCallback (

cb
Callback function to remove
+

Return Value

+

Remove a callback.

mxmlFindElement

Find the named element.

@@ -800,7 +809,7 @@ void *mxmlGetUserData (

Return Value

User data pointer

mxmlIndexDelete

-

Delete an index.

+

void mxmlIndexDelete (
    mxml_index_t *ind
@@ -810,6 +819,8 @@ void mxmlIndexDelete (

ind
Index to delete
+

Return Value

+

Delete an index.

mxmlIndexEnum

Return the next node in the index.

@@ -1232,7 +1243,7 @@ is deleted via mxmlDelete.

mxmlRemove

-

Remove a node from its parent.

+

Create the node and set the text value...

void mxmlRemove (
    mxml_node_t *node
@@ -1242,7 +1253,8 @@ void mxmlRemove (

node
Node to remove
-

Discussion

+

Return Value

+

Remove a node from its parent.

This function does not free memory used by the node - use mxmlDelete for that. This function does nothing if the node has no parent.

 Mini-XML 2.3 mxmlRetain

@@ -1532,7 +1544,7 @@ int mxmlSetCustom (

mxmlSetCustomHandlers

-

Set the handling functions for custom data.

+

Read the XML data...

void mxmlSetCustomHandlers (
    mxml_custom_load_cb_t load,
@@ -1545,7 +1557,8 @@ void mxmlSetCustomHandlers (

save
Save function
-

Discussion

+

Return Value

+

Set the handling functions for custom data.

The load function accepts a node pointer and a data string and must return 0 on success and non-zero on error.

@@ -1570,7 +1583,7 @@ int mxmlSetElement (

Discussion

The node is not changed if it is not an element node.

mxmlSetErrorCallback

-

Set the error message callback.

+

Global data

void mxmlSetErrorCallback (
    mxml_error_cb_t cb
@@ -1580,6 +1593,8 @@ void mxmlSetErrorCallback (

cb
Error callback function
+

Return Value

+

Set the error message callback.

mxmlSetInteger

Set the value of an integer node.

@@ -1718,8 +1733,8 @@ int mxmlSetUserData (

Return Value

0 on success, -1 on failure

-

 Mini-XML 2.3 mxmlSetWrapMargin

-

Set the wrap margin when saving XML data.

+

mxmlSetWrapMargin

+

Global data

void mxmlSetWrapMargin (
    int column
@@ -1729,7 +1744,8 @@ void mxmlSetWrapMargin (

column
Column for wrapping, 0 to disable wrapping
-

Discussion

+

Return Value

+

Set the wrap margin when saving XML data.

Wrapping is disabled when "column" is 0.

diff --git a/mxmldoc.c b/mxmldoc.c index e82c8fd..6e89d26 100644 --- a/mxmldoc.c +++ b/mxmldoc.c @@ -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");