Tasks, tools and tribulations
Inspired by Entity Crisis, I'm finally taking the plunge and converting my task scheduler to use generator-powered cooperative multitasking instead of normal functions. It should make both the task scheduler implementation and future task writing much more elegant. I'm also thinking of extending it later with threadable, networked and Stackless-based tasks. More on this as I get it done.
Good-ish news on the parser front: Dave Kuhlman released a new version of generateDS, which now succesfully parses the Collada schema, but the generated parser still fails to parse more complex Collada files, specifically transformation elements such as translate. I hope it's "just" a bug and not a missing feature. If it is, I just might contribute the missing features myself if needed and it's not too complex. In any case, this is promising.
I also started writing the C header parser using Pyparsing. It's easy enough to work with, though I wish its documentation was more decent and its interface cleaner and more Pythonic. Anyway, from the humble start it looks like it won't be too difficult a project for the small subset of C grammar I need it to understand. I already got it to recognize some preprocessor directives, now I just need it to do something with them, and then it's on to actual C grammar.
And I'm still waiting for Trac 0.11 to be released, and hoping it will be easier to install than 0.10, which I never could get to work on shared webhosting.
Parsing, oh my…
Recently I have been thinking about parsing. There are two areas of Spineless (yes, I'm continuing to develop the engine, but only for my game project, not for the public for now) that need some kind of parsing to implement cleanly: C library support and COLLADA loading.
To use C libraries from Python, I'm going to parse their headers to generate a ctypes interface which can then be used from Python without any compiling required. There are existing solutions, such as the ctypes code generator, but nothing that could be called a released product. So I'm going to see how difficult it would be to do myself. Parsing is a huge topic however, as demonstarted, for example, by this old newsgroup topic: http://www.thescripts.com/forum/thread41389.html. The two tools I'm initially considering are Pyparsing, which might be too simple (ie. tedious to do complex stuff with) for my purposes, and PLY, which might be far too complex (ie. hard to learn) for this relatively simple task. Experience on either of the tools or other suggestions are really welcome, I'll be sure to post mine when I have learned more!
COLLADA, as you may know, is an XML-based 3D asset file format. Unfortunately the official API, COLLADA DOM, is a C++ library, and using C++ libraries from Python is a can of worms I'm not willing to open if I can avoid it. Until now, I have been writing code to read COLLADA files by hand, but it's really quickly getting really messy. Instead I'm going to generate a Python interface / COLLADA parser based on the XML Schema describing the file format. There's an excellent-looking tool for it too, called generateDS, but unfortunately it fails when trying to read the COLLADA XML Schema, hanging forever. I sent an e-mail to the author, and I hope he can fix the problem. Failing that, it seems I'm on my own, as there don't seem to be any Python libraries to help with parsing XML Schema. All I can find are tools for validating documents based on a schema, but that's not what I'm trying to do... Again, suggestions are welcome!
