From c4d9412483bc561cef53a784e9f28b827e010e7b Mon Sep 17 00:00:00 2001 From: "Serge A. Zaitsev" Date: Mon, 27 Dec 2010 17:05:22 +0200 Subject: [PATCH] Some comments added in json.c --- jsmn.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/jsmn.c b/jsmn.c index d02c2bb..3f2b149 100644 --- a/jsmn.c +++ b/jsmn.c @@ -2,6 +2,9 @@ #include "jsmn.h" +/** + * Allocates a fresh unused token from the token pull. + */ static jsmntok_t *jsmn_get_token(jsmn_parser *parser) { unsigned int i; jsmntok_t *tokens = parser->tokens; @@ -14,12 +17,20 @@ static jsmntok_t *jsmn_get_token(jsmn_parser *parser) { return NULL; } -static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, int start, int end) { +/** + * Fills token type and boundaries. + */ +static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, + int start, int end) { token->type = type; token->start = start; token->end = end; } +/** + * Creates a new parser based over a given buffer with an array of tokens + * available. + */ void jsmn_init_parser(jsmn_parser *parser, const char *js, jsmntok_t *tokens, unsigned int num_tokens) { unsigned int i; @@ -35,6 +46,9 @@ void jsmn_init_parser(jsmn_parser *parser, const char *js, } } +/** + * Fills next available token with JSON primitive. + */ static int jsmn_parse_primitive(jsmn_parser *parser) { const char *js; jsmntok_t *token; @@ -64,6 +78,9 @@ static int jsmn_parse_primitive(jsmn_parser *parser) { return JSMN_ERROR_PART; } +/** + * Filsl next token with JSON string. + */ static int jsmn_parse_string(jsmn_parser *parser) { const char *js; jsmntok_t *token; @@ -110,6 +127,9 @@ static int jsmn_parse_string(jsmn_parser *parser) { return JSMN_ERROR_PART; } +/** + * Parse JSON string and fill tokens. + */ jsmnerr_t jsmn_parse(jsmn_parser *parser) { int r; unsigned int i;