[C++-SIG] (Still) confused about wrapping C++ types with CXX
Barry Scott
barry at scottb.demon.co.uk
Sun Jun 4 14:49:49 CEST 2000
Steve,
Maybe this is the time to try and put a FAQ together.
Some of what you are asking seems to come down the following
questions:
Q1: How does Python get its first object from the C++ application?
A1: Starting point objects will be returned from attributes of a
module. The attributes can be variables or functions.
Q2: Object X exposes a list/map of object Y
A2A: Make a copy of the C++ list/map as a Python list/map. Each
value in the list/map will be a wrapper around a C++ object Y.
A2B: Add methods to the wrapping of object X that allow typical
operations on the list/map.
A2C: Add a wrapper object that forwards the Python list/map operations
into the list/map exposed by object X.
Which of A2A, A2B or A3C that applies depends on the nature of the
list/map that is exposed.
Q3: Can I have many wrappers around a single C++ object instance?
A3a: No if you expect the Python code to be able to compare object
identities. Arrange that the same wrapper is return for each unique
C++ object whose identity is critical for the applications operation.
A3b: Yes if object identity is not important.
Q4: How should function sequence_XXX/map_XXX be implemented?
A4: The implementation depends on the semantics of the C++ objects
API that is being exposed as a sequence or map. There isn't a
generic answer.
BArry
More information about the Cplusplus-sig
mailing list