473,396 Members | 1,886 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,396 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 1688

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...

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.