<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title type="text">Will's Journal</title>
<subtitle type="html"><![CDATA[
random useless stuff
]]></subtitle>
<id>http://wbb4.com/journal/index.atom</id>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal" />
<link rel="self" type="text/xml" href="http://wbb4.com/journal/index.atom" />

<author>
<name>will</name>
<uri>http://wbb4.com/journal/index.atom</uri>
<email>spam@willbarton.com</email>
</author>
<rights>Copyright 2001-2007 Will Barton</rights>
<generator uri="http://pyblosxom.sourceforge.net/" version="1.4.3 01/10/2008">
PyBlosxom http://pyblosxom.sourceforge.net/ 1.4.3 01/10/2008
</generator>

<updated>2007-12-30T20:34:00Z</updated>
<!-- icon?  logo?  -->

<entry>
<title type="html">We Have a Rachel
</title>
<category term="/personal/peanut" />
<id>http://wbb4.com/journal/2007/12/30/we-have-a-rachel</id>
<updated>2007-12-30T20:34:00Z</updated>
<published>2007-12-30T20:34:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/personal/peanut/we-have-a-rachel" />
<content type="html">&lt;p&gt;&lt;img alt=&quot;rachel&quot; src=&quot;http://rachel.willbarton.com/photos/birth/images/display/IMG_7182.jpg&quot; /&gt;
&lt;a class=&quot;reference&quot; href=&quot;http://rachel.willbarton.com&quot;&gt;More at rachel.willbarton.com&lt;/a&gt;&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">Loading C Plugins for PureDocs
</title>
<category term="/code/puredocs" />
<id>http://wbb4.com/journal/2007/09/01/loading-cplugins</id>
<updated>2007-09-01T13:25:00Z</updated>
<published>2007-09-01T13:25:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/code/puredocs/loading-cplugins" />
<content type="html">&lt;p&gt;I finally had a chance to sit back down with PureDocs, after getting the build process straightened out, and figure out how to load C plugins.  Turns out, it&apos;s pretty simple with &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;ctypes&lt;/span&gt;&lt;/tt&gt;.  Let&apos;s imagine I have a C library, compiled and linked as &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;libtest&lt;/span&gt;&lt;/tt&gt;, containing the following (a simple modification of my original example):&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;puredocs.h&amp;quot;

