interrogate2swig.py

Current status:

  • swig will run without errors now
  • occurred to me that I dont need to manually process macros in the script, since Swig is perfectly capable of handling them itself in fact, as long as we tell Swig about the macro definitions
  • issues with compiling resulting file, see below
  • possible namespace issues, see below

Template-style defines

Panda uses defines instead of templates, which probably makes this a lot easier than it otherwise would be. Nevertheless we do have to do something with these defines.

  • FLOATNAME and FLOATTYPE are being defined to name##f and float respectively.
  • CDP is being hardcoded to name##Swig, since presumably these classes are so low-level that they dont actually matter.

Info on swig pass

Swig will take the generated .i file, and process it in about 30 seconds.

The output is:

  • panda.py (1.5MB)
  • panda_wrap.cxx (9.5MB)

Currently it ignores anything with any hint of being a template, since we’re not telling it about templates (it expects a %template line for each template instantiation, which is doable, but we didnt do this yet).

Compilation issues

Since we just took all .h files in panda/src, it looks like we’re probably taking more than we really should do. For example char_headers.h and a few other _headers files dont seem to want to build on their own.

Also, a lot of these .h files want files from the thirdparty directory, which I’d rather exclude for now, for a few reasons. At least, make it optional.

Script has been modified to:

  • only take files from a specific set of directories (audio, chan, char, collide, device, dgraph etc), missing out the hardware specific ones, such as mesagl, wgl etc
  • ignore any files starting in test_ or ending in _headers.h

… but errors persist.

Current strategy is to think about whether we can plug the script into makepanda.py somehow, so that makepanda.py is going to describe what headers we process.

Presumably, makepanda.py can tell us:

  • the module name
  • the header files associated with this module name
  • composite file names (not sure why/if we need these?)

Worst case, makepanda.py can simply call something like registerfilesforswigprocessing.py, and later we take the output from that, and process it in one go, in batch-type style.

Namespace issues

Swig doesnt do anything with namespaces: it just ignores them.

Looking at the manual for Panda, it looks like interrogate is providing some namespace information?

For example, we have:

import direct.directbase.DirectStart

So, direct is the module name, and I’m guessing that directbase is a namespace? And DirectStart is probably a class?

This would essentially break backwards-compatibility with old scripts?

However, the impact could perhaps we limited to just the import commands at the head of each script?

Hugh

Current script is at