1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-20 18:50:08 +03:00

parser: Convert inputPush and inputPop to macros

This commit is contained in:
Nick Wellnhofer 2025-03-04 13:11:18 +01:00
parent 361f7bff92
commit c42b32277d
4 changed files with 13 additions and 121 deletions

View File

@ -829,12 +829,12 @@
<exports symbol='XML_SUBSTITUTE_NONE' type='macro'/>
<exports symbol='XML_SUBSTITUTE_PEREF' type='macro'/>
<exports symbol='XML_SUBSTITUTE_REF' type='macro'/>
<exports symbol='inputPop' type='macro'/>
<exports symbol='inputPush' type='macro'/>
<exports symbol='xmlParserMaxDepth' type='variable'/>
<exports symbol='xmlStringComment' type='variable'/>
<exports symbol='xmlStringText' type='variable'/>
<exports symbol='xmlStringTextNoenc' type='variable'/>
<exports symbol='inputPop' type='function'/>
<exports symbol='inputPush' type='function'/>
<exports symbol='xmlCheckLanguageID' type='function'/>
<exports symbol='xmlCopyChar' type='function'/>
<exports symbol='xmlCopyCharMultiByte' type='function'/>
@ -4315,6 +4315,10 @@
<info>Returns the attributes required for the specified element.</info>
<arg name='elt' info='HTML element'/>
</macro>
<macro name='inputPop' file='parserInternals'>
</macro>
<macro name='inputPush' file='parserInternals'>
</macro>
<macro name='isolat1ToUTF8' file='encoding'>
</macro>
<macro name='xmlChildrenNode' file='tree'>
@ -7413,17 +7417,6 @@ crash if you try to modify the tree)'/>
<return type='void'/>
<arg name='handler' type='xmlGenericErrorFunc *' info='the handler'/>
</function>
<function name='inputPop' file='parserInternals' module='parser'>
<info>Pops the top parser input from the input stack</info>
<return type='xmlParserInputPtr' info='the input just removed'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
</function>
<function name='inputPush' file='parserInternals' module='parser'>
<info>Pushes a new parser input on top of the input stack</info>
<return type='int' info='-1 in case of error, the index in the stack otherwise'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
<arg name='value' type='xmlParserInputPtr' info='the parser input'/>
</function>
<functype name='internalSubsetSAXFunc' file='parser' module='parser'>
<info>Callback on internal subset declaration.</info>
<return type='void'/>

View File

@ -22,6 +22,12 @@
extern "C" {
#endif
/*
* Backward compatibility
*/
#define inputPush xmlCtxtPushInput
#define inputPop xmlCtxtPopInput
/**
* xmlParserMaxDepth:
*
@ -558,13 +564,6 @@ XMLPUBFUN xmlChar *
xmlChar end2,
xmlChar end3);
/*
* Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.
*/
XMLPUBFUN int inputPush (xmlParserCtxtPtr ctxt,
xmlParserInputPtr value);
XMLPUBFUN xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt);
/*
* other commodities shared between parser.c and parserInternals.
*/

View File

@ -2048,33 +2048,6 @@ xmlCtxtPopInput(xmlParserCtxtPtr ctxt)
return (ret);
}
/**
* inputPush:
* @ctxt: an XML parser context
* @value: the parser input
*
* Pushes a new parser input on top of the input stack
*
* Returns -1 in case of error, the index in the stack otherwise
*/
int
inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
{
return(xmlCtxtPushInput(ctxt, value));
}
/**
* inputPop:
* @ctxt: an XML parser context
*
* Pops the top parser input from the input stack
*
* Returns the input just removed
*/
xmlParserInputPtr
inputPop(xmlParserCtxtPtr ctxt)
{
return(xmlCtxtPopInput(ctxt));
}
/**
* nodePush:
* @ctxt: an XML parser context

View File

@ -15625,77 +15625,6 @@ test_parser(void) {
return(test_ret);
}
static int
test_inputPop(void) {
int test_ret = 0;
int mem_base;
xmlParserInputPtr ret_val;
xmlParserCtxtPtr ctxt; /* an XML parser context */
int n_ctxt;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
ret_val = inputPop(ctxt);
desret_xmlParserInputPtr(ret_val);
call_tests++;
des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in inputPop",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf("\n");
}
}
function_tests++;
return(test_ret);
}
static int
test_inputPush(void) {
int test_ret = 0;
int mem_base;
int ret_val;
xmlParserCtxtPtr ctxt; /* an XML parser context */
int n_ctxt;
xmlParserInputPtr value; /* the parser input */
int n_value;
for (n_ctxt = 0;n_ctxt < gen_nb_xmlParserCtxtPtr;n_ctxt++) {
for (n_value = 0;n_value < gen_nb_xmlParserInputPtr;n_value++) {
mem_base = xmlMemBlocks();
ctxt = gen_xmlParserCtxtPtr(n_ctxt, 0);
value = gen_xmlParserInputPtr(n_value, 1);
ret_val = inputPush(ctxt, value);
desret_int(ret_val);
call_tests++;
des_xmlParserCtxtPtr(n_ctxt, ctxt, 0);
des_xmlParserInputPtr(n_value, value, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in inputPush",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_ctxt);
printf(" %d", n_value);
printf("\n");
}
}
}
function_tests++;
return(test_ret);
}
static int
test_xmlCheckLanguageID(void) {
int test_ret = 0;
@ -16826,9 +16755,7 @@ static int
test_parserInternals(void) {
int test_ret = 0;
if (quiet == 0) printf("Testing parserInternals : 30 of 77 functions ...\n");
test_ret += test_inputPop();
test_ret += test_inputPush();
if (quiet == 0) printf("Testing parserInternals : 28 of 75 functions ...\n");
test_ret += test_xmlCheckLanguageID();
test_ret += test_xmlCopyChar();
test_ret += test_xmlCopyCharMultiByte();