2006-10-03

Ideas for a extension module boilerplate generator

So for the umpteenth time I have written a type from scratch in C and made some stupid, basic mistakes. And as always I end up going back to the Extending and Embedding Python tutorial to figure out what the hell I forgot. Well, this is an itch I definitely want to scratch.

As of right now there exists bgen in the Tools directory. Now the problem I have with bgen is no one is maintaining it and it does not work the way I want it to. For instance, the init module that is created has a return value of 'void' instead of the macro that is used today. There also is no explicit tests.

In terms of implementaiton, I want to use string templates and build off of those rather than output individual lines. I like big picture code generation rather than line-by-line building.

Working off of xxmodule.c and xxsubtype.c don't work since I don't want all of the tutorial stuff in there. It acts as now for me since I know about setting attributes and such already.

So I want to start from scratch. I want a command-line tool that can generate a basic skeleton that compiles for a module and a type. It should be able to spit out either a module or type individually with the proper "XXX" warnings about what needs to be done for common things like putting PyType_Ready() in your modules init function if you are only doing a type or what typically goes in a header file (if you supress header generation). It should even go as far as create a basic Distutils file.

Bottom line is I should never have to write up the boilerplate for a very basic type or module again nor make the same stupid mistakes I tend to make because I forget some little step because I don't have a checklist in front of me.

Now let's see if I ever get around to actually writing such a script. =)