views:

96

answers:

1

Hi,

I have a bunch of classes and APIs written in C++ and exposed to Python with help of Boost.Python

I am currently investigating the possibilities of creating the following architecture.
In python:

from boostPythonModule import *
AddFunction( boostPythonObject.Method1, args )
AddFunction( boostPythonObject.Method2, args )
AddFunction( boostPythonObject.Method2, args )
RunAll( ) # running is done by C++

In C++:

void AddFunction( boost::object method,  boost::object args )
{
    /// 1. Here i need to extract a real pointer to a function
    /// 2. Make argument and type checking for a function under method
    /// 3. Unpack all arguments to native types
    /// 4. Store the pointer to a function somewhere in local storage
}

void RunAll( )
{
    /// 1. run all previously stored functions and arguments for them
}

Basically I am trying to put all functions down to the native part of my program. The thing is that I am not sure if it's possible to extract all required data from Boost metainfo to do this in generic way - at compile time I should not know what functions I'm gonna call and what arguments they accept.

Few questions:
1. Is there any shared Python info tables I can access to check for some of this stuff ?
2. Boost.Python does type arguments checking. Can it be reused separately ?

Let me know your thoughts.

Thanks

A: 

I am trying to create a general approach for a user to operate with some methods... not to optimize.

Here is a similar thing I am looking for - URL
Basically I think AddCommand should accept boost::function, but I also need to be able to check for arguments and see if it maps.

Alex