]> git.proxmox.com Git - qemu.git/commitdiff
qapi: introduce "size" type
authorLaszlo Ersek <lersek@redhat.com>
Tue, 17 Jul 2012 14:17:07 +0000 (16:17 +0200)
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Mon, 23 Jul 2012 10:55:17 +0000 (11:55 +0100)
v1->v2:
- fall back to uint64 rather than int

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qapi/qapi-visit-core.c
qapi/qapi-visit-core.h
scripts/qapi.py

index d41595eaa1af3db8c47d0cadd60032cba563e604..7a82b63766410ce8c78e66fd8e4c633d113d7f62 100644 (file)
@@ -234,6 +234,13 @@ void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp)
     }
 }
 
+void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp)
+{
+    if (!error_is_set(errp)) {
+        (v->type_size ? v->type_size : v->type_uint64)(v, obj, name, errp);
+    }
+}
+
 void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp)
 {
     if (!error_is_set(errp)) {
index a19d70c1048a1f1f5dc8b081e6c781140a602c83..60acedac77e03f921f15f53fb6c12e8f14f45868 100644 (file)
@@ -60,6 +60,8 @@ struct Visitor
     void (*type_int16)(Visitor *v, int16_t *obj, const char *name, Error **errp);
     void (*type_int32)(Visitor *v, int32_t *obj, const char *name, Error **errp);
     void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error **errp);
+    /* visit_type_size() falls back to (*type_uint64)() if type_size is unset */
+    void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error **errp);
 };
 
 void visit_start_handle(Visitor *v, void **obj, const char *kind,
@@ -85,6 +87,7 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp);
 void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp);
 void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp);
 void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp);
+void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp);
 void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
 void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
 void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
index 1292476a7d70a7ff000e9d159958b3f28a9fdfd4..8082af3fcddb76285d7858547a95cd5ebb5d0334 100644 (file)
@@ -163,6 +163,8 @@ def c_type(name):
           name == 'int64' or name == 'uint8' or name == 'uint16' or
           name == 'uint32' or name == 'uint64'):
         return name + '_t'
+    elif name == 'size':
+        return 'uint64_t'
     elif name == 'bool':
         return 'bool'
     elif name == 'number':