I haven't written in a while because I've been pretty heads down on a project I'm working on. Hopefully, it will be in a shape where it makes sense to share with everyone before too long.
In this project, I needed an RPC system that could have multiple transport and be fully asynchronous (with GAsyncResult, etc). So I took a little time and wrote a crappy little python program that generates the following peices in GObject/C from a simple input format.
Anyway, code is here[1]. There is a sample video below where I generate a mockup service for getting information on "Books" and "Authors". See the Makefile in the outdir directory for how to build things. Keep in mind I have absolutely NO INTENTION of maintaining this. But at minimum, I figured it might serve useful for someone.
So a quick example of the imput format would be like the following. I've removed the header lines for succinctness.
object Book {
# books are identified by a unique int (string also supported).
id int
"""
Document your rpc's with python style docs. Comments persist into
the generated code's gtkdoc.
"""
rpc get_name (out string name)
"""
Retrieves the book's author.
"""
rpc get_author (out Author author)
}
object Author {
id int
"""
Retrieves the books by this author.
"""
rpc get_books (out Book[] books)
}
object Manager {
# only one of these per application (/org/blah/Project/Manager).
# might consider this later to simply be the default servce such as
# (/org/blah/Project).
singleton
rpc get_books (out Book[] books)
rpc get_authors (out Author[] authors)
}
Thats pretty much it. The code is uglier than anything you've ever seen, but at least the generated C is pretty. The code parser/generator is not super resilient or anything. I pretty much hack it to have what I need as I go.
[1] http://github.com/chergert/yosemite
-- Christian Hergert 2010-05-13