-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support for ref specs, fixed issue with assoc spec, added hex-dump, set version to 1.0.2 #11
Conversation
Adding support for dynamic specs where the length is stored in another spec, fixing a size issue with assoc spec, adding hex-dump function, set version to 1.0.2. Changes: o changed the map containing the assoc spec so that it keeps insertion order even for assoc specs larger than 10 o added a new protocol ISpecWithRef which is an either-or with ISpec. Not sure about the best way to model this, input welcomed. o added new code to AssociativeSpec and IndexedSpec to support the new ISpecWithRef type of spec where the contained spec needs to be aware of the containers data / structure. o added new spec types ref-string* and ref-bytes* for dynamic types where the length is stored in another spec. o added a hex-dump function capable of printing a human readable dump of nio ByteBuffers, netty ByteBufs, byte arrays, and Strings. Buffy has this. If accepted, octet will have one too (though faster, terser, and more configurable :). I find this very useful when trying to understand a binary format. o added tests for the new ref spec types. Not done: documentation
oh, and the version increment was just for my local testing. I can naturally pull that out to support whatever versioning cadence fits the project. |
many thanks, im currently traveling with very limited connectivity. i'll
review that once i have returned to my country.
On Sep 14, 2017 9:12 PM, "Matias Bjarland" <notifications@github.com> wrote:
oh, and the version increment was just for my local testing. I can
naturally pull that out to support whatever versioning cadence fits the
project.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAzfqdwEkN62WXz1ay0y6Dhh-fLOc-7xks5siXq5gaJpZM4PXaNR>
.
|
Any ballpark on timeframe here? Only asking as I have another library which I would like to push to clojars some time soonish which depends on the features in this PR. |
i will review(and probably merge) it thuesday of the next week
…On Sep 22, 2017 2:25 PM, "Matias Bjarland" ***@***.***> wrote:
Any ballpark on timeframe here? Only asking as I have another library
which I would like to push to clojars some time soonish which depends on
the features in this PR.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#11 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAzfqY9oPKbVCzteV5dPUpkfAMhI9QH2ks5sk6dSgaJpZM4PXaNR>
.
|
as a side note the hex-dump function currently supports byte buffers, byte arrays, and strings. Its trivial to extend this to say files. |
@mbjarland very nice work! I have reviewed it and it is excelent. I have one question, the vector-ref* has a TODO, is this something missing. I expect you go to implement it? |
|
Yes, the todo was more a note to self that I should probably implement a similar pattern for vectors. Will have to think that one through a bit. |
Also I have not considered the following two things:
Anyway, hopefully I did not break any composability aspects with this change. |
The next week or two will be tight for me with my dayjob, but if I get time I will try to fill in the documentation pieces for this change and perhaps consider the above composability aspect. The clojurescript stuff I would probably not be qualified to consider so if you have the chops that would be much appreciated. |
Adding support for dynamic specs where the length is stored in another spec, fixing a size issue with assoc spec, adding hex-dump function, set version to 1.0.2.
Input welcomed as I am somewhat new to clojure and some of the additions touch the core design of the library.
The reason for adding this is that a lot of binary formats out there do not store the string/byte-array/x length immediately preceding the data. Also the size of the length field (i.e. inte16 vs int32 etc) varies from binary format to binary format and can not be known beforehand.
Real world example from the zip file specification which I'm currently parsing with octet:
note thte file name (ref-string*), extra-field (ref-bytes*) and file comment (ref-string*) fields and their corresponding length fields further up in the specification. Using the new spec types in this pull request, the above could be represented as:
This pr also supports the equivalent syntax for indexed specs, replacing the keyword references with long indexes.
Also adding a hex-dump function, example usage:
details:
to array map so that it keeps insertion order even for assoc
specs larger than 10. Implemented assoc-ordered in
octet.util to support modifications
with ISpec. Not sure about the best way to model this,
input welcomed. ISpecWithRef indicates that the spec
needs to know about its surrounding AssociativeSpec or
IndexedSpec as the size of the spec is stored in another
spec in the surrounding spec.
support the new ISpecWithRef type of spec where the
contained spec needs to be aware of the containers
data / structure.
dynamic types where the length is stored in another
spec.
readable dump of nio ByteBuffers, netty ByteBufs, byte
arrays, and Strings. Buffy has this and as I like octet
better and find it extremely useful I figured it would be
a good addition. Compared to the buffy one, this
implementation is faster, terser, and more
configurable.
Not done: documentation. Will add documentation if this pull request is deemed sane.