Q: accessing method name from within a c-function

Jan Boelsche jan at muskelfisch.com
Wed Jan 16 14:23:44 EST 2002


I have kind of an excotic problem, I hope you can help with.

I'm trying to create a unified interface for embeding script
interpreters into C++ applications. The idea is to have a unified
Fascade (like in Design Patterns by the GOF) for a number of script
interpreters including Python, ECMAScript etc.
It's kind of what MS does with OLEScript I think... but my approach
would be portable and well, ... non-MS :)

C++ Application should be able to register native method through this
interface.
These native method then would be available to python scripts being
run by the interpreter.
The Python-implementation of this interface would have to convert
arguments and the return value from Python to a generic C++ class
(called Variant) and vice versa.

Until now, there's no problem - the embedding/extending docs on
www.python.org cover all of this.

The problem arises here: 
Because the native methods (the c/c++ functions) are registered at
run-time, there would only be a single generic c-function that is
directly called by the Python interpreter.

This C-function would have to
1) convert the arguments to instances of C++ class Variant
2) call the appropriate C++ function/method that was originally
registered by the client through the Fascade
3) do the return value conversion and return the value to Python

And here finally comes the question :)
How is it possible for the one-and-only c-function that is called by
the interpreter to properly dispatch the call to the function that was
originally registered by the client?
Is there a way to get the name of the method that currently is being
called, from within a c-function? (in other words: the name under
which it was registered with the Python interpreter)

I hope I at least succeeded half-way in trying to point out my problem
:)

Any Ideas, Comments?

jan



More information about the Python-list mailing list