RE: [C++-sig] RE: ÆC++-sigÅ How to export arrays from C(++) to python using boost

Kirsebom Nikolai nikolai.kirsebom at siemens.no
Wed Feb 11 16:44:09 CET 2004


Yes, you have understood the principle of my construction.  As you
understand, I did not need to have an array exported as a python array.
Instead I use the mentioned File<-->Blob methods and then in the python
context I use the python module array.  See the documentation of the python
array module.  In my context there is no need to expose the DLBlob class to
python, so only the 3 needed methods (that is not available in the Element
class) is exposed by the PyElement class, which again is the class exposed
to python (through BOOST).

Nikolai




> -----Original Message-----
> From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com]
> Sent: 11. februar 2004 14:54
> To: 'Development of Python/C++ integration'
> Subject: RE: [C++-sig] RE: ÆC++-sigÅ How to export arrays 
> from C(++) to
> python using boost
> 
> 
> I may need bit more clarification I guess. If I am not wrong 
> (correct me if I am), your class DLBlob contains an array 
> (unsigned char) but I couldn't see this class being exported 
> to python module. 
> 
> Instead in "BOOST_PYTHON_MODULE" you have exported only 
> "PyElement" class which exports the functions "Blob2File" 
> and "File2Blob". You have finally made it by writing the 
> array into a file and then reading it where it is required. 
> This spared you from actually exporting an array to python, 
> which is exactly what I want to do. Let me know if that's 
> not the correct interpretation of your logic and I have missed 
> out something here.
> 
> Nitin
> 
> 
> > -----Original Message-----
> > From: Kirsebom Nikolai [mailto:nikolai.kirsebom at siemens.no]
> > Sent: Wednesday, February 11, 2004 6:04 AM
> > To: Development of Python/C++ integration
> > Subject: RE: [C++-sig] RE: ÆC++-sigÅ How to export arrays 
> > from C(++) to
> > python using boost
> > 
> > 
> > 
> > 
> > > -----Original Message-----
> > > From: Shukla, Nitin (Export) [mailto:nitin.shukla at pw.utc.com]
> > > Sent: 10. februar 2004 18:44
> > > To: 'Development of Python/C++ integration'
> > > Subject: RE: [C++-sig] RE: ÆC++-sigÅ How to export arrays 
> > > from C(++) to
> > > python using boost
> > > 
> > > 
> > > Thanks Nikolai. Can you show me the declaration of your class 
> > > PyElement.
> > > That will give me better understanding of your code and help 
> > > me create my 
> > > own class.
> > > 
> > > Nitin
> > > 
> > > 
> > 
> > There is really not very much in PyElement:
> > 
> > PyElement.h:
> > #pragma once
> > 
> > class PyElement : public Element
> > {
> > public:
> > 	int File2Blob(CString fileName);
> > 	int Blob2File(CString fileName);
> > 	int BlobSize();
> > };
> > 
> > The class Element is a 'big' class - and I cannot share the 
> > complete content
> > of it.  However, some parts of the class definition is given below.
> > 
> > class AFX_EXT_CLASS Element : public CObject
> > {
> > 	...
> > 	DLBlob GetBlobValue(){return BlobValue;}
> > 	void SetBlobValue(DLBlob BlobValuep)
> > 		{if (BlobValue == BlobValuep) return; 
> > BlobValue=BlobValuep;
> > Modified= TRUE;}
> > 	...
> > }
> > 
> > The class DLBlob is in principle a class wrapping an array 
> > (unsigned char).
> > 
> > Hope info is of any use
> > Nikolai
> > 
> > _______________________________________________
> > C++-sig mailing list
> > C++-sig at python.org
> > http://mail.python.org/mailman/listinfo/c++-sig
> > 
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 




More information about the Cplusplus-sig mailing list