diff options
author | midipix <writeonce@midipix.org> | 2018-12-02 09:13:21 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2018-12-02 19:48:56 -0500 |
commit | f0663f4ef1f428769f4557dfd24f22cdd0281c0e (patch) | |
tree | 3888428e4e4bbcf96898f089f444dd583743437a /project | |
parent | c3000ac0d42ecb2ae3a6335164daa067879ce468 (diff) | |
download | sbpython2-f0663f4ef1f428769f4557dfd24f22cdd0281c0e.tar.bz2 sbpython2-f0663f4ef1f428769f4557dfd24f22cdd0281c0e.tar.xz |
project: pyexts.c helper program: added --py-init-func, --init-func-ptr.
Diffstat (limited to 'project')
-rw-r--r-- | project/pyexts.c | 35 |
1 files changed, 34 insertions, 1 deletions
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; |