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.
- Transport agnostic (currently has DBus backend).
- A client library with lowlevel RPC calls and an object model built on top of the lowlevel calls. Consumer can choose which best fits their use case. (Object model not finished).
- A server implementation (also transport agnostic).
- Fully Asynchronous. Synchronous implementation is built on top of the asynchronous implementation.
- Unit tests (for testing RPC round trips, etc).
- Generated code should be clean to read and debug.
- Tracing support for debugging. (Use -DDISABLE_TRACING to turn off).
- Generate DBus Introspection XML.
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.

Comments (5)
You know if Vala having a great support for DBus right? You can mix both C and Vala.
Quite aware. Not interested however. It doesn’t provide transport abstractions that I want and it is terribly painful to debug the generated code.
This looks very nice, and was looking at writing myself. Could you post a license in the source. I would prefer LGPLv2 or BSD.
Very nice job!
The source to my generator is MITX11. But the output is whatever you want it to be.
Thanks!