-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys: add Universal Binary JSON module (UBJSON) #1659
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
Conversation
Nice! |
nice ! I think the message pack lib is that small, that we can integrate it as well... |
@@ -0,0 +1,252 @@ | |||
#include <stdio.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license missing
Reading and writing is implemented. The example application was moved to examples. Licenses added for every file. All functions have doxygen. A few unittests are implemented. Should be ready to merge. |
We want less examples, not more. |
Although I've probably stated exactly that recently, it's not entirely true from my perspective: I would say we do not want to increase the number of examples, but demonstrate more features. I'll open an issue for that. |
*content = (marker == UBJSON_MARKER_TRUE); | ||
break; | ||
|
||
if (false) { case UBJSON_MARKER_INT8: *content = UBJSON_INT32_INT8; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is your attention here to comment out these case statements until a later phase of implementation, or did you just forget to delete them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shall reduce duplicated code.
Labels inside an if (false)
block are still valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. the lines
if (false) { case UBJSON_MARKER_INT8: *content = UBJSON_INT32_INT8; }
if (false) { case UBJSON_MARKER_INT16: *content = UBJSON_INT32_INT16; }
abc;
do the same as:
case UBJSON_MARKER_INT8:
case UBJSON_MARKER_INT16:
switch (marker) {
case UBJSON_MARKER_INT8: *content = UBJSON_INT32_INT8; break;
case UBJSON_MARKER_INT16: *content = UBJSON_INT32_INT16; break;
}
abc;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I wasn't aware of this neat trick. Thanks for the hint (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still vote for the more readable version - including newlines.
@OlegHahm so you are in favor of having this example? |
@LudwigOrtmann, not as part of the main RIOT repository, I would say. |
Well, the apps repo is gone. |
No, it just lives in hiding. |
Well, living isn't the best term, but it exists. |
@LudwigOrtmann, well, were is it hiding then? :) |
But I assure you, it's as good as dead. |
Rebase. |
The unittests need #1990 to compile. |
#1990 is merged |
/* case UBJSON_MARKER_HP_NUMBER: | ||
* ... | ||
* break; | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep the comments for high-precision numbers. Just so I know where to add code if I need to implement them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: please add this as a comment to the code (the NOTE
tag is nice for stuff like this)
From my point that's an ACK. @authmillenon, @cgundogan, wanna add something? |
Nope. Please SQUASH |
Rebased, squashed, 3092aed unpicked. |
} | ||
#endif | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the guard name to the closing #endif
: #endif /* ifndef UBJSON__INTERNAL_H__ */
I know,this is sugar.., but I like how you used this notation in your other files.
Looks all fine to me, but Travis complains about: ERROR: The following new files generate doxygen warnings: sys/include/ubjson.h |
First strik of the doxygen checker. :-)
|
Cannot reproduce the error at home. |
So, we want to use our own version of doxygen in addition to our own build of cppcheck... sheesh. |
The problem was my master != origin/master. :) |
Sure? I checked out your branch and rebased on an up-to-date master (at least I think I did). |
Ah - the fix was already included. |
/** | ||
* @brief A cookie passed between the read and write functions. | ||
* @details You probably want to wrap the cookie in some other data structure, | ||
* which you retreive with container_of() in the callback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/retreive/retrieve
That's all the spelling errors my checker found =) |
Squashed |
ACK and go. |
sys: add Universal Binary JSON module (UBJSON)
Yay |
→ http://ubjson.org/
Right now I
onlyimplemented reading and write,but thisand it should work.It is an SAX/expat-style parser, i.e. you provide a read function and a callback function.
The example application is a pretty printer.
I implemented the dialect that's described on their homepage, which is quite different to the Wikipedia article.
The advantage of UBJSON is that it is
I don't know CBOR.
UBJSON is -- like JSON -- schemaless.