/* * Generate the XML export file. */ void generateXML(sipSpec *pt, moduleDef *mod, const char *xmlFile) { FILE *fp; classDef *cd; memberDef *md; if ((fp = fopen(xmlFile, "w")) == NULL) fatal("Unable to create file \"%s\"\n", xmlFile); fprintf(fp, "<?xml version=\"1.0\"?>\n"); fprintf(fp, "<Module version=\"%u\" name=\"%s\">\n", XML_VERSION_NR, mod->name); /* * Note that we don't yet handle mapped types, templates or exceptions. */ for (cd = pt->classes; cd != NULL; cd = cd->next) { if (cd->iff->module != mod) continue; if (isExternal(cd)) continue; xmlClass(pt, mod, cd, fp); } for (cd = mod->proxies; cd != NULL; cd = cd->next) xmlClass(pt, mod, cd, fp); xmlEnums(pt, mod, NULL, 1, fp); xmlVars(pt, mod, NULL, 1, fp); for (md = mod->othfuncs; md != NULL; md = md->next) xmlFunction(pt, NULL, md, mod->overs, 1, fp); fprintf(fp, "</Module>\n"); fclose(fp); }
/* * Generate the XML for a class. */ static void xmlClass(sipSpec *pt, moduleDef *mod, classDef *cd, FILE *fp) { int indent = 1; ctorDef *ct; memberDef *md; if (isOpaque(cd)) { xmlIndent(indent, fp); fprintf(fp, "<OpaqueClass name=\""); prScopedPythonName(fp, cd->ecd, cd->pyname->text); fprintf(fp, "\"/>\n"); return; } xmlIndent(indent++, fp); fprintf(fp, "<Class name=\""); prScopedPythonName(fp, cd->ecd, cd->pyname->text); fprintf(fp, "\""); if (cd->picklecode != NULL) fprintf(fp, " pickle=\"1\""); if (cd->convtocode != NULL) fprintf(fp, " convert=\"1\""); if (cd->convfromcode != NULL) fprintf(fp, " convertfrom=\"1\""); if (cd->real != NULL) fprintf(fp, " extends=\"%s\"", cd->real->iff->module->name); if (cd->supers != NULL) { classList *cl; fprintf(fp, " inherits=\""); for (cl = cd->supers; cl != NULL; cl = cl->next) { if (cl != cd->supers) fprintf(fp, " "); prScopedPythonName(fp, cl->cd->ecd, cl->cd->pyname->text); } fprintf(fp, "\""); } fprintf(fp, ">\n"); xmlEnums(pt, mod, cd, indent, fp); xmlVars(pt, mod, cd, indent, fp); for (ct = cd->ctors; ct != NULL; ct = ct->next) { if (isPrivateCtor(ct)) continue; if (xmlCtor(pt, cd, ct, FALSE, indent, fp)) xmlCtor(pt, cd, ct, TRUE, indent, fp); } for (md = cd->members; md != NULL; md = md->next) xmlFunction(pt, cd, md, cd->overs, indent, fp); xmlIndent(--indent, fp); fprintf(fp, "</Class>\n"); }
/* * Generate the XML for a class. */ static void xmlClass(sipSpec *pt, moduleDef *mod, classDef *cd, FILE *fp) { int indent = 1; ctorDef *ct; memberDef *md; if (isOpaque(cd)) { xmlIndent(indent, fp); fprintf(fp, "<OpaqueClass name=\""); prScopedPythonName(fp, cd->ecd, cd->pyname->text); fprintf(fp, "\"/>\n"); return; } if (!isHiddenNamespace(cd)) { xmlIndent(indent++, fp); fprintf(fp, "<Class name=\""); prScopedPythonName(fp, cd->ecd, cd->pyname->text); fprintf(fp, "\""); xmlRealName(classFQCName(cd), NULL, fp); if (cd->picklecode != NULL) fprintf(fp, " pickle=\"1\""); if (cd->convtocode != NULL) fprintf(fp, " convert=\"1\""); if (cd->convfromcode != NULL) fprintf(fp, " convertfrom=\"1\""); if (cd->real != NULL) fprintf(fp, " extends=\"%s\"", cd->real->iff->module->name); if (cd->pyqt_flags_enums != NULL) { const char *sep; stringList *sl; fprintf(fp, " flagsenums=\""); sep = ""; for (sl = cd->pyqt_flags_enums; sl != NULL; sl = sl->next) { fprintf(fp, "%s%s", sep, sl->s); sep = " "; } fprintf(fp, "\""); } if (cd->supers != NULL) { classList *cl; fprintf(fp, " inherits=\""); for (cl = cd->supers; cl != NULL; cl = cl->next) { if (cl != cd->supers) fprintf(fp, " "); restPyClass(cl->cd, fp); } fprintf(fp, "\""); } fprintf(fp, ">\n"); } for (ct = cd->ctors; ct != NULL; ct = ct->next) { if (isPrivateCtor(ct)) continue; xmlCtor(pt, mod, cd, ct, indent, fp); } xmlEnums(pt, mod, cd, indent, fp); xmlVars(pt, mod, cd, indent, fp); for (md = cd->members; md != NULL; md = md->next) xmlFunction(pt, mod, cd, md, cd->overs, indent, fp); if (!isHiddenNamespace(cd)) { xmlIndent(--indent, fp); fprintf(fp, "</Class>\n"); } }