[zeromq-dev] zproto python support?

Pieter Hintjens ph at imatix.com
Sun May 10 23:49:46 CEST 2015


GSL provides several functions inside loops that you can use for this.
There's first(), last(), and index ().

So e.g.

.for class.state
.   if index () > 1
        else
.   endif
        if (self->state == $(name:c)_state) {
.   for event where name <> "*"
.       if index () > 1
            else
.       endif
            if (self->event == $(name)_event) {
.       output_action_list ()
            }
.   endfor
...

taken from https://github.com/LeptaSpace/zs/blob/master/src/fsm_c.gsl.

-Pieter


On Sun, May 10, 2015 at 6:38 PM, Arnaud Loonstra <arnaud at sphaero.org> wrote:

> I've created a generator for Python. It still misses some functionality
> as I don't have an approach for the Zframe and Zmsg types.
>
> However one thing I didn't find out how to do with gsl is the
> following:
>
> In Python there's no switch construct. So instead you're supposed to
> use if, elif, else.
> However how do I tell gsl to only do "if" for the first element and
> then continue with "elif"?
>
> For example the if at:
>
> https://github.com/sphaero/zproto/blob/python_gen/src/python/zproto/ZprotoExample.py#L250
>
> Then the next if:
>
> https://github.com/sphaero/zproto/blob/python_gen/src/python/zproto/ZprotoExample.py#L262
>
> should be an "elif"
>
> The gsl code looks like this:
>
> .for class.message where count (field)
>          if self._id == $(ClassName).$(MESSAGE.NAME):
> .   for field
> .       if type = "number"
>              #  $(name) is a $(size)-byte integer
> .           if defined (field.value)
>              self._put_number$(size)($(value:))
> .           else
>              self._put_number$(size)(self._$(name))
> .           endif
> .......
> .   endfor
> .endfor
>
>
> Any suggestions?
>
> Rg,
>
> Arnaud
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20150510/2f3d4ad9/attachment.htm>


More information about the zeromq-dev mailing list