Message ID | 1363200988-17865-3-git-send-email-jschopp@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
You need to adjust your patch script. This will make the summary in git be: qapi_c_arrays.gdiff Forward ported Mike's previously sent patch (see http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg05782.html ) ... Regards, Anthony Liguori Joel Schopp <jschopp@linux.vnet.ibm.com> writes: > Forward ported Mike's previously sent patch > (see http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg05782.html ) in my > series since it implements a qapi array interface the ASN.1 BER visitor needs. > > Generally these will be serialized into lists, but the > representation can be of any form so long as it can > be deserialized into a single-dimension C array. > > Cc: Michael Tsirkin <mst@redhat.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> > Signed-off-by: Joel Schopp <jschopp@linux.vnet.ibm.com> > --- > include/qapi/visitor-impl.h | 4 ++++ > include/qapi/visitor.h | 4 ++++ > qapi/qapi-visit-core.c | 25 +++++++++++++++++++++++++ > 3 files changed, 33 insertions(+) > > diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h > index 5159964..9d87f2d 100644 > --- a/include/qapi/visitor-impl.h > +++ b/include/qapi/visitor-impl.h > @@ -34,6 +34,10 @@ struct Visitor > void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp); > void (*type_number)(Visitor *v, double *obj, const char *name, > Error **errp); > + void (*start_carray)(Visitor *v, void **obj, const char *name, > + size_t elem_count, size_t elem_size, Error **errp); > + void (*next_carray)(Visitor *v, Error **errp); > + void (*end_carray)(Visitor *v, Error **errp); > > /* May be NULL */ > void (*start_optional)(Visitor *v, bool *present, const char *name, > diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h > index 1fef18c..74bddef 100644 > --- a/include/qapi/visitor.h > +++ b/include/qapi/visitor.h > @@ -51,5 +51,9 @@ 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); > +void visit_start_carray(Visitor *v, void **obj, const char *name, > + size_t elem_count, size_t elem_size, Error **errp); > +void visit_next_carray(Visitor *v, Error **errp); > +void visit_end_carray(Visitor *v, Error **errp); > > #endif > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > index 401ee6e..d9982f8 100644 > --- a/qapi/qapi-visit-core.c > +++ b/qapi/qapi-visit-core.c > @@ -313,3 +313,28 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[], > g_free(enum_str); > *obj = value; > } > + > +void visit_start_carray(Visitor *v, void **obj, const char *name, > + size_t elem_count, size_t elem_size, Error **errp) > +{ > + g_assert(v->start_carray); > + if (!error_is_set(errp)) { > + v->start_carray(v, obj, name, elem_count, elem_size, errp); > + } > +} > + > +void visit_next_carray(Visitor *v, Error **errp) > +{ > + g_assert(v->next_carray); > + if (!error_is_set(errp)) { > + v->next_carray(v, errp); > + } > +} > + > +void visit_end_carray(Visitor *v, Error **errp) > +{ > + g_assert(v->end_carray); > + if (!error_is_set(errp)) { > + v->end_carray(v, errp); > + } > +} > -- > 1.7.10.4
On 03/13/2013 02:56 PM, Joel Schopp wrote: > Forward ported Mike's previously sent patch > (see http://lists.gnu.org/archive/html/qemu-devel/2012-10/msg05782.html ) in my > series since it implements a qapi array interface the ASN.1 BER visitor needs. > > Generally these will be serialized into lists, but the > representation can be of any form so long as it can > be deserialized into a single-dimension C array. > > Cc: Michael Tsirkin <mst@redhat.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com> > Signed-off-by: Joel Schopp <jschopp@linux.vnet.ibm.com> > --- > include/qapi/visitor-impl.h | 4 ++++ > include/qapi/visitor.h | 4 ++++ > qapi/qapi-visit-core.c | 25 +++++++++++++++++++++++++ > 3 files changed, 33 insertions(+) > > +++ b/include/qapi/visitor.h > @@ -51,5 +51,9 @@ 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); > +void visit_start_carray(Visitor *v, void **obj, const char *name, > + size_t elem_count, size_t elem_size, Error **errp); > +void visit_next_carray(Visitor *v, Error **errp); > +void visit_end_carray(Visitor *v, Error **errp); > > #endif > diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c > index 401ee6e..d9982f8 100644 > --- a/qapi/qapi-visit-core.c > +++ b/qapi/qapi-visit-core.c > @@ -313,3 +313,28 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[], > g_free(enum_str); > *obj = value; > } > + > +void visit_start_carray(Visitor *v, void **obj, const char *name, > + size_t elem_count, size_t elem_size, Error **errp) > +{ > + g_assert(v->start_carray); > + if (!error_is_set(errp)) { > + v->start_carray(v, obj, name, elem_count, elem_size, errp); > + } So this is a c-like array with a given number of elements and each element having to have the same size? As long as all use cases for QEMU can live with this, I guess it's fine, though an array of sized buffers, each with different size, may be more 'general'. How many other callers are there so that we can talk about disparities between visitors as mentioned in the comment in 5/9? At least we would have immediate callers for the sized buffer interface. http://lists.gnu.org/archive/html/qemu-devel/2013-03/msg02254.html Regards, Stefan
diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index 5159964..9d87f2d 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -34,6 +34,10 @@ struct Visitor void (*type_str)(Visitor *v, char **obj, const char *name, Error **errp); void (*type_number)(Visitor *v, double *obj, const char *name, Error **errp); + void (*start_carray)(Visitor *v, void **obj, const char *name, + size_t elem_count, size_t elem_size, Error **errp); + void (*next_carray)(Visitor *v, Error **errp); + void (*end_carray)(Visitor *v, Error **errp); /* May be NULL */ void (*start_optional)(Visitor *v, bool *present, const char *name, diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 1fef18c..74bddef 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -51,5 +51,9 @@ 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); +void visit_start_carray(Visitor *v, void **obj, const char *name, + size_t elem_count, size_t elem_size, Error **errp); +void visit_next_carray(Visitor *v, Error **errp); +void visit_end_carray(Visitor *v, Error **errp); #endif diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 401ee6e..d9982f8 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -313,3 +313,28 @@ void input_type_enum(Visitor *v, int *obj, const char *strings[], g_free(enum_str); *obj = value; } + +void visit_start_carray(Visitor *v, void **obj, const char *name, + size_t elem_count, size_t elem_size, Error **errp) +{ + g_assert(v->start_carray); + if (!error_is_set(errp)) { + v->start_carray(v, obj, name, elem_count, elem_size, errp); + } +} + +void visit_next_carray(Visitor *v, Error **errp) +{ + g_assert(v->next_carray); + if (!error_is_set(errp)) { + v->next_carray(v, errp); + } +} + +void visit_end_carray(Visitor *v, Error **errp) +{ + g_assert(v->end_carray); + if (!error_is_set(errp)) { + v->end_carray(v, errp); + } +}