[zeromq-dev] [zproject] How to detect fresh = "1" attribute?

Joe McIlvain joe.eli.mac at gmail.com
Mon Jan 4 07:23:14 CET 2016

This is one example that I think demonstrates that we actually do encode
more information in the zproject API models than is found in the C
headers.  This extra information is necessary for the API to understood to
generate well-behaved bindings, but is, as you've found, merely an
understood convention in C.

It was this kind of property that made me first skeptical of your mkapi.py
project.  In general, I think it would be best to view it as a best effort
to translate C header to API model, useful so that the initial models for a
project moving to using zproject API models does not have to write the bulk
of the XML by hand.  However, after this point it's probably best to tweak
and continue maintenance using the established zproject workflow, modifying
the API model first when you modify your API, allowing the C header to be

In general, I think the API models will always encode a bit more
information than you can (reliably) extract from the C header, and this is
by design (speaking as the one who designed most of the initial structure
of the models).  The API models were introduced for that specific reason -
if the C headers could reliably provide all of the information needed to
generate proper high-level bindings, then we wouldn't need the API models
at all.  As it turns out, the API models are a clean way to make explicit
and machine-readable the properties that were previously only encoded in
highly varied human-language comments.

On Sun, Jan 3, 2016 at 12:04 PM, Michal Vyskocil <michal.vyskocil at gmail.com>

> Hi,
> during the last few weeks I have improved the mkapi.py enough the
> generated model is almost 1:1 with the one from czmq (I am testing
> zactor.xml right now).
> My biggest problem is how can I detect fresh = "1" attribute. Right
> now code adds fresh="1" to each function, which returns non const
> pointer. Which is far from true, as czmq usually have functions
> returing the low-level objects The question is how to deal with it?
> I see only solution:
> Detect phrase "caller is responsible for ..." or so in functions
> comment and add fresh="1" only for those functions.
> It is a bit hacky, but at least encourage developers to explicitly
> document ownership.
> What do you think?
> --
> best regards
>      Michal Vyskocil
> _______________________________________________
> 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/20160103/cc8adac3/attachment.htm>

More information about the zeromq-dev mailing list