/* * Generate a class reference, including its owning module if necessary and * handling forward references if necessary. */ static void prClassRef(classDef *cd, moduleDef *mod, ifaceFileList *defined, int pep484, FILE *fp) { if (pep484) { /* * We assume that an external class will be handled properly by some * handwritten type hint code. */ int is_defined = (isExternal(cd) || isDefined(cd->iff, cd->ecd, mod, defined)); if (!is_defined) fprintf(fp, "'"); if (cd->iff->module != mod) fprintf(fp, "%s.", cd->iff->module->name); prScopedPythonName(fp, cd->ecd, cd->pyname->text); if (!is_defined) fprintf(fp, "'"); } else { prScopedPythonName(fp, cd->ecd, cd->pyname->text); } }
/* * Generate an API ctor. */ static void apiCtor(sipSpec *pt, moduleDef *mod, classDef *scope, ctorDef *ct, FILE *fp) { int need_comma, a; /* Do the callable type form. */ fprintf(fp, "%s.", mod->name); prScopedPythonName(fp, scope->ecd, scope->pyname->text); fprintf(fp, "?%d(", CLASS_ID); need_comma = FALSE; for (a = 0; a < ct->pysig.nrArgs; ++a) { argDef *ad = &ct->pysig.args[a]; need_comma = apiArgument(pt, ad, FALSE, need_comma, TRUE, TRUE, FALSE, fp); } fprintf(fp, ")\n"); /* Do the call __init__ form. */ fprintf(fp, "%s.", mod->name); prScopedPythonName(fp, scope->ecd, scope->pyname->text); fprintf(fp, ".__init__?%d(self", CLASS_ID); for (a = 0; a < ct->pysig.nrArgs; ++a) apiArgument(pt, &ct->pysig.args[a], FALSE, TRUE, TRUE, TRUE, FALSE, fp); fprintf(fp, ")\n"); }
/* * Generate the APIs for all the enums in a scope. */ static void apiEnums(sipSpec *pt, moduleDef *mod, classDef *scope, FILE *fp) { enumDef *ed; for (ed = pt->enums; ed != NULL; ed = ed->next) { enumMemberDef *emd; if (ed->module != mod) continue; if (ed->ecd != scope) continue; if (ed->pyname != NULL) { fprintf(fp, "%s.", mod->name); prScopedPythonName(fp, ed->ecd, ed->pyname->text); fprintf(fp, "?%d\n", ENUM_ID); } for (emd = ed->members; emd != NULL; emd = emd->next) { fprintf(fp, "%s.", mod->name); prScopedPythonName(fp, ed->ecd, emd->pyname->text); fprintf(fp, "?%d\n", ENUM_ID); } } }
/* * Generate the XML for all the enums in a scope. */ static void xmlEnums(sipSpec *pt, moduleDef *mod, classDef *scope, int indent, FILE *fp) { enumDef *ed; for (ed = pt->enums; ed != NULL; ed = ed->next) { if (ed->module != mod) continue; if (ed->ecd != scope) continue; if (ed->pyname != NULL) { enumMemberDef *emd; xmlIndent(indent++, fp); fprintf(fp, "<Enum name=\""); prScopedPythonName(fp, ed->ecd, ed->pyname->text); fprintf(fp, "\""); xmlRealName(ed->fqcname, NULL, fp); fprintf(fp, ">\n"); for (emd = ed->members; emd != NULL; emd = emd->next) { xmlIndent(indent, fp); fprintf(fp, "<EnumMember name=\""); prScopedPythonName(fp, ed->ecd, ed->pyname->text); fprintf(fp, ".%s\"", emd->pyname->text); xmlRealName(ed->fqcname, emd->cname, fp); fprintf(fp, "/>\n"); } xmlIndent(--indent, fp); fprintf(fp, "</Enum>\n"); } else { enumMemberDef *emd; for (emd = ed->members; emd != NULL; emd = emd->next) { xmlIndent(indent, fp); fprintf(fp, "<Member name=\""); prScopedPythonName(fp, ed->ecd, emd->pyname->text); fprintf(fp, "\""); xmlRealScopedName(scope, emd->cname, fp); fprintf(fp, " const=\"1\" typename=\"int\"/>\n"); } } } }
/* * Generate the XML for all the variables in a scope. */ static void xmlVars(sipSpec *pt, moduleDef *mod, classDef *scope, int indent, FILE *fp) { varDef *vd; for (vd = pt->vars; vd != NULL; vd = vd->next) { if (vd->module != mod) continue; if (vd->ecd != scope) continue; xmlIndent(indent, fp); fprintf(fp, "<Member name=\""); prScopedPythonName(fp, vd->ecd, vd->pyname->text); fprintf(fp, "\""); if (isConstArg(&vd->type) || scope == NULL) fprintf(fp, " const=\"1\""); if (isStaticVar(vd)) fprintf(fp, " static=\"1\""); xmlType(pt, &vd->type, FALSE, fp); fprintf(fp, "/>\n"); } }
/* * Generate the API for an argument. */ static int apiArgument(sipSpec *pt, argDef *ad, int out, int need_comma, int names, int defaults, int in_str, FILE *fp) { const char *tname; classDef *tscope; if (isArraySize(ad)) return need_comma; if ((tname = pyType(pt, ad, &tscope)) == NULL) return need_comma; if (need_comma) fprintf(fp, ", "); prScopedPythonName(fp, tscope, tname); /* * Handle the default value is required, but ignore it if it is an output * only argument. */ if (defaults && ad->defval && !out) { if (names && ad->name != NULL) fprintf(fp, " %s", ad->name->text); fprintf(fp, "="); prDefaultValue(ad, in_str, fp); } return TRUE; }
/* * Generate a fully qualified attribute name as a reST reference. */ static void restPyAttribute(moduleDef *mod, classDef *scope, nameDef *name, FILE *fp) { fprintf(fp, ":sip:ref:`~%s.", mod->fullname->text); prScopedPythonName(fp, scope, name->text); fprintf(fp, "`"); }
/* * Generate a scoped enum name. */ static void prScopedEnumName(FILE *fp, enumDef *ed) { if (ed->emtd != NULL) fprintf(fp, "%s.%s", ed->emtd->pyname->text, ed->pyname->text); else prScopedPythonName(fp, ed->ecd, ed->pyname->text); }
/* * Generate an ctor type hint. */ static void pyiCtor(sipSpec *pt, moduleDef *mod, classDef *cd, ctorDef *ct, int overloaded, int sec, ifaceFileList *defined, int indent, FILE *fp) { int a, need_comma; if (overloaded) { prIndent(indent, fp); fprintf(fp, "@typing.overload\n"); } prIndent(indent, fp); if (cd == NULL) { fprintf(fp, "def __init__(self"); need_comma = TRUE; } else { prScopedPythonName(fp, cd->ecd, cd->pyname->text); fprintf(fp, "("); need_comma = FALSE; } for (a = 0; a < ct->pysig.nrArgs; ++a) need_comma = pyiArgument(pt, mod, &ct->pysig.args[a], a, FALSE, need_comma, sec, TRUE, TRUE, defined, ct->kwargs, (cd == NULL), fp); fprintf(fp, (cd == NULL) ? ") -> None: ...\n" : ")"); }
/* * Generate a scoped Python name. */ void prScopedPythonName(FILE *fp, classDef *scope, const char *pyname) { if (scope != NULL) { prScopedPythonName(fp, scope->ecd, NULL); fprintf(fp, "%s.", scope->pyname->text); } if (pyname != NULL) fprintf(fp, "%s", pyname); }
/* * Generate a single API overload. */ static void apiOverload(sipSpec *pt, moduleDef *mod, classDef *scope, overDef *od, FILE *fp) { fprintf(fp, "%s.", mod->name); prScopedPythonName(fp, scope, od->common->pyname->text); fprintf(fp, "?%d", METHOD_ID); exportPythonSignature(pt, fp, &od->pysig, TRUE, TRUE, FALSE, FALSE); fprintf(fp, "\n"); }
/* * Generate a single API overload. */ static int apiOverload(sipSpec *pt, moduleDef *mod, classDef *scope, overDef *od, int sec, FILE *fp) { int need_sec; fprintf(fp, "%s.", mod->name); prScopedPythonName(fp, scope, od->common->pyname->text); fprintf(fp, "?%d", METHOD_ID); need_sec = prPythonSignature(pt, fp, &od->pysig, sec, TRUE, TRUE, FALSE); fprintf(fp, "\n"); return need_sec; }
/* * Generate the APIs for all the variables in a scope. */ static void apiVars(sipSpec *pt, moduleDef *mod, classDef *scope, FILE *fp) { varDef *vd; for (vd = pt->vars; vd != NULL; vd = vd->next) { if (vd->module != mod) continue; if (vd->ecd != scope) continue; fprintf(fp, "%s.", mod->name); prScopedPythonName(fp, vd->ecd, vd->pyname->text); fprintf(fp, "?%d\n", VARIABLE_ID); } }
/* * Generate the XML for a function. */ static void xmlFunction(sipSpec *pt, classDef *scope, memberDef *md, overDef *oloads, int indent, FILE *fp) { overDef *od; const char *default_str = "default=\"1\" "; for (od = oloads; od != NULL; od = od->next) { int isstat; classDef *xtnds; if (od->common != md) continue; if (isPrivate(od)) continue; if (isSignal(od)) { xmlIndent(indent, fp); fprintf(fp, "<Signal %sname=\"", default_str); prScopedPythonName(fp, scope, md->pyname->text); fprintf(fp, "\" sig=\""); xmlCppSignature(fp, od); fprintf(fp, "\"/>\n"); default_str = ""; continue; } xtnds = NULL; isstat = (scope == NULL || scope->iff->type == namespace_iface || isStatic(od)); if (scope == NULL && md->slot != no_slot && od->pysig.args[0].atype == class_type) { xtnds = od->pysig.args[0].u.cd; isstat = FALSE; } if (xmlOverload(pt, scope, md, od, xtnds, isstat, FALSE, indent, fp)) xmlOverload(pt, scope, md, od, xtnds, isstat, TRUE, indent, fp); } }
/* * Generate the XML for a ctor. */ static void xmlCtor(sipSpec *pt, moduleDef *mod, classDef *scope, ctorDef *ct, int indent, FILE *fp) { int a; xmlIndent(indent++, fp); fprintf(fp, "<Function name=\""); prScopedPythonName(fp, scope, "__init__"); fprintf(fp, "\""); xmlRealScopedName(scope, "__init__", fp); if (hasCppSignature(ct->cppsig)) { fprintf(fp, " cppsig=\""); xmlCppSignature(fp, ct->cppsig, FALSE); fprintf(fp, "\""); } /* Handle the trivial case. */ if (ct->pysig.nrArgs == 0) { fprintf(fp, "/>\n"); return; } fprintf(fp, ">\n"); for (a = 0; a < ct->pysig.nrArgs; ++a) { argDef *ad = &ct->pysig.args[a]; if (isInArg(ad)) xmlArgument(pt, mod, ad, FALSE, ct->kwargs, FALSE, indent, fp); if (isOutArg(ad)) xmlArgument(pt, mod, ad, TRUE, ct->kwargs, FALSE, indent, fp); } xmlIndent(--indent, fp); fprintf(fp, "</Function>\n"); }
/* * Generate the XML for a ctor. */ static int xmlCtor(sipSpec *pt, classDef *scope, ctorDef *ct, int sec, int indent, FILE *fp) { int a, need_sec; xmlIndent(indent++, fp); fprintf(fp, "<Function name=\""); prScopedPythonName(fp, scope, "__init__"); fprintf(fp, "\""); /* Handle the trivial case. */ if (ct->pysig.nrArgs == 0) { fprintf(fp, "/>\n"); return FALSE; } fprintf(fp, ">\n"); need_sec = FALSE; for (a = 0; a < ct->pysig.nrArgs; ++a) { argDef *ad = &ct->pysig.args[a]; xmlArgument(pt, ad, dirAttribute(ad), FALSE, sec, indent, fp); if (ad->atype == rxcon_type || ad->atype == rxdis_type) need_sec = TRUE; } xmlIndent(--indent, fp); fprintf(fp, "</Function>\n"); return need_sec; }
/* * Generate a fully qualified class name as a reST reference. */ void restPyClass(classDef *cd, FILE *fp) { fprintf(fp, ":sip:ref:`~%s.", cd->iff->module->fullname->text); prScopedPythonName(fp, cd->ecd, cd->pyname->text); fprintf(fp, "`"); }
/* * Generate a fully qualified attribute name as a reST reference. */ static void restPyEnumMember(enumMemberDef *emd, FILE *fp) { fprintf(fp, ":sip:ref:`~%s.", emd->ed->module->fullname->text); prScopedPythonName(fp, emd->ed->ecd, emd->ed->pyname->text); fprintf(fp, ".%s`", emd->pyname->text); }
/* * 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"); } }
/* * Generate the XML for a type. */ static void xmlType(sipSpec *pt, argDef *ad, int sec, FILE *fp) { const char *type_type = NULL, *type_name; classDef *type_scope; fprintf(fp, " typename=\""); switch (ad->atype) { case class_type: type_type = (isOpaque(ad->u.cd) ? "opaque" : "class"); break; case enum_type: if (ad->u.ed->pyname != NULL) type_type = "enum"; break; case rxcon_type: case rxdis_type: if (!sec) type_type = "class"; break; case qobject_type: type_type = "class"; break; case slotcon_type: case slotdis_type: { int a; prcode(fp, "SLOT("); for (a = 0; a < ad->u.sa->nrArgs; ++a) { if (a > 0) prcode(fp, ", "); prcode(fp, "%M%B%M", &ad->u.sa->args[a]); } prcode(fp, ")"); } break; case mapped_type: type_type = "mappedtype"; break; } if ((type_name = pyType(pt, ad, sec, &type_scope)) != NULL) prScopedPythonName(fp, type_scope, type_name); fprintf(fp, "\""); if (type_type != NULL) fprintf(fp, " typetype=\"%s\"", type_type); if (ad->name != NULL) fprintf(fp, " name=\"%s\"", ad->name->text); }
/* * Generate the XML for an overload. */ static int xmlOverload(sipSpec *pt, classDef *scope, memberDef *md, overDef *od, classDef *xtnds, int stat, int sec, int indent, FILE *fp) { int a, need_sec, no_res; xmlIndent(indent++, fp); fprintf(fp, "<Function name=\""); prScopedPythonName(fp, scope, md->pyname->text); fprintf(fp, "\""); if (isAbstract(od)) fprintf(fp, " abstract=\"1\""); if (stat) fprintf(fp, " static=\"1\""); if (isSlot(od)) { fprintf(fp, " slot=\""); xmlCppSignature(fp, od); fprintf(fp, "\""); } if (xtnds != NULL) { fprintf(fp, " extends=\""); prScopedPythonName(fp, xtnds->ecd, xtnds->pyname->text); fprintf(fp, "\""); } no_res = (od->pysig.result.atype == void_type && od->pysig.result.nrderefs == 0); /* Handle the trivial case. */ if (no_res && od->pysig.nrArgs == 0) { fprintf(fp, "/>\n"); return FALSE; } fprintf(fp, ">\n"); if (!no_res) xmlArgument(pt, &od->pysig.result, "out", isResultTransferredBack(od), FALSE, indent, fp); need_sec = FALSE; for (a = 0; a < od->pysig.nrArgs; ++a) { argDef *ad = &od->pysig.args[a]; /* Ignore the first argument of number slots. */ if (isNumberSlot(md) && a == 0 && od->pysig.nrArgs == 2) continue; xmlArgument(pt, ad, dirAttribute(ad), FALSE, sec, indent, fp); if (ad->atype == rxcon_type || ad->atype == rxdis_type) need_sec = TRUE; } xmlIndent(--indent, fp); fprintf(fp, "</Function>\n"); return need_sec; }
/* * Generate the XML for a function. */ static void xmlFunction(sipSpec *pt, moduleDef *mod, classDef *scope, memberDef *md, overDef *oloads, int indent, FILE *fp) { overDef *od; for (od = oloads; od != NULL; od = od->next) { int isstat; classDef *xtnds; if (od->common != md) continue; if (isPrivate(od)) continue; if (isSignal(od)) { int a; xmlIndent(indent++, fp); fprintf(fp, "<Signal name=\""); prScopedPythonName(fp, scope, md->pyname->text); fprintf(fp, "\""); xmlRealScopedName(scope, od->cppname, fp); if (hasCppSignature(od->cppsig)) { fprintf(fp, " cppsig=\""); xmlCppSignature(fp, od->cppsig, FALSE); fprintf(fp, "\""); } /* Handle the trivial case. */ if (od->pysig.nrArgs == 0) { fprintf(fp, "/>\n"); continue; } fprintf(fp, ">\n"); for (a = 0; a < od->pysig.nrArgs; ++a) { argDef *ad = &od->pysig.args[a]; xmlArgument(pt, mod, ad, FALSE, od->kwargs, FALSE, indent, fp); } xmlIndent(--indent, fp); fprintf(fp, "</Signal>\n"); continue; } xtnds = NULL; isstat = (scope == NULL || scope->iff->type == namespace_iface || isStatic(od)); if (scope == NULL && md->slot != no_slot && od->pysig.args[0].atype == class_type) { xtnds = od->pysig.args[0].u.cd; isstat = FALSE; } xmlOverload(pt, mod, scope, md, od, xtnds, isstat, indent, 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 an overload. */ static void xmlOverload(sipSpec *pt, moduleDef *mod, classDef *scope, memberDef *md, overDef *od, classDef *xtnds, int stat, int indent, FILE *fp) { const char *name, *cppname = od->cppname; int a, no_res; xmlIndent(indent++, fp); fprintf(fp, "<Function name=\""); if (isReflected(od)) { if ((name = reflectedSlot(md->slot)) != NULL) cppname = name; else name = md->pyname->text; } else { name = md->pyname->text; } prScopedPythonName(fp, scope, name); fprintf(fp, "\""); xmlRealScopedName(scope, cppname, fp); if (hasCppSignature(od->cppsig)) { fprintf(fp, " cppsig=\""); xmlCppSignature(fp, od->cppsig, isConst(od)); fprintf(fp, "\""); } if (isAbstract(od)) fprintf(fp, " abstract=\"1\""); if (stat) fprintf(fp, " static=\"1\""); if (isSlot(od)) fprintf(fp, " slot=\"1\""); if (isVirtual(od)) { fprintf(fp, " virtual=\"1\""); } if (xtnds != NULL) { fprintf(fp, " extends=\""); prScopedPythonName(fp, xtnds->ecd, xtnds->pyname->text); fprintf(fp, "\""); } /* An empty type hint specifies a void return. */ if (od->pysig.result.typehint_out != NULL && od->pysig.result.typehint_out->raw_hint[0] == '\0') no_res = TRUE; else no_res = (od->pysig.result.atype == void_type && od->pysig.result.nrderefs == 0); /* Handle the trivial case. */ if (no_res && od->pysig.nrArgs == 0) { fprintf(fp, "/>\n"); return; } fprintf(fp, ">\n"); if (!no_res) xmlArgument(pt, mod, &od->pysig.result, TRUE, NoKwArgs, isResultTransferredBack(od), indent, fp); for (a = 0; a < od->pysig.nrArgs; ++a) { argDef *ad = &od->pysig.args[a]; /* * Ignore the first argument of non-reflected number slots and the * second argument of reflected number slots. */ if (isNumberSlot(md) && od->pysig.nrArgs == 2) if ((a == 0 && !isReflected(od)) || (a == 1 && isReflected(od))) continue; if (isInArg(ad)) xmlArgument(pt, mod, ad, FALSE, od->kwargs, FALSE, indent, fp); if (isOutArg(ad)) xmlArgument(pt, mod, ad, TRUE, od->kwargs, FALSE, indent, fp); } xmlIndent(--indent, fp); fprintf(fp, "</Function>\n"); }
/* * Generate a fully qualified enum name as a reST reference. */ void restPyEnum(enumDef *ed, FILE *fp) { fprintf(fp, ":sip:ref:`~%s.", ed->module->fullname->text); prScopedPythonName(fp, ed->ecd, ed->pyname->text); fprintf(fp, "`"); }
/* * Generate the XML for a type. */ static void xmlType(sipSpec *pt, moduleDef *mod, argDef *ad, int out, KwArgs kwargs, FILE *fp) { const char *type_name; classDef *type_scope; typeHintDef *thd; fprintf(fp, " typename=\""); /* Handle the argument name. */ if (!out && ad->name != NULL) { if (kwargs == AllKwArgs || (kwargs == OptionalKwArgs && ad->defval != NULL)) fprintf(fp, "%s: ", ad->name->text); } /* Use any explicit type hint unless the argument is constrained. */ thd = (out ? ad->typehint_out : (isConstrained(ad) ? NULL : ad->typehint_in)); if (thd != NULL) { pyiTypeHint(pt, thd, mod, out, NULL, FALSE, TRUE, fp); } else { switch (ad->atype) { case class_type: restPyClass(ad->u.cd, fp); break; case enum_type: if (ad->u.ed->pyname != NULL) restPyEnum(ad->u.ed, fp); else fprintf(fp, "int"); break; case qobject_type: restPyClass(pt->qobject_cd, fp); break; case mapped_type: /* There would normally be a type hint. */ fprintf(fp, "unknown-type"); break; default: if ((type_name = pyType(pt, ad, &type_scope)) != NULL) prScopedPythonName(fp, type_scope, type_name); } } if (!out && ad->name != NULL && ad->defval != NULL) { fprintf(fp, " = "); /* * Try and convert the value to a reST reference. We don't try very * hard but will get most cases. */ if (!restValue(pt, ad->defval, fp)) prDefaultValue(ad, FALSE, fp); } fprintf(fp, "\""); }