+
+struct definition *lookup_definition(const struct definition *definition,
+ const char *field_name)
+{
+ struct definition_scope *scope = get_definition_scope(definition);
+
+ if (!scope)
+ return NULL;
+
+ return lookup_field_definition_scope(g_quark_from_string(field_name),
+ scope);
+}
+
+struct definition_integer *lookup_integer(const struct definition *definition,
+ const char *field_name,
+ int signedness)
+{
+ struct definition *lookup;
+ struct definition_integer *lookup_integer;
+
+ lookup = lookup_definition(definition, field_name);
+ if (!lookup)
+ return NULL;
+ if (lookup->declaration->id != CTF_TYPE_INTEGER)
+ return NULL;
+ lookup_integer = container_of(lookup, struct definition_integer, p);
+ if (lookup_integer->declaration->signedness != signedness)
+ return NULL;
+ return lookup_integer;
+}
+
+struct definition_enum *lookup_enum(const struct definition *definition,
+ const char *field_name,
+ int signedness)
+{
+ struct definition *lookup;
+ struct definition_enum *lookup_enum;
+
+ lookup = lookup_definition(definition, field_name);
+ if (!lookup)
+ return NULL;
+ if (lookup->declaration->id != CTF_TYPE_ENUM)
+ return NULL;
+ lookup_enum = container_of(lookup, struct definition_enum, p);
+ if (lookup_enum->integer->declaration->signedness != signedness)
+ return NULL;
+ return lookup_enum;
+}
+
+struct definition *lookup_variant(const struct definition *definition,
+ const char *field_name)
+{
+ struct definition *lookup;
+ struct definition_variant *lookup_variant;
+
+ lookup = lookup_definition(definition, field_name);
+ if (!lookup)
+ return NULL;
+ if (lookup->declaration->id != CTF_TYPE_VARIANT)
+ return NULL;
+ lookup_variant = container_of(lookup, struct definition_variant, p);
+ lookup = variant_get_current_field(lookup_variant);
+ assert(lookup);
+ return lookup;
+}