/* * 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 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 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 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); } }