473,799 Members | 3,310 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Modify a C++ instance from the embed python interpreter

Hi, is there a tool that automatically expose an object to python? i
have an instance of a C++ (or ObjC) object and i want to pass it to the
embed interpreter that runs inside my program.
Python code have to call c++ method and register some callback.

I know that swig helps when python creates c++ instance but i've the
instance and i want to use it with python.

Thanks

--
Ciao
Fabio
Aug 27 '05 #1
2 1866
Wezzy wrote:
Hi, is there a tool that automatically expose an object to python? i
have an instance of a C++ (or ObjC) object and i want to pass it to the
embed interpreter that runs inside my program.
Python code have to call c++ method and register some callback.

I know that swig helps when python creates c++ instance but i've the
instance and i want to use it with python.


That is the same case, wrt SWIG - the objects methods get accessed by
functions like

int Object_foo(Obje ct *s) {
return s->foo();
}
So passing a exiting object reference to such a function will work. You
might also consider using SIP, it appears to me to be much more OO.

Diez
Aug 27 '05 #2
Diez B. Roggisch <de***@nospam.w eb.de> wrote:
Wezzy wrote:
Hi, is there a tool that automatically expose an object to python? i
have an instance of a C++ (or ObjC) object and i want to pass it to the
embed interpreter that runs inside my program.
Python code have to call c++ method and register some callback.

I know that swig helps when python creates c++ instance but i've the
instance and i want to use it with python.
That is the same case, wrt SWIG - the objects methods get accessed by
functions like

int Object_foo(Obje ct *s) {
return s->foo();
}


Can you post few line of code ?
So passing a exiting object reference to such a function will work. You
might also consider using SIP, it appears to me to be much more OO.

Diez


well i'll look to SIP but i prefer to use swig because it can interface
C++ with other language such as ruby

--
Ciao
Fabio
Aug 28 '05 #3

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

Similar topics

2
2888
by: disgracelands | last post by:
I've been looking at using python and it's been going fairly well so far, i can call C from python and python from C fine but now i've hit a snag and i'm wondering how you guys have got around it. I have to initialise python inside my C project so that i can make calls to python modules whenever i need to but i can't create a dll for the project as it's got to produce an exe or at least a lib so that i can execute the initialisation...
11
1763
by: Robert Ferber | last post by:
Hi, I'm a PHP-programmer who evaluates Python for a new project. I really like a lot of concepts of Python, especially the shell, but there is one great feature of PHP which I don't know how to replace in Python: For database-intensive webpages, I like to cache the HTML-output on the fly in the filesystem and put out the file later whenever the same URL is requested again, for example:
1
1600
by: Vio | last post by:
My story: I played with a little embedded python piece of code (python interpreter embedded in wxWidgets app), and used SWIG to extend this embedded py interpreter. I did it in Linux, after some ironing all builds and runs as expected. On a particularily lazy day, I pasted these same wrapper sources to Win32 (cygnus). After fiddling with the Makefile to point in the right directions, compilation seems to go ok (give or take a couple of...
0
1125
by: Tommy Ryding | last post by:
Hi, Background: Im currently working on my own Python port for VxWorks this is part of my master thesis. What I want to do is to only to embed the interpreter and not the compiler. Both to save memory on the target device and to be get some security in the device. It is a mission critical device im applying it to.
2
1813
by: Lloyd | last post by:
Hi After researching on Extending and Embedding it appears Extending is favoured greatly over Embedding. I've tested Boost::Python successfully in a test project but have run into an issue. I have about 10 shared libraries that up until now have only been statically linked into an application and used from C++. I'd like to expose a lot of this functionality as different Python modules ( core, network, input, etc ), however the...
8
3042
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to what I really should do. I've had a look through Programming Python and the Python Cookbook, which have given me ideas, but nothing has gelled yet, so I thought I'd put the question to the community. But first, let me be a little more detailed...
13
2942
by: python | last post by:
hello and thanks for reading this, i have been a dos/windows user using some form of the basic language for 30 years now. i own and run a small programming company and there is one feature that keeps me in the windows/basic world. while i will agree that it has not evolved well, it does have one awesome feature that i have yet to see replicated in any linux product that i know about so far. i am a long time windows user and have had...
5
3211
by: Sandra-24 | last post by:
Is there a way in python to add the items of a dictionary to the local function scope? i.e. var_foo = dict. I don't know how many items are in this dictionary, or what they are until runtime. exec statements are difficult for debuggers to deal with, so as a workaround I built my code into a function and saved it in a .py file. The I load the .py file as a module and call the function instead. This works great, and it has the added...
1
2090
by: Petr Prikryl | last post by:
Do you think that the following could became PEP (pre PEP). Please, read it, comment it, reformulate it,... Abstract Introduction of the mechanism for language extensions via modules written using other languages. Extensions of Python could be done via special interpreter extensions. From Python sources, the special modules would look like other modules, with the Python API (the key feature from
0
9687
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, 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...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
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 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...
0
10027
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 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...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
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...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.