Resource * test_function() {
    Resource * r = puredocs_createResource(&amp;quot;foo&amp;quot;);
    Resource * c = puredocs_createResource(&amp;quot;bar&amp;quot;);

    puredocs_setDocString(r, &amp;quot;omg some docs lol&amp;quot;);
    puredocs_setDocString(c, &amp;quot;some bar docs omg lol&amp;quot;);

    puredocs_setProperty(r, &amp;quot;feh&amp;quot;, &amp;quot;omg&amp;quot;);

    if ((puredocs_addChild(r, c)) &amp;lt; 0) {
        printf(&amp;quot;OH NOES!\n&amp;quot;);
    }

    return r;
}
&lt;/pre&gt;
&lt;p&gt;This function can easily be called when loading the libary with``ctypes``&apos;s &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;PyDLL&lt;/span&gt;&lt;/tt&gt; type (won&apos;t release the Python interpreter&apos;s GIL, which is important if we&apos;re creating Python objects we want to use).  The &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;restype&lt;/span&gt;&lt;/tt&gt; of the function needs to be set to &lt;tt class=&quot;docutils literal&quot;&gt;&lt;span class=&quot;pre&quot;&gt;ctypes.py_object&lt;/span&gt;&lt;/tt&gt;, since we&apos;re returning a Python object.  The whole process looks like this:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
&amp;gt;&amp;gt;&amp;gt; from ctypes import *
&amp;gt;&amp;gt;&amp;gt; t = pydll.LoadLibrary(&amp;quot;libtest.dylib&amp;quot;)
&amp;gt;&amp;gt;&amp;gt; t.test_function.restype=py_object
&amp;gt;&amp;gt;&amp;gt; r = t.test_function()
&amp;gt;&amp;gt;&amp;gt; r
&amp;lt;Resource foo [&amp;lt;Resource bar []&amp;gt;]&amp;gt;
&lt;/pre&gt;
&lt;p&gt;The whole point of this exercise is basically to make it possible to write C libraries that serve as plugins for PureDocs that don&apos;t necessarily have any knowledge of Python.  They&apos;ll be linked against a PureDocs library that provides the glue-code.  So, for PureDocs&apos;s purpose, I now just need to wrap this around some library loading and registration code, and we&apos;ll be ready to go!&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">Peanut Thumbing Her Nose
</title>
<category term="/personal/peanut" />
<id>http://wbb4.com/journal/2007/08/21/peanut-thumbing-her-nose</id>
<updated>2007-08-21T05:54:35Z</updated>
<published>2007-08-21T05:54:35Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/personal/peanut/peanut-thumbing-her-nose" />
<content type="html">&lt;p&gt;&lt;img alt=&quot;peanut&quot; src=&quot;http://willbarton.com/peanut/Peanut_Week21.png&quot; /&gt;&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">Building PureDocs, Redux
</title>
<category term="/code/puredocs" />
<id>http://wbb4.com/journal/2007/08/10/building-puredocs-redux</id>
<updated>2007-08-11T03:58:00Z</updated>
<published>2007-08-11T03:58:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/code/puredocs/building-puredocs-redux" />
<content type="html">&lt;p&gt;After much trial and tribulation with Pyhton&apos;s distutils and setuptools, I decided it wasn&apos;t really appropriate to be building a C library with the Python tools.  While the capability exists in distutils, it&apos;s pretty obvious that it suffers from some pretty substantial code rot.&lt;/p&gt;
&lt;p&gt;So, I&apos;ve gone the autoconf route.  I didn&apos;t really want to, but really there&apos;s no better solution that I can find that doesn&apos;t involve setting PureDocs aside while I start yet another project.&lt;/p&gt;
&lt;p&gt;In any case, the autoconf&apos;ing isn&apos;t complete, and it doesn&apos;t quite work, but I&apos;ve committed what I have so far.  Once I get it all working well on multiple platforms, I&apos;ll finish off the C API.  Then Kate should be able to add some C-based plugins using the &lt;a class=&quot;reference&quot; href=&quot;http://www.tendra.org/projects/sid/index.html&quot;&gt;SID parser generator&lt;/a&gt;.&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">We Have a Peanut
</title>
<category term="/personal/peanut" />
<id>http://wbb4.com/journal/2007/05/15/we-have-a-peanut</id>
<updated>2007-05-15T23:34:00Z</updated>
<published>2007-05-15T23:34:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/personal/peanut/we-have-a-peanut" />
<content type="html">&lt;p&gt;&lt;img alt=&quot;peanut&quot; src=&quot;http://willbarton.com/peanut/Baby_Week7.png&quot; /&gt;&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">Building PureDocs
</title>
<category term="/code/puredocs" />
<id>http://wbb4.com/journal/2007/04/24/building</id>
<updated>2007-04-25T00:45:43Z</updated>
<published>2007-04-25T00:45:43Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/code/puredocs/building" />
<content type="html">&lt;p&gt;PureDocs seems reasonably unique in being a Python system that provides an external C library, the kind of thing that would probably be happiest with autoconf and make.  Yes, I dislike autoconf, automake, and everything in between, but I&apos;m writing an API doc-generation system, I don&apos;t want to maintain a build system.&lt;/p&gt;
&lt;p&gt;But, I naturally want a unified build system for the entire kit and kaboodle.  The C library should come with the Python system, and the Python system could come with the C library.  This includes Python egg files, which can serve as the basis for other package files.  So, anything I choose needs to integrate with the existing distutils/setuptools-based Python distribution system.&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">Transforming xar Files with XSLT
</title>
<category term="/code/xar" />
<id>http://wbb4.com/journal/2007/04/14/xsltxar</id>
<updated>2007-04-14T05:23:00Z</updated>
<published>2007-04-14T05:23:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/code/xar/xsltxar" />
<content type="html">&lt;p&gt;One of the more interesting things about xar is the representation of the the Table of Contents (toc) in XML, with the ability to store &amp;quot;subdocs&amp;quot;, or additional XML trees, within the toc.  You can easily add your own metadata to a xar file, in addition to its support for a variety of new metadata, including Extended-Attributes, both POSIX and Mac OS X&apos;s.&lt;/p&gt;
&lt;p&gt;Anyway, I&apos;ve been playing with prototyping a package manager based on XSL transformations of xar files.  Basically registering extension functions that can perform the necessary actions on the xar file as it is transformed.  It&apos;s a very interesting concept, and one I&apos;m looking forward to exploring in greater detail.&lt;/p&gt;
&lt;p&gt;I&apos;ll write some more about this as I have time to play with it.&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">C Plugins for PureDocs
</title>
<category term="/code/puredocs" />
<id>http://wbb4.com/journal/2007/03/17/cplugins</id>
<updated>2007-03-18T01:05:00Z</updated>
<published>2007-03-18T01:05:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/code/puredocs/cplugins" />
<content type="html">&lt;p&gt;I had the opportunity to sit down and design a C API for creating PureDocs Resource objects this weekend.  For the C API, Resource is an opaque type, and the API provides the ability to create a Resource, add properties, children, etc, without having to worry about it being a Python type.&lt;/p&gt;
&lt;p&gt;The reason behind C plugin support for an API documentation generation utility that parses files based on grammars should be pretty obvious.  Because most higher-level languages, at the very least, have implementations in C, there are readily available parsers.  Having to reinvent the wheel just because we&apos;re using Python, or at the very least, write Python-C support code, would be painful and reduce the usefulness of PureDocs.  Having a simple C API that can be used to wrap one of these existing parsers seems to be the optimal situation.&lt;/p&gt;
&lt;p&gt;The C API itself is defined in a library, libpuredocs, that links against Python to provide access to the Python data types.  C plugins will be loadable modules linked against libpuredocs.  They will be dyanmically loaded by PureDocs (perhaps by a C Python module) into the same address space, so that Resource objects ca easily be passed back and forth between PureDocs and the C plugin.&lt;/p&gt;
&lt;p&gt;It took me a little while to come up with just the right way to do this to avoid C plugin authors having to have any interaction with Python at all.  I still haven&apos;t figured out how loading and registration of C plugins will work, but I think the datatypes were the hard part.  I&apos;ll write more about this once the entire thing is finalized.  For testing purposes, I have passed a Resource object back and forth between a pure-C loadable module and a C python module, with success.&lt;/p&gt;
&lt;p&gt;A quick test showing that Resource objects created using the libpuredocs library can be used in Python looks something like the following, implemented in C:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
#include &amp;lt;Python.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;puredocs.h&amp;quot;

