On Sun, Mar 30, 2014 at 6:32 PM, Leonardo Santagada <santag...@gmail.com> wrote:
> On Sun, Mar 30, 2014 at 9:36 AM, anatoly techtonik <techto...@gmail.com>
> wrote:
>>
>> On ABI level tools can be more useful, and there is where idea
>> intersects with CFFI. It doesn't cancel the fact that people need safe
>> feet injury prevention interfaces. Look for my previous answer with
>> the phrase "I mix C with binary manipulation" that covers this.
>
>
> I think you want something like https://pypi.python.org/pypi/construct/2.5.1
> right? It exists and is pretty good... some guys in my company are using it
> to model a binary audio control protocol both to prototype and to test the
> embeded implementation (which is in C).

Right. Construct is a starting point. What's why I included Tomer into CC list.
It's primary use, as I see it - is reversing existing binary formats.
I'm not quite
persuaded that it has the best declarative specification for binary data.

The difference is that binary data is multi-level. You can set types as UBInt8,
but that's not user friendly. It says it is unsigned, it is integer,
with 1 byte in
size. Why should I care? In terms of binary protocol I care only about allowed
rage of values. How do I work with them is the task of the next level. I
decompose the problem into multiple levels:

level 0: binary data location and size
level 1: check/get/set binary values as-is
level 2: processing nested binary values and dependent binary data
level 3: converting single values into user data types and back (symmetry)
level 4: serializing complex user data types into binary structures and back

I believe every linker/assembler does that. If the structure can not be
decomposed into these levels - it can not be statically analyzed. There are
also many interesting tasks about detecting constraints, processing
dependencies and most important - the user experience, interface for
humans to work on each level.

The basic drawback for construct is that it is hard to write tools that work
on top of it. There is no obvious decoupling between different levels, that's
why I can hardly think, for example, how can I compile a binary executable
from a lot of bytecodes with it.

Basically, why I raised the question in CFFI context is an attempt to play
with a different user story - assembling binary code - the part that is
currently done by tools written in C.
-- 
anatoly t.
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to