473,388 Members | 1,322 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

SWIG -- Passing python proxy class instance to python callback

I'm trying to pass a proxy class instance (SWIG generated) of CClass,
to a python callback function from C++. The proxy class instance of
CClass is created from a pointer to the C++ class CClass.

Using the code below, I receive the error message:

"AttributeError: 'PySwigObject' object has no attribute 'GetName'"
The python callback function is being passed in through the clientdata
pointer, and the CClass *class pointer is what's being converted to an
instance of the SWIG proxy class and passed to the python callback
function as an argument.

static void PythonCallBack(CClass *class,void *clientdata)
{
PyObject *func, *arglist,*obj;
PyObject *result;

func = (PyObject *) clientdata; // Get Python function
obj = SWIG_NewPointerObj((void*) cmd, SWIGTYPE_p_CSCSICommand, 1);
//create instance of python proxy class from c++ pointer

arglist=Py_BuildValue("(O)",*obj); //convert to tuple
result = PyEval_CallObject(func,arglist); // Call Python

Py_XDECREF(result);
return;
}

Any input would greatly appreciated. Thanks,
Jeff

Jul 19 '05 #1
0 1686

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Collier | last post by:
hello, i am not sure whether this problem relates to swig, python or my c++ compiler. +please forgive me if this is inappropriately posted but i am sure that someone +on this list must have some...
1
by: Markus von Ehr | last post by:
Hi, I tried to build the swig: callback example, but when I run the runme.py file I get a message box: abnormal program termination The error appears in already in the first line of the...
3
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>...
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
1
by: m2i3k | last post by:
Hi I have C code with requires me to register a python callback. I am able to get the callback working well using ctypes if I use global functions without any context argument for the callback. ...
0
by: Keith Sabine | last post by:
Hi Did you ever find a solution to this? I am having the exact same problem... - Keith I'm trying to pass a proxy class instance (SWIG generated) of CClass, to a python callback function...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.