<?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/"
	>

<channel>
	<title>Mateusz Loskot &#187; programming</title>
	<atom:link href="http://mateusz.loskot.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://mateusz.loskot.net</link>
	<description>mloskot&#039;s life, programming, c++, geo and adventures</description>
	<lastBuildDate>Tue, 10 Jan 2012 22:03:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Robert&#8217;s rules of Boost testing</title>
		<link>http://mateusz.loskot.net/2012/01/05/roberts-rules-of-boost-testing/</link>
		<comments>http://mateusz.loskot.net/2012/01/05/roberts-rules-of-boost-testing/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 23:16:44 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[boost.geometry]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2887</guid>
		<description><![CDATA[By the way of trying to figure out how to make tests building faster? (I will post about it later), I have learned some interesting practices regarding Boost testing in general. Especially, Robert Ramey shared his best practices, worth to &#8230; <a href="http://mateusz.loskot.net/2012/01/05/roberts-rules-of-boost-testing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By the way of trying to figure out <a href="http://lists.boost.org/Archives/boost/2011/12/189026.php">how to make tests building faster?</a> (I will post about it later), I have learned some interesting practices regarding Boost testing in general. Especially, <a href="http://lists.boost.org/Archives/boost/2011/12/189045.php">Robert Ramey shared</a> his best practices, worth to look at really. New release of Boost will be released <a href="http://www.boost.org/community/index.html">next week</a>, so I&#8217;m testing <a href="http://www.boost.org/libs/geometry/">Boost.Geometry</a> library and it is a good opportunity to apply some of Robert&#8217;s rules.</p>
<blockquote><p>I&#8217;m testing against &#8220;known good&#8221; components &#8211; the next release branch.</p></blockquote>
<p>How to run tests of current development line of a library (a Boost library, e.g. Boost.Geometry) against Boost release branch? Assuming all the library development happens in Boost trunk, let&#8217;s say in <code>${DEV}/boost/_svn/trunk</code> where <code>${DEV}</code> is your base workshop location, do this:</p>
<ul>
<li>Checkout Boost release branch<code>
<pre class="brush: plain; title: ; notranslate">
mkdir -p ${DEV}/boost/_svn/branches/release
cd ${DEV}/boost/_svn/branches/release
svn co https://svn.boost.org/svn/boost/branches/release/ .
</pre>
<p></code></li>
<li>Stay in <code>${DEV}/boost/_svn/branches/release</code></li>
<li>Build and install Boost.Build v2 from the release branch:
<pre class="brush: plain; title: ; notranslate">
cd tools/build/v2
# On Windows, run bootstrap.bat
./bootstrap.sh
# On Windows, I use C:\usr as prefix for my Boost installation
./b2 --prefix=/usr/local install
# Note, this command will also install b2 utility in ${prefix}/bin
</pre>
</li>
<li>Switch Boost.Geometry directories to trunk:
<pre class="brush: plain; title: ; notranslate">
svn switch https://svn.boost.org/svn/boost/trunk/boost/geometry boost/geometry
svn switch https://svn.boost.org/svn/boost/trunk/libs/geometry libs/geometry
</pre>
</li>
<li>Run tests and generate full log in file:
<pre class="brush: plain; title: ; notranslate">
export BGLOG=boost-geometry-test.log
date &gt; $BGLOG &amp; b2 &gt;&gt; $BGLOG 2&lt;&amp;1 &amp; date &gt;&gt; $BGLOG

# On Windows, I run this with logging this way:
set BGLOG=%CD%\boost-geometry-test.log
dateu.exe &gt; %BGLOG% &amp; b2 &gt;&gt; %BGLOG% 2&lt;&amp;1 &amp; dateu.exe &gt;&gt; %BGLOG%
</pre>
<p>Note, the <code>dateu.exe</code> is renamed Unix utility <code>date.exe</code> installed from <a href="http://gnuwin32.sourceforge.net/">GnuWin32</a> packages. I just like it.</p>
</li>
</ul>
<p>Inspect the log file for test failures, for example by quick check of number of passed tests:</p>
<pre class="brush: plain; title: ; notranslate">
$ grep &quot;\*passed\*&quot; boost-geometry-test.log | wc -l
111
</pre>
<p>That&#8217;s it.</p>
<blockquote><p>Try this out &#8211; it will help a lot.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2012/01/05/roberts-rules-of-boost-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boost.Geometry mailing list moved</title>
		<link>http://mateusz.loskot.net/2012/01/05/boost-geometry-mailing-list-moved/</link>
		<comments>http://mateusz.loskot.net/2012/01/05/boost-geometry-mailing-list-moved/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 00:08:55 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[boost.geometry]]></category>
		<category><![CDATA[geometry]]></category>
		<category><![CDATA[mailing list]]></category>
		<category><![CDATA[osgeo]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2868</guid>
		<description><![CDATA[I have moved mailing list of the Boost.Geometry library from server at OSGeo to Boost mailing list server. All existing subscribers and archives have been moved to the new server. The new list is available at geometry at lists dot &#8230; <a href="http://mateusz.loskot.net/2012/01/05/boost-geometry-mailing-list-moved/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have moved mailing list of the Boost.Geometry library from server at <a href="http://lists.osgeo.org">OSGeo</a> to <a href="http://lists.boost.org ">Boost</a> mailing list server. All existing subscribers and archives have been moved to the new server.</p>
<p>The new list is available at <a href="http://lists.boost.org/mailman/listinfo.cgi/geometry">geometry at lists dot boost dot org</a>. It is also mirrored at Nabble as <a href="http://boost-geometry.203548.n3.nabble.com/">Boost.Geometry</a>.</p>
<p>The old <a href="http://lists.osgeo.org/mailman/listinfo/ggl">ggl at lists dot osgeo dot org</a> will be wiped out soon.</p>
<p>If anyone experiences any problems with the new geometry at lists.boost.org, please <a href="/contact">contact</a> me directly.</p>
<p>Big thanks to the <a href="http://osgeo.org">OSGeo Foundation</a> for hosting the <em>ggl</em> mailing list and thanks to <a href="http://www.boost.org">Boost</a> admins for help with the new server.</p>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2012/01/05/boost-geometry-mailing-list-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 11 patch for Boost.Build accepted</title>
		<link>http://mateusz.loskot.net/2011/12/19/visual-studio-11-patch-for-boost-build-accepted/</link>
		<comments>http://mateusz.loskot.net/2011/12/19/visual-studio-11-patch-for-boost-build-accepted/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 11:28:11 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[boost.build]]></category>
		<category><![CDATA[visual c++]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio 11]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2861</guid>
		<description><![CDATA[A few days ago I submitted patch with small fixes for Boost.Build to support Visual Studio 11 toolset. The patch has been accepted and committed to the current trunk in Boost repo. Thanks to Volodya for reviewing the patch.]]></description>
			<content:encoded><![CDATA[<p>A few days ago I submitted patch with <a href="/?p=2841">small fixes for Boost.Build</a> to support Visual Studio 11 toolset. The <a href="https://svn.boost.org/trac/boost/ticket/6283">patch has been accepted</a> and committed to the current trunk in Boost repo. Thanks to <a href="http://vladimir_prus.blogspot.com/">Volodya</a> for reviewing the patch.</p>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/12/19/visual-studio-11-patch-for-boost-build-accepted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pygit-svn-mirror 0.1 released</title>
		<link>http://mateusz.loskot.net/2011/12/19/pygit-svn-mirror-0-1-released/</link>
		<comments>http://mateusz.loskot.net/2011/12/19/pygit-svn-mirror-0-1-released/#comments</comments>
		<pubDate>Mon, 19 Dec 2011 01:13:40 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Eloy Durán]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2849</guid>
		<description><![CDATA[I have been looking for easy and quick solution to mirror Subversion repositories in Git at GitHub. With bit of reading and testing, I came up with some quite usable workflow. But, most likely due to my lack of Git &#8230; <a href="http://mateusz.loskot.net/2011/12/19/pygit-svn-mirror-0-1-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been looking for easy and quick solution to mirror <a href="http://subversion.apache.org/">Subversion</a> repositories in <a href="http://git-scm.com/">Git</a> at <a href="http://github.com">GitHub</a>. With bit of reading and testing, I came up with some quite usable <a href="http://trac.osgeo.org/gdal/wiki/UsingGitToMaintainGDALWorkflow">workflow</a>. But, most likely due to my lack of <a href="http://progit.org/">Git fu</a>, I wasn&#8217;t happy with it. Especially, could not find how to update Git mirrors from various locations and computers, also to allow others to do that.</p>
<p>Lately, I have found a tool written in <a href="http://www.ruby-lang.org/">Ruby</a> by <a href="https://github.com/alloy">Eloy Durán</a>. It is <a href="https://github.com/alloy/git-svn-mirror/">git-svn-mirror</a> &#8211; <em>a command-line tool that automates the task of creating a Git mirror for a SVN repository, and keeping it up-to-date</em>. I installed Eloy&#8217;s tool from <a href="https://rubygems.org/gems/git-svn-mirror">Ruby gems</a> and played with it for a while. I really liked it.</p>
<p>I skimmed the Ruby code of <code>git-svn-mirror</code> and found out it makes use of <a href="http://schacon.github.com/git/user-manual.html">bare repositories in Git</a>. A Git bare repository stores just the contents of the <code>.git</code> directory, without any files checked out around it. Long story short, this script does almost exactly what I need and if there is something it does not do, then I can add it.</p>
<p>I have never written a single line of code in Ruby and I don&#8217;t feel like I need to learn it now. So, I decided to port <a href="https://github.com/alloy/git-svn-mirror/">git-svn-mirror</a> to Python. I have just pushed <a href="https://github.com/mloskot/pygit-svn-mirror">pygit-svn-mirror</a> 0.1 based on git-svn-mirror 0.1 to the repository at GitHub. I have tried to follow command line interface and overall code structure of the original version in Ruby. I have also preserved the original license and Eloy&#8217;s copyright.</p>
<p>There is README.md file included with detailed guide on how to use the <code>pygit-svn-mirror</code>. Basically, there are two commands: <code>init</code> and <code>update</code>. For each command, <code>--help</code> option will display required and supported arguments.</p>
<p>For example, creating mirror of Subversion repository of PROJ.4 project at GitHub involves the following commands:</p>
<pre class="brush: plain; gutter: true; light: true; title: ; notranslate">
mkdir /path/to/proj4/mirror
cd /path/to/proj4/mirror
git-svn-mirror.py init \
  --from=https://svn.osgeo.org/metacrs/proj/ \
  --to=git@github.com:&lt;USRNAME&gt;/proj.4.git
</pre>
<p>and to update the mirror from its workbench directory:</p>
<pre class="brush: plain; gutter: true; light: true; title: ; notranslate">
cd /path/to/proj4/mirror
git-svn-mirror.py update
</pre>
<p>or from any folder but with workbench location pointed explicitly:</p>
<pre class="brush: plain; gutter: true; light: true; title: ; notranslate">
git-svn-mirror.py update -w /path/to/proj4/mirror
</pre>
<p><a href="/contact">Feedback</a>, <a href="https://github.com/mloskot/pygit-svn-mirror/issues">bug reports and patches</a> highly appreciated.</p>
<p>Finally, big thanks to <a href="https://github.com/alloy">Eloy Durán</a> for the original <a href="https://github.com/alloy/git-svn-mirror/">git-svn-mirror</a> written in Ruby.</p>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/12/19/pygit-svn-mirror-0-1-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 11 support for Boost.Build</title>
		<link>http://mateusz.loskot.net/2011/12/17/visual-studio-11-support-for-boost-build/</link>
		<comments>http://mateusz.loskot.net/2011/12/17/visual-studio-11-support-for-boost-build/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 15:57:09 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bjam]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[boost.build]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[patch]]></category>
		<category><![CDATA[toolset]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2841</guid>
		<description><![CDATA[I have just submitted patch with update for Boost.Build machinery to properly detect Visual Studio 11 (currently available as Developer Preview). I have very little experience with Boost.Build v2 internals, so the patch may need further improvements. It works in &#8230; <a href="http://mateusz.loskot.net/2011/12/17/visual-studio-11-support-for-boost-build/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have just submitted <a href="https://svn.boost.org/trac/boost/ticket/6283" title="#6283 (Visual Studio 11 support for Boost.Build) - Boost C++ Libraries">patch with update for Boost.Build</a> machinery to properly detect Visual Studio 11 (currently available as Developer Preview).</p>
<p>I have very little experience with <a href="http://www.boost.org/boost-build2/">Boost.Build v2</a> internals, so the patch may need further improvements. It works in my environment on Windows 7 (64-bit) with Visual Studio 2010 Express Edition installed alongside the <a href="http://msdn.microsoft.com/en-us/vstudio/hh127353">Visual Studio 11 Developer Preview</a>.</p>
<p>If you want to use Visual Studio 11 as Boost.Build toolset, just put the following entry in your user-config.jam file:</p>
<pre class="brush: plain; title: ; notranslate">
using msvc : 11.0 ;
</pre>
<p>To verify if the toolset is recognised correctly, use <code>b2</code> debugging options:</p>
<pre class="brush: plain; title: ; notranslate">
b2 --debug-configuration --debug-building --debug-generator buffer.cpp
notice: found boost-build.jam at D:/dev/boost/_svn/trunk/boost-build.jam
notice: loading Boost.Build from D:/dev/boost/_svn/trunk/tools/build/v2
notice: Searching C:\Windows C:\Users\mloskot C:\Users\mloskot D:\dev\boost\_svn\trunk\tools/build/v2 D:/dev/boost/_svn/trunk/tools/build/v2/kernel D:/dev/
boost/_svn/trunk/tools/build/v2/util D:/dev/boost/_svn/trunk/tools/build/v2/build D:/dev/boost/_svn/trunk/tools/build/v2/tools D:/dev/boost/_svn/trunk/tool
s/build/v2/contrib D:/dev/boost/_svn/trunk/tools/build/v2/. for site-config configuration file site-config.jam .
notice: Loading site-config configuration file site-config.jam from D:/dev/boost/_svn/trunk/tools/build/v2/site-config.jam .
notice: Searching C:\Users\mloskot C:\Users\mloskot D:\dev\boost\_svn\trunk\tools/build/v2 D:/dev/boost/_svn/trunk/tools/build/v2/kernel D:/dev/boost/_svn/
trunk/tools/build/v2/util D:/dev/boost/_svn/trunk/tools/build/v2/build D:/dev/boost/_svn/trunk/tools/build/v2/tools D:/dev/boost/_svn/trunk/tools/build/v2/
contrib D:/dev/boost/_svn/trunk/tools/build/v2/. for user-config configuration file user-config.jam .
notice: Loading user-config configuration file user-config.jam from C:/Users/mloskot/user-config.jam .
notice: [msvc-cfg] msvc-11.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe'
notice: [msvc-cfg] msvc-10.0 detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe'
notice: [msvc-cfg] msvc-10.0express detected, command: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\cl.exe'
notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe' for msvc, condition &lt;toolset&gt;msvc-11.0
notice: [msvc-cfg] condition: '&lt;toolset&gt;msvc-11.0/&lt;architecture&gt;/&lt;address-model&gt;', setup: 'call &quot;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcv
arsall.bat&quot; x86 &gt;nul
...
</pre>
<p>and look for the following message reported:</p>
<pre class="brush: plain; title: ; notranslate">
notice: will use 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe' for msvc, condition &lt;toolset&gt;msvc-11.0
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/12/17/visual-studio-11-support-for-boost-build/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Python sys.stdout redirection in C++</title>
		<link>http://mateusz.loskot.net/2011/12/01/python-sys-stdout-redirection-in-cpp/</link>
		<comments>http://mateusz.loskot.net/2011/12/01/python-sys-stdout-redirection-in-cpp/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 00:30:25 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[embedding]]></category>
		<category><![CDATA[extending]]></category>
		<category><![CDATA[interpreter]]></category>
		<category><![CDATA[lambda]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[stdout]]></category>
		<category><![CDATA[sys]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2819</guid>
		<description><![CDATA[Lately, I have been embedding Python interpreter and implementing plenty of Python extensions in C++ using plain C API provided by Python 3. One of common challenges at C/C++ level is to intercept output sent to sys.stdout or sys.stderr by &#8230; <a href="http://mateusz.loskot.net/2011/12/01/python-sys-stdout-redirection-in-cpp/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Lately, I have been <a href="http://docs.python.org/py3k/extending/embedding.html">embedding Python interpreter</a> and implementing plenty of Python extensions in C++ using <a href="http://docs.python.org/py3k/c-api/index.html">plain C API</a> provided by Python 3. One of common challenges at C/C++ level is to intercept output sent to <code>sys.stdout</code> or <code>sys.stderr</code> by Python functions like <code>print</code>. <a href="http://docs.python.org/py3k/faq/extending.html">Python Embedding/Extending FAQ</a> suggests common solution based on Python code:</p>
<pre class="brush: python; title: ; notranslate">
# catcher code
import sys
class StdoutCatcher:
   def __init__(self):
      self.data = ''
   def write(self, stuff):
      self.data = self.data + stuff
catcher = StdoutCatcher()
sys.stdout = catcher
</pre>
<p>This Python code can be executed by embedded Python interpreter using <code>PyRun_SimpleString</code>, then the output can be accessed by fetching <code>__main__</code> module attributes:</p>
<pre class="brush: cpp; title: ; notranslate">
PyObject* m = PyImport_AddModule(&quot;__main__&quot;);
char const* code = &quot;... catcher code here...&quot;;
PyRun_SimpleString(code);
PyRun_SimpleString(&quot;print(3.14)&quot;);
PyObject* catcher = PyObject_GetAttrString(m, &quot;catcher&quot;);
PyObject* output = PyObject_GetAttrString(catcher, &quot;data&quot;);
// get textual data contained in output
</pre>
<p>Such mix of Python and C code is neither convenient to use nor states a flexible solution. I simply don&#8217;t like this prosthesis, especially if I need to frequently switch between number output sinks.</p>
<p>So, I have come up with better solution which allows me to directly bind any callable C++ entity. The syntax I mean looks and feels like this:</p>
<pre class="brush: cpp; title: ; notranslate">
int main()
{
    PyImport_AppendInittab(&quot;emb&quot;, emb::PyInit_emb);
    Py_Initialize();
    PyImport_ImportModule(&quot;emb&quot;);

    PyRun_SimpleString(&quot;print(\'hello to console\')&quot;);

    // here comes the ***magic***
    std::string buffer;
    {
        // switch sys.stdout to custom handler
        emb::stdout_write_type write =
            [&amp;buffer] (std::string s) { buffer += s; };

        emb::set_stdout(write);
        PyRun_SimpleString(&quot;print(\'hello to buffer\')&quot;);
        PyRun_SimpleString(&quot;print(3.14)&quot;);
        PyRun_SimpleString(&quot;print(\'still talking to buffer\')&quot;);
        emb::reset_stdout();
    }

    PyRun_SimpleString(&quot;print(\'hello to console again\')&quot;);
    Py_Finalize();

    // output what was written to buffer object
    std::clog &lt;&lt; buffer &lt;&lt; std::endl;
}
</pre>
<p>This allows me to handle <code>sys.stdout.write</code> with C++ free function, class member function, named function objects or even anonymous functions as in the example above where I use <a href="http://en.wikipedia.org/wiki/C%2B%2B11">C++11 lambda</a>.</p>
<p>Complete implementation of the <code>emb</code> module in C/C++ using plain Python C API is available from my <a href="https://github.com/mloskot/workshop/tree/master/python">Python workshop at GitHub</a>:</p>
<pre>git clone git://github.com/mloskot/workshop.git</pre>
<p>The complete code is enclosed in <a href="https://github.com/mloskot/workshop/blob/master/python/emb/emb.cpp">python/emb/emb.cpp</a> file. Note, this is a minimal example to present the essential concept. In production-ready code, it certainly needs more attention around reference counting of PyObject, getting rid of global state, and so one.</p>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/12/01/python-sys-stdout-redirection-in-cpp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 11 visualizers for Boost.Geometry</title>
		<link>http://mateusz.loskot.net/2011/11/29/visual-studio-11-visualizers-for-boost-geometry/</link>
		<comments>http://mateusz.loskot.net/2011/11/29/visual-studio-11-visualizers-for-boost-geometry/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 00:12:23 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Barend Gehrels]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[boost.geometry]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio 11]]></category>
		<category><![CDATA[visualizer]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2816</guid>
		<description><![CDATA[Some time ago Barend Gehrels blogged about Visual Studio 2010 debugger visualizers for Boost.Geometry. Barend&#8217;s templates added to autoexp.dat file are of great help while working with the Boost.Geometry library in Visual Studio. Recently, I&#8217;ve started using Visual Studio 11 &#8230; <a href="http://mateusz.loskot.net/2011/11/29/visual-studio-11-visualizers-for-boost-geometry/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some time ago <a href="http://barendgehrels.blogspot.com/">Barend Gehrels</a> blogged about <a href="http://barendgehrels.blogspot.com/2011/05/debugger-visualizers.html">Visual Studio 2010 debugger visualizers for Boost.Geometry</a>. Barend&#8217;s templates added to <code>autoexp.dat</code> file are of great help while working with the <a href="www.boost.org/doc/libs/release/libs/geometry/doc/html/index.html">Boost.Geometry</a> library in Visual Studio.</p>
<p>Recently, I&#8217;ve started using <a href="http://www.microsoft.com/download/en/details.aspx?id=27538">Visual Studio 11 Developer Preview</a> and discovered the <a href="/?p=2289">new style debugger visualizers</a> this new edition introduces. I decided to port Barend&#8217;s work to the new XML-based format in <code>.natvis</code> files.</p>
<p><a href="http://www.flickr.com/photos/mloskot/6421696735/" title="vs11-visualizers-boost-geometry by Pantera and Mateusz, on Flickr"><img src="http://farm8.staticflickr.com/7172/6421696735_8c7107bc3c_z.jpg" width="640" height="428" alt="vs11-visualizers-boost-geometry"/></a></p>
<p>All my visualizers, not only for Boost.Geometry but also for other libraries, are available in <a href="https://github.com/mloskot/visualstudio11">visualstudio11</a> Git repository on my <a href="https://github.com/mloskot/">GitHub</a>. The <code>.natvis</code> files are not overly complicated and the installation is dead easy, see README file attached.</p>
<p>Comments, suggestions and fixes are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/11/29/visual-studio-11-visualizers-for-boost-geometry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick fix for CMake broken Visual Studio 11 .sln</title>
		<link>http://mateusz.loskot.net/2011/11/24/quick-fix-for-cmake-broken-visual-studio-11-sln/</link>
		<comments>http://mateusz.loskot.net/2011/11/24/quick-fix-for-cmake-broken-visual-studio-11-sln/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 20:55:54 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bat]]></category>
		<category><![CDATA[cmake]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio 11]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2808</guid>
		<description><![CDATA[Current CMake 2.8.6 generates broken .sln files for Visual Studio 11 Developer Preview. The bug has been fixed already in CMake upstream. Meanwhile, I have become annoyed by manually fixing the solution files. Here is quick .bat script I call &#8230; <a href="http://mateusz.loskot.net/2011/11/24/quick-fix-for-cmake-broken-visual-studio-11-sln/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Current <a href="/?p=2278">CMake 2.8.6 generates broken <code>.sln</code> files</a> for <a href="http://msdn.microsoft.com/en-us/vstudio/hh127353">Visual Studio 11 Developer Preview</a>. The <a href="http://public.kitware.com/Bug/view.php?id=12572">bug has been fixed</a> already in CMake upstream.</p>
<p>Meanwhile, I have become annoyed by manually fixing the solution files. Here is quick <code>.bat</code> script I call from my <code>cmake-{project}.bat</code> proxy scripts I maintain for every project configured with CMake. So the fix is applied automatically every time I run CMake:</p>
<pre class="brush: plain; title: ; notranslate">
@echo off
REM Fix broken Visual Studio 11 .sln generated by CMake 2.8.6 (or earlier)
set SED=&quot;C:\Program Files (x86)\GnuWin32\bin\sed.exe&quot;
set SLN=%1
copy %SLN% %SLN%.copy
%SED% &quot;s/Studio 2011/Studio 11/g&quot; %SLN%.copy &gt; %SLN%
del /Q %SLN%.copy
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/11/24/quick-fix-for-cmake-broken-visual-studio-11-sln/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modular visualizers in Visual Studio 11</title>
		<link>http://mateusz.loskot.net/2011/11/22/modular-visualizers-in-visual-studio-11/</link>
		<comments>http://mateusz.loskot.net/2011/11/22/modular-visualizers-in-visual-studio-11/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 23:58:34 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[autoexp.dat]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[defaultvis.natvis]]></category>
		<category><![CDATA[loki]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[natvis]]></category>
		<category><![CDATA[poco]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio 11]]></category>
		<category><![CDATA[visualizer]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2797</guid>
		<description><![CDATA[Previously, I talked about the new debugger visualizers in Visual Studio 11 (Developer Preview) based on XML. By the way, I haven&#8217;t any luck trying to figure out where does the file type .NATVIS come from. In previous versions of &#8230; <a href="http://mateusz.loskot.net/2011/11/22/modular-visualizers-in-visual-studio-11/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Previously, I talked about the new <a href="/?p=2289">debugger visualizers in Visual Studio 11</a> (Developer Preview) based on XML. By the way, I haven&#8217;t any luck trying to figure out where does the file type <code>.NATVIS</code> come from.</p>
<p>In previous versions of the Visual Studio, all templates of debugger visualizers have to be saved in single file: <code>%VSINSTALLDIR%\Common7\Packages\Debugger\autoexp.dat</code>. In case one wants to extend or improve the templates definition, maintaining everything in one system-wide file is neither practical nor safe.</p>
<p>The visualizers in Visual Studio 11 seem to solve the maintenance hassle by allowing more modular approach. First nice feature is that custom templates can be defined without touching any of the installed Visual Studio files and can be put in <code>%USERPROFILE%\Documents\Visual Studio 11\Visualizers</code>. Second nice feature I&#8217;ve just discovered is that definitions of visualizers can be split into several separate <code>.natvis</code> files. It is especially useful if one wants to maintain visualizers grouped according to libraries (e.g. <a href="http://loki-lib.sourceforge.net/">Loki</a>, <a href="http://www.boost.org">Boost</a>, <a href="http://pocoproject.org">POCO</a>).</p>
<p>Basically, <code>%USERPROFILE%\Documents\Visual Studio 11\Visualizers</code> works like a package of custom visualizers now:</p>
<p><a href="http://www.flickr.com/photos/mloskot/6379533713/" title="vs11-user-natvis by Pantera and Mateusz, on Flickr"><img src="http://farm7.staticflickr.com/6223/6379533713_9362254f30_o.png" width="463" height="144" alt="vs11-user-natvis"/></a></p>
<p>Having the <a href="/?p=2781">visualizers diagnostics enabled</a>, whole process of parsing and loading <code>.natvis</code> files will be traced in Visual Studio 11 output window:</p>
<p><a href="http://www.flickr.com/photos/mloskot/6379627735/" title="vs11-modular-natvis by Pantera and Mateusz, on Flickr"><img src="http://farm7.staticflickr.com/6037/6379627735_e6388b61b2_z.jpg" width="640" height="89" alt="vs11-modular-natvis"/></a></p>
<p>No more copying and pasting <a href="https://svn.boost.org/trac/boost/wiki/DebuggerVisualizers">debugger visualizers for Boost</a> and others into big muddy autoexp.dat.</p>
<p>BTW, who knows where does NATVIS come from, hmm? :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/11/22/modular-visualizers-in-visual-studio-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting EnableNatvisDiagnostics in Visual Studio 11</title>
		<link>http://mateusz.loskot.net/2011/11/20/setting-enablenatvisdiagnostics-in-visual-studio-11/</link>
		<comments>http://mateusz.loskot.net/2011/11/20/setting-enablenatvisdiagnostics-in-visual-studio-11/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 03:54:42 +0000</pubDate>
		<dc:creator>mloskot</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[defaultvis.natvis]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[natvis]]></category>
		<category><![CDATA[visual c++]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio 11]]></category>
		<category><![CDATA[visualizer]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://mateusz.loskot.net/?p=2781</guid>
		<description><![CDATA[Previously, I posted about the new XML-style debugger visualizers I discovered in Visual Studio 11. I mentioned that one of reasons the feature has been redesigned is to enable debugging of the visualizers templates defined in default or user-defined .natvis &#8230; <a href="http://mateusz.loskot.net/2011/11/20/setting-enablenatvisdiagnostics-in-visual-studio-11/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Previously, I <a href="/?p=2289">posted</a> about the new XML-style debugger visualizers I discovered in Visual Studio 11. I mentioned that one of reasons the feature has been redesigned is to enable debugging of the visualizers templates defined in default or user-defined <code>.natvis</code> files. So, it looks there is something more to discover: how to actually make use of the diagnostics capability.</p>
<p>Unfortunately, it seems the new debugger visualizers have not been documented anywhere. At the time of writing this blog, Google reports one link about <a href="http://www.google.com/search?q=%22defaultvis.natvis%22">defaultvis.natvis</a>, it is the <a href="http://social.msdn.microsoft.com/Forums/is/vcgeneral/thread/5e847744-aa01-49cd-ac47-fe32da1673a3">brief post</a> on Visual C++ forum.</p>
<p>Luckily, there is a short manual included as comment in header of the <code>%ProgramFiles%\Microsoft Visual Studio 11.0\Common7\Packages\Debugger\Visualizers\defaultvis.natvis</code> file. It says:</p>
<blockquote><p>1) give better diagnostic reporting.<br />
 a) Set the name-value entry under the Debugger registry key: EnableNatvisDiagnostics which is a REG_DWORD to a value of 1 this will output each expression string that is evaluated under the native visualizer into the output window and is good for debugging type definition typos in .natvis files.</p></blockquote>
<p>The first thing is to figure out where to set the <code>EnableNatvisDiagnostics</code> flag. The Visual Studio 11 installer does not put it into the registry. Also, there are several <code>Debugger</code> keys. However, a few experiments proved the flag should be set under <code>HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\Debugger</code>:</p>
<p><a href="http://www.flickr.com/photos/mloskot/6366775823/" title="vs11-visualizers-enable-natvis-diagnostics by Pantera and Mateusz, on Flickr"><img src="http://farm7.staticflickr.com/6058/6366775823_6c76e463e1_o.png" width="685" height="183" alt="vs11-visualizers-enable-natvis-diagnostics"/></a></p>
<p>Once it is set, every time Visual Studio 11 debugger is launched and use of visualized types is determined, the .natvis files are parsed and evaluated templates validated. The process is reported in the Output window:</p>
<p><a href="http://www.flickr.com/photos/mloskot/6366775645/" title="vs11-evaluating-visualizer-1 by Pantera and Mateusz, on Flickr"><img src="http://farm7.staticflickr.com/6045/6366775645_20e510cc0e_z.jpg" width="640" height="327" alt="vs11-evaluating-visualizer-1"/></a></p>
<p>If anything goes wrong, a type definition template is incorrect and its evaluation fails, it is also reported in the Output window:</p>
<p><a href="http://www.flickr.com/photos/mloskot/6366775745/" title="vs11-evaluating-visualizer-2-validation by Pantera and Mateusz, on Flickr"><img src="http://farm7.staticflickr.com/6034/6366775745_a2b0770a59_z.jpg" width="640" height="347" alt="vs11-evaluating-visualizer-2-validation"/></a></p>
<p>It will be a very useful feature especially when defining visualizers of complex types. Previous versions of Visual Studio used old format of templates defined in autoexp.dat file which stated its own <a href="http://en.wikipedia.org/wiki/Domain-specific_language">DSL</a> based on regular expressions, so the syntax was complex and fragile, and as <a href="http://blogs.msdn.com/b/andypennell/archive/2006/03/28/563221.aspx">Andy Pennel has confessed</a>, <a href="http://connect.microsoft.com/VisualStudio/feedback/details/168571/publish-documentation-for-visualizer-section-of-autoexp-dat">not documented</a>. (Here kudos to <a href="http://www.virtualdub.org">Avery Lee</a> who did great job <a href="http://www.virtualdub.org/blog/pivot/entry.php?id=172">reverse-engineering the autoexp.dat syntax</a>.)</p>
<p>At least, this time folks get the XML Schema for the Visual Studio debugger visualizers.</p>
]]></content:encoded>
			<wfw:commentRss>http://mateusz.loskot.net/2011/11/20/setting-enablenatvisdiagnostics-in-visual-studio-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

