How to extend Interrogate?

I plan to generate .NET/C# bindings for Panda3D using Interrogate. Based on what I have read so far, it already can do half of the work by generating C functions. The other part of this will be importing the functions into C# and creating wrapper classes – can anyone from the dev team point me in the right direction regarding what changes I need to make to interrogate so that it can generate the C# bindings? (I think I can handle the code generation, just don’t know how to get the class/function tables or where to plug in at)

Unfortunately, interrogate is a poorly-documented system (it’s not even documented well internally, unlike most of the rest of Panda). And this part of interrogate hasn’t been touched in a while, so there might be considerable cruft. So, you may have your work cut out for you here.

Still, I admire your enthusiasm, and I’m excited about the prospect of porting to C# and other .NET languages. I’d like to do whatever I can to help you succeed.

In the short answer, you can find all of the code for interrogate in the dtool tree. In particular, the C++ parser is dtool/src/cppparser, and interrogate itself is dtool/src/interrogate. There is also an “interrogate database” in dtool/src/interrogatedb; this is the database that reports the names of classes and methods and stuff that interrogate has discovered. It can be loaded and queried at runtime.

The command line for running interrogate during the normal Python build is fairly complex; you can see this being generated by makepanda. In particular, we pass -python-obj, which tells interrogate to generate Python objects for all of the C++ classes. This is a more-recently-added feature to interrogate that removes a layer of indirection and obviates the need for querying the interrogate database, since the Python objects are already fully constructed.

An older (no longer used) Python wrapper generation method was -python; this generated plain Python wrapper functions for all of the C++ methods, and relied on another layer of Python code (in direct/src/ffi) to query the interrogate database and use it reconstruct the Python objects as a set of methods that call the generated wrapper functions.

The still older wrapper generation method was -c, this was similar to the above -python output, except it generated C-API callable wrapper functions for all of the C++ methods. It was these wrappers that we used to call from Squeak, back in Panda’s early days.

None of these older generation methods have been removed from the codebase, but I would be stunned if they still work as advertised today, due to 10+ years of code rot. Still, development in interrogate is uncommon, so code rot may not be severe; even if these mechanisms don’t work now, they may not be that far off from working.


Thanks for the pointers, I will dig in and see what I can get working.

Just curious though – Have you guys considered re-writing the tool in python? =D
I always found parsing/code gen easier with python…

Ack… didn’t make it very far. Tried getting the build going after installing windows sdk/directx sdk, ran into some issues. I am on Windows 7 64 bit, and I tried this from both cygwin and the cmd shell, with different results…

cygwin prompt:

$ ./makepanda/makepanda.bat --everything --verbose
Generating library cache…
Generating dependencies…
WARNING: file dependencies changed: [‘built/models/maps/smiley.rgb’]
WARNING: file dependencies changed: [‘built/models/maps/smiley.rgb’]
[ 0%] Building resource object built/tmp/pandaIcon.res
rc /Fobuilt/tmp/pandaIcon.res /Ipanda/src/configfiles /Ithirdparty/win-python/include /Ibuilt/tmp /Ibuilt/include /DMAKEPANDA= panda/src/configfiles/pandaIcon.rc
/Fobuilt/tmp/pandaIcon.res: No such file or directory
Storing dependency cache.
Elapsed Time: 2 sec

Build terminated.

cmd prompt:

C:\Panda3d_build\panda3d-1.7.0>makepanda\makepanda.bat --everything --verbose
You seem to be missing the ‘thirdparty’ directory. You probably checked
the source code out from sourceforge. The sourceforge repository is
missing the ‘thirdparty’ directory. You will need to supplement the
code by downloading the ‘thirdparty’ directory from

Really not sure why the error from cmd prompt, the thirdparty directory is there, I got it from the panda tools zip. Not familiar enough yet with the build to understand the error from cygwin prompt. Any idea what I might be doing wrong here?

You’re supposed to invoke it from the Visual Studio 2008 Command Prompt. Apparently you have a copy of rc.exe installed somewhere that is different from the one in Visual Studio.

I’ve heard of pyBindGen which seems to be a well-featured binding generator written in Python.

Invoked from VS 2008 prompt, same behavior :frowning:
I think the other rc is probably from cygwin.

$ which rc

Any idea why it doesn’t see thirdparty directory from the windows prompt…?

Can you try temporarily removing the other copy of rc from the PATH?

I tried removing rc.exe from my PATH variable (renamed the exe) in cygwin shell. The result is that rc.exe cannot be found anywhere else. This is the same when I try just running “rc.exe” from the vs 2008 command prompt. Have any idea where the other rc.exe is?

result of “which rc”:
$ which rc
which: no rc in (/usr/local/bin:/usr/bin:/bin:“C:/Program Files (x86)/Microsoft
DirectX SDK (August 2006)/Utilities/Bin/x86”:/cygdrive/c/Program Files (x86)/PC
Connectivity Solution/:/cygdrive/c/windows/SYSTEM32:/cygdrive/c/windows:/cygdriv
rogram Files (x86)/Java/jdk1.6.0_18/BIN:/cygdrive/c/PANDA3D-1.6.2/PYTHON:/cygdri



Result of just the VS 2008 prompt without cygwin:

Setting environment for using Microsoft Visual Studio 2008 x86 tools.
\Microsoft was unexpected at this time.
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>which rc
which: no rc in (“C:/Program Files (x86)/Microsoft DirectX SDK (August 2006)/Uti
lities/Bin/x86”:/cygdrive/c/Program Files (x86)/PC Connectivity Solution/:/cygdr
gdrive/c/windows/SYSTEM32/WINDOWSPOWERSHELL/V1.0/:/cygdrive/c/PROGRAM FILES (X86
)/MICROSOFT SQL SERVER/90/TOOLS/BINN/:/cygdrive/c/Program Files (x86)/Java/jdk1.
ive/c/CYGWIN:/cygdrive/c/PROGRAM FILES (X86)/NOTEPAD++:/cygdrive/c/SCRIPTS:/cygd
rive/c/PROGRAM FILES (X86)/GEDIT/BIN:/cygdrive/c/windows/system32/wbem:/cygdrive
/c/Program Files (x86)/IVT Corporation/BlueSoleil/Mobile:/cygdrive/c/cmvc_cmds:/

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>

I think the cygwin paths are there because of the “which” command

Where should the rc executable be? I suspect that I don’t have something installed correctly…