From f0663f4ef1f428769f4557dfd24f22cdd0281c0e Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 2 Dec 2018 09:13:21 -0500 Subject: project: pyexts.c helper program: added --py-init-func, --init-func-ptr. --- project/pyexts.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/project/pyexts.c b/project/pyexts.c index cec86e9..44af123 100644 --- a/project/pyexts.c +++ b/project/pyexts.c @@ -156,7 +156,7 @@ static void pyext_uppercase(char * buf, const char * name) *dst = 0; } -int main(void) +int main(int argc, char ** argv) { const struct pyext_meta * p; size_t nlen; @@ -171,6 +171,39 @@ int main(void) const char * name; char uname[64]; + if ((argc == 2) && !strcmp(argv[1],"--py-init-func")) { + for (p=pyexts; p->name; p++) + printf("PY_INIT_FUNC(init%s);\n",p->name); + + return 0; + } + + if ((argc == 2) && !strcmp(argv[1],"--init-func-ptr")) { + for (p=pyexts; p->name; p++) { + nlen = strlen(p->name); + + if (nlen <= 3) + dtab = "\t\t\t"; + + else if (nlen <= 11) + dtab = "\t\t"; + + else + dtab = "\t"; + + if (nlen <= 9) + rtab = "\t\t"; + + else + rtab = "\t"; + + printf("\t{\"%s\",%sinit%s},%s\\\n", + p->name,dtab,p->name,rtab); + } + + return 0; + } + for (p=pyexts; p->name; p++) { /* init */ name = (p->name[0] == '_') ? &p->name[1] : p->name; -- cgit v1.2.3