interrogate interrogate_module and python dependencies

I’m working on understanding how interrogate commands work and how to use resulting generated code.
My objective is to decouple panda from base C++ libraries but using these in a panda3D application hence I do not use reference counting feature.

Q1/
I’m wondering if interrogate_module uses a specific search path to find the in file because the only success I had was when the interrogate_module was run in the directory where where the in file lies.

Q2/ what are the intended use for -I and -S for interrogate command ?

Q3/ I tried to develop a tiny project just to understand the wrapping/binding stuff. I could produce a pyd library but I am not able to run a simple python test script using this newly created module (CppTest).

In Release configuration the class defined in the C++ code in not recognized at run time in the python code.
In Debug configuration a dll is not found and ImportError exception is raised. I get “DLL load failed” error message (phyton26_d.lib seems to mess it up). Python interpreter version 2.6 is used by the way.

NameError exception is raised

Here are the couple command lines I used for this purpose (Windows/VC 2010)

interrogate -module (TargetName) -library (TargetName) -vvv -assert -string -fnames -python-native -srcdir (Projectdir).. -Dvolatile -Dmutable -oc ..\..\py(ProjectName)%(FileName)igate.cxx -od …\py$(ProjectName)%(FileName).in %(FileName).h -DUSE_INTERROGATE -D__cplusplus -D__STDC_=1 -D__inline -longlong _int64 -D_X86 -DWIN32_VC -D_WIN32

the igate and in files are generated into a directory named …/…/pycpptest while original C++ file lies in cpptest

The following command is run in …/…/pycpptest:

interrogate_module -module pycpptest -library pycpptest -oc CppTest_module.cxx -python-native CppTest.in

which generates the module file.

At the end my minimal python test is just like this

import os
import sys
print sys.path

import panda3d.core 
from pycpptest import *

cppt=CppTest(3)
code=cppt.Code()
print (code,"the py code is ")

The C++ code is as following
for the header file, the include file published.h defines PUBLISHED, BEGIN_PUBLISH and END_PUBLISH according to USE_INTERROGATE macro - instead of CPPPARSER used in panda(if defined they will contain respectivelly __published, __begin_publish and __end_publish allowing interrogate to do its job).

#pragma once 

#include "published.h"


class CppTest 
{
public:
BEGIN_PUBLISH
	CppTest(int code=0);
	int Code(void)const;
END_PUBLISH
	virtual ~CppTest();
private:
	int mCode;
};

The source code

#include "CppTest.h"

#include <iostream>
using namespace std;
CppTest::CppTest(int code):mCode(code)
{}
CppTest::~CppTest(){}
int CppTest::Code(void)const{cout<<"my code is"<<mCode<<endl;return(mCode);}

You can pass .in files to the interrogate_module command-line. If you pass “foobar.in” to the command it will search in the current directory of course, you have to specify the relative or absolute path to the file otherwise.

The -I option is for include files, -S is for system includes (parser-inc directory, usually).

I’m not sure why your class isn’t defined in the Python scope. Could be a number of things. For one, you should use “PUBLISHED:” for class members instead of BEGIN_PUBLISH and END_PUBLISH.
It would help to give the output of interrogate with the -v option, and possibly the generated _igate.cxx and _module.cxx files.
You can take a look in panda/src/skel in the Panda3D source code, this was intended to be an example for interrogate and other things.

Your sample should look like:

#pragma once 

#include "published.h"

class CppTest 
{ 
PUBLISHED: 
   CppTest(int code=0); 
   int Code(void)const; 
public: 
   virtual ~CppTest(); 
private: 
   int mCode; 
}; 

You shouldn’t try to compile in debug mode unless you’ve got a debug build of Python and Panda.