A difficult question to put a title to so I'll paint a brief scenario...
The application is written in c++
It receives a data message and instantiates a message decoder class.
Based on the contends that are extracted into the class variables, a
response is built by instantiating an encoder class and setting its
class variables with setter methods. At this point I want to pass
control over to a Python script so that it can modify the encoder class
variables (via the accessors) if required before the response is
actually sent. These accessors would form an extension to the
interpreter. Note that doing more work in the Python script is not an
option - too much data in too short a time!!
I've got as far as embedding the interpreter and calling the correct
method in a script but I've hit a problem in extending the interpreter
to access the decoder and encoder classes in my main app.
Note that I want to access the specific instances of the classes to
manipulate the class variables that were set before entering the Python
domain. Now the questions...
* My understanding is that extending Python *always* uses a dynamically
loaded library (i.e. a run time linkage) as part of the import mechanism
- is there something in the C/API that will override this? If I load an
extra library, even one built from the same source as my classes in the
main app, I won't be accessing the same instance of them.
* Since the class has already be instantiated in the main app, how do I
pass the instance pointer to Python so that it can pass it back when it
makes the extension call to my class methods (assuming I can get past
the previous point!!). I would assume that it involves a PyCObject but
none of the code examples I have found give much clue as to how the
extension is invoked from the Python side with the instance pointer
apart from when using a new_class constructor call.
I'm sure I'm close, I just can't get past the two points above...
Cheers
--
Robin
=======================================================================
This email, including any attachments, is only for the intended
addressee. It is subject to copyright, is confidential and may be
the subject of legal or other privilege, none of which is waived or
lost by reason of this transmission.
If the receiver is not the intended addressee, please accept our
apologies, notify us by return, delete all copies and perform no
other act on the email.
Unfortunately, we cannot warrant that the email has not been
altered or corrupted during transmission.
=======================================================================
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig