[Mesa-dev] [PATCH 2/3] intel: aubinator: load fields values from xml data
Gandikota, Sirisha
sirisha.gandikota at intel.com
Tue Nov 1 21:54:22 UTC 2016
>-----Original Message-----
>From: mesa-dev [mailto:mesa-dev-bounces at lists.freedesktop.org] On Behalf Of
>Lionel Landwerlin
>Sent: Monday, October 17, 2016 1:57 PM
>To: mesa-dev at lists.freedesktop.org
>Cc: Landwerlin, Lionel G <lionel.g.landwerlin at intel.com>
>Subject: [Mesa-dev] [PATCH 2/3] intel: aubinator: load fields values from xml
>data
>
>Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
>---
> src/intel/tools/decoder.c | 31 +++++++++++++++++++++++++++++++
>src/intel/tools/decoder.h | 9 +++++++++
> 2 files changed, 40 insertions(+)
>
>diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c index
>cab5271..88ba5c0 100644
>--- a/src/intel/tools/decoder.c
>+++ b/src/intel/tools/decoder.c
>@@ -303,6 +303,21 @@ create_field(struct parser_context *ctx, const char
>**atts)
> return field;
> }
>
>+static struct gen_value *
>+create_value(struct parser_context *ctx, const char **atts) {
>+ struct gen_value *value = xzalloc(sizeof(*value));
>+
>+ for (int i = 0; atts[i]; i += 2) {
>+ if (strcmp(atts[i], "name") == 0)
>+ value->name = xstrdup(atts[i + 1]);
>+ else if (strcmp(atts[i], "value") == 0)
>+ value->value = strtoul(atts[i + 1], NULL, 0);
>+ }
>+
>+ return value;
>+}
>+
> static void
> start_element(void *data, const char *element_name, const char **atts) { @@
>-352,6 +367,22 @@ start_element(void *data, const char *element_name, const
>char **atts)
> } while (ctx->group->group_count > 0);
> } else if (strcmp(element_name, "enum") == 0) {
> } else if (strcmp(element_name, "value") == 0) {
>+ if (ctx->nfields > 0) {
>+ struct gen_field *field = ctx->fields[ctx->nfields - 1];
>+ if (field->n_allocated_values <= field->n_values) {
>+ if (field->n_allocated_values == 0) {
>+ field->n_allocated_values = 2;
>+ field->values =
>+ xzalloc(sizeof(field->values[0]) * field->n_allocated_values);
>+ } else {
>+ field->n_allocated_values *= 2;
>+ field->values =
>+ realloc(field->values,
>+ sizeof(field->values[0]) * field->n_allocated_values);
>+ }
>+ }
>+ field->values[field->n_values++] = create_value(ctx, atts);
>+ }
> }
> }
>
>diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h index
>9a677be..ecc9ff1 100644
>--- a/src/intel/tools/decoder.h
>+++ b/src/intel/tools/decoder.h
>@@ -99,6 +99,15 @@ struct gen_field {
> struct gen_type type;
> bool has_default;
> uint32_t default_value;
>+
>+ struct gen_value **values;
>+ uint32_t n_values;
>+ uint32_t n_allocated_values;
>+};
>+
>+struct gen_value {
>+ char *name;
>+ uint64_t value;
> };
>
> void gen_field_iterator_init(struct gen_field_iterator *iter,
>--
>2.9.3
>
[SG] Works for me
Reviewed-by: Sirisha Gandikota <sirisha.gandikota at intel.com>
>_______________________________________________
>mesa-dev mailing list
>mesa-dev at lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list