ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] Re: Problem Wrapping DirectX with Boost Python
by David Abrahams other posts by this author
Nov 12 2002 7:05PM messages near this date
Re: [C++-sig] wrapping complex attributes | [C++-sig] Re: call_method
Mark Russell <mrussell8081@[...].net>  writes:

>  Hi Dave,

Hi Mark. Please post Boost.Python questions to the C++-sig:

    http://www.python.org/sigs/c++-sig

>  I am using Boost Python to wrap DirectX and have run into a problem
>  I can't seem to get around.  Def seems to have trouble with
>  __stdcall this works ok for me when I call bind directly so I'm not
>  sure where to go from here.  I have attached a short test example
>  cloned from the bind tests to show you where the problem is.  I am
>  using msvc 6.5 and have tried both boost 1.29 and the latest from
>  CVS.  Thanks in advance -- great library!  I am very excited to be
>  working with it.

Thanks, I'm excited that so many people are using it!
> 
>  Test Code:
> 
>  #define BOOST_BIND_ENABLE_STDCALL
>  #define BOOST_MEM_FN_ENABLE_STDCALL
> 
>  #include <boost/python.hpp>
>  using namespace boost::python;
> 
>  long __stdcall f_0()
>  {
>      return 17041L;
>  }
> 
> 
>  BOOST_PYTHON_MODULE_INIT(test_std_call)
>  {
>      def("f_0", f_0);
> 
>  }
> 
>  Error Message:
> 
>  Compiling...
>  stdcall.cpp
>  c:\boost\boost\python\detail\arg_tuple_size.hpp(61) : error C2664: 'struct
>  boost::python::detail::char_array<0> __cdecl
>  boost::python::detail::arg_tuple_size_helper(long (__cdecl *)(void))' :
>  cannot convert parameter 1 from 'long (__stdcall *)(void)
>  ' to 'long (__cdecl *)(void)'
>          This conversion requires a reinterpret_cast, a C-style cast or
>  function-style cast

Right. The problem is that there are lots of Boost.Python components
which don't account for the presence of "extralegal" constructs like
__stdcall and __fastcall. In order to handle these automatically we'd
need, at the very least, to extend
boost/python/detail/arg_tuple_size.hpp to handle these cases, and I'm
guessing that there are a quite a few other places like that in the
code as well (e.g. boost/python/detail/returning.hpp). Here are your
choices:

1. Implement the extensions yourself and submit a patch. We'd really
   love that!

2. Write "thin wrapper" functions around all the functions you want to
   wrap, and wrap the wrappers:

   long f_0_aux() { return f_0(); }
   ...
      def("f_0", f_0_aux);

3. Wait for us to get around to extending Boost.Python to deal with
   __stdcall. Joel may be working on an ActiveX project soon himself,
   so it's not an impossibility that it will happen. However, this is
   still somewhat of a long shot.

-- 
                       David Abrahams
   dave@[...].com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution


_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved