Hi, I asked this on the SWIG mailing list, but it's pretty dead over there....
I'm trying to get Python to pass a subclass of a C++ object to another
C++ object...
I have three C++ classes,
TiledImageSourc e
ZoomifyReaderWx which ISA TiledImageSourc e
TiffWriter which has a method which takes a TiledImageSourc e
reader = bright.ZoomifyR eaderWx()
writer = bright.TiledTif fWriter()
writer.SetImage Source(reader) <- doesn't work, error below.
TiffWriter has a SetImageSource method that takes a pointer to a
TiledImageSourc e.
When I try to pass an instance of ZoomifyReaderWx to TiffWriter, SWIG
can't hook the two up.
How can I fix this? I think I need a typemap, but I'm not sure of the syntax.
Thanks!
-Jim
Test script
----------------------------
reader = bright.ZoomifyR eaderWx()
reader.Open("C:/Slides/test.pff")
writer = bright.TiledTif fWriter()
writer.SetImage Source(reader)
writer.CreateFi le("C:/Slides/test.tif")
while not writer.IsFinish ed():
writer.ProcessA Bit()
print ".",
Exception
----------------------------
C:\jimc\prj\bri ght\scripts\vsE dit>python piplineTest.py
Traceback (most recent call last):
File "piplineTest.py ", line 11, in ?
writer.SetImage Source(reader)
File "C:\jimc\prj\br ight\scripts\vs Edit\bright.py" , line 88, in SetImageSource
def SetImageSource( *args): return _bright.TiledTi ffWriter_SetIma geSource(*ar
gs)
TypeError: argument number 2: a 'TiledImageSour ce *' is expected, 'PySwigObject(
_p_ZoomifyReade rWx)' is received
Interface files (exceprts)
----------------------------
class ZoomifyReaderWx : public TiledImageSourc e
{
public:
bool Open(wxString filename);
void Close();
ZoomifyReaderWx ();
//%pragma(python) addtomethod = "__init__:self. _setOORInfo(sel f)"
// necessary for ZoomableImageRe ader
virtual int GetWidth(int reduction = 0);
virtual int GetHeight(int reduction = 0);
....
class TiledTiffWriter
{
public:
TiledTiffWriter ();
//%pragma(python) addtomethod = "__init__:self. _setOORInfo(sel f)"
void SetImageSource( TiledImageSourc e *source);
void SetJpegQuality( int quality) { m_iJpegQuality = quality; }
void CreateFile(char *filename);
....
class TiledImageSourc e
{
public:
//%pragma(python) addtomethod = "__init__:self. _setOORInfo(sel f)"
virtual int GetWidth(int reduction = 0);
virtual int GetHeight(int reduction = 0); 0 1241 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Philip Smith |
last post by:
Does anyone use SWIG?????
I'm having trouble patching it to allow me to compile wrappers in Borland
C++ Builder because Borland will insist on adding underscores to symbols.
Turn this off and it won't link the Python library.
The answer is to declare init_function and any other exported functions as
__stdcall. Easy enough to patch the SWIG file for the init_function but I
can't for the life of me see how to automate this process for...
|
by: Lars Moastuen |
last post by:
Im trying to extend a class written in C++ in Python and use this
extended class in a C++ call... I made an example to clarify:
-- Foo.h --
#ifndef FOO_H
#define FOO_H
#include <iostream>
using namespace std;
|
by: It's me |
last post by:
I am playing around with SWING building a Python module using the no brainer
example in http://www.swig.org/tutorial.html. With that first example,
/* File : example.c */
#include <time.h>
double My_variable = 3.0;
int fact(int n) {
|
by: Krish |
last post by:
Hello People
I hope I am On Topic. Anyways, here is my problem. Any insights would
be really appreciated.
I have wrapped a C IO module using SWIG -> Python Module. Suppose the
name of the module is "imageio" and the reader function from the file
is image_read() which returns an object ( "filled" C structure) with a
lot of members.
|
by: fdu.xiaojf |
last post by:
Hi all,
I am going to generate a python wrapper of a C library, and I am
wondering which one is a better tool for me, SIP or SWIG ?
SWIG supports many scripting languages such as python, ruby, and perl,
while SIP is specific to python, so I think maybe SIP is more suitable
to generate better wrappers(sorry for my ignorance if I am wrong at this
point) with python.
| |
by: Bart Ogryczak |
last post by:
Hi,
I´m looking for some benchmarks comparing SWIG generated modules with
modules made directly with C/Python API. Just how much overhead does
SWIG give? Doing profile of my code I see, that it spends quiet some
time in functions like _swig_setattr_nondinamic, _swig_setattr,
_swig_getattr.
|
by: cody314 |
last post by:
Versions:
Python 2.5.1 (r251:54863, May 14 2007, 10:50:04)
SWIG Version 1.3.20
Hello I have some code that wraps a C++ library so I may use it in
python. The code basically just gets some data and puts it in the
PyArrayObject* which is returned as a PyObject*.
I then call it from python like so:
self.c = __f2.fdct2_wrapper(x,self.nbs,self.nba,self.ac)
|
by: Paul Anton Letnes |
last post by:
Hello guys,
(related to previous thread on wrapping C/C++ in Python, trying the
SWIG approach.)
Trying to map a C++ class to python, one method for now. Running the
following commands to "compile":
--------------------------------------
#!/usr/bin/env bash
|
by: Uberman |
last post by:
I have a bit of a odd arrangement here with SWIG, Python, Embedded Python and
C++ classes exported into Python. Here's the plot:
I have a class defined in a C++ DLL library. I am wrapping this class (we'll
call it "Peter") with SWIG so some of its base functionality is available in
Python. For the sake of this example, Peter has a method called get_type(),
that takes no arguments and returns an integer. This all works, and within my...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |