Re: [Qemu-devel] [Qemu-block] [PATCH v14 11/21] qapi: add integer range support for QObjectInputVisitor
Kevin Wolfwrites: > Am 12.10.2016 um 17:50 hat Markus Armbruster geschrieben: >> "Daniel P. Berrange" writes: >> >> > The traditional CLI arg syntax allows two ways to specify >> > integer lists, either one value per key, or a range of >> > values per key. eg the following are identical: >> > >> > -arg foo=5,foo=6,foo=7 >> > -arg foo=5-7 >> > >> > This extends the QObjectInputVisitor so that it is able >> > to parse ranges and turn them into distinct list entries. >> > >> > This means that >> > >> > -arg foo=5-7 >> > >> > is treated as equivalent to >> > >> > -arg foo.0=5,foo.1=6,foo.2=7 >> > >> > Edge case tests are copied from test-opts-visitor to >> > ensure identical behaviour when parsing. >> > >> > Signed-off-by: Daniel P. Berrange > >> > @@ -329,21 +335,87 @@ static void >> > qobject_input_type_int64_autocast(Visitor *v, const char *name, >> >int64_t *obj, Error **errp) >> > { >> > QObjectInputVisitor *qiv = to_qiv(v); >> > -QString *qstr = qobject_to_qstring(qobject_input_get_object(qiv, name, >> > -true)); >> > +QString *qstr; >> > int64_t ret; >> > +const char *end = NULL; >> > +StackObject *tos; >> > +bool inlist = false; >> > + >> > +/* Preferentially generate values from a range, before >> > + * trying to consume another QList element */ >> > +tos = QSLIST_FIRST(>stack); >> > +if (tos) { >> > +if ((int64_t)tos->range_val < (int64_t)tos->range_limit) { >> > +*obj = tos->range_val + 1; >> > +tos->range_val++; >> >> Roundabout way to write >> >>*obj = tos->range_val++; > > *obj = ++tos->range_val, actually. Of course, thanks.
Re: [Qemu-devel] [Qemu-block] [PATCH v14 11/21] qapi: add integer range support for QObjectInputVisitor
Am 12.10.2016 um 17:50 hat Markus Armbruster geschrieben: > "Daniel P. Berrange"writes: > > > The traditional CLI arg syntax allows two ways to specify > > integer lists, either one value per key, or a range of > > values per key. eg the following are identical: > > > > -arg foo=5,foo=6,foo=7 > > -arg foo=5-7 > > > > This extends the QObjectInputVisitor so that it is able > > to parse ranges and turn them into distinct list entries. > > > > This means that > > > > -arg foo=5-7 > > > > is treated as equivalent to > > > > -arg foo.0=5,foo.1=6,foo.2=7 > > > > Edge case tests are copied from test-opts-visitor to > > ensure identical behaviour when parsing. > > > > Signed-off-by: Daniel P. Berrange > > @@ -329,21 +335,87 @@ static void qobject_input_type_int64_autocast(Visitor > > *v, const char *name, > >int64_t *obj, Error **errp) > > { > > QObjectInputVisitor *qiv = to_qiv(v); > > -QString *qstr = qobject_to_qstring(qobject_input_get_object(qiv, name, > > -true)); > > +QString *qstr; > > int64_t ret; > > +const char *end = NULL; > > +StackObject *tos; > > +bool inlist = false; > > + > > +/* Preferentially generate values from a range, before > > + * trying to consume another QList element */ > > +tos = QSLIST_FIRST(>stack); > > +if (tos) { > > +if ((int64_t)tos->range_val < (int64_t)tos->range_limit) { > > +*obj = tos->range_val + 1; > > +tos->range_val++; > > Roundabout way to write > >*obj = tos->range_val++; *obj = ++tos->range_val, actually. Kevin