#include "qapi-types.h"
#include "qobject.h"
-typedef struct LiteralQDictEntry LiteralQDictEntry;
-typedef struct LiteralQObject LiteralQObject;
+typedef struct QLitDictEntry QLitDictEntry;
+typedef struct QLitObject QLitObject;
-struct LiteralQObject {
+struct QLitObject {
int type;
union {
int64_t qnum;
const char *qstr;
- LiteralQDictEntry *qdict;
- LiteralQObject *qlist;
+ QLitDictEntry *qdict;
+ QLitObject *qlist;
} value;
};
-struct LiteralQDictEntry {
+struct QLitDictEntry {
const char *key;
- LiteralQObject value;
+ QLitObject value;
};
#define QLIT_QNUM(val) \
- (LiteralQObject){.type = QTYPE_QNUM, .value.qnum = (val)}
+ (QLitObject){.type = QTYPE_QNUM, .value.qnum = (val)}
#define QLIT_QSTR(val) \
- (LiteralQObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
+ (QLitObject){.type = QTYPE_QSTRING, .value.qstr = (val)}
#define QLIT_QDICT(val) \
- (LiteralQObject){.type = QTYPE_QDICT, .value.qdict = (val)}
+ (QLitObject){.type = QTYPE_QDICT, .value.qdict = (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 */
int i;
struct {
const char *encoded;
- LiteralQObject decoded;
+ QLitObject decoded;
} test_cases[] = {
{
.encoded = "{\"foo\": 42, \"bar\": \"hello world\"}",
- .decoded = QLIT_QDICT(((LiteralQDictEntry[]){
+ .decoded = QLIT_QDICT(((QLitDictEntry[]){
{ "foo", QLIT_QNUM(42) },
{ "bar", QLIT_QSTR("hello world") },
{ }
})),
}, {
.encoded = "{}",
- .decoded = QLIT_QDICT(((LiteralQDictEntry[]){
+ .decoded = QLIT_QDICT(((QLitDictEntry[]){
{ }
})),
}, {
.encoded = "{\"foo\": 43}",
- .decoded = QLIT_QDICT(((LiteralQDictEntry[]){
+ .decoded = QLIT_QDICT(((QLitDictEntry[]){
{ "foo", QLIT_QNUM(43) },
{ }
})),
int i;
struct {
const char *encoded;
- LiteralQObject decoded;
+ QLitObject decoded;
} test_cases[] = {
{
.encoded = "[43,42]",
- .decoded = QLIT_QLIST(((LiteralQObject[]){
+ .decoded = QLIT_QLIST(((QLitObject[]){
QLIT_QNUM(43),
QLIT_QNUM(42),
{ }
},
{
.encoded = "[43]",
- .decoded = QLIT_QLIST(((LiteralQObject[]){
+ .decoded = QLIT_QLIST(((QLitObject[]){
QLIT_QNUM(43),
{ }
})),
},
{
.encoded = "[]",
- .decoded = QLIT_QLIST(((LiteralQObject[]){
+ .decoded = QLIT_QLIST(((QLitObject[]){
{ }
})),
},
{
.encoded = "[{}]",
- .decoded = QLIT_QLIST(((LiteralQObject[]){
- QLIT_QDICT(((LiteralQDictEntry[]){
+ .decoded = QLIT_QLIST(((QLitObject[]){
+ QLIT_QDICT(((QLitDictEntry[]){
{},
})),
{},
int i;
struct {
const char *encoded;
- LiteralQObject decoded;
+ QLitObject decoded;
} test_cases[] = {
{
.encoded = " [ 43 , 42 ]",
- .decoded = QLIT_QLIST(((LiteralQObject[]){
+ .decoded = QLIT_QLIST(((QLitObject[]){
QLIT_QNUM(43),
QLIT_QNUM(42),
{ }
},
{
.encoded = " [ 43 , { 'h' : 'b' }, [ ], 42 ]",
- .decoded = QLIT_QLIST(((LiteralQObject[]){
+ .decoded = QLIT_QLIST(((QLitObject[]){
QLIT_QNUM(43),
- QLIT_QDICT(((LiteralQDictEntry[]){
+ QLIT_QDICT(((QLitDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ }})),
- QLIT_QLIST(((LiteralQObject[]){
+ QLIT_QLIST(((QLitObject[]){
{ }})),
QLIT_QNUM(42),
{ }
},
{
.encoded = " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]",
- .decoded = QLIT_QLIST(((LiteralQObject[]){
+ .decoded = QLIT_QLIST(((QLitObject[]){
QLIT_QNUM(43),
- QLIT_QDICT(((LiteralQDictEntry[]){
+ QLIT_QDICT(((QLitDictEntry[]){
{ "h", QLIT_QSTR("b") },
{ "a", QLIT_QNUM(32) },
{ }})),
- QLIT_QLIST(((LiteralQObject[]){
+ QLIT_QLIST(((QLitObject[]){
{ }})),
QLIT_QNUM(42),
{ }
{
QObject *embedded_obj;
QObject *obj;
- LiteralQObject decoded = QLIT_QLIST(((LiteralQObject[]){
+ QLitObject decoded = QLIT_QLIST(((QLitObject[]){
QLIT_QNUM(1),
QLIT_QNUM(2),
- QLIT_QLIST(((LiteralQObject[]){
+ QLIT_QLIST(((QLitObject[]){
QLIT_QNUM(32),
QLIT_QNUM(42),
{}})),