PyObject * test_function(PyObject * self, PyObject * args) {
    Resource * r = puredocs_createResource(&amp;quot;foo&amp;quot;);
    Resource * c = puredocs_createResource(&amp;quot;bar&amp;quot;);

    puredocs_setDocString(r, &amp;quot;omg some docs lol&amp;quot;);
    puredocs_setDocString(c, &amp;quot;some bar docs omg lol&amp;quot;);

    puredocs_setProperty(r, &amp;quot;feh&amp;quot;, &amp;quot;omg&amp;quot;);

    if ((puredocs_addChild(r, c)) &amp;lt; 0) {
        printf(&amp;quot;OH NOES!\n&amp;quot;);
    }

    return (PyObject *)r;
}
&lt;/pre&gt;
&lt;p&gt;The C API (along with the Python API) is documented in &lt;a class=&quot;reference&quot; href=&quot;http://ideas.water-powered.com/projects/puredocs/docs/plugins/index.html&quot;&gt;The PureDocs Plugin Architecture&lt;/a&gt;.   Again, I&apos;m going to provide more concrete examples once I have loading and registration worked out, and have some working C plugins as examples.&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">I Haven&apos;t Forgotten TracGantt
</title>
<category term="/code/tracgantt" />
<id>http://wbb4.com/journal/2007/02/13/notforgotten</id>
<updated>2007-02-13T22:34:00Z</updated>
<published>2007-02-13T22:34:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/code/tracgantt/notforgotten" />
<content type="html">&lt;p&gt;TracGantt isn&apos;t forgotten, but it&apos;s definitely neglected.  I&apos;m thoroughly convinced that putting tickets themselves on a Gantt chart, by using extra fields, was a fundamentally bad idea.  The correct thing to do would be to use Milestones, which already have a lot of the implementation details that we were adding to Tickets.&lt;/p&gt;
&lt;p&gt;I plan to rewrite TracGantt at some point in the future, but I don&apos;t know when that will be.&lt;/p&gt;
</content>
</entry>

<entry>
<title type="html">Implementing pyxar With ctypes
</title>
<category term="/code/xar" />
<id>http://wbb4.com/journal/2007/01/15/ctypesxar</id>
<updated>2007-01-16T00:14:00Z</updated>
<published>2007-01-16T00:14:00Z</published>
<link rel="alternate" type="text/html" href="http://wbb4.com/journal/code/xar/ctypesxar" />
<content type="html">&lt;p&gt;I&apos;ve been exploring implementing pyxar with the ctypes FFI module for Python, which is included in Python2.5.  Currently, pyxar is a compiled C module for Python built with Pyrex.  Ultimately, ctypes might be easier to maintain than Pyrex, and it certainly requires less on the user&apos;s end, now that it is included with Python.&lt;/p&gt;
&lt;p&gt;I&apos;m hoping to have something working soon.&lt;/p&gt;
</content>
</entry>
</feed>
