<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>/* No Comments */ &#187; C++</title>
	<atom:link href="http://panyam.wordpress.com/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://panyam.wordpress.com</link>
	<description>About a few hacks and the violin.</description>
	<lastBuildDate>Mon, 19 Oct 2009 03:47:12 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='panyam.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/b4400557b2a114677b7c34dd66f01d34?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>/* No Comments */ &#187; C++</title>
		<link>http://panyam.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://panyam.wordpress.com/osd.xml" title="/* No Comments */" />
		<item>
		<title>gprobe &#8211; Part 1 &#8211; Message Formats</title>
		<link>http://panyam.wordpress.com/2008/02/04/gprobe-part-1-message-formats/</link>
		<comments>http://panyam.wordpress.com/2008/02/04/gprobe-part-1-message-formats/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 14:27:04 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/?p=24</guid>
		<description><![CDATA[Message transport (between the gprobe, the game server I had written for my work in my spare time and the front end client) was using json or  Action Message Format, AMF.  Reason for the duality, was that for quick testing, I could login into the server with simple telnet and send (textual) commands and recieve [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&blog=841257&post=24&subd=panyam&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Message transport (between the gprobe, the game server I had written for my work in my spare time and the front end client) was using json or  Action Message Format, AMF.  Reason for the duality, was that for quick testing, I could login into the server with simple telnet and send (textual) commands and recieve data in json format &#8211; Simple.  However, I could not find a built in JSON parser for Flex and writing one (again, as I had already written one in C++ for the server side) &#8211; didnt just seem too appealing.  Luckily, Flex is capable of serializing and deserializing objects in binary format over a stream &#8211; yep &#8211; the <a href="http://en.wikipedia.org/wiki/Action_Message_Format" target="_blank">Action Message Format or AMF</a>.  Adding the AMF serializer to the server was fairly simple (did take few hints on the integer encoding from <a href="http://pyamf.org" target="_blank">pyamf</a> &#8211; thanks guys).</p>
<p>Now the problem was that I could not find a way of debugging the decoding (on the flex side) of the AMF stream I had generated from my server.  Why do I need debugging you ask?  Well, I was having random errors in the AMF stream (no doubt due to my encoding) while encoding strings.  Due to time-constraints I had decided to switch to JSON.  This meant I had to write a json parser for flex (as I could not find one at the time).  Not too bad as it gave me a lot of insight into what was being sent and so on.  One day when I earn more free time at work I may decided to debug my AMF encoder.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/24/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/24/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&blog=841257&post=24&subd=panyam&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2008/02/04/gprobe-part-1-message-formats/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>Flex</title>
		<link>http://panyam.wordpress.com/2007/12/18/flex/</link>
		<comments>http://panyam.wordpress.com/2007/12/18/flex/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 00:51:30 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/2007/12/18/flex/</guid>
		<description><![CDATA[At work I write games.  No not the cool ones like Xbox or PS3 or Wii, but pokie machines ones.  Enough said.  Anyway, each build of the game takes about 5-10 minutes and each start takes upto 3 minutes.  Needless to say, the bug-fixing and configuration is quite the pain in the posterior.
An obvious realisation [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&blog=841257&post=23&subd=panyam&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>At <a href="http://www.wms.com" target="_blank">work</a> I write games.  No not the cool ones like Xbox or PS3 or Wii, but pokie machines ones.  Enough said.  Anyway, each build of the game takes about 5-10 minutes and each start takes upto 3 minutes.  Needless to say, the bug-fixing and configuration is quite the pain in the posterior.</p>
<p>An obvious realisation was, why not write a server that could listen to commands from &#8220;somewhere&#8221; and make changes to the game (objects) at run time.  This would mean a build is only necessary on a critical improvent.  And a restart (of the the game) would only be required on a rebuild!  This would be useful for modifying Sprite locations and properties and just about anything which the custom server can get hold off.  Now such a tool did exist.  Unfortunatly it was a custom written http server, which printed out the entire Sprite tree on each request.  Worse still, each request opened a new connection and then closed it.  Did I mention that this server only allowed querying, not modifying or creation of sprites (or other game objects)?</p>
<p>So I embarked on a new probing utility for doing just that.  The server was written in C++ using pthreads for multi-threading.  No big deal.  That is not what I am going to talk about &#8211; better people have written and preached about the art of server writing.  Thing that got me tickled was I used this opportunity to learn flash, so I begain writing the gui in flash/flex.  Main reason was that I wanted a web based UI for the client-side.  The experience was amazing.  The API is fantastic and intuitive, the IDE (well painful was having to move from VIM to Flex Builder/Linux on Eclipse due to intellisense).  Conversely without intellisense, the experience is tortuous.</p>
<p>Il talk more about the features in future posts each dealing with a subchallenge in the project.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&blog=841257&post=23&subd=panyam&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2007/12/18/flex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
		<item>
		<title>C++ &#8211; Python Bindings</title>
		<link>http://panyam.wordpress.com/2007/07/10/c-python-bindings/</link>
		<comments>http://panyam.wordpress.com/2007/07/10/c-python-bindings/#comments</comments>
		<pubDate>Tue, 10 Jul 2007 12:22:44 +0000</pubDate>
		<dc:creator>Sri</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://panyam.wordpress.com/2007/07/10/c-python-bindings/</guid>
		<description><![CDATA[Version 3.0 of omnifs saw the onset of python bindings for the omnifs library (written in C++ using Curl).  In this post I am going to talk about what I had learnt in writing python bindings for C++.  What this means essentially is that a library written in C++ can now be used [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&blog=841257&post=17&subd=panyam&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><font color="#000000">Version 3.0 of <a href="http://users.tpg.com.au/panyam/omnifs.html">omnifs</a> saw the onset of python bindings for the omnifs library (written in C++ using Curl).  In this post I am going to talk about what I had learnt in writing python bindings for C++.  What this means essentially is that a library written in C++ can now be used from python.  This is ideal for situations where the core modules can be written in a more efficient/lower level languages and can be controlled in a higher level scripting language.  This, some (including myself) believe would assist in testing and development in general.</font></p>
<p><font color="#000000">I will be referring to libomnifs, part of the <a href="http://users.tpg.com.au/panyam/omnifs.html" title="OmniFS">omnifs</a> package, in this posting for any examples.  I wont be showing the details of libomnifs, and will focus on what additions were required to enable python bindings.</font></p>
<p><font color="#000000">I have used the <a href="http://www.boost.org/libs/python/doc/index.html" title="Boost.python">Boost.python</a> library for creating the python bindings to omnifs.  There other ways of doing this, but I wont go into them here.  I had chosen Boost.python as it was fairly well documented and easy to follow (plus it looked cool).</font></p>
<p><font color="#000000"><strong> Prerequistes</strong></font></p>
<ol>
<li><font color="#000000">First download and install the boost library.  I had used version 1.34.0.  Please follow the installation guide for Boost on how to do this.</font></li>
<li><font color="#000000">Then read the bjam tutorial.  bjam is the build system created and used by Boost.  It is very very powerful and can make life a lot simpler (once you get the hang of it).</font></li>
<li><font color="#000000">Read the <a href="http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html" title="Boost.Python Tutorial">boost.python tutorial</a> &#8211; This is a must.  In fact this highlights everything one would need to create the bindings.  I will only document what &#8220;extras&#8221; I have learnt in the process and will try to keep the repititions to a minimum.</font></li>
<li><font color="#000000">Install python if you do not already have it.</font></li>
</ol>
<p><font color="#000000">ONCE AGAIN &#8211; The <a href="http://www.boost.org/libs/python/doc/tutorial/doc/html/index.html" title="Boost.Python Tutorial">boost.python tutorial</a> is fantastic so please have a look at it.</font></p>
<p><font color="#000000"><strong><u>Step 1: First Make a list of Exportable Classes</u></strong></font></p>
<p><font color="#000000">In my case, one of the classes I had chosen to export was OMNI_Action.  OMNI_Action class is superclass of all actions that can be taken agains/on the omnidrive server.  For example &#8220;ListFolder&#8221;, &#8220;UploadFile&#8221; etc.</font></p>
<p><font color="#000000">The public interface of the OMNI_Action is (protected, static and private members are not shown):<br />
</font> <font color="#000000"><code><br />
class OMNI_Action<br />
{<br />
public:     // Virtual methods and constructors<br />
OMNI_Action(OMNI_Session &amp;p_Session);<br />
virtual                 ~OMNI_Action();<br />
virtual bool            Perform()       = 0;</code></font></p>
<p><font color="#000000">public:     // Non virtual methods<br />
int             Result();<br />
const char *    Message();<br />
OMNI_Session *  Session();<br />
};</font></p>
<p><font color="#000000">I have chosen the Action object as the example (rather than the Session object which is required by all Actions) as it is a class that is extended and thus requires more work to create the bindings:</font></p>
<ul>
<li><font color="#000000">every OMNI_Action derived class, needs to only implement the Perform method (to *surprise surprise*  perform the method).</font></li>
<li><font color="#000000">Each OMNI_Action object also needs a OMNI_Session object &#8211; the session in which omnifs is running.  T his is another class that is exported but not shown.</font></li>
</ul>
<p><font color="#000000"><u><strong>Step 2: Include necessary Boost headers</strong></u></font></p>
<p><font color="#000000">Include the required boost headers as follows:</font></p>
<p><font color="#000000"><code>#include &lt;boost/python/module.hpp&gt;<br />
#include &lt;boost/python/def.hpp&gt;<br />
#include &lt;boost/python/class.hpp&gt;<br />
#include &lt;boost/python/args.hpp&gt;<br />
#include &lt;boost/python/overloads.hpp&gt;<br />
#include &lt;boost/python/docstring_options.hpp&gt;<br />
#include &lt;boost/python/enum.hpp&gt;<br />
#include &lt;boost/python/pure_virtual.hpp&gt;</code></font></p>
<p><font color="#000000">#include &lt;boost/python/return_internal_reference.hpp&gt;<br />
#include &lt;boost/python/copy_const_reference.hpp&gt;<br />
#include &lt;boost/python/copy_non_const_reference.hpp&gt;<br />
#include &lt;boost/python/return_value_policy.hpp&gt;</font></p>
<p><font color="#000000">or alternatively include ALL python related headers by include just python.hpp as:</font></p>
<p><font color="#000000"><code>#include &lt;boosts/python.hpp&gt;</code></font></p>
<p><font color="#000000">Also enable the use of the python namespace:</font></p>
<p><font color="#000000"><code>using namespace boost::python;</code></font></p>
<p><font color="#000000">Note that this could be avoided if you prefer to explicitly qualify items with the python namespace each time.</font></p>
<p><font color="#000000"><u><strong>Step 3: Create the module</strong></u></font></p>
<p><font color="#000000">All the generated python bindings happen inside a module definition.  This is done as:</font></p>
<p><font color="#000000"><code>BOOST_PYTHON_MODULE(module_name)</code></font></p>
<p><font color="#000000">{</font></p>
<p><font color="#000000">// Put binding definitions here &#8211; ie class exports and method exports</font></p>
<p><font color="#000000">}</font></p>
<p><font color="#000000">This is it.  no need for a main function or anything.  Think of the BOOST_PYTHON_MODULE bit as the main entry point of the generated shared object.</font></p>
<p><font color="#000000"><u><strong>Step 4: Export the Classes</strong></u></font></p>
<p><font color="#000000">As shown in the <a href="http://www.boost.org/libs/python/doc/tutorial/doc/html/python/exposing.html" title="Boost.Python - Exposing Classes">&#8220;Exposing Classes&#8221; section of the boost.python tutorial</a>, exporting OMNI_Action is simply a matter of doing:<br />
</font> <font color="#000000"><code><br />
<strong>class</strong>_&lt;OMNI_Action&gt;("Action")</code></font></p>
<p><font color="#000000"><code>    .<strong>def</strong>("Perform",<br />
pure_virtual(&amp;OMNI_ActionAuthenticate::Perform),<br />
"The function that performs the specific action.")<br />
.<strong>def</strong>("Result", &amp;OMNI_Action::Result,<br />
"Returns the result of the action after \"Perform\" is called.")<br />
.<strong>def</strong>("Message", &amp;OMNI_Action::Message,<br />
"Returns the message associated with the return result \n"<br />
"after \"Perform\" is called.")<br />
.<strong>def</strong>("Session", &amp;OMNI_Action::Session, return_internal_reference&lt;&gt;(),<br />
"Reference to the session object on which the action "<br />
"object is valid.")</code></font></p>
<p><font color="#000000">    ;</font></p>
<p><font color="#000000">Now there is on <strong>SMALL</strong> problem with the above.  The Perform method is a pure virtual method.  Which means that due to a &#8220;no implementation&#8221; the above class cannot actually be exported.  In order to do this, a wrapper class (called ActionWrap) is created for OMNI_Action, and <strong>THIS wrapper class </strong>is exported instead as shown below:</font></p>
<p><font color="#000000"><code><br />
</code>struct ActionWrap : OMNI_Action, wrapper&lt;OMNI_Action&gt;<br />
{<br />
bool Perform()<br />
{<br />
</font></p>
<blockquote><p><font color="#000000"> #if BOOST_WORKAROUND(BOOST_MSVC, &lt;= 1300) // Workaround for vc6/vc7<br />
return call&lt;int&gt;(this-&gt;<strong>get_override</strong>(&#8220;Perform&#8221;).ptr());<br />
#else<br />
return this-&gt;<strong>get_override</strong>(&#8220;Perform&#8221;)();<br />
#endif</font></p>
<p><font color="#000000">}<br />
</font></p></blockquote>
<p><font color="#000000"> };</font></p>
<p><font color="#000000">This is it.  Now we have provided a proxy implementation of the Perform method which essentially calls the derived Perform method when invoked and we have gotten ridden of the pure virtual method.</font></p>
<p><font color="#000000">The exporting of this class is:</font></p>
<p><font color="#000000"><strong>class</strong>_&lt;ActionWrap, boost::noncopyable&gt;(&#8220;Action&#8221;,<br />
&#8220;A wrapper for classes deriving from the Action object.\n&#8221;<br />
&#8220;The Action class is the super class of all classes that \n&#8221;<br />
&#8220;perform work on the omnidrive server.&#8221;,  no_init)<br />
.<strong>def</strong>(&#8220;Perform&#8221;,<br />
pure_virtual(&amp;OMNI_ActionAuthenticate::Perform),<br />
&#8220;The function that performs the specific action.&#8221;)<br />
.<strong>def</strong>(&#8220;Result&#8221;, &amp;OMNI_Action::Result,<br />
&#8220;Returns the result of the action after \&#8221;Perform\&#8221; is called.&#8221;)<br />
.<strong>def</strong>(&#8220;Message&#8221;, &amp;OMNI_Action::Message,<br />
&#8220;Returns the message associated with the return result \n&#8221;<br />
&#8220;after \&#8221;Perform\&#8221; is called.&#8221;)<br />
.<strong>def</strong>(&#8220;Session&#8221;, &amp;OMNI_Action::Session, return_internal_reference&lt;&gt;(),<br />
&#8220;Reference to the session object on which the action &#8220;<br />
&#8220;object is valid.&#8221;)<br />
;</font></p>
<p><font color="#000000"><strong>Note </strong></font></p>
<ul>
<li><font color="#000000">how all the methods of the original OMNI_Action class are also exposed (ie Perform, Result, Message, and Session)</font></li>
<li><font color="#000000">The noncopyable specifies that the ActionWrap cannot be copied or instantiated</font></li>
<li><font color="#000000">The &#8220;return_internal_reference&lt;&gt;&#8221; specifies that the return value of the &#8220;Session&#8221; object is infact a pointer to a class member, which means that the lifetime of the return value (a session object) is tied to the lifetime of the Action object.  So unless the Action object is destroyed, the reference count of the return Session instance cannot be reduced!  Please refer to <a href="http://www.boost.org/libs/python/doc/tutorial/doc/html/python/functions.html#python.call_policies" title="Call Policies">Call Policies in the Boost.python tutorial</a> for more information on this.</font></li>
<li><font color="#000000">The string values are essentially documentation strings in exported python module (docstrings).<br />
</font></li>
</ul>
<p>Once this is done, the derived classes can be exposed normally.<br />
<u><strong>Step 5: The Build Process</strong></u></p>
<p>Once you have exposed all the classes in the above fashion, it is time for setting up your builds!</p>
<p>The builds are performed using <strong>bjam</strong> &#8211; the Boost build system.  <strong>bjam </strong>looks for the file <strong>Jamroot</strong> in the current directory the same way that <strong>make</strong> looks for a <strong>Makefile</strong>.</p>
<p>bjam is a lot more complex than make and the bjam tutorial is an excellent source of all the information you are going to need.</p>
<p>I will go through my Jamroot file line by line:</p>
<p>1. Specify the Boost directory: This is the location where boost was installed.</p>
<p><strong>use-project boost<br />
: /opt/boost_1_34_9 ;<br />
</strong><br />
2. Specify the requirements and default builds.  To make debug the default build, simply specify that in the default-build line.</p>
<p><strong>project<br />
: requirements &lt;library&gt;/boost/python//boost_python<br />
: default-build release<br />
;<br />
</strong><br />
3. Specify a dependency on the libomnifs C++ library.  The C++ library is infact built in ../bld/&lt;build_mode&gt;</p>
<p>The following two rules mention that in the debug mode the debug build of the libomnifs is to be used and similar in the release mode, the release build of the libomnifs is to be used, as indicated by the &#8220;variant&#8221; flags.</p>
<p><strong>lib libomnifs<br />
:<br />
: &lt;file&gt;&lt;locateion of omnifs source tree&gt;/bld/debug/libomnifs.so &lt;variant&gt;debug<br />
;</strong></p>
<p><strong>lib libomnifs<br />
:<br />
: &lt;file&gt; &lt;omnifs_build_dir_path&gt;/bld/release/libomnifs.so &lt;variant&gt;release<br />
;<br />
</strong><br />
4. This specifies the installation target.  Unlike in &#8220;make&#8221; where installations are arbitrary actions, they have a bit more meaning in bjam.  These (in this rule) simply specify the installation location (in this case the current directory &#8220;.&#8221;) and types (install a library instead of an executable):</p>
<p><strong>install dist : omnipy : &lt;location&gt; . &lt;install-type&gt;LIB ;<br />
</strong><br />
5. Finally the following specifies that the object being built is a python-extension library (of the name <strong>omnipy</strong>).  Many other types of projects are also possible.  Please refer to the bjam tutorial for a full list of build types.  The .cc files are the files in which I had divided the export declarations.  It is recommended to break up the class export declarations into multiple files so that changes in one class will not require the compilation of the entire source &#8211; there by speeding up the build process.</p>
<p><strong>python-extension omnipy<br />
: omnipy.cc omnipy-logger.cc omnipy-utils.cc omnipy-session.cc<br />
omnipy-connection.cc omnipy-memory.cc omnipy-actions.cc libomnifs<br />
; </strong></p>
<p><u><strong>Step 6 &#8211; In Action</strong> </u></p>
<p>Finally to see a glimpse of the library in action, simply start python and run the following:</p>
<p>&#8211;     Import required modules including the one we just created</p>
<p>&gt;&gt;&gt; import omnipy, sys, os</p>
<p>&#8211;    create a session object by calling the Session constructor (refer to the actual distribution)<br />
&gt;&gt;&gt; session = omnipy.Session()</p>
<p>&#8211;   create an actual action object &#8211; the action for creating a folder:</p>
<p>&gt;&gt;&gt; action = omnipy.ActionCreateFolder(session, &#8220;new_folder1&#8243;, &#8220;&#8221;)</p>
<p>&#8211;  Perform the action</p>
<p>&gt;&gt;&gt; action.Perform()</p>
<p>and so on and so forth.</p>
<p>Please refer to the example.py and utils.py in the <a href="http://users.tpg.com.au/panyam/omnifs-download.html" title="OmniFS Download">omnifs source distribution</a> for more details.</p>
<p><u><strong>Step 7: Gotchas and Todos</strong></u></p>
<p>There a still a few things I havent yet figured out.  One of them is how to export FILE * and streams so that we could use Python file handles instead.  Once Im done with that Il put that up in here as well.</p>
<hr />Well that concludes my little tip on how to create python bindings (more of a self-learning set of notes more than anything else).   I hope this really saves you a lot of time.  Please let me know if you find anything I am missing or forgot or just plainly got wrong.  Id be glad to learn from it myself.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/panyam.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/panyam.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/panyam.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/panyam.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/panyam.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/panyam.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/panyam.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/panyam.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/panyam.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/panyam.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/panyam.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/panyam.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=panyam.wordpress.com&blog=841257&post=17&subd=panyam&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://panyam.wordpress.com/2007/07/10/c-python-bindings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/99d3b34a9f7e1e14fdfc9f8d6210fd50?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Sri</media:title>
		</media:content>
	</item>
	</channel>
</rss>