Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 1 | #!/usr/bin/python -u |
| 2 | # |
| 3 | # generate a tester program for the API |
| 4 | # |
| 5 | import sys |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 6 | import os |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 7 | import string |
| 8 | try: |
| 9 | import libxml2 |
| 10 | except: |
| 11 | print "libxml2 python bindings not available, skipping testapi.c generation" |
| 12 | sys.exit(0) |
| 13 | |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 14 | if len(sys.argv) > 1: |
| 15 | srcPref = sys.argv[1] + '/' |
| 16 | else: |
| 17 | srcPref = '' |
| 18 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 19 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 20 | # Modules we want to skip in API test |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 21 | # |
Daniel Veillard | 2a4fb5a | 2004-11-08 14:02:18 +0000 | [diff] [blame] | 22 | skipped_modules = [ "SAX", "xlink", "threads", "globals", |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 23 | "xmlmemory", "xmlversion", "xmlexports", |
| 24 | #deprecated |
| 25 | "DOCBparser", |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 26 | ] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 27 | |
| 28 | # |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 29 | # defines for each module |
| 30 | # |
| 31 | modules_defines = { |
| 32 | "HTMLparser": "LIBXML_HTML_ENABLED", |
| 33 | "catalog": "LIBXML_CATALOG_ENABLED", |
| 34 | "xmlreader": "LIBXML_READER_ENABLED", |
| 35 | "relaxng": "LIBXML_SCHEMAS_ENABLED", |
| 36 | "schemasInternals": "LIBXML_SCHEMAS_ENABLED", |
| 37 | "xmlschemas": "LIBXML_SCHEMAS_ENABLED", |
| 38 | "xmlschemastypes": "LIBXML_SCHEMAS_ENABLED", |
| 39 | "xpath": "LIBXML_XPATH_ENABLED", |
| 40 | "xpathInternals": "LIBXML_XPATH_ENABLED", |
| 41 | "xinclude": "LIBXML_XINCLUDE_ENABLED", |
| 42 | "xpointer": "LIBXML_XPTR_ENABLED", |
| 43 | "xmlregexp" : "LIBXML_REGEXP_ENABLED", |
| 44 | "xmlautomata" : "LIBXML_AUTOMATA_ENABLED", |
| 45 | "xmlsave" : "LIBXML_OUTPUT_ENABLED", |
| 46 | "DOCBparser" : "LIBXML_DOCB_ENABLED", |
Daniel Veillard | fc0b6f6 | 2005-01-09 17:48:02 +0000 | [diff] [blame] | 47 | "xmlmodule" : "LIBXML_MODULES_ENABLED", |
William M. Brack | ba1d317 | 2005-03-25 03:05:46 +0000 | [diff] [blame] | 48 | "pattern" : "LIBXML_PATTERN_ENABLED", |
William M. Brack | dc904f1 | 2005-10-22 02:04:26 +0000 | [diff] [blame] | 49 | "schematron" : "LIBXML_SCHEMATRON_ENABLED", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | # |
| 53 | # defines for specific functions |
| 54 | # |
| 55 | function_defines = { |
| 56 | "htmlDefaultSAXHandlerInit": "LIBXML_HTML_ENABLED", |
| 57 | "xmlSAX2EndElement" : "LIBXML_SAX1_ENABLED", |
| 58 | "xmlSAX2StartElement" : "LIBXML_SAX1_ENABLED", |
| 59 | "xmlSAXDefaultVersion" : "LIBXML_SAX1_ENABLED", |
| 60 | "UTF8Toisolat1" : "LIBXML_OUTPUT_ENABLED", |
| 61 | "xmlCleanupPredefinedEntities": "LIBXML_LEGACY_ENABLED", |
| 62 | "xmlInitializePredefinedEntities": "LIBXML_LEGACY_ENABLED", |
| 63 | "xmlSetFeature": "LIBXML_LEGACY_ENABLED", |
| 64 | "xmlGetFeature": "LIBXML_LEGACY_ENABLED", |
| 65 | "xmlGetFeaturesList": "LIBXML_LEGACY_ENABLED", |
| 66 | "xmlIOParseDTD": "LIBXML_VALID_ENABLED", |
| 67 | "xmlParseDTD": "LIBXML_VALID_ENABLED", |
| 68 | "xmlParseDoc": "LIBXML_SAX1_ENABLED", |
| 69 | "xmlParseMemory": "LIBXML_SAX1_ENABLED", |
| 70 | "xmlRecoverDoc": "LIBXML_SAX1_ENABLED", |
| 71 | "xmlParseFile": "LIBXML_SAX1_ENABLED", |
| 72 | "xmlRecoverFile": "LIBXML_SAX1_ENABLED", |
| 73 | "xmlRecoverMemory": "LIBXML_SAX1_ENABLED", |
| 74 | "xmlSAXParseFileWithData": "LIBXML_SAX1_ENABLED", |
| 75 | "xmlSAXParseMemory": "LIBXML_SAX1_ENABLED", |
| 76 | "xmlSAXUserParseMemory": "LIBXML_SAX1_ENABLED", |
| 77 | "xmlSAXParseDoc": "LIBXML_SAX1_ENABLED", |
| 78 | "xmlSAXParseDTD": "LIBXML_SAX1_ENABLED", |
| 79 | "xmlSAXUserParseFile": "LIBXML_SAX1_ENABLED", |
| 80 | "xmlParseEntity": "LIBXML_SAX1_ENABLED", |
| 81 | "xmlParseExternalEntity": "LIBXML_SAX1_ENABLED", |
| 82 | "xmlSAXParseMemoryWithData": "LIBXML_SAX1_ENABLED", |
| 83 | "xmlParseBalancedChunkMemory": "LIBXML_SAX1_ENABLED", |
| 84 | "xmlParseBalancedChunkMemoryRecover": "LIBXML_SAX1_ENABLED", |
| 85 | "xmlSetupParserForBuffer": "LIBXML_SAX1_ENABLED", |
| 86 | "xmlStopParser": "LIBXML_PUSH_ENABLED", |
| 87 | "xmlAttrSerializeTxtContent": "LIBXML_OUTPUT_ENABLED", |
| 88 | "xmlSAXParseFile": "LIBXML_SAX1_ENABLED", |
| 89 | "xmlSAXParseEntity": "LIBXML_SAX1_ENABLED", |
| 90 | "xmlNewTextChild": "LIBXML_TREE_ENABLED", |
| 91 | "xmlNewDocRawNode": "LIBXML_TREE_ENABLED", |
| 92 | "xmlNewProp": "LIBXML_TREE_ENABLED", |
| 93 | "xmlReconciliateNs": "LIBXML_TREE_ENABLED", |
| 94 | "xmlValidateNCName": "LIBXML_TREE_ENABLED", |
| 95 | "xmlValidateNMToken": "LIBXML_TREE_ENABLED", |
| 96 | "xmlValidateName": "LIBXML_TREE_ENABLED", |
| 97 | "xmlNewChild": "LIBXML_TREE_ENABLED", |
| 98 | "xmlValidateQName": "LIBXML_TREE_ENABLED", |
| 99 | "xmlSprintfElementContent": "LIBXML_OUTPUT_ENABLED", |
| 100 | "xmlValidGetPotentialChildren" : "LIBXML_VALID_ENABLED", |
| 101 | "xmlValidGetValidElements" : "LIBXML_VALID_ENABLED", |
| 102 | "docbDefaultSAXHandlerInit" : "LIBXML_DOCB_ENABLED", |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 103 | "xmlTextReaderPreservePattern" : "LIBXML_PATTERN_ENABLED", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 107 | # Some functions really need to be skipped for the tests. |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 108 | # |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 109 | skipped_functions = [ |
| 110 | # block on I/O |
| 111 | "xmlFdRead", "xmlReadFd", "xmlCtxtReadFd", |
| 112 | "htmlFdRead", "htmlReadFd", "htmlCtxtReadFd", |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 113 | "xmlReaderNewFd", "xmlReaderForFd", |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 114 | "xmlIORead", "xmlReadIO", "xmlCtxtReadIO", |
| 115 | "htmlIORead", "htmlReadIO", "htmlCtxtReadIO", |
Daniel Veillard | 27f2010 | 2004-11-05 11:50:11 +0000 | [diff] [blame] | 116 | "xmlReaderNewIO", "xmlBufferDump", "xmlNanoFTPConnect", |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 117 | "xmlNanoFTPConnectTo", "xmlNanoHTTPMethod", "xmlNanoHTTPMethodRedir", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 118 | # Complex I/O APIs |
| 119 | "xmlCreateIOParserCtxt", "xmlParserInputBufferCreateIO", |
| 120 | "xmlRegisterInputCallbacks", "xmlReaderForIO", |
| 121 | "xmlOutputBufferCreateIO", "xmlRegisterOutputCallbacks", |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 122 | "xmlSaveToIO", "xmlIOHTTPOpenW", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 123 | # library state cleanup, generate false leak informations and other |
| 124 | # troubles, heavillyb tested otherwise. |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 125 | "xmlCleanupParser", "xmlRelaxNGCleanupTypes", "xmlSetListDoc", |
| 126 | "xmlSetTreeDoc", "xmlUnlinkNode", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 127 | # hard to avoid leaks in the tests |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 128 | "xmlStrcat", "xmlStrncat", "xmlCatalogAddLocal", "xmlNewTextWriterDoc", |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 129 | "xmlXPathNewValueTree", "xmlXPathWrapString", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 130 | # unimplemented |
| 131 | "xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml", |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 132 | "xmlTextReaderReadString", |
| 133 | # destructor |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 134 | "xmlListDelete", "xmlOutputBufferClose", "xmlNanoFTPClose", "xmlNanoHTTPClose", |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 135 | # deprecated |
| 136 | "xmlCatalogGetPublic", "xmlCatalogGetSystem", "xmlEncodeEntities", |
Daniel Veillard | 2a4fb5a | 2004-11-08 14:02:18 +0000 | [diff] [blame] | 137 | "xmlNewGlobalNs", "xmlHandleEntity", "xmlNamespaceParseNCName", |
| 138 | "xmlNamespaceParseNSDef", "xmlNamespaceParseQName", |
| 139 | "xmlParseNamespace", "xmlParseQuotedString", "xmlParserHandleReference", |
| 140 | "xmlScanName", |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 141 | "xmlDecodeEntities", |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 142 | # allocators |
| 143 | "xmlMemFree", |
Daniel Veillard | c2c894f | 2004-11-07 12:17:35 +0000 | [diff] [blame] | 144 | # verbosity |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 145 | "xmlCatalogSetDebug", "xmlShellPrintXPathError", "xmlShellPrintNode", |
Daniel Veillard | 2a4fb5a | 2004-11-08 14:02:18 +0000 | [diff] [blame] | 146 | # Internal functions, no user space should really call them |
| 147 | "xmlParseAttribute", "xmlParseAttributeListDecl", "xmlParseName", |
| 148 | "xmlParseNmtoken", "xmlParseEntityValue", "xmlParseAttValue", |
| 149 | "xmlParseSystemLiteral", "xmlParsePubidLiteral", "xmlParseCharData", |
| 150 | "xmlParseExternalID", "xmlParseComment", "xmlParsePITarget", "xmlParsePI", |
| 151 | "xmlParseNotationDecl", "xmlParseEntityDecl", "xmlParseDefaultDecl", |
| 152 | "xmlParseNotationType", "xmlParseEnumerationType", "xmlParseEnumeratedType", |
| 153 | "xmlParseAttributeType", "xmlParseAttributeListDecl", |
| 154 | "xmlParseElementMixedContentDecl", "xmlParseElementChildrenContentDecl", |
| 155 | "xmlParseElementContentDecl", "xmlParseElementDecl", "xmlParseMarkupDecl", |
| 156 | "xmlParseCharRef", "xmlParseEntityRef", "xmlParseReference", |
| 157 | "xmlParsePEReference", "xmlParseDocTypeDecl", "xmlParseAttribute", |
| 158 | "xmlParseStartTag", "xmlParseEndTag", "xmlParseCDSect", "xmlParseContent", |
| 159 | "xmlParseElement", "xmlParseVersionNum", "xmlParseVersionInfo", |
| 160 | "xmlParseEncName", "xmlParseEncodingDecl", "xmlParseSDDecl", |
| 161 | "xmlParseXMLDecl", "xmlParseTextDecl", "xmlParseMisc", |
| 162 | "xmlParseExternalSubset", "xmlParserHandlePEReference", |
| 163 | "xmlSkipBlankChars", |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 164 | ] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 165 | |
| 166 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 167 | # These functions have side effects on the global state |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 168 | # and hence generate errors on memory allocation tests |
| 169 | # |
| 170 | skipped_memcheck = [ "xmlLoadCatalog", "xmlAddEncodingAlias", |
| 171 | "xmlSchemaInitTypes", "xmlNanoFTPProxy", "xmlNanoFTPScanProxy", |
| 172 | "xmlNanoHTTPScanProxy", "xmlResetLastError", "xmlCatalogConvert", |
| 173 | "xmlCatalogRemove", "xmlLoadCatalogs", "xmlCleanupCharEncodingHandlers", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 174 | "xmlInitCharEncodingHandlers", "xmlCatalogCleanup", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 175 | "xmlSchemaGetBuiltInType", |
Daniel Veillard | 1f33c4d | 2005-07-10 21:38:31 +0000 | [diff] [blame] | 176 | "htmlParseFile", "htmlCtxtReadFile", # loads the catalogs |
Daniel Veillard | 34e3f64 | 2008-07-29 09:02:27 +0000 | [diff] [blame] | 177 | "xmlTextReaderSchemaValidate", "xmlSchemaCleanupTypes", # initialize the schemas type system |
| 178 | "xmlCatalogResolve", "xmlIOParseDTD" # loads the catalogs |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 179 | ] |
| 180 | |
| 181 | # |
| 182 | # Extra code needed for some test cases |
| 183 | # |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 184 | extra_pre_call = { |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 185 | "xmlSAXUserParseFile": """ |
| 186 | #ifdef LIBXML_SAX1_ENABLED |
| 187 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 188 | #endif |
| 189 | """, |
| 190 | "xmlSAXUserParseMemory": """ |
| 191 | #ifdef LIBXML_SAX1_ENABLED |
| 192 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 193 | #endif |
| 194 | """, |
| 195 | "xmlParseBalancedChunkMemory": """ |
| 196 | #ifdef LIBXML_SAX1_ENABLED |
| 197 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 198 | #endif |
| 199 | """, |
| 200 | "xmlParseBalancedChunkMemoryRecover": """ |
| 201 | #ifdef LIBXML_SAX1_ENABLED |
| 202 | if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL; |
| 203 | #endif |
| 204 | """, |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 205 | "xmlParserInputBufferCreateFd": |
| 206 | "if (fd >= 0) fd = -1;", |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 207 | } |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 208 | extra_post_call = { |
| 209 | "xmlAddChild": |
| 210 | "if (ret_val == NULL) { xmlFreeNode(cur) ; cur = NULL ; }", |
Daniel Veillard | 2cba415 | 2008-08-27 11:45:41 +0000 | [diff] [blame] | 211 | "xmlAddEntity": |
| 212 | "if (ret_val != NULL) { xmlFreeNode(ret_val) ; ret_val = NULL; }", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 213 | "xmlAddChildList": |
| 214 | "if (ret_val == NULL) { xmlFreeNodeList(cur) ; cur = NULL ; }", |
| 215 | "xmlAddSibling": |
| 216 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 217 | "xmlAddNextSibling": |
| 218 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 219 | "xmlAddPrevSibling": |
| 220 | "if (ret_val == NULL) { xmlFreeNode(elem) ; elem = NULL ; }", |
| 221 | "xmlDocSetRootElement": |
| 222 | "if (doc == NULL) { xmlFreeNode(root) ; root = NULL ; }", |
| 223 | "xmlReplaceNode": |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 224 | """if (cur != NULL) { |
| 225 | xmlUnlinkNode(cur); |
| 226 | xmlFreeNode(cur) ; cur = NULL ; } |
| 227 | if (old != NULL) { |
| 228 | xmlUnlinkNode(old); |
| 229 | xmlFreeNode(old) ; old = NULL ; } |
| 230 | ret_val = NULL;""", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 231 | "xmlTextMerge": |
| 232 | """if ((first != NULL) && (first->type != XML_TEXT_NODE)) { |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 233 | xmlUnlinkNode(second); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 234 | xmlFreeNode(second) ; second = NULL ; }""", |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 235 | "xmlBuildQName": |
| 236 | """if ((ret_val != NULL) && (ret_val != ncname) && |
| 237 | (ret_val != prefix) && (ret_val != memory)) |
| 238 | xmlFree(ret_val); |
| 239 | ret_val = NULL;""", |
Daniel Veillard | c394f73 | 2005-01-26 00:04:52 +0000 | [diff] [blame] | 240 | "xmlNewDocElementContent": |
| 241 | """xmlFreeDocElementContent(doc, ret_val); ret_val = NULL;""", |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 242 | "xmlDictReference": "xmlDictFree(dict);", |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 243 | # Functions which deallocates one of their parameters |
| 244 | "xmlXPathConvertBoolean": """val = NULL;""", |
| 245 | "xmlXPathConvertNumber": """val = NULL;""", |
| 246 | "xmlXPathConvertString": """val = NULL;""", |
| 247 | "xmlSaveFileTo": """buf = NULL;""", |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 248 | "xmlSaveFormatFileTo": """buf = NULL;""", |
| 249 | "xmlIOParseDTD": "input = NULL;", |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 250 | "xmlRemoveProp": "cur = NULL;", |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 251 | "xmlNewNs": "if ((node == NULL) && (ret_val != NULL)) xmlFreeNs(ret_val);", |
| 252 | "xmlCopyNamespace": "if (ret_val != NULL) xmlFreeNs(ret_val);", |
| 253 | "xmlCopyNamespaceList": "if (ret_val != NULL) xmlFreeNsList(ret_val);", |
| 254 | "xmlNewTextWriter": "if (ret_val != NULL) out = NULL;", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 255 | "xmlNewTextWriterPushParser": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;} if (ret_val != NULL) ctxt = NULL;", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 256 | "xmlNewIOInputStream": "if (ret_val != NULL) input = NULL;", |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 257 | "htmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 258 | "htmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 259 | "xmlParseDocument": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 260 | "xmlParseChunk": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
| 261 | "xmlParseExtParsedEnt": "if (ctxt != NULL) {xmlFreeDoc(ctxt->myDoc); ctxt->myDoc = NULL;}", |
Daniel Veillard | 7e33dba | 2005-07-03 22:40:26 +0000 | [diff] [blame] | 262 | "xmlDOMWrapAdoptNode": "if ((node != NULL) && (node->parent == NULL)) {xmlUnlinkNode(node);xmlFreeNode(node);node = NULL;}", |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 263 | } |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 264 | |
| 265 | modules = [] |
| 266 | |
| 267 | def is_skipped_module(name): |
| 268 | for mod in skipped_modules: |
| 269 | if mod == name: |
| 270 | return 1 |
| 271 | return 0 |
| 272 | |
| 273 | def is_skipped_function(name): |
| 274 | for fun in skipped_functions: |
| 275 | if fun == name: |
| 276 | return 1 |
| 277 | # Do not test destructors |
| 278 | if string.find(name, 'Free') != -1: |
| 279 | return 1 |
| 280 | return 0 |
| 281 | |
| 282 | def is_skipped_memcheck(name): |
| 283 | for fun in skipped_memcheck: |
| 284 | if fun == name: |
| 285 | return 1 |
| 286 | return 0 |
| 287 | |
| 288 | missing_types = {} |
| 289 | def add_missing_type(name, func): |
| 290 | try: |
| 291 | list = missing_types[name] |
| 292 | list.append(func) |
| 293 | except: |
| 294 | missing_types[name] = [func] |
| 295 | |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 296 | generated_param_types = [] |
| 297 | def add_generated_param_type(name): |
| 298 | generated_param_types.append(name) |
| 299 | |
| 300 | generated_return_types = [] |
| 301 | def add_generated_return_type(name): |
| 302 | generated_return_types.append(name) |
| 303 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 304 | missing_functions = {} |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 305 | missing_functions_nr = 0 |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 306 | def add_missing_functions(name, module): |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 307 | global missing_functions_nr |
| 308 | |
| 309 | missing_functions_nr = missing_functions_nr + 1 |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 310 | try: |
| 311 | list = missing_functions[module] |
| 312 | list.append(name) |
| 313 | except: |
| 314 | missing_functions[module] = [name] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 315 | |
| 316 | # |
| 317 | # Provide the type generators and destructors for the parameters |
| 318 | # |
| 319 | |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 320 | def type_convert(str, name, info, module, function, pos): |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 321 | # res = string.replace(str, " ", " ") |
| 322 | # res = string.replace(str, " ", " ") |
| 323 | # res = string.replace(str, " ", " ") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 324 | res = string.replace(str, " *", "_ptr") |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 325 | # res = string.replace(str, "*", "_ptr") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 326 | res = string.replace(res, " ", "_") |
| 327 | if res == 'const_char_ptr': |
| 328 | if string.find(name, "file") != -1 or \ |
| 329 | string.find(name, "uri") != -1 or \ |
| 330 | string.find(name, "URI") != -1 or \ |
| 331 | string.find(info, "filename") != -1 or \ |
| 332 | string.find(info, "URI") != -1 or \ |
| 333 | string.find(info, "URL") != -1: |
William M. Brack | 83d9c37 | 2004-11-08 02:26:08 +0000 | [diff] [blame] | 334 | if string.find(function, "Save") != -1 or \ |
| 335 | string.find(function, "Create") != -1 or \ |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 336 | string.find(function, "Write") != -1 or \ |
| 337 | string.find(function, "Fetch") != -1: |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 338 | return('fileoutput') |
| 339 | return('filepath') |
| 340 | if res == 'void_ptr': |
| 341 | if module == 'nanoftp' and name == 'ctx': |
| 342 | return('xmlNanoFTPCtxtPtr') |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 343 | if function == 'xmlNanoFTPNewCtxt' or \ |
| 344 | function == 'xmlNanoFTPConnectTo' or \ |
| 345 | function == 'xmlNanoFTPOpen': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 346 | return('xmlNanoFTPCtxtPtr') |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 347 | if module == 'nanohttp' and name == 'ctx': |
| 348 | return('xmlNanoHTTPCtxtPtr') |
William M. Brack | 015ccb2 | 2005-02-13 08:18:52 +0000 | [diff] [blame] | 349 | if function == 'xmlNanoHTTPMethod' or \ |
| 350 | function == 'xmlNanoHTTPMethodRedir' or \ |
| 351 | function == 'xmlNanoHTTPOpen' or \ |
| 352 | function == 'xmlNanoHTTPOpenRedir': |
| 353 | return('xmlNanoHTTPCtxtPtr'); |
| 354 | if function == 'xmlIOHTTPOpen': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 355 | return('xmlNanoHTTPCtxtPtr') |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 356 | if string.find(name, "data") != -1: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 357 | return('userdata') |
Daniel Veillard | d005b9e | 2004-11-03 17:07:05 +0000 | [diff] [blame] | 358 | if string.find(name, "user") != -1: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 359 | return('userdata') |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 360 | if res == 'xmlDoc_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 361 | res = 'xmlDocPtr' |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 362 | if res == 'xmlNode_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 363 | res = 'xmlNodePtr' |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 364 | if res == 'xmlDict_ptr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 365 | res = 'xmlDictPtr' |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 366 | if res == 'xmlNodePtr' and pos != 0: |
| 367 | if (function == 'xmlAddChild' and pos == 2) or \ |
| 368 | (function == 'xmlAddChildList' and pos == 2) or \ |
| 369 | (function == 'xmlAddNextSibling' and pos == 2) or \ |
| 370 | (function == 'xmlAddSibling' and pos == 2) or \ |
| 371 | (function == 'xmlDocSetRootElement' and pos == 2) or \ |
| 372 | (function == 'xmlReplaceNode' and pos == 2) or \ |
| 373 | (function == 'xmlTextMerge') or \ |
| 374 | (function == 'xmlAddPrevSibling' and pos == 2): |
| 375 | return('xmlNodePtr_in'); |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 376 | if res == 'const xmlBufferPtr': |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 377 | res = 'xmlBufferPtr' |
Daniel Veillard | 27f2010 | 2004-11-05 11:50:11 +0000 | [diff] [blame] | 378 | if res == 'xmlChar_ptr' and name == 'name' and \ |
| 379 | string.find(function, "EatName") != -1: |
| 380 | return('eaten_name') |
Daniel Veillard | d5cc0f7 | 2004-11-06 19:24:28 +0000 | [diff] [blame] | 381 | if res == 'void_ptr*': |
| 382 | res = 'void_ptr_ptr' |
| 383 | if res == 'char_ptr*': |
| 384 | res = 'char_ptr_ptr' |
| 385 | if res == 'xmlChar_ptr*': |
| 386 | res = 'xmlChar_ptr_ptr' |
| 387 | if res == 'const_xmlChar_ptr*': |
| 388 | res = 'const_xmlChar_ptr_ptr' |
| 389 | if res == 'const_char_ptr*': |
| 390 | res = 'const_char_ptr_ptr' |
Daniel Veillard | a82b182 | 2004-11-08 16:24:57 +0000 | [diff] [blame] | 391 | if res == 'FILE_ptr' and module == 'debugXML': |
| 392 | res = 'debug_FILE_ptr'; |
Daniel Veillard | 6128c01 | 2004-11-08 17:16:15 +0000 | [diff] [blame] | 393 | if res == 'int' and name == 'options': |
| 394 | if module == 'parser' or module == 'xmlreader': |
| 395 | res = 'parseroptions' |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 396 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 397 | return res |
| 398 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 399 | known_param_types = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 400 | |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 401 | def is_known_param_type(name, rtype): |
| 402 | global test |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 403 | for type in known_param_types: |
| 404 | if type == name: |
| 405 | return 1 |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 406 | for type in generated_param_types: |
| 407 | if type == name: |
| 408 | return 1 |
| 409 | |
| 410 | if name[-3:] == 'Ptr' or name[-4:] == '_ptr': |
| 411 | if rtype[0:6] == 'const ': |
| 412 | crtype = rtype[6:] |
| 413 | else: |
| 414 | crtype = rtype |
| 415 | |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 416 | define = 0 |
| 417 | if modules_defines.has_key(module): |
| 418 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 419 | define = 1 |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 420 | test.write(""" |
| 421 | #define gen_nb_%s 1 |
| 422 | static %s gen_%s(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 423 | return(NULL); |
| 424 | } |
| 425 | static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 426 | } |
| 427 | """ % (name, crtype, name, name, rtype)) |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 428 | if define == 1: |
| 429 | test.write("#endif\n\n") |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 430 | add_generated_param_type(name) |
| 431 | return 1 |
| 432 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 433 | return 0 |
| 434 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 435 | # |
| 436 | # Provide the type destructors for the return values |
| 437 | # |
| 438 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 439 | known_return_types = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 440 | |
| 441 | def is_known_return_type(name): |
| 442 | for type in known_return_types: |
| 443 | if type == name: |
| 444 | return 1 |
| 445 | return 0 |
| 446 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 447 | # |
| 448 | # Copy the beginning of the C test program result |
| 449 | # |
| 450 | |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 451 | try: |
| 452 | input = open("testapi.c", "r") |
| 453 | except: |
| 454 | input = open(srcPref + "testapi.c", "r") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 455 | test = open('testapi.c.new', 'w') |
| 456 | |
| 457 | def compare_and_save(): |
| 458 | global test |
| 459 | |
| 460 | test.close() |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 461 | try: |
| 462 | input = open("testapi.c", "r").read() |
| 463 | except: |
| 464 | input = '' |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 465 | test = open('testapi.c.new', "r").read() |
| 466 | if input != test: |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 467 | try: |
| 468 | os.system("rm testapi.c; mv testapi.c.new testapi.c") |
| 469 | except: |
| 470 | os.system("mv testapi.c.new testapi.c") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 471 | print("Updated testapi.c") |
| 472 | else: |
| 473 | print("Generated testapi.c is identical") |
| 474 | |
| 475 | line = input.readline() |
| 476 | while line != "": |
| 477 | if line == "/* CUT HERE: everything below that line is generated */\n": |
| 478 | break; |
| 479 | if line[0:15] == "#define gen_nb_": |
| 480 | type = string.split(line[15:])[0] |
| 481 | known_param_types.append(type) |
| 482 | if line[0:19] == "static void desret_": |
| 483 | type = string.split(line[19:], '(')[0] |
| 484 | known_return_types.append(type) |
| 485 | test.write(line) |
| 486 | line = input.readline() |
| 487 | input.close() |
| 488 | |
| 489 | if line == "": |
| 490 | print "Could not find the CUT marker in testapi.c skipping generation" |
| 491 | test.close() |
| 492 | sys.exit(0) |
| 493 | |
| 494 | print("Scanned testapi.c: found %d parameters types and %d return types\n" % ( |
| 495 | len(known_param_types), len(known_return_types))) |
| 496 | test.write("/* CUT HERE: everything below that line is generated */\n") |
| 497 | |
| 498 | |
| 499 | # |
| 500 | # Open the input API description |
| 501 | # |
William M. Brack | 106cad6 | 2004-12-23 15:56:12 +0000 | [diff] [blame] | 502 | doc = libxml2.readFile(srcPref + 'doc/libxml2-api.xml', None, 0) |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 503 | if doc == None: |
| 504 | print "Failed to load doc/libxml2-api.xml" |
| 505 | sys.exit(1) |
| 506 | ctxt = doc.xpathNewContext() |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 507 | |
| 508 | # |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 509 | # Generate a list of all function parameters and select only |
| 510 | # those used in the api tests |
| 511 | # |
| 512 | argtypes = {} |
| 513 | args = ctxt.xpathEval("/api/symbols/function/arg") |
| 514 | for arg in args: |
| 515 | mod = arg.xpathEval('string(../@file)') |
| 516 | func = arg.xpathEval('string(../@name)') |
| 517 | if (mod not in skipped_modules) and (func not in skipped_functions): |
| 518 | type = arg.xpathEval('string(@type)') |
| 519 | if not argtypes.has_key(type): |
| 520 | argtypes[type] = func |
| 521 | |
| 522 | # similarly for return types |
| 523 | rettypes = {} |
| 524 | rets = ctxt.xpathEval("/api/symbols/function/return") |
| 525 | for ret in rets: |
| 526 | mod = ret.xpathEval('string(../@file)') |
| 527 | func = ret.xpathEval('string(../@name)') |
| 528 | if (mod not in skipped_modules) and (func not in skipped_functions): |
| 529 | type = ret.xpathEval('string(@type)') |
| 530 | if not rettypes.has_key(type): |
| 531 | rettypes[type] = func |
| 532 | |
| 533 | # |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 534 | # Generate constructors and return type handling for all enums |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 535 | # which are used as function parameters |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 536 | # |
| 537 | enums = ctxt.xpathEval("/api/symbols/typedef[@type='enum']") |
| 538 | for enum in enums: |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 539 | module = enum.xpathEval('string(@file)') |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 540 | name = enum.xpathEval('string(@name)') |
| 541 | # |
| 542 | # Skip any enums which are not in our filtered lists |
| 543 | # |
| 544 | if (name == None) or ((name not in argtypes) and (name not in rettypes)): |
| 545 | continue; |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 546 | define = 0 |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 547 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 548 | if argtypes.has_key(name) and is_known_param_type(name, name) == 0: |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 549 | values = ctxt.xpathEval("/api/symbols/enum[@type='%s']" % name) |
| 550 | i = 0 |
| 551 | vals = [] |
| 552 | for value in values: |
| 553 | vname = value.xpathEval('string(@name)') |
| 554 | if vname == None: |
| 555 | continue; |
| 556 | i = i + 1 |
| 557 | if i >= 5: |
| 558 | break; |
| 559 | vals.append(vname) |
| 560 | if vals == []: |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 561 | print "Didn't find any value for enum %s" % (name) |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 562 | continue |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 563 | if modules_defines.has_key(module): |
| 564 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 565 | define = 1 |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 566 | test.write("#define gen_nb_%s %d\n" % (name, len(vals))) |
| 567 | test.write("""static %s gen_%s(int no, int nr ATTRIBUTE_UNUSED) {\n""" % |
| 568 | (name, name)) |
| 569 | i = 1 |
| 570 | for value in vals: |
| 571 | test.write(" if (no == %d) return(%s);\n" % (i, value)) |
| 572 | i = i + 1 |
| 573 | test.write(""" return(0); |
| 574 | } |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 575 | |
| 576 | static void des_%s(int no ATTRIBUTE_UNUSED, %s val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) { |
| 577 | } |
| 578 | |
| 579 | """ % (name, name)); |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 580 | known_param_types.append(name) |
| 581 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 582 | if (is_known_return_type(name) == 0) and (name in rettypes): |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 583 | if define == 0 and modules_defines.has_key(module): |
| 584 | test.write("#ifdef %s\n" % (modules_defines[module])) |
| 585 | define = 1 |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 586 | test.write("""static void desret_%s(%s val ATTRIBUTE_UNUSED) { |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 587 | } |
| 588 | |
William M. Brack | 094dd86 | 2004-11-14 14:28:34 +0000 | [diff] [blame] | 589 | """ % (name, name)) |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 590 | known_return_types.append(name) |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 591 | if define == 1: |
| 592 | test.write("#endif\n\n") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 593 | |
| 594 | # |
| 595 | # Load the interfaces |
| 596 | # |
Daniel Veillard | 57b2516 | 2004-11-06 14:50:18 +0000 | [diff] [blame] | 597 | headers = ctxt.xpathEval("/api/files/file") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 598 | for file in headers: |
| 599 | name = file.xpathEval('string(@name)') |
| 600 | if (name == None) or (name == ''): |
| 601 | continue |
| 602 | |
| 603 | # |
| 604 | # Some module may be skipped because they don't really consists |
| 605 | # of user callable APIs |
| 606 | # |
| 607 | if is_skipped_module(name): |
| 608 | continue |
| 609 | |
| 610 | # |
| 611 | # do not test deprecated APIs |
| 612 | # |
| 613 | desc = file.xpathEval('string(description)') |
| 614 | if string.find(desc, 'DEPRECATED') != -1: |
| 615 | print "Skipping deprecated interface %s" % name |
| 616 | continue; |
| 617 | |
| 618 | test.write("#include <libxml/%s.h>\n" % name) |
| 619 | modules.append(name) |
| 620 | |
| 621 | # |
| 622 | # Generate the callers signatures |
| 623 | # |
| 624 | for module in modules: |
| 625 | test.write("static int test_%s(void);\n" % module); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 626 | |
| 627 | # |
| 628 | # Generate the top caller |
| 629 | # |
| 630 | |
| 631 | test.write(""" |
| 632 | /** |
| 633 | * testlibxml2: |
| 634 | * |
| 635 | * Main entry point of the tester for the full libxml2 module, |
| 636 | * it calls all the tester entry point for each module. |
| 637 | * |
| 638 | * Returns the number of error found |
| 639 | */ |
| 640 | static int |
| 641 | testlibxml2(void) |
| 642 | { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 643 | int test_ret = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 644 | |
| 645 | """) |
| 646 | |
| 647 | for module in modules: |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 648 | test.write(" test_ret += test_%s();\n" % module) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 649 | |
| 650 | test.write(""" |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 651 | printf("Total: %d functions, %d tests, %d errors\\n", |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 652 | function_tests, call_tests, test_ret); |
| 653 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | """) |
| 657 | |
| 658 | # |
| 659 | # How to handle a function |
| 660 | # |
| 661 | nb_tests = 0 |
| 662 | |
| 663 | def generate_test(module, node): |
| 664 | global test |
| 665 | global nb_tests |
| 666 | nb_cond = 0 |
| 667 | no_gen = 0 |
| 668 | |
| 669 | name = node.xpathEval('string(@name)') |
| 670 | if is_skipped_function(name): |
| 671 | return |
| 672 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 673 | # |
| 674 | # check we know how to handle the args and return values |
| 675 | # and store the informations for the generation |
| 676 | # |
| 677 | try: |
| 678 | args = node.xpathEval("arg") |
| 679 | except: |
| 680 | args = [] |
| 681 | t_args = [] |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 682 | n = 0 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 683 | for arg in args: |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 684 | n = n + 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 685 | rtype = arg.xpathEval("string(@type)") |
| 686 | if rtype == 'void': |
| 687 | break; |
| 688 | info = arg.xpathEval("string(@info)") |
| 689 | nam = arg.xpathEval("string(@name)") |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 690 | type = type_convert(rtype, nam, info, module, name, n) |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 691 | if is_known_param_type(type, rtype) == 0: |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 692 | add_missing_type(type, name); |
| 693 | no_gen = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 694 | if (type[-3:] == 'Ptr' or type[-4:] == '_ptr') and \ |
| 695 | rtype[0:6] == 'const ': |
| 696 | crtype = rtype[6:] |
| 697 | else: |
| 698 | crtype = rtype |
| 699 | t_args.append((nam, type, rtype, crtype, info)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 700 | |
| 701 | try: |
| 702 | rets = node.xpathEval("return") |
| 703 | except: |
| 704 | rets = [] |
| 705 | t_ret = None |
| 706 | for ret in rets: |
| 707 | rtype = ret.xpathEval("string(@type)") |
| 708 | info = ret.xpathEval("string(@info)") |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 709 | type = type_convert(rtype, 'return', info, module, name, 0) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 710 | if rtype == 'void': |
| 711 | break |
| 712 | if is_known_return_type(type) == 0: |
| 713 | add_missing_type(type, name); |
| 714 | no_gen = 1 |
| 715 | t_ret = (type, rtype, info) |
| 716 | break |
| 717 | |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 718 | test.write(""" |
| 719 | static int |
| 720 | test_%s(void) { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 721 | int test_ret = 0; |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 722 | |
| 723 | """ % (name)) |
| 724 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 725 | if no_gen == 1: |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 726 | add_missing_functions(name, module) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 727 | test.write(""" |
| 728 | /* missing type support */ |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 729 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | """) |
| 733 | return |
| 734 | |
| 735 | try: |
| 736 | conds = node.xpathEval("cond") |
| 737 | for cond in conds: |
William M. Brack | 21e4ef2 | 2005-01-02 09:53:13 +0000 | [diff] [blame] | 738 | test.write("#if %s\n" % (cond.get_content())) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 739 | nb_cond = nb_cond + 1 |
| 740 | except: |
| 741 | pass |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 742 | |
| 743 | define = 0 |
| 744 | if function_defines.has_key(name): |
| 745 | test.write("#ifdef %s\n" % (function_defines[name])) |
| 746 | define = 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 747 | |
| 748 | # Declare the memory usage counter |
| 749 | no_mem = is_skipped_memcheck(name) |
| 750 | if no_mem == 0: |
| 751 | test.write(" int mem_base;\n"); |
| 752 | |
| 753 | # Declare the return value |
| 754 | if t_ret != None: |
| 755 | test.write(" %s ret_val;\n" % (t_ret[1])) |
| 756 | |
| 757 | # Declare the arguments |
| 758 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 759 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 760 | # add declaration |
Daniel Veillard | ce682bc | 2004-11-05 17:22:25 +0000 | [diff] [blame] | 761 | test.write(" %s %s; /* %s */\n" % (crtype, nam, info)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 762 | test.write(" int n_%s;\n" % (nam)) |
| 763 | test.write("\n") |
| 764 | |
| 765 | # Cascade loop on of each argument list of values |
| 766 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 767 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 768 | # |
| 769 | test.write(" for (n_%s = 0;n_%s < gen_nb_%s;n_%s++) {\n" % ( |
| 770 | nam, nam, type, nam)) |
| 771 | |
| 772 | # log the memory usage |
| 773 | if no_mem == 0: |
| 774 | test.write(" mem_base = xmlMemBlocks();\n"); |
| 775 | |
| 776 | # prepare the call |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 777 | i = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 778 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 779 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 780 | # |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 781 | test.write(" %s = gen_%s(n_%s, %d);\n" % (nam, type, nam, i)) |
| 782 | i = i + 1; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 783 | |
| 784 | # do the call, and clanup the result |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 785 | if extra_pre_call.has_key(name): |
| 786 | test.write(" %s\n"% (extra_pre_call[name])) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 787 | if t_ret != None: |
| 788 | test.write("\n ret_val = %s(" % (name)) |
| 789 | need = 0 |
| 790 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 791 | (nam, type, rtype, crtype, info) = arg |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 792 | if need: |
| 793 | test.write(", ") |
| 794 | else: |
| 795 | need = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 796 | if rtype != crtype: |
| 797 | test.write("(%s)" % rtype) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 798 | test.write("%s" % nam); |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 799 | test.write(");\n") |
| 800 | if extra_post_call.has_key(name): |
| 801 | test.write(" %s\n"% (extra_post_call[name])) |
| 802 | test.write(" desret_%s(ret_val);\n" % t_ret[0]) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 803 | else: |
| 804 | test.write("\n %s(" % (name)); |
| 805 | need = 0; |
| 806 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 807 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 808 | if need: |
| 809 | test.write(", ") |
| 810 | else: |
| 811 | need = 1 |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 812 | if rtype != crtype: |
| 813 | test.write("(%s)" % rtype) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 814 | test.write("%s" % nam) |
| 815 | test.write(");\n") |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 816 | if extra_post_call.has_key(name): |
| 817 | test.write(" %s\n"% (extra_post_call[name])) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 818 | |
Daniel Veillard | 8a32fe4 | 2004-11-02 22:10:16 +0000 | [diff] [blame] | 819 | test.write(" call_tests++;\n"); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 820 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 821 | # Free the arguments |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 822 | i = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 823 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 824 | (nam, type, rtype, crtype, info) = arg; |
William M. Brack | d46c1ca | 2007-02-08 23:34:34 +0000 | [diff] [blame] | 825 | # This is a hack to prevent generating a destructor for the |
| 826 | # 'input' argument in xmlTextReaderSetup. There should be |
| 827 | # a better, more generic way to do this! |
| 828 | if string.find(info, 'destroy') == -1: |
| 829 | test.write(" des_%s(n_%s, " % (type, nam)) |
| 830 | if rtype != crtype: |
| 831 | test.write("(%s)" % rtype) |
| 832 | test.write("%s, %d);\n" % (nam, i)) |
Daniel Veillard | 3d97e66 | 2004-11-04 10:49:00 +0000 | [diff] [blame] | 833 | i = i + 1; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 834 | |
| 835 | test.write(" xmlResetLastError();\n"); |
| 836 | # Check the memory usage |
| 837 | if no_mem == 0: |
| 838 | test.write(""" if (mem_base != xmlMemBlocks()) { |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 839 | printf("Leak of %%d blocks found in %s", |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 840 | xmlMemBlocks() - mem_base); |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 841 | test_ret++; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 842 | """ % (name)); |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 843 | for arg in t_args: |
William M. Brack | f13f77f | 2004-11-12 16:03:48 +0000 | [diff] [blame] | 844 | (nam, type, rtype, crtype, info) = arg; |
Daniel Veillard | a03e365 | 2004-11-02 18:45:30 +0000 | [diff] [blame] | 845 | test.write(""" printf(" %%d", n_%s);\n""" % (nam)) |
| 846 | test.write(""" printf("\\n");\n""") |
| 847 | test.write(" }\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 848 | |
| 849 | for arg in t_args: |
| 850 | test.write(" }\n") |
| 851 | |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 852 | test.write(" function_tests++;\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 853 | # |
| 854 | # end of conditional |
| 855 | # |
| 856 | while nb_cond > 0: |
| 857 | test.write("#endif\n") |
| 858 | nb_cond = nb_cond -1 |
Daniel Veillard | a521d28 | 2004-11-09 14:59:59 +0000 | [diff] [blame] | 859 | if define == 1: |
| 860 | test.write("#endif\n") |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 861 | |
| 862 | nb_tests = nb_tests + 1; |
| 863 | |
| 864 | test.write(""" |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 865 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 866 | } |
| 867 | |
| 868 | """) |
| 869 | |
| 870 | # |
| 871 | # Generate all module callers |
| 872 | # |
| 873 | for module in modules: |
| 874 | # gather all the functions exported by that module |
| 875 | try: |
| 876 | functions = ctxt.xpathEval("/api/symbols/function[@file='%s']" % (module)) |
| 877 | except: |
| 878 | print "Failed to gather functions from module %s" % (module) |
| 879 | continue; |
| 880 | |
| 881 | # iterate over all functions in the module generating the test |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 882 | i = 0 |
| 883 | nb_tests_old = nb_tests |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 884 | for function in functions: |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 885 | i = i + 1 |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 886 | generate_test(module, function); |
| 887 | |
| 888 | # header |
| 889 | test.write("""static int |
| 890 | test_%s(void) { |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 891 | int test_ret = 0; |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 892 | |
Daniel Veillard | d0cf7f6 | 2004-11-09 16:17:02 +0000 | [diff] [blame] | 893 | if (quiet == 0) printf("Testing %s : %d of %d functions ...\\n"); |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 894 | """ % (module, module, nb_tests - nb_tests_old, i)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 895 | |
| 896 | # iterate over all functions in the module generating the call |
| 897 | for function in functions: |
| 898 | name = function.xpathEval('string(@name)') |
| 899 | if is_skipped_function(name): |
| 900 | continue |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 901 | test.write(" test_ret += test_%s();\n" % (name)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 902 | |
| 903 | # footer |
| 904 | test.write(""" |
Daniel Veillard | 4259532 | 2004-11-08 10:52:06 +0000 | [diff] [blame] | 905 | if (test_ret != 0) |
| 906 | printf("Module %s: %%d errors\\n", test_ret); |
| 907 | return(test_ret); |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 908 | } |
| 909 | """ % (module)) |
| 910 | |
Daniel Veillard | ce244ad | 2004-11-05 10:03:46 +0000 | [diff] [blame] | 911 | # |
| 912 | # Generate direct module caller |
| 913 | # |
| 914 | test.write("""static int |
| 915 | test_module(const char *module) { |
| 916 | """); |
| 917 | for module in modules: |
| 918 | test.write(""" if (!strcmp(module, "%s")) return(test_%s());\n""" % ( |
| 919 | module, module)) |
| 920 | test.write(""" return(0); |
| 921 | } |
| 922 | """); |
| 923 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 924 | print "Generated test for %d modules and %d functions" %(len(modules), nb_tests) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 925 | |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 926 | compare_and_save() |
| 927 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 928 | missing_list = [] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 929 | for missing in missing_types.keys(): |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 930 | if missing == 'va_list' or missing == '...': |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 931 | continue; |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 932 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 933 | n = len(missing_types[missing]) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 934 | missing_list.append((n, missing)) |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 935 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 936 | def compare_missing(a, b): |
| 937 | return b[0] - a[0] |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 938 | |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 939 | missing_list.sort(compare_missing) |
Daniel Veillard | 0ea9c9f | 2004-11-05 14:30:41 +0000 | [diff] [blame] | 940 | print "Missing support for %d functions and %d types see missing.lst" % (missing_functions_nr, len(missing_list)) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 941 | lst = open("missing.lst", "w") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 942 | lst.write("Missing support for %d types" % (len(missing_list))) |
| 943 | lst.write("\n") |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 944 | for miss in missing_list: |
| 945 | lst.write("%s: %d :" % (miss[1], miss[0])) |
| 946 | i = 0 |
| 947 | for n in missing_types[miss[1]]: |
| 948 | i = i + 1 |
| 949 | if i > 5: |
| 950 | lst.write(" ...") |
| 951 | break |
| 952 | lst.write(" %s" % (n)) |
| 953 | lst.write("\n") |
Daniel Veillard | 34099b4 | 2004-11-04 17:34:35 +0000 | [diff] [blame] | 954 | lst.write("\n") |
| 955 | lst.write("\n") |
| 956 | lst.write("Missing support per module"); |
| 957 | for module in missing_functions.keys(): |
| 958 | lst.write("module %s:\n %s\n" % (module, missing_functions[module])) |
Daniel Veillard | 1ba06bb | 2004-11-04 12:32:18 +0000 | [diff] [blame] | 959 | |
| 960 | lst.close() |
Daniel Veillard | b1b3a3e | 2004-11-03 23:25:47 +0000 | [diff] [blame] | 961 | |
Daniel Veillard | 36e5cd5 | 2004-11-02 14:52:23 +0000 | [diff] [blame] | 962 | |