Boost C++ Libraries: Ticket #9687: introduce boost::python::raw_method https://svn.boost.org/trac10/ticket/9687 <p> Hi, </p> <p> I am developing a Python's module using boost::python. I need to create a method for certain class, which takes <code>*args</code> and <code>**kwargs</code>. </p> <p> Boost::python is capable of creating a raw function/constructor, but lacks an API for creating a <strong>raw method</strong>. I attach a header, which introduces this option. </p> <p> Thank you for a feedback. </p> <p> Regards </p> <hr /> <p> Example: </p> <div class="wiki-code"><div class="code"><pre> <span class="k">namespace</span> <span class="n">bp</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">python</span><span class="p">;</span> <span class="k">class</span> <span class="nc">ClassName</span> <span class="p">{</span> <span class="k">public</span><span class="o">:</span> <span class="c1">// ...</span> <span class="k">static</span> <span class="kt">void</span> <span class="n">init</span><span class="p">()</span> <span class="p">{</span> <span class="n">s_class</span> <span class="o">=</span> <span class="n">bp</span><span class="o">::</span><span class="n">class_</span><span class="o">&lt;</span><span class="n">ClassName</span><span class="o">&gt;</span><span class="p">(</span><span class="s">&quot;ClassName&quot;</span><span class="p">,</span> <span class="cm">/* ... */</span><span class="p">)</span> <span class="p">.</span><span class="n">def</span><span class="p">(</span><span class="s">&quot;RawMethodName&quot;</span><span class="p">,</span> <span class="n">bp</span><span class="o">::</span><span class="n">raw_method</span><span class="o">&lt;</span><span class="n">ClassName</span><span class="o">&gt;</span><span class="p">(</span> <span class="o">&amp;</span><span class="n">ClassName</span><span class="o">::</span><span class="n">MethodName</span><span class="p">,</span> <span class="mi">2</span><span class="p">));</span> <span class="p">}</span> <span class="n">bp</span><span class="o">::</span><span class="n">object</span> <span class="n">RawMethodName</span><span class="p">(</span> <span class="k">const</span> <span class="n">bp</span><span class="o">::</span><span class="n">tuple</span> <span class="o">&amp;</span><span class="n">args</span><span class="p">,</span> <span class="k">const</span> <span class="n">bp</span><span class="o">::</span><span class="n">dict</span> <span class="o">&amp;</span><span class="n">kwargs</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Do something with args, kwargs</span> <span class="k">return</span> <span class="n">bp</span><span class="o">::</span><span class="n">object</span><span class="p">();</span> <span class="p">}</span> <span class="c1">// ...</span> <span class="k">private</span><span class="o">:</span> <span class="k">static</span> <span class="n">bp</span><span class="o">::</span><span class="n">object</span> <span class="n">s_class</span><span class="p">;</span> <span class="p">};</span> <span class="n">bp</span><span class="o">::</span><span class="n">object</span> <span class="n">ClassName</span><span class="o">::</span><span class="n">s_class</span><span class="p">;</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9687 Trac 1.4.3 phatina@… Thu, 20 Feb 2014 10:02:08 GMT attachment set https://svn.boost.org/trac10/ticket/9687 https://svn.boost.org/trac10/ticket/9687 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">make_method.hpp</span> </li> </ul> <p> Raw method API </p> Ticket