[PATCH v2 1/6] widl: Print full namespace name on error.
Rémi Bernon
rbernon at codeweavers.com
Thu Aug 27 08:10:52 CDT 2020
Not really necessary as the errors are usually more cryptic, but nice
to have when it fails there.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
v2: Tweak style in a few locations.
tools/widl/parser.y | 10 ++++++++--
tools/widl/widltypes.h | 1 +
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 3ef8d89ba1c..98bd8949f13 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -118,7 +118,7 @@ static statement_list_t *append_statements(statement_list_t *, statement_list_t
static attr_list_t *append_attribs(attr_list_t *, attr_list_t *);
static struct namespace global_namespace = {
- NULL, NULL, LIST_INIT(global_namespace.entry), LIST_INIT(global_namespace.children)
+ NULL, NULL, NULL, LIST_INIT(global_namespace.entry), LIST_INIT(global_namespace.children)
};
static struct namespace *current_namespace = &global_namespace;
@@ -1833,6 +1833,12 @@ static void push_namespace(const char *name)
if(!namespace) {
namespace = xmalloc(sizeof(*namespace));
namespace->name = xstrdup(name);
+ if (!current_namespace->full_name) namespace->full_name = xstrdup(name);
+ else
+ {
+ namespace->full_name = xmalloc(strlen(current_namespace->full_name) + strlen(name) + 1);
+ sprintf(namespace->full_name, "%s.%s", current_namespace->full_name, name);
+ }
namespace->parent = current_namespace;
list_add_tail(¤t_namespace->children, &namespace->entry);
list_init(&namespace->children);
@@ -1961,7 +1967,7 @@ static type_t *find_type_or_error(const char *name, int t)
{
type_t *type = find_type(name, NULL, t);
if (!type) {
- error_loc("type '%s' not found\n", name);
+ error_loc("type '%s' not found in %s\n", name, current_namespace->full_name);
return NULL;
}
return type;
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 085a0ff55f5..1634f9bd50b 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -409,6 +409,7 @@ struct alias_details
struct namespace {
const char *name;
+ char *full_name;
struct namespace *parent;
struct list entry;
struct list children;
--
2.28.0
More information about the wine-devel
mailing list