widl [1/3]: Allow quoted UUIDs
Dan Hipschman
dsh at linux.ucla.edu
Mon Oct 8 18:45:09 CDT 2007
This patch allows widl to handle UUIDs that are quoted. For example:
uuid("1ff70682-0a51-30e8-076d-740be8cee98b"),
which is taken from one of the Samba files. MIDL also allows these.
---
tools/widl/parser.l | 2 +-
tools/widl/parser.y | 26 +++++++++++++++++++++++++-
tools/widl/utils.h | 3 +++
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/tools/widl/parser.l b/tools/widl/parser.l
index 4cd98bb..e9bfb1f 100644
--- a/tools/widl/parser.l
+++ b/tools/widl/parser.l
@@ -78,7 +78,7 @@ int import_stack_ptr = 0;
static void pop_import(void);
-static UUID* parse_uuid(const char*u)
+UUID *parse_uuid(const char *u)
{
UUID* uuid = xmalloc(sizeof(UUID));
char b[3];
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index ae7f8f1..8399b40 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -265,6 +265,7 @@ static void check_all_user_types(ifref_list_t *ifaces);
%type <type> coclass coclasshdr coclassdef
%type <num> pointer_type version
%type <str> libraryhdr
+%type <uuid> uuid_string
%left ','
%right '?' ':'
@@ -498,7 +499,7 @@ attribute: { $$ = NULL; }
| tSWITCHIS '(' expr ')' { $$ = make_attrp(ATTR_SWITCHIS, $3); }
| tSWITCHTYPE '(' type ')' { $$ = make_attrp(ATTR_SWITCHTYPE, $3); }
| tTRANSMITAS '(' type ')' { $$ = make_attrp(ATTR_TRANSMITAS, $3); }
- | tUUID '(' aUUID ')' { $$ = make_attrp(ATTR_UUID, $3); }
+ | tUUID '(' uuid_string ')' { $$ = make_attrp(ATTR_UUID, $3); }
| tV1ENUM { $$ = make_attr(ATTR_V1ENUM); }
| tVARARG { $$ = make_attr(ATTR_VARARG); }
| tVERSION '(' version ')' { $$ = make_attrv(ATTR_VERSION, $3); }
@@ -506,6 +507,12 @@ attribute: { $$ = NULL; }
| pointer_type { $$ = make_attrv(ATTR_POINTERTYPE, $1); }
;
+uuid_string:
+ aUUID
+ | aSTRING { if (!is_valid_uuid($1))
+ yyerror("invalid UUID: %s", $1);
+ $$ = parse_uuid($1); }
+
callconv:
| tSTDCALL
;
@@ -2037,3 +2044,20 @@ static void check_all_user_types(ifref_list_t *ifrefs)
check_for_user_types_and_context_handles(f->args);
}
}
+
+int is_valid_uuid(const char *s)
+{
+ int i;
+
+ for (i = 0; i < 36; ++i)
+ if (i == 8 || i == 13 || i == 18 || i == 23)
+ {
+ if (s[i] != '-')
+ return FALSE;
+ }
+ else
+ if (!isxdigit(s[i]))
+ return FALSE;
+
+ return s[i] == '\0';
+}
diff --git a/tools/widl/utils.h b/tools/widl/utils.h
index 3641aae..aa1d6b4 100644
--- a/tools/widl/utils.h
+++ b/tools/widl/utils.h
@@ -42,4 +42,7 @@ void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
char *dup_basename(const char *name, const char *ext);
+UUID *parse_uuid(const char *u);
+int is_valid_uuid(const char *s);
+
#endif
More information about the wine-patches
mailing list