cleanup patch from Anthony Jones fix the headers to avoid in make scan

* SAX.c: cleanup patch from Anthony Jones
* doc/Makefile.am: fix the headers to avoid in make scan
* parserInternals.c xpath.c include/libxml/*.h: cleanup of the
  includes, * vs Ptr and general cleanup
* parsedecl.py: first version of a script to extract the
  module interfaces, the goal will be to provide .decl or XML
  specification of the interfaces to build wrappers.
Daniel
This commit is contained in:
Daniel Veillard 2002-01-20 22:08:18 +00:00
parent 0f5f162eeb
commit 963d2ae415
16 changed files with 254 additions and 65 deletions

View File

@ -1,3 +1,13 @@
Sun Jan 20 23:03:41 CET 2002 Daniel Veillard <daniel@veillard.com>
* SAX.c: cleanup patch from Anthony Jones
* doc/Makefile.am: fix the headers to avoid in make scan
* parserInternals.c xpath.c include/libxml/*.h: cleanup of the
includes, * vs Ptr and general cleanup
* parsedecl.py: first version of a script to extract the
module interfaces, the goal will be to provide .decl or XML
specification of the interfaces to build wrappers.
Sun Jan 20 13:38:22 CET 2002 Daniel Veillard <daniel@veillard.com>
* doc/xmlcatalog_man.xml xmlcatalog.c: Fixed bug #68830, xmlcatalog

View File

@ -847,18 +847,6 @@ static const char *docbStartClose[] = {
NULL
};
/*
* The list of SGML elements which are supposed not to have
* CDATA content and where a p element will be implied
*
* TODO: extend that list by reading the SGML SGML DTD on
* implied paragraph
*/
static char *docbNoContentElements[] = {
NULL
};
static const char** docbStartCloseIndex[100];
static int docbStartCloseIndexinitialized = 0;

13
SAX.c
View File

