Re: [xml] xmlHashScan and *data argument



On Sunday 19 October 2003 23:01, Daniel Veillard wrote:
On Sun, Oct 19, 2003 at 10:43:33PM +0200, Melvyn Sopacua wrote:
Content-Description: signed data

This works:
========================================================================
void printElementStructured(xmlElementPtr el)

[...]

This doesn't:
========================================================================
void printElementStructured(int *level, xmlElementPtr el)
{

[...]

    xmlHashScan(table, (xmlHashScanner) printElementStructured, &level);

 And you're surprised ?
 Your problem is the use of the C language apparently. You cannot expect
to shuffle arguments and have the compiler guess magically that your
interface changed and reorder arguments.

Ehm - then I don't know why your own code in valid.c works.

 xmlElementPtr is the first argument, changing it to the second one is
unlikely to work with any C compiler. Parameters are accessed by index
on the stack relative to the current function frame pointer, not by magic
name association.

How is the second version different from:
/**
 * xmlDumpElementDecl:
 * @buf:  the XML buffer output
 * @elem:  An element table
 *
 * This will dump the content of the element declaration as an XML
 * DTD definition
 */
void
xmlDumpElementDecl(xmlBufferPtr buf, xmlElementPtr elem) {
/* Notice buf as first argument */
}

/**
 * xmlDumpElementTable:
 * @buf:  the XML buffer output
 * @table:  An element table
 *
 * This will dump the content of the element table as an XML DTD definition
 */
void
xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table) {
    xmlHashScan(table, (xmlHashScanner) xmlDumpElementDecl, buf);
}

Further investigation shows that xmlSchemaTypeDump in xmlschema.c indeed has 
the argument order you list and swapping the arguments in my function works.
-- 
Melvyn

Attachment: pgpRNKcMAhrO9.pgp
Description: signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]