Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91015

Strategies for using cffi with C++ code?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'means,': 0.07; 'subject:code': 0.07; 'wrapped': 0.07; 'libraries.': 0.09; 'subject:using': 0.09; 'url:github': 0.09; 'python': 0.11; 'example:': 0.11; '"extern': 0.16; 'exposes': 0.16; 'received :mail-oi0-x22a.google.com': 0.16; 'pointer': 0.18; 'skip': 0.18; 'python?': 0.18; 'thanks,': 0.19; 'example': 0.25; 'message- id:@mail.gmail.com': 0.28; 'correct,': 0.29; 'methods.': 0.29; 'function': 0.30; "can't": 0.32; 'class': 0.33; 'subject:?': 0.34; 'received:google.com': 0.34; 'to:addr:python-list': 0.35; 'c++': 0.35; 'but': 0.36; 'someone': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'subject:with': 0.40; 'simple': 0.61; 'provide': 0.61; 'more': 0.62; 'to:name:python': 0.84; 'exposing': 0.91; 'subject:Strategies': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=/shQT7tcm7flre5lIt/OyZsnG//Ud4JCOYtDbEDGNQo=; b=cxxbM08ULimXmK4Y8Lyvd7f/4LwEn9KBZAPc/wcOt9ZUuOaCALe7bWNJMehMA3JfWc Y1hfnIr5j7EcWcKhFDqt8W20pf6ny66sbw8NLwETtJWkAcbooMU+zWvA9/V40VYMf1Vu Hn6Oyv5YwbDkZgIWs9agGtAKcsEoCrg40Nc9ZmSQZXcwNglDxFqQlJoDvFTxKBwSZSts 4Xy8T8r2SuQEGdhnChGh3lf2MzvDmHn5qY1zDrDyWJSq4wD4Wvfhu3ICRBvF1JoUtFAB EM7MKjm54iNyCpS1+nK8VTgTS9qvcoytLyyvRfu0TfOg7x4Lwn+RL8rowmtdkTg30Hq8 lZtw==
MIME-Version 1.0
X-Received by 10.60.74.34 with SMTP id q2mr3086765oev.68.1432226490772; Thu, 21 May 2015 09:41:30 -0700 (PDT)
Date Thu, 21 May 2015 11:41:30 -0500
Subject Strategies for using cffi with C++ code?
From Skip Montanaro <skip.montanaro@gmail.com>
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=001a1135fc5a38734605169a374f
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.203.1432226500.17265.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1432226500 news.xs4all.nl 2913 [2001:888:2000:d::a6]:48109
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:91015

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

If my reading so far is correct, you can't directly apply cffi to C++
libraries. Everything has to be wrapped in "extern C" declarations, which
means, practically speaking, that you have to provide factory function
wrapper(s) around constructors and methods. I did find a trivial example:

https://gist.github.com/tonyseek/7821993

but that just exposes a simple function to the Python programmer. Does
someone have a pointer to more substantive example of exposing a C++ class
to Python?

Thanks,

Skip

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Strategies for using cffi with C++ code? Skip Montanaro <skip.montanaro@gmail.com> - 2015-05-21 11:41 -0500

csiph-web