Updated 2014-06-12 16:58:15 by kpv

Tcl Binding to Protocol Buffers edit

Areas (De)serialization, RPC
Good if student knows Tcl, C
Priority Medium to Low
Difficulty Medium to High
Benefits to the student Learning about data serialization, the challenges therein.
Benefits to Tcl Enhanced ability to exchange data with other languages
Mentor AK
Related Project Ideas GSoC Idea: Tcl Binding to Thrift
GSoC Idea: Tcl Binding to MessagePack
GSoC Idea: Updated Tcl bindings for ZeroMQ

Project Description edit

Protocol Buffers are Google's data serialization and RPC format, with an associated Interface Description Language (IDL) and bindings to various languages.

The aim of this project is to provide a binding of Protocol Buffers to Tcl, i.e. a package which can convert between Tcl data structures and protocol buffers, in whole, and incremental (when reading from streams, like sockets, or pipes).

This binding will likely consist of two layers, the "runtime", so to speak, for handling any PB, and a second layer which is code generated from a PD IDL to handle a specific set of buffers.

This second part will require either some sort of plugin for Google's PB IDL compiler, or our own parser and translator for PB IDL.

For this Tcllib's parsetools might be suitable, or other parser generators for Tcl (...).

Students doing this project should consider coordinating with any student doing the related projects as there is potential for common infrastructure between these projects.

Requirements: edit

  • ...
  • ...

Notes: edit

EF I might be able to provide some mentorship help around this, though not entirely.

KPV Here's something I wrote when I needed a way to ingest simple protocol buffers by converting them into a tcl dictionary.
proc Proto2Dict {protoFile} {
    set fin [open $protoFile r]
    set lines [split [string trim [read $fin]] \n] ; list
    lappend lines "done: @ done" ; list
    close $fin

    set protoDict {}
    set currentSection ""
    set currentData ""
    foreach line $lines {
        set newSection [regexp {^ *(.*): +@ } $line . sectionName]
        if {$newSection} {
            if {$currentSection ne ""} {
                dict set protoDict $currentSection $currentData
                puts "adding $currentSection"
            set currentSection $sectionName
            set currentData ""
        } else {
            if {[regexp {(\w*): (.*)} line . key value]} {
                append currentData "$key $value\n"
            } else {
                append currentData "$line\n"
    return $protoDict