Message ID | 1337683555-13301-3-git-send-email-lersek@redhat.com |
---|---|
State | New |
Headers | show |
Il 22/05/2012 12:45, Laszlo Ersek ha scritto: > Signed-off-by: Laszlo Ersek <lersek@redhat.com> > --- > qapi/qapi-visit-core.h | 4 ++++ > qapi/qapi-visit-core.c | 7 +++++++ > scripts/qapi.py | 2 +- > 3 files changed, 12 insertions(+), 1 deletions(-) > > diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h > index e850746..bab2fec 100644 > --- a/qapi/qapi-visit-core.h > +++ b/qapi/qapi-visit-core.h > @@ -39,6 +39,9 @@ struct Visitor > const char *kind, const char *name, Error **errp); > > void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp); > + /* visit_type_size() falls back to (*type_int)() if type_size is unset */ > + void (*type_size)(Visitor *v, int64_t *obj, const char *name, > + Error **errp); > void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp); > void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp); > void (*type_number)(Visitor *v, double *obj, const char *name, > @@ -69,6 +72,7 @@ void visit_end_optional(Visitor *v, Error **errp); > void visit_type_enum(Visitor *v, int *obj, const char *strings[], > const char *kind, const char *name, Error **errp); > void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp); > +void visit_type_size(Visitor *v, int64_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); > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > index df1ed5c..ea31cf5 100644 > --- a/qapi/qapi-visit-core.c > +++ b/qapi/qapi-visit-core.c > @@ -95,6 +95,13 @@ void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp) > } > } > > +void visit_type_size(Visitor *v, int64_t *obj, const char *name, Error **errp) > +{ > + if (!error_is_set(errp)) { > + (v->type_size ? v->type_size : v->type_int)(v, obj, name, errp); > + } > +} > + > void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) > { > if (!error_is_set(errp)) { > diff --git a/scripts/qapi.py b/scripts/qapi.py > index e062336..6aebb0f 100644 > --- a/scripts/qapi.py > +++ b/scripts/qapi.py > @@ -157,7 +157,7 @@ def is_enum(name): > def c_type(name): > if name == 'str': > return 'char *' > - elif name == 'int': > + elif name == 'int' or name == 'size': > return 'int64_t' > elif name == 'bool': > return 'bool' Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Paolo
diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h index e850746..bab2fec 100644 --- a/qapi/qapi-visit-core.h +++ b/qapi/qapi-visit-core.h @@ -39,6 +39,9 @@ struct Visitor const char *kind, const char *name, Error **errp); void (*type_int)(Visitor *v, int64_t *obj, const char *name, Error **errp); + /* visit_type_size() falls back to (*type_int)() if type_size is unset */ + void (*type_size)(Visitor *v, int64_t *obj, const char *name, + Error **errp); void (*type_bool)(Visitor *v, bool *obj, const char *name, Error **errp); void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp); void (*type_number)(Visitor *v, double *obj, const char *name, @@ -69,6 +72,7 @@ void visit_end_optional(Visitor *v, Error **errp); void visit_type_enum(Visitor *v, int *obj, const char *strings[], const char *kind, const char *name, Error **errp); void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp); +void visit_type_size(Visitor *v, int64_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); diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index df1ed5c..ea31cf5 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -95,6 +95,13 @@ void visit_type_int(Visitor *v, int64_t *obj, const char *name, Error **errp) } } +void visit_type_size(Visitor *v, int64_t *obj, const char *name, Error **errp) +{ + if (!error_is_set(errp)) { + (v->type_size ? v->type_size : v->type_int)(v, obj, name, errp); + } +} + void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) { if (!error_is_set(errp)) { diff --git a/scripts/qapi.py b/scripts/qapi.py index e062336..6aebb0f 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -157,7 +157,7 @@ def is_enum(name): def c_type(name): if name == 'str': return 'char *' - elif name == 'int': + elif name == 'int' or name == 'size': return 'int64_t' elif name == 'bool': return 'bool'
Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- qapi/qapi-visit-core.h | 4 ++++ qapi/qapi-visit-core.c | 7 +++++++ scripts/qapi.py | 2 +- 3 files changed, 12 insertions(+), 1 deletions(-)