@ -1062,14 +1062,14 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
((attr->prefix == NULL) &&
(xmlStrEqual(attr->name, BAD_CAST "xmlns"))) ||
(ctxt->loadsubset & XML_COMPLETE_ATTRS)) {
xmlChar buffer[100];
const xmlChar *fulln = attr->name;
xmlChar *fulln;
if (attr->prefix != NULL) {
snprintf((char *) buffer, 99, "%s:%s",
attr->prefix, attr->name);
buffer[99] = 0;
fulln = buffer;
fulln = xmlStrdup(attr->prefix);
fulln = xmlStrcat(fulln, BAD_CAST ":");
fulln = xmlStrcat(fulln, attr->name);
} else {
fulln = xmlStrdup(attr->name);
}
/*
@ -1089,6 +1089,7 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
}
if (att == NULL)
attribute(ctxt, fulln, attr->defaultValue);
xmlFree(fulln);
}
}
attr = attr->nexth;

View File

@ -26,7 +26,7 @@ $(PAGES): xml.html site.xsl
$(bindir)/xsltproc --html $(top_srcdir)/doc/site.xsl $(top_srcdir)/doc/xml.html > index.html ; fi );
scan:
gtkdoc-scan --module=libxml --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="acconfig.h config.h xmlwin32version.h win32config.h trio.h strio.h triop.h"
gtkdoc-scan --module=libxml --source-dir=$(DOC_SOURCE_DIR) --ignore-headers="acconfig.h config.h xmlwin32version.h win32config.h trio.h triostr.h triop.h config-mac.h XMLTestPrefix2.h XMLTestPrefix.h triodef.h trionan.h xlink.h"
templates: scan
gtkdoc-mktmpl --module=libxml

View File

@ -30,9 +30,9 @@ typedef xmlNodePtr docbNodePtr;
/*
* There is only few public functions.
*/
int docbEncodeEntities(unsigned char* out,
int docbEncodeEntities(unsigned char *out,
int *outlen,
const unsigned char* in,
const unsigned char *in,
int *inlen, int quoteChar);
docbDocPtr docbSAXParseDoc (xmlChar *cur,

View File

@ -58,16 +58,16 @@ struct _htmlEntityDesc {
/*
* There is only few public functions.
*/
const htmlElemDesc * htmlTagLookup (const xmlChar *tag);
const htmlEntityDesc * htmlEntityLookup(const xmlChar *name);
const htmlEntityDesc * htmlEntityValueLookup(unsigned int value);
const htmlElemDesc * htmlTagLookup (const xmlChar *tag);
const htmlEntityDesc * htmlEntityLookup(const xmlChar *name);
const htmlEntityDesc * htmlEntityValueLookup(unsigned int value);
int htmlIsAutoClosed(htmlDocPtr doc,
htmlNodePtr elem);
int htmlAutoCloseTag(htmlDocPtr doc,
const xmlChar *name,
htmlNodePtr elem);
const htmlEntityDesc * htmlParseEntityRef(htmlParserCtxtPtr ctxt,
const htmlEntityDesc * htmlParseEntityRef(htmlParserCtxtPtr ctxt,
xmlChar **str);
int htmlParseCharRef(htmlParserCtxtPtr ctxt);
void htmlParseElement(htmlParserCtxtPtr ctxt);
@ -84,13 +84,13 @@ htmlDocPtr htmlSAXParseFile(const char *filename,
void *userData);
htmlDocPtr htmlParseFile (const char *filename,
const char *encoding);
int UTF8ToHtml (unsigned char* out,
int UTF8ToHtml (unsigned char *out,
int *outlen,
const unsigned char* in,
const unsigned char *in,
int *inlen);
int htmlEncodeEntities(unsigned char* out,
int htmlEncodeEntities(unsigned char *out,
int *outlen,
const unsigned char* in,
const unsigned char *in,
int *inlen, int quoteChar);
int htmlIsScriptAttribute(const xmlChar *name);
int htmlHandleOmittedElem(int val);

View File

@ -63,7 +63,7 @@ const xmlChar * htmlGetMetaEncoding (htmlDocPtr doc);
int htmlSetMetaEncoding (htmlDocPtr doc,
const xmlChar *encoding);
void htmlDocDumpMemory (xmlDocPtr cur,
xmlChar**mem,
xmlChar **mem,
int *size);
int htmlDocDump (FILE *f,
xmlDocPtr cur);

View File

@ -102,7 +102,8 @@ typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
xmlNodePtr node,
xmlNodePtr node2);
void xmlShellPrintXPathError (int errorType, const char* arg);
void xmlShellPrintXPathError (int errorType,
const char *arg);
void xmlShellPrintNode (xmlNodePtr node);
void xmlShellPrintXPathResult(xmlXPathObjectPtr list);
int xmlShellList (xmlShellCtxtPtr ctxt,

View File

@ -96,8 +96,8 @@ typedef enum {
* as the return value is positive, else unpredictiable.
* The value of @outlen after return is the number of octets consumed.
*/
typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen);
typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen);
/**
@ -118,8 +118,8 @@ typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
* as the return value is positive, else unpredictiable.
* The value of @outlen after return is the number of ocetes consumed.
*/
typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int *outlen,
const unsigned char* in, int *inlen);
typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
const unsigned char *in, int *inlen);
/*
@ -161,15 +161,15 @@ const char *
xmlGetEncodingAlias (const char *alias);
void xmlCleanupEncodingAliases (void);
xmlCharEncoding
xmlParseCharEncoding (const char* name);
const char*
xmlParseCharEncoding (const char *name);
const char *
xmlGetCharEncodingName (xmlCharEncoding enc);
/*
* Interfaces directly used by the parsers.
*/
xmlCharEncoding
xmlDetectCharEncoding (const unsigned char* in,
xmlDetectCharEncoding (const unsigned char *in,
int len);
int xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
@ -187,13 +187,13 @@ int xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
/*
* Export a few useful functions
*/
int UTF8Toisolat1 (unsigned char* out,
int UTF8Toisolat1 (unsigned char *out,
int *outlen,
const unsigned char* in,
const unsigned char *in,
int *inlen);
int isolat1ToUTF8 (unsigned char* out,
int isolat1ToUTF8 (unsigned char *out,
int *outlen,
const unsigned char* in,
const unsigned char *in,
int *inlen);
/*
* exports additional "UTF-8 aware" string routines which are

View File

@ -39,7 +39,7 @@ extern "C" {
* Note that only one of year and day:minute are specified
*/
typedef void (*ftpListCallback) (void *userData,
const char *filename, const char* attrib,
const char *filename, const char *attrib,
const char *owner, const char *group,
unsigned long size, int links, int year,
const char *month, int day, int hour,
@ -52,7 +52,9 @@ typedef void (*ftpListCallback) (void *userData,
*
* A callback for the xmlNanoFTPGet command
*/
typedef void (*ftpDataCallback) (void *userData, const char *data, int len);
typedef void (*ftpDataCallback) (void *userData,
const char *data,
int len);
/*
* Init

View File

@ -502,7 +502,7 @@ void xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
const xmlChar* buffer,
const char* filename);
const char *filename);
xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur);
/*
@ -550,14 +550,14 @@ xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
* Node infos
*/
const xmlParserNodeInfo*
xmlParserFindNodeInfo (const xmlParserCtxt* ctxt,
const xmlNode* node);
xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
const xmlNodePtr node);
void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
const xmlNode* node);
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
const xmlNodePtr node);
void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
const xmlParserNodeInfo* info);
const xmlParserNodeInfoPtr info);
/*
* External entities handling actually implemented in xmlIO

View File

@ -787,11 +787,11 @@ int xmlReconciliateNs (xmlDocPtr doc,
* Saving
*/
void xmlDocDumpFormatMemory (xmlDocPtr cur,
xmlChar**mem,
xmlChar **mem,
int *size,
int format);
void xmlDocDumpMemory (xmlDocPtr cur,
xmlChar**mem,
xmlChar **mem,
int *size);
void xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
xmlChar **doc_txt_ptr,

View File

@ -335,8 +335,7 @@ void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
/*
* Function Lookup forwarding
*/
typedef xmlXPathFunction
(*xmlXPathFuncLookupFunc) (void *ctxt,
typedef xmlXPathFunction xmlXPathFuncLookupFunc (void *ctxt,
const xmlChar *name,
const xmlChar *ns_uri);
@ -448,7 +447,7 @@ int valuePush (xmlXPathParserContextPtr ctxt,
xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val);
xmlXPathObjectPtr xmlXPathNewCString (const char *val);
xmlXPathObjectPtr xmlXPathWrapString (xmlChar *val);
xmlXPathObjectPtr xmlXPathWrapCString (char *val);
xmlXPathObjectPtr xmlXPathWrapCString (char * val);
xmlXPathObjectPtr xmlXPathNewFloat (double val);
xmlXPathObjectPtr xmlXPathNewBoolean (int val);
xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);

185
parsedecl.py Executable file
View File

@ -0,0 +1,185 @@
#!/usr/bin/python -u
#
# tries to parse the output of gtk-doc declaration files and make
# something usable from them
#
import sys
import string
input = open('doc/libxml-decl.txt')
macros = []
structs = []
typedefs = []
enums = {}
functions = {}
private_functions = {}
types = {}
def extractTypes(raw, function):
global types
tokens = string.split(raw)
type = ''
for token in tokens:
if type != '':
type = type + ' ' + token
else:
type = token
if types.has_key(type):
types[type].append(function)
else:
types[type] = [function]
return type
def parseMacro():
global input
global macros
line = input.readline()[:-1]
while line != "</MACRO>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
line = input.readline()[:-1]
macros.append(name)
def parseStruct():
global input
global structs
line = input.readline()[:-1]
while line != "</STRUCT>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
line = input.readline()[:-1]
structs.append(name)
def parseTypedef():
global input
global typedefs
line = input.readline()[:-1]
while line != "</TYPEDEF>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
line = input.readline()[:-1]
typedefs.append(name)
def parseEnum():
global input
global enums
line = input.readline()[:-1]
consts = []
while line != "</ENUM>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
elif string.find(line, 'enum') >= 0:
pass
elif string.find(line, '{') >= 0:
pass
elif string.find(line, '}') >= 0:
pass
elif string.find(line, ';') >= 0:
pass
else:
comment = string.find(line, '/*')
if comment >= 0:
line = line[0:comment]
decls = string.split(line, ",")
for decl in decls:
val = string.split(decl, "=")[0]
tokens = string.split(val)
if len(tokens) >= 1:
token = tokens[0]
if string.find(string.letters, token[0]) >= 0:
consts.append(token)
line = input.readline()[:-1]
enums[name] = consts
def parseStaticFunction():
global input
global private_functions
line = input.readline()[:-1]
type = None
signature = None
while line != "</USER_FUNCTION>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
elif line[0:9] == "<RETURNS>" and line[-10:] == "</RETURNS>":
type = extractTypes(line[9:-10], name)
else:
signature = line
line = input.readline()[:-1]
args = string.split(signature, ",")
sig = []
for arg in args:
l = string.split(arg)
sig.append(extractTypes(l[0], name))
private_functions[name] = (type , sig)
def parseFunction():
global input
global functions
line = input.readline()[:-1]
type = None
signature = None
while line != "</FUNCTION>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
elif line[0:9] == "<RETURNS>" and line[-10:] == "</RETURNS>":
type = extractTypes(line[9:-10], name)
else:
signature = line
line = input.readline()[:-1]
args = string.split(signature, ",")
sig = []
for arg in args:
l = string.split(arg)
sig.append(extractTypes(l[0], name))
functions[name] = (type , sig)
while 1:
line = input.readline()
if not line:
break
line = line[:-1]
if line == "<MACRO>":
parseMacro()
elif line == "<ENUM>":
parseEnum()
elif line == "<FUNCTION>":
parseFunction()
elif line == "<STRUCT>":
parseStruct()
elif line == "<TYPEDEF>":
parseTypedef()
elif line == "<USER_FUNCTION>":
parseStaticFunction()
elif len(line) >= 1 and line[0] == "<":
print "unhandled %s" % (line)
print "Parsed: %d macros. %d structs, %d typedefs, %d enums" % (
len(macros), len(structs), len(typedefs), len(enums))
c = 0
for enum in enums.keys():
consts = enums[enum]
c = c + len(consts)
print " %d constants, %d functions and %d private functions" % (
c, len(functions.keys()), len(private_functions.keys()))
print "The functions uses %d different types" % (len(types.keys()))
for type in types.keys():
if string.find(type, '*') >= 0 or (type[0:3] != 'xml' and
type[0:4] != 'html' and type[0:4] != 'docb'):
# print " %s : %s" % (type, types[type])
print " %s" % (type)

View File

@ -2378,8 +2378,8 @@ xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
*
* Returns an xmlParserNodeInfo block pointer or NULL
*/
const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* ctx,
const xmlNode* node)
const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxtPtr ctx,
const xmlNodePtr node)
{
unsigned long pos;
@ -2433,8 +2433,8 @@ xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
*
* Returns a long indicating the position of the record
*/
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
const xmlNode* node)
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
const xmlNodePtr node)
{
unsigned long upper, lower, middle;
int found = 0;
@ -2470,13 +2470,14 @@ unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
*/
void
xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
const xmlParserNodeInfo* info)
const xmlParserNodeInfoPtr info)
{
unsigned long pos;
static unsigned int block_size = 5;
/* Find pos and check to see if node is already in the sequence */
pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, info->node);
pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (const xmlNodePtr)
info->node);
if ( pos < ctxt->node_seq.length
&& ctxt->node_seq.buffer[pos].node == info->node ) {
ctxt->node_seq.buffer[pos] = *info;

10
xpath.c
View File

@ -2291,9 +2291,10 @@ xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
if (ctxt->funcLookupFunc != NULL) {
xmlXPathFunction ret;
xmlXPathFuncLookupFunc *f;
ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
(ctxt->funcLookupData, name, NULL);
f = (xmlXPathFuncLookupFunc *) ctxt->funcLookupFunc;
ret = f(ctxt->funcLookupData, name, NULL);
if (ret != NULL)
return(ret);
}
@ -2321,9 +2322,10 @@ xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
if (ctxt->funcLookupFunc != NULL) {
xmlXPathFunction ret;
xmlXPathFuncLookupFunc *f;
ret = ((xmlXPathFuncLookupFunc) ctxt->funcLookupFunc)
(ctxt->funcLookupData, name, ns_uri);
f = (xmlXPathFuncLookupFunc *) ctxt->funcLookupFunc;
ret = f(ctxt->funcLookupData, name, ns_uri);
if (ret != NULL)
return(ret);
}