Skip to content

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

Merged
merged 2 commits into from
Dec 3, 2014
Merged

sys: add Universal Binary JSON module (UBJSON) #1659

merged 2 commits into from
Dec 3, 2014

Conversation

Kijewski
Copy link
Contributor

http://ubjson.org/

Right now I only implemented reading and write, but this and 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.

@Kijewski Kijewski added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Sep 12, 2014
@kaspar030
Copy link
Contributor

Nice!

@mehlis
Copy link
Contributor

mehlis commented Sep 13, 2014

nice ! I think the message pack lib is that small, that we can integrate it as well...

@@ -0,0 +1,252 @@
#include <stdio.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license missing

@Kijewski
Copy link
Contributor Author

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.

@Kijewski Kijewski added Type: new feature The issue requests / The PR implemements a new feature for RIOT and removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Sep 23, 2014
@LudwigKnuepfer
Copy link
Member

We want less examples, not more.

@OlegHahm
Copy link
Member

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; }
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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;

Copy link
Member

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 (:

Copy link
Member

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.

@LudwigKnuepfer
Copy link
Member

@OlegHahm so you are in favor of having this example?

@Kijewski Kijewski added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet State: waiting for other PR State: The PR requires another PR to be merged first and removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Sep 24, 2014
@Kijewski
Copy link
Contributor Author

@OlegHahm
Copy link
Member

@LudwigOrtmann, not as part of the main RIOT repository, I would say.

@Kijewski
Copy link
Contributor Author

Well, the apps repo is gone.

@LudwigKnuepfer
Copy link
Member

No, it just lives in hiding.

@LudwigKnuepfer
Copy link
Member

Well, living isn't the best term, but it exists.

@Kijewski
Copy link
Contributor Author

@LudwigOrtmann, well, were is it hiding then? :)

@LudwigKnuepfer
Copy link
Member

@LudwigKnuepfer
Copy link
Member

But I assure you, it's as good as dead.

@Kijewski Kijewski added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet and removed State: waiting for other PR State: The PR requires another PR to be merged first State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Oct 10, 2014
@OlegHahm
Copy link
Member

Rebase.

@Kijewski
Copy link
Contributor Author

The unittests need #1990 to compile.

@miri64
Copy link
Member

miri64 commented Nov 11, 2014

#1990 is merged

/* case UBJSON_MARKER_HP_NUMBER:
* ...
* break;
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove?

Copy link
Contributor Author

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.

Copy link
Member

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)

@OlegHahm OlegHahm added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Dec 3, 2014
@OlegHahm
Copy link
Member

OlegHahm commented Dec 3, 2014

From my point that's an ACK. @authmillenon, @cgundogan, wanna add something?

@miri64
Copy link
Member

miri64 commented Dec 3, 2014

Nope. Please SQUASH

@Kijewski
Copy link
Contributor Author

Kijewski commented Dec 3, 2014

Rebased, squashed, 3092aed unpicked.

}
#endif

#endif
Copy link
Member

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.

@cgundogan
Copy link
Member

Looks all fine to me, but Travis complains about: ERROR: The following new files generate doxygen warnings: sys/include/ubjson.h

https://travis-ci.org/RIOT-OS/RIOT/builds/42878709

@OlegHahm
Copy link
Member

OlegHahm commented Dec 3, 2014

First strik of the doxygen checker. :-)

RIOT/sys/include/ubjson.h:218: warning: Member ubjson_cookie_t (typedef) of group sys_ubjson is not documented.
RIOT/sys/include/ubjson.h:218: warning: Member ubjson_cookie_t (typedef) of group sys_ubjson is not documented.
RIOT/sys/include/ubjson.h:248: warning: Member rw (variable) of class ubjson_cookie is not documented.
RIOT/sys/include/ubjson.h:252: warning: Member callback (variable) of class ubjson_cookie is not documented.
RIOT/sys/include/ubjson.h:254: warning: Member marker (variable) of class ubjson_cookie is not documented.

@OlegHahm OlegHahm removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Dec 3, 2014
@LudwigKnuepfer LudwigKnuepfer added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Dec 3, 2014
@Kijewski
Copy link
Contributor Author

Kijewski commented Dec 3, 2014

$ ./dist/tools/doccheck/check.sh master || exit
ERROR: The following new files generate doxygen warnings:
sys/include/ubjson.h

Cannot reproduce the error at home.

@LudwigKnuepfer
Copy link
Member

So, we want to use our own version of doxygen in addition to our own build of cppcheck... sheesh.

@Kijewski
Copy link
Contributor Author

Kijewski commented Dec 3, 2014

The problem was my master != origin/master. :)

@LudwigKnuepfer
Copy link
Member

Sure? I checked out your branch and rebased on an up-to-date master (at least I think I did).

@LudwigKnuepfer
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/retreive/retrieve

@LudwigKnuepfer
Copy link
Member

That's all the spelling errors my checker found =)

@Kijewski Kijewski removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Dec 3, 2014
@Kijewski
Copy link
Contributor Author

Kijewski commented Dec 3, 2014

Squashed

@OlegHahm
Copy link
Member

OlegHahm commented Dec 3, 2014

ACK and go.

OlegHahm added a commit that referenced this pull request Dec 3, 2014
sys: add  Universal Binary JSON module (UBJSON)
@OlegHahm OlegHahm merged commit f386de6 into RIOT-OS:master Dec 3, 2014
@Kijewski
Copy link
Contributor Author

Kijewski commented Dec 3, 2014

Yay

@Kijewski Kijewski deleted the ubjson branch December 3, 2014 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants