rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
all: examples.xml index.html
rebuild: examples.xml index.html
def dump_Makefile(): for file in glob.glob('*.xml'): extras.append(file) for file in glob.glob('*.out'): extras.append(file) Makefile="""# Beware this is autogenerated by index.py
if type(o) == type([]) or type(o) == type(()): ret = map(lambda x: nodeWrap(x), o)
otype = type(o) if otype == type([]): ret = map(xpathObjectRet, o)
def xpathObjectRet(o): if type(o) == type([]) or type(o) == type(()): ret = map(lambda x: nodeWrap(x), o) return ret return o
return o
elif otype == type(()): ret = map(xpathObjectRet, o) return tuple(ret) elif otype == type('') or otype == type(0) or otype == type(0.0): return o else: return nodeWrap(o)
def xpathObjectRet(o): if type(o) == type([]) or type(o) == type(()): ret = map(lambda x: nodeWrap(x), o) return ret return o
res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), reader.Value(), reader.IsEmptyElement())
res=res + "%s (%s) [%s] %d %d\n" % (reader.NodeType(),reader.Name(), reader.Value(), reader.IsEmptyElement(), reader.Depth())
def tst_reader(s): f = StringIO.StringIO(s) input = libxml2.inputBuffer(f) reader = input.newTextReader("tst") res = "" while reader.Read(): res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), reader.Value(), reader.IsEmptyElement()) if reader.NodeType() == 1: # Element while reader.MoveToNextAttribute():...
res = res + "-- %s (%s) [%s]\n" % (reader.NodeType(), reader.Name(),reader.Value())
res = res + "-- %s (%s) [%s] %d\n" % (reader.NodeType(), reader.Name(),reader.Value(), reader.Depth())
def tst_reader(s): f = StringIO.StringIO(s) input = libxml2.inputBuffer(f) reader = input.newTextReader("tst") res = "" while reader.Read(): res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), reader.Value(), reader.IsEmptyElement()) if reader.NodeType() == 1: # Element while reader.MoveToNextAttribute():...
expect="""1 (a) [None] 0 1 (b) [None] 1 1 (c) [None] 0 3 ( 15 (c) [None] 0 15 (a) [None] 0
expect="""1 (a) [None] 0 0 1 (b) [None] 1 1 -- 2 (b1) [b1] 2 1 (c) [None] 0 1 3 ( 15 (c) [None] 0 1 15 (a) [None] 0 0
def tst_reader(s): f = StringIO.StringIO(s) input = libxml2.inputBuffer(f) reader = input.newTextReader("tst") res = "" while reader.Read(): res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), reader.Value(), reader.IsEmptyElement()) if reader.NodeType() == 1: # Element while reader.MoveToNextAttribute():...
expect="""1 (test) [None] 0 1 (b) [None] 1 1 (c) [None] 1 15 (test) [None] 0
expect="""1 (test) [None] 0 0 1 (b) [None] 1 1 1 (c) [None] 1 1 15 (test) [None] 0 0
def tst_reader(s): f = StringIO.StringIO(s) input = libxml2.inputBuffer(f) reader = input.newTextReader("tst") res = "" while reader.Read(): res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), reader.Value(), reader.IsEmptyElement()) if reader.NodeType() == 1: # Element while reader.MoveToNextAttribute():...
print "test5 failed"
print "test9 failed" print res sys.exit(1) doc="""<a><b>bbb</b><c>ccc</c></a>""" expect="""1 (a) [None] 0 0 1 (b) [None] 0 1 3 ( 15 (b) [None] 0 1 1 (c) [None] 0 1 3 ( 15 (c) [None] 0 1 15 (a) [None] 0 0 """ res = tst_reader(doc) if res != expect: print "test10 failed"
def tst_reader(s): f = StringIO.StringIO(s) input = libxml2.inputBuffer(f) reader = input.newTextReader("tst") res = "" while reader.Read(): res=res + "%s (%s) [%s] %d\n" % (reader.NodeType(),reader.Name(), reader.Value(), reader.IsEmptyElement()) if reader.NodeType() == 1: # Element while reader.MoveToNextAttribute():...
if level >= 1: old_schemas_tests = nb_schemas_tests old_schemas_success = nb_schemas_success old_schemas_failed = nb_schemas_failed old_instances_tests = nb_instances_tests old_instances_success = nb_instances_success old_instances_failed = nb_instances_failed
old_schemas_tests = nb_schemas_tests old_schemas_success = nb_schemas_success old_schemas_failed = nb_schemas_failed old_instances_tests = nb_instances_tests old_instances_success = nb_instances_success old_instances_failed = nb_instances_failed
def handle_testSuite(node, level = 0): global nb_schemas_tests, nb_schemas_success, nb_schemas_failed global nb_instances_tests, nb_instances_success, nb_instances_failed if level >= 1: old_schemas_tests = nb_schemas_tests old_schemas_success = nb_schemas_success old_schemas_failed = nb_schemas_failed old_instances_tes...
sections = node.xpathEval('section') if sections != [] and level <= 0: msg = "" for section in sections: msg = msg + section.content + " " print "Tests for section %s" % (msg)
def handle_testSuite(node, level = 0): global nb_schemas_tests, nb_schemas_success, nb_schemas_failed global nb_instances_tests, nb_instances_success, nb_instances_failed if level >= 1: old_schemas_tests = nb_schemas_tests old_schemas_success = nb_schemas_success old_schemas_failed = nb_schemas_failed old_instances_tes...
if level >= 1 and sections != []: msg = "" for section in sections: msg = msg + section.content + " " print "Result of tests for section %s" % (msg) if nb_schemas_tests != old_schemas_tests: print "found %d test schemas: %d success %d failures" % ( nb_schemas_tests - old_schemas_tests, nb_schemas_success - old_schemas_...
print "Result of tests for %s" % (node.xpathEval('string(documentation)')) if nb_schemas_tests != old_schemas_tests: print "found %d test schemas: %d success %d failures" % ( nb_schemas_tests - old_schemas_tests, nb_schemas_success - old_schemas_success, nb_schemas_failed - old_schemas_failed) if nb_instances_tests != ...
def handle_testSuite(node, level = 0): global nb_schemas_tests, nb_schemas_success, nb_schemas_failed global nb_instances_tests, nb_instances_success, nb_instances_failed if level >= 1: old_schemas_tests = nb_schemas_tests old_schemas_success = nb_schemas_success old_schemas_failed = nb_schemas_failed old_instances_tes...
def analyzeHTML():
def analyzeHTMLTop():
def analyzeHTML(): global wordsDictHTML ret = analyzeHTMLPages() print "Indexed %d words in %d HTML pages" % (len(wordsDictHTML), ret) i = 0 skipped = 0 for word in wordsDictHTML.keys(): refs = wordsDictHTML[word] if refs == None: skipped = skipped + 1 continue; for resource in refs.keys(): (relevance, id, section) ...
def analyzeAPI():
def analyzeAPITop():
def analyzeAPI(): global wordsDict try: doc = loadAPI(API) ret = analyzeAPI(doc) print "Analyzed %d blocs" % (ret) doc.freeDoc() except: print "Failed to parse and analyze %s" % (API) print sys.exc_type, sys.exc_value sys.exit(1) print "Indexed %d words" % (len(wordsDict)) i = 0 skipped = 0 for word in wordsDict.keys...
analyzeAPI()
analyzeAPITop()
def main(): args = sys.argv[1:] force = 0 if args: i = 0 while i < len(args): if args[i] == '--force': force = 1 elif args[i] == '--archive': analyzeArchives(None, force) elif args[i] == '--archive-year': i = i + 1; year = args[i] months = ["January" , "February", "March", "April", "May", "June", "July", "August", "Sep...
analyzeHTML()
analyzeHTMLTop()
def main(): args = sys.argv[1:] force = 0 if args: i = 0 while i < len(args): if args[i] == '--force': force = 1 elif args[i] == '--archive': analyzeArchives(None, force) elif args[i] == '--archive-year': i = i + 1; year = args[i] months = ["January" , "February", "March", "April", "May", "June", "July", "August", "Sep...
doc = libxml2.parseFile("xml/c14n.xml"); analyzeXMLDoc(doc) doc.freeDoc()
def analyzeXMLDoc(doc): if doc == None: return ctxt = doc.xpathNewContext() descriptions = ctxt.xpathEval("//refsect2") print len(descriptions) for description in descriptions: analyzeXMLDescription(doc, description)
"xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr",
"xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr", "xmlValidCtxtPtr",
def type_convert(str, name, info, module, function, pos): res = string.replace(str, " *", "_ptr") res = string.replace(res, " ", "_") res = string.replace(res, "htmlNode", "xmlNode") res = string.replace(res, "htmlDoc", "xmlDoc") res = string.replace(res, "htmlParser", "xmlParser") if res == 'const_char_ptr': if string...
return('userdata');
return('userdata')
def type_convert(str, name, info, module, function, pos):
res = 'xmlDocPtr';
res = 'xmlDocPtr'
def type_convert(str, name, info, module, function, pos):
res = 'xmlNodePtr';
res = 'xmlNodePtr'
def type_convert(str, name, info, module, function, pos):
res = 'xmlDictPtr';
res = 'xmlDictPtr'
def type_convert(str, name, info, module, function, pos):
res = 'xmlBufferPtr';
res = 'xmlBufferPtr'
def type_convert(str, name, info, module, function, pos):
if name == None:
if (name == None) or ((name not in argtypes) and (name not in rettypes)):
def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated testapi.c is identical")
module = enum.xpathEval('string(@file)')
def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated testapi.c is identical")
if is_known_param_type(name, name) == 0:
if argtypes.has_key(name) and is_known_param_type(name, name) == 0:
def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated testapi.c is identical")
print "Didn't found any value for enum %s" % (name)
print "Didn't find any value for enum %s" % (name)
def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated testapi.c is identical")
""");
static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { } """ % (name, name));
test.write("#ifdef %s\n" % (modules_defines[module]))
if is_known_return_type(name) == 0:
if (is_known_return_type(name) == 0) and (name in rettypes):
test.write("#ifdef %s\n" % (modules_defines[module]))
test.write("""static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { } static void desret_%s(%s val ATTRIBUTE_UNUSED) { } """ % (name, name, name, name))
test.write("""static void desret_%s(%s val ATTRIBUTE_UNUSED) { } """ % (name, name))
test.write("#ifdef %s\n" % (modules_defines[module]))
output.write(' {"%s", xmlUCSIs%s}' % (name, name))
output.write(' {"%s", xmlUCSIs%s}' % (block, name))
typedef struct { xmlUnicodeRange *table; int numentries;
if len(BlockNames[block]) == 0: continue (start, end) = BlockNames[block]
typedef struct { xmlUnicodeRange *table; int numentries;
output.write("int\nxmlUCSIs%s(int code) {\n" % name) output.write(" return((code >= %s) && (code <= %s));\n" % (start, end)) output.write("}\n\n")
output.write("int\nxmlUCSIs%s(int code) {\n return(" % name) flag = 0 for (start, end) in BlockNames[block]: if flag: output.write(" ||\n ") else: flag = 1 output.write("((code >= %s) && (code <= %s))" % (start, end)) output.write(");\n}\n\n")
typedef struct { xmlUnicodeRange *table; int numentries;
/* The following routines are an UGLY HACK to provide aliases for block names which are not in the current release, but are needed for ABI compatibility. */ /** * xmlUCSIsCombiningMarksforSymbols: * @code: UCS code point * * Check whether the character is part of CombiningMarksforSymbols UCS Block * * Returns 1 if tru...
typedef struct { xmlUnicodeRange *table; int numentries;
if name == "
if (name == "
def parsePreproc(self, token):
int xmlCharInRange(unsigned int val, const xmlChRangeGroupPtr group);
XMLPUBFUN int XMLCALL xmlCharInRange(unsigned int val, const xmlChRangeGroupPtr group);
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
header.write("extern unsigned char %s_tab[256];\n" % f)
header.write("XMLPUBVAR unsigned char %s_tab[256];\n" % f)
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
header.write("extern xmlChRangeGroup %sGroup;\n" % f)
header.write("XMLPUBVAR xmlChRangeGroup %sGroup;\n" % f)
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
header.write(""" } """); header.close()
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
name varchar(255) NOT NULL, module varchar(255) NOT NULL,
name varchar(255) BINARY NOT NULL, module varchar(255) BINARY NOT NULL,
def callback(ctx, str): return
name varchar(50) NOT NULL, symbol varchar(255) NOT NULL,
name varchar(50) BINARY NOT NULL, symbol varchar(255) BINARY NOT NULL,
def callback(ctx, str): return
name varchar(50) NOT NULL, resource varchar(255) NOT NULL,
name varchar(50) BINARY NOT NULL, resource varchar(255) BINARY NOT NULL,
def callback(ctx, str): return
resource varchar(255) NOT NULL, title varchar(255) NOT NULL,
resource varchar(255) BINARY NOT NULL, title varchar(255) BINARY NOT NULL,
def callback(ctx, str): return
return 0 if len(d) > 15: wordsDictHTML[word] = None
print "skipped %s" % (word)
def addWordHTML(word, resource, id, section, relevance): global wordsDictHTML if word == None or len(word) < 3: return -1 if resource == None or section == None: return -1 if wordsDictHTML.has_key(word): d = wordsDictHTML[word] if d == None: return 0 if len(d) > 15: wordsDictHTML[word] = None return 0 try: (r,i,s) = ...
wordsDictHTML[word][resource] = (relevance, id, section)
d = wordsDictHTML[word]; d[resource] = (relevance, id, section)
def addWordHTML(word, resource, id, section, relevance): global wordsDictHTML if word == None or len(word) < 3: return -1 if resource == None or section == None: return -1 if wordsDictHTML.has_key(word): d = wordsDictHTML[word] if d == None: return 0 if len(d) > 15: wordsDictHTML[word] = None return 0 try: (r,i,s) = ...
ret = ret + addWordHTML(word, resource, id, section, relevance)
try: r = addWordHTML(word, resource, id, section, relevance) if r <= 0: print "addWordHTML failed: %s %s" % (word, resource) ret = ret + r except: print "addWordHTML failed: %s %s %d" % (word, resource, relevance) print sys.exc_type, sys.exc_value
def addStringHTML(str, resource, id, section, relevance): if str == None or len(str) < 3: return -1 ret = 0 str = string.replace(str, ".", " ") str = string.replace(str, ",", " ") str = string.replace(str, "'", " ") str = string.replace(str, '"', " ") str = string.replace(str, ";", " ") str = string.replace(str, "-", "...
elif item.name == 'text':
elif item.name == 'p':
def analyzeHTML(doc, resource): para = 0; ctxt = doc.xpathNewContext() try: res = ctxt.xpathEval("//head/title") title = res[0].content except: title = "Page %s" % (resource) addPage(resource, title) try: items = ctxt.xpathEval("//h1 | //h2 | //h3 | //text()") section = title id = "" for item in items: if item.name == ...
l = len(args) if l == 0: f elif l == 1: f(args[0]) elif l == 2: f(args[0], args[1]) elif l == 3: f(args[0], args[1], args[2]) elif l == 4: f(args[0], args[1], args[2], args[3]) elif l == 5: f(args[0], args[1], args[2], args[3], args[4]) else: self.fail("Too many arguments for function")
apply(f,args)
def failUnlessXmlError(self,f,args,exc,domain,code,message,level,file,line): """Run function f, with arguments args and expect an exception exc; when the exception is raised, check the libxml2.lastError for expected values.""" # disable the default error handler libxml2.registerErrorHandler(None,None) try: # Emulate f(...
string.find(function, "Write") != -1:
string.find(function, "Write") != -1 or \ string.find(function, "Fetch") != -1:
def type_convert(str, name, info, module, function, pos):
if function == 'xmlNanoFTPNewCtxt':
if function == 'xmlNanoFTPNewCtxt' or \ function == 'xmlNanoFTPConnectTo' or \ function == 'xmlNanoFTPOpen':
def type_convert(str, name, info, module, function, pos):
if function == 'xmlIOHTTPOpenW':
if function == 'xmlNanoHTTPMethod' or \ function == 'xmlNanoHTTPMethodRedir' or \ function == 'xmlNanoHTTPOpen' or \ function == 'xmlNanoHTTPOpenRedir': return('xmlNanoHTTPCtxtPtr'); if function == 'xmlIOHTTPOpen':
def type_convert(str, name, info, module, function, pos):
def get_doc(self): ret = libxml2mod.doc(self._o) if ret == None: return None return xmlDoc(_obj=ret)
def get_doc(self): ret = libxml2mod.doc(self._o) if ret == None: return None return xmlDoc(_obj=ret)
return xmlAttr(_obj=o)
return xmlDtd(_obj=o)
def nodeWrap(o): # TODO try to cast to the most appropriate node class name = libxml2mod.name(o) if name == "element" or name == "text": return xmlNode(_obj=o) if name == "attribute": return xmlAttr(_obj=o) if name[0:8] == "document": return xmlDoc(_obj=o) if name[0:8] == "namespace": return xmlNs(_obj=o) if name == "e...
if is_skipped_module(name): continue
def add_missing_type(name, func): try: list = missing_types[name] list.append(func) except: missing_types[name] = [func]
"xmlChar_ptr", "const_xmlChar_ptr" ];
"xmlChar_ptr", "const_xmlChar_ptr", "void_ptr" ];
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
print missing_types[miss1]
test.write("#ifdef %s\n" % (cond.get_content()))
elif file == "HTMLtree" or file == "HTMLparser":
elif file == "HTMLtree" or file == "HTMLparser" or name[0:4] == "html":
output.write("#ifdef LIBXML_DEBUG_ENABLED\n");
elif file == "HTMLtree" or file == "HTMLparser":
elif file == "HTMLtree" or file == "HTMLparser" or name[0:4] == "html":
output.write("#ifdef LIBXML_SCHEMAS_ENABLED\n");
class parserError:
class parserError(libxmlError):
def __str__(self): return self.msg
class uriError:
class uriError(libxmlError):
def __str__(self): return self.msg
class xpathError:
class xpathError(libxmlError):
def __str__(self): return self.msg
format = "%s:%%s" % (classname) classes.write(" return \"%s\" %% (self.name)\n\n" % (
format = "<%s (%%s) object at 0x%%x>" % (classname) classes.write(" return \"%s\" %% (self.name, id (self))\n\n" % (
classes.write(" def __repr__(self):\n")
print msg
pass
def warning(self, msg): print msg
global log error_nr = 0
global error_msg global log error_nr = 0 error_msg = ''
def testNotWf(filename, id): global error_nr global log error_nr = 0 ctxt = libxml2.createFileParserCtxt(filename) if ctxt == None: return -1 ctxt.parseDocument() doc = ctxt.doc() if error_nr == 0 or ctxt.wellFormed() != 0: print "%s: error: Well Formedness error not detected" % (id) log.write("%s: error: Well Forme...
global log error_nr = 0
global error_msg global log error_nr = 0 error_msg = ''
def testNotWfEnt(filename, id): global error_nr global log error_nr = 0 ctxt = libxml2.createFileParserCtxt(filename) if ctxt == None: return -1 ctxt.replaceEntities(1) ctxt.parseDocument() doc = ctxt.doc() if error_nr == 0 or ctxt.wellFormed() != 0: print "%s: error: Well Formedness error not detected" % (id) log.w...
global log error = '' error_nr = 0
global error_msg global log error_nr = 0 error_msg = ''
def testNotWfEntDtd(filename, id): global error_nr global log error = '' error_nr = 0 ctxt = libxml2.createFileParserCtxt(filename) if ctxt == None: return -1 ctxt.replaceEntities(1) ctxt.loadSubset(1) ctxt.parseDocument() doc = ctxt.doc() if error_nr == 0 or ctxt.wellFormed() != 0: print "%s: error: Well Formedness...
global log error = '' error_nr = 0
global error_msg global log error_nr = 0 error_msg = ''
def testWfEntDtd(filename, id): global error_nr global log error = '' error_nr = 0 ctxt = libxml2.createFileParserCtxt(filename) if ctxt == None: return -1 ctxt.replaceEntities(1) ctxt.loadSubset(1) ctxt.parseDocument() doc = ctxt.doc() if ctxt.wellFormed() == 0: print "%s: error: wrongly failed to parse the documen...
global log error_nr = 0
global error_msg global log error_nr = 0 error_msg = ''
def testInvalid(filename, id): global error_nr global log error_nr = 0 ctxt = libxml2.createFileParserCtxt(filename) if ctxt == None: return -1 ctxt.validate(1) ctxt.parseDocument() doc = ctxt.doc() valid = ctxt.isValid() if doc == None: print "%s: error: wrongly failed to parse the document" % (id) log.write("%s: e...
error_nr = 0
global error_msg error_nr = 0 error_msg = ''
def testValid(filename, id): global error_nr error_nr = 0 ctxt = libxml2.createFileParserCtxt(filename) if ctxt == None: return -1 ctxt.validate(1) ctxt.parseDocument() doc = ctxt.doc() valid = ctxt.isValid() if doc == None: print "%s: error: wrongly failed to parse the document" % (id) log.write("%s: error: wrongly...
content = test.content
content = string.strip(test.content) while content[-1] == '\n': content = content[0:-1]
def runTest(test): global test_nr global test_failed global test_error global test_succeed global log uri = test.prop('URI') id = test.prop('ID') if uri == None: print "Test without ID:", uri return -1 if id == None: print "Test without URI:", id return -1 base = test.getBase(None) URI = libxml2.buildURI(uri, base) if...
log.write(" %s:%s:%s\n\n" % (type, extra, content))
log.write(" %s:%s:%s\n" % (type, extra, content))
def runTest(test): global test_nr global test_failed global test_error global test_succeed global log uri = test.prop('URI') id = test.prop('ID') if uri == None: print "Test without ID:", uri return -1 if id == None: print "Test without URI:", id return -1 base = test.getBase(None) URI = libxml2.buildURI(uri, base) if...
if pref[0] == ref[0]:
if pref[0] == classname:
classes.write(" def %s(self" % func)
self.debugMsg("schema result is OK") self.debugMsg("after checking schema result")
def processSchema(self, filePath): global msgSchemaNotValidButShould, msgSchemaValidButShouldNot schema = None # # Parse the schema. # self.debugMsg("loading schema: %s" % filePath) schema_ParserCtxt = libxml2.schemaNewParserCtxt(filePath) try: try: schema = schema_ParserCtxt.schemaParse() except: pass finally: self.d...
writeline(global_functions_hdr, "
writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
writeline(global_functions_impl, "extern "+fields[0]+" "+fields[1]+";")
writeline(global_functions_hdr, "#ifdef LIBXML_THREAD_ENABLED")
output.write(" value='%s'" % info[0]);
try: val = eval(info[0]) except: val = info[0] output.write(" value='%s'" % (val));
def serialize_enum(self, output, name): id = self.idx.enums[name] output.write(" <enum name='%s' file='%s'" % (name, self.modulename_file(id.module)))
if found == 1: break
def buildWrappers(): global ctypes global py_types global py_return_types global unknown_types global functions global function_classes global classes_type global classes_list global converter_type global primary_classes global converter_type global classes_ancestor global converter_type global primary_classes global c...
doc = libxml2.readFile('doc/libxml2-api.xml', None, 0) if doc == None: print "Failed to load doc/libxml2-api.xml" sys.exit(1) test = open('testapi.c', 'w') ctxt = doc.xpathNewContext() headers = ctxt.xpathEval("/api/files/file") test.write("""/* * testapi.c: libxml2 API tester program. * * Automatically generated b...
missing_functions = {} def add_missing_functions(name, module): try: list = missing_functions[module] list.append(name) except: missing_functions[module] = [name]
def add_missing_type(name, func): try: list = missing_types[name] list.append(func) except: missing_types[name] = [func]
known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr", "xmlParserCtxtPtr", "xmlDocPtr", "filepath", "fileoutput", "xmlNodePtr", "xmlNodePtr_in", "userdata", "xmlChar_ptr", "xmlTextWriterPtr", "xmlTextReaderPtr", "xmlBufferPtr", "xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr", "xmlValidCtxtPtr", "void_...
known_param_types = []
def type_convert(str, name, info, module, function, pos): res = string.replace(str, " *", "_ptr") res = string.replace(res, " ", "_") res = string.replace(res, "htmlNode", "xmlNode") res = string.replace(res, "htmlDoc", "xmlDoc") res = string.replace(res, "htmlParser", "xmlParser") if res == 'const_char_ptr': if string...
test.write(""" static void *gen_void_ptr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { return(NULL); } static void des_void_ptr(int no ATTRIBUTE_UNUSED, void *val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { } static const void *gen_const_void_ptr(int no, int nr ATTRIBUTE_UNUSED) { if (no == 0) return((const...
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
known_return_types = [ "int", "const_char_ptr", "xmlDocPtr", "xmlNodePtr", "xmlChar_ptr", "const_xmlChar_ptr", "void_ptr", "xmlXPathObjectPtr", "xmlCharEncoding", "long", "const_void_ptr", "double", "xmlTextReaderPtr", "xmlDictPtr", ]
known_return_types = []
def is_known_param_type(name): for type in known_param_types: if type == name: return 1 return 0
test.write(""" static void desret_int(int val ATTRIBUTE_UNUSED) { } static void desret_long(long val ATTRIBUTE_UNUSED) { } static void desret_double(double val ATTRIBUTE_UNUSED) { } static void desret_xmlCharEncoding(xmlCharEncoding val ATTRIBUTE_UNUSED) { } static void desret_const_void_ptr(void *val ATTRIBUTE_UNUSED)...
input = open("testapi.c", "r") test = open('testapi.c.new', 'w') def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated te...
def is_known_return_type(name): for type in known_return_types: if type == name: return 1 return 0
test.close()
def compare_missing(a, b): return b[0] - a[0]
int ret = 0;
int test_ret = 0;
def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated testapi.c is identical")
test.write(" ret += test_%s();\n" % module)
test.write(" test_ret += test_%s();\n" % module)
def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated testapi.c is identical")
function_tests, call_tests, ret); return(ret);
function_tests, call_tests, test_ret); return(test_ret);
def compare_and_save(): global test test.close() input = open("testapi.c", "r").read() test = open('testapi.c.new', "r").read() if input != test: os.system("rm testapi.c ; mv testapi.c.new testapi.c") print("Updated testapi.c") else: print("Generated testapi.c is identical")
int ret = 0;
int test_ret = 0;
def generate_test(module, node): global test global nb_tests nb_cond = 0 no_gen = 0 name = node.xpathEval('string(@name)') if is_skipped_function(name): return # # check we know how to handle the args and return values # and store the informations for the generation # try: args = node.xpathEval("arg") except: args = ...
return(ret);
return(test_ret);
def generate_test(module, node): global test global nb_tests nb_cond = 0 no_gen = 0 name = node.xpathEval('string(@name)') if is_skipped_function(name): return # # check we know how to handle the args and return values # and store the informations for the generation # try: args = node.xpathEval("arg") except: args = ...
ret++;
test_ret++;
test.write("#ifdef %s\n" % (cond.get_content()))
return(ret);
return(test_ret);
test.write("#ifdef %s\n" % (cond.get_content()))
int ret = 0;
int test_ret = 0;
test.write("#ifdef %s\n" % (cond.get_content()))
test.write(" ret += test_%s();\n" % (name))
test.write(" test_ret += test_%s();\n" % (name))
test.write("#ifdef %s\n" % (cond.get_content()))
if (ret != 0) printf("Module %s: %%d errors\\n", ret); return(ret);
if (test_ret != 0) printf("Module %s: %%d errors\\n", test_ret); return(test_ret);
test.write("#ifdef %s\n" % (cond.get_content()))
instance = parserCtxt.ctxtReadFile(filePath, None, libxml2.XML_PARSE_NOWARNING) except: pass
validationCtxt = schema.schemaNewValidCtxt() if (validationCtxt is None): self.failCritical("Could not create the validation context.") return try: self.debugMsg("validating instance") if options.validationSAX: instance_Err = validationCtxt.schemaValidateFile(filePath, 0) else: instance_Err = validationCtxt.schemaVali...
def validate(self): instance = None schema = None filePath = self.fileName # os.path.join(options.baseDir, self.fileName)
del parserCtxt self.debugMsg("after loading instance") if instance is None: self.debugMsg("instance is None") self.failCritical("Failed to parse the instance for unknown reasons.") return else: try: self.debugMsg("loading schema: %s" % self.group.schemaFileName) schema = parseSchema(self.group.schemaFileName) try: ...
if instance is not None:
def validate(self): instance = None schema = None filePath = self.fileName # os.path.join(options.baseDir, self.fileName)
Ranges = {}
def makeRange(lst): ret = [] pos = 0 while pos < len(lst): try: # index generates exception if not present s = lst[pos:].index(1) # look for start of next range except: break # if no more, finished pos += s # pointer to start of possible range try: e = lst[pos:].index(0) # look for end of range e += pos except: ...
if Ranges.has_key(currange): Ranges[currange].append(name) else: Ranges[currange] = [ name ]
# The lines in the .def file have three types:-
pline = "
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
pline += " || \\\n\t\t\t"
pline += " || \\\n\t\t\t\t "
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
pline += "((c) == " + hex(rg[0]) + ")" else: pline += "((" + hex(rg[0]) + "<= (c)) &&" pline += " ((c) <= " + hex(rg[1]) + "))"
pline += "((c) == 0x%x)" % rg[0] else: pline += "((0x%x <= (c)) &&" % rg[0] pline += " ((c) <= 0x%x))" % rg[1]
typedef xmlChRangeGroup *xmlChRangeGroupPtr;
header.write("
pline = " ntab = 4 - (len(pline)) / 8 if ntab < 0: ntab = 0 just = "" for i in range(ntab): just += "\t" header.write(pline + just + "(((c) < 0x100) ? \\\n\t\t\t\t ")
typedef xmlChRangeGroup *xmlChRangeGroupPtr;