qlit: use QLit prefix consistently
Rename from LiteralQ to QLit. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20170825105913.4060-4-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
28035bcdf4
commit
082696e767
|
@ -17,33 +17,33 @@
|
||||||
#include "qapi-types.h"
|
#include "qapi-types.h"
|
||||||
#include "qobject.h"
|
#include "qobject.h"
|
||||||
|
|
||||||
typedef struct LiteralQDictEntry LiteralQDictEntry;
|
typedef struct QLitDictEntry QLitDictEntry;
|
||||||
typedef struct LiteralQObject LiteralQObject;
|
typedef struct QLitObject QLitObject;
|
||||||
|
|
||||||
struct LiteralQObject {
|
struct QLitObject {
|
||||||
int type;
|
int type;
|
||||||
union {
|
union {
|
||||||
int64_t qnum;
|
int64_t qnum;
|
||||||
const char *qstr;
|
const char *qstr;
|
||||||
LiteralQDictEntry *qdict;
|
QLitDictEntry *qdict;
|
||||||
LiteralQObject *qlist;
|
QLitObject *qlist;
|
||||||
} value;
|
} value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LiteralQDictEntry {
|
struct QLitDictEntry {
|
||||||
const char *key;
|
const char *key;
|
||||||
LiteralQObject value;
|
QLitObject value;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define QLIT_QNUM(val) \
|
#define QLIT_QNUM(val) \
|
||||||
(LiteralQObject){.type = QTYPE_QNUM, .value.qnum = (val)}
|
(QLitObject){.type = QTYPE_QNUM, .value.qnum = (val)}
|
||||||
#define QLIT_QSTR(val) \
|
#define QLIT_QSTR(val) \
|
||||||
(LiteralQObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
|
(QLitObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
|
||||||
#define QLIT_QDICT(val) \
|
#define QLIT_QDICT(val) \
|
||||||
(LiteralQObject){.type = QTYPE_QDICT, .value.qdict = (val)}
|
(QLitObject){.type = QTYPE_QDICT, .value.qdict = (val)}
|
||||||
#define QLIT_QLIST(val) \
|
#define QLIT_QLIST(val) \
|
||||||
(LiteralQObject){.type = QTYPE_QLIST, .value.qlist = (val)}
|
(QLitObject){.type = QTYPE_QLIST, .value.qlist = (val)}
|
||||||
|
|
||||||
int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs);
|
int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs);
|
||||||
|
|
||||||
#endif /* QLIT_H */
|
#endif /* QLIT_H */
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
typedef struct QListCompareHelper {
|
typedef struct QListCompareHelper {
|
||||||
int index;
|
int index;
|
||||||
LiteralQObject *objs;
|
QLitObject *objs;
|
||||||
int result;
|
int result;
|
||||||
} QListCompareHelper;
|
} QListCompareHelper;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ static void compare_helper(QObject *obj, void *opaque)
|
||||||
compare_litqobj_to_qobj(&helper->objs[helper->index++], obj);
|
compare_litqobj_to_qobj(&helper->objs[helper->index++], obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs)
|
int compare_litqobj_to_qobj(QLitObject *lhs, QObject *rhs)
|
||||||
{
|
{
|
||||||
int64_t val;
|
int64_t val;
|
||||||
|
|
||||||
|
|
|
@ -1065,23 +1065,23 @@ static void simple_dict(void)
|
||||||
int i;
|
int i;
|
||||||
struct {
|
struct {
|
||||||
const char *encoded;
|
const char *encoded;
|
||||||
LiteralQObject decoded;
|
QLitObject decoded;
|
||||||
} test_cases[] = {
|
} test_cases[] = {
|
||||||
{
|
{
|
||||||
.encoded = "{\"foo\": 42, \"bar\": \"hello world\"}",
|
.encoded = "{\"foo\": 42, \"bar\": \"hello world\"}",
|
||||||
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
|
.decoded = QLIT_QDICT(((QLitDictEntry[]){
|
||||||
{ "foo", QLIT_QNUM(42) },
|
{ "foo", QLIT_QNUM(42) },
|
||||||
{ "bar", QLIT_QSTR("hello world") },
|
{ "bar", QLIT_QSTR("hello world") },
|
||||||
{ }
|
{ }
|
||||||
})),
|
})),
|
||||||
}, {
|
}, {
|
||||||
.encoded = "{}",
|
.encoded = "{}",
|
||||||
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
|
.decoded = QLIT_QDICT(((QLitDictEntry[]){
|
||||||
{ }
|
{ }
|
||||||
})),
|
})),
|
||||||
}, {
|
}, {
|
||||||
.encoded = "{\"foo\": 43}",
|
.encoded = "{\"foo\": 43}",
|
||||||
.decoded = QLIT_QDICT(((LiteralQDictEntry[]){
|
.decoded = QLIT_QDICT(((QLitDictEntry[]){
|
||||||
{ "foo", QLIT_QNUM(43) },
|
{ "foo", QLIT_QNUM(43) },
|
||||||
{ }
|
{ }
|
||||||
})),
|
})),
|
||||||
|
@ -1163,11 +1163,11 @@ static void simple_list(void)
|
||||||
int i;
|
int i;
|
||||||
struct {
|
struct {
|
||||||
const char *encoded;
|
const char *encoded;
|
||||||
LiteralQObject decoded;
|
QLitObject decoded;
|
||||||
} test_cases[] = {
|
} test_cases[] = {
|
||||||
{
|
{
|
||||||
.encoded = "[43,42]",
|
.encoded = "[43,42]",
|
||||||
.decoded = QLIT_QLIST(((LiteralQObject[]){
|
.decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QNUM(43),
|
QLIT_QNUM(43),
|
||||||
QLIT_QNUM(42),
|
QLIT_QNUM(42),
|
||||||
{ }
|
{ }
|
||||||
|
@ -1175,21 +1175,21 @@ static void simple_list(void)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.encoded = "[43]",
|
.encoded = "[43]",
|
||||||
.decoded = QLIT_QLIST(((LiteralQObject[]){
|
.decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QNUM(43),
|
QLIT_QNUM(43),
|
||||||
{ }
|
{ }
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.encoded = "[]",
|
.encoded = "[]",
|
||||||
.decoded = QLIT_QLIST(((LiteralQObject[]){
|
.decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
{ }
|
{ }
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.encoded = "[{}]",
|
.encoded = "[{}]",
|
||||||
.decoded = QLIT_QLIST(((LiteralQObject[]){
|
.decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QDICT(((LiteralQDictEntry[]){
|
QLIT_QDICT(((QLitDictEntry[]){
|
||||||
{},
|
{},
|
||||||
})),
|
})),
|
||||||
{},
|
{},
|
||||||
|
@ -1220,11 +1220,11 @@ static void simple_whitespace(void)
|
||||||
int i;
|
int i;
|
||||||
struct {
|
struct {
|
||||||
const char *encoded;
|
const char *encoded;
|
||||||
LiteralQObject decoded;
|
QLitObject decoded;
|
||||||
} test_cases[] = {
|
} test_cases[] = {
|
||||||
{
|
{
|
||||||
.encoded = " [ 43 , 42 ]",
|
.encoded = " [ 43 , 42 ]",
|
||||||
.decoded = QLIT_QLIST(((LiteralQObject[]){
|
.decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QNUM(43),
|
QLIT_QNUM(43),
|
||||||
QLIT_QNUM(42),
|
QLIT_QNUM(42),
|
||||||
{ }
|
{ }
|
||||||
|
@ -1232,12 +1232,12 @@ static void simple_whitespace(void)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]",
|
.encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]",
|
||||||
.decoded = QLIT_QLIST(((LiteralQObject[]){
|
.decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QNUM(43),
|
QLIT_QNUM(43),
|
||||||
QLIT_QDICT(((LiteralQDictEntry[]){
|
QLIT_QDICT(((QLitDictEntry[]){
|
||||||
{ "h", QLIT_QSTR("b") },
|
{ "h", QLIT_QSTR("b") },
|
||||||
{ }})),
|
{ }})),
|
||||||
QLIT_QLIST(((LiteralQObject[]){
|
QLIT_QLIST(((QLitObject[]){
|
||||||
{ }})),
|
{ }})),
|
||||||
QLIT_QNUM(42),
|
QLIT_QNUM(42),
|
||||||
{ }
|
{ }
|
||||||
|
@ -1245,13 +1245,13 @@ static void simple_whitespace(void)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]",
|
.encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]",
|
||||||
.decoded = QLIT_QLIST(((LiteralQObject[]){
|
.decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QNUM(43),
|
QLIT_QNUM(43),
|
||||||
QLIT_QDICT(((LiteralQDictEntry[]){
|
QLIT_QDICT(((QLitDictEntry[]){
|
||||||
{ "h", QLIT_QSTR("b") },
|
{ "h", QLIT_QSTR("b") },
|
||||||
{ "a", QLIT_QNUM(32) },
|
{ "a", QLIT_QNUM(32) },
|
||||||
{ }})),
|
{ }})),
|
||||||
QLIT_QLIST(((LiteralQObject[]){
|
QLIT_QLIST(((QLitObject[]){
|
||||||
{ }})),
|
{ }})),
|
||||||
QLIT_QNUM(42),
|
QLIT_QNUM(42),
|
||||||
{ }
|
{ }
|
||||||
|
@ -1282,10 +1282,10 @@ static void simple_varargs(void)
|
||||||
{
|
{
|
||||||
QObject *embedded_obj;
|
QObject *embedded_obj;
|
||||||
QObject *obj;
|
QObject *obj;
|
||||||
LiteralQObject decoded = QLIT_QLIST(((LiteralQObject[]){
|
QLitObject decoded = QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QNUM(1),
|
QLIT_QNUM(1),
|
||||||
QLIT_QNUM(2),
|
QLIT_QNUM(2),
|
||||||
QLIT_QLIST(((LiteralQObject[]){
|
QLIT_QLIST(((QLitObject[]){
|
||||||
QLIT_QNUM(32),
|
QLIT_QNUM(32),
|
||||||
QLIT_QNUM(42),
|
QLIT_QNUM(42),
|
||||||
{}})),
|
{}})),
|
||||||
|
|
Loading…
Reference in New Issue