diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-08-23 18:40:18 +0200 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2018-08-24 20:26:37 +0200 |
commit | abe7c2067c21a89c6fd4cf2d8ba2fa37160d1d55 (patch) | |
tree | 9b47fe3f0c5dc56c37c6ba9ef7072ea6d7276706 /qobject/json-parser.c | |
parent | a2731e08ee8633fcdc2af944b8f8f315678f7669 (diff) |
json: Make JSONToken opaque outside json-parser.c
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180823164025.12553-52-armbru@redhat.com>
Diffstat (limited to 'qobject/json-parser.c')
-rw-r--r-- | qobject/json-parser.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/qobject/json-parser.c b/qobject/json-parser.c index e9a9f937f3..a247875f14 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -26,6 +26,13 @@ #include "qapi/qmp/json-lexer.h" #include "qapi/qmp/json-streamer.h" +struct JSONToken { + JSONTokenType type; + int x; + int y; + char str[]; +}; + typedef struct JSONParserContext { Error *err; @@ -538,6 +545,18 @@ static QObject *parse_value(JSONParserContext *ctxt, va_list *ap) } } +JSONToken *json_token(JSONTokenType type, int x, int y, GString *tokstr) +{ + JSONToken *token = g_malloc(sizeof(JSONToken) + tokstr->len + 1); + + token->type = type; + memcpy(token->str, tokstr->str, tokstr->len); + token->str[tokstr->len] = 0; + token->x = x; + token->y = y; + return token; +} + QObject *json_parser_parse(GQueue *tokens, va_list *ap, Error **errp) { JSONParserContext ctxt = { .buf = tokens }; |