hidl-gen: Allow missing package name for FQName matching.
Example: @1.0::IExpression.Constants can be looked up.
Bug: 31705664
Test: `mma` compiles (along with the related CL in hardware/interfaces)
Change-Id: I57371bb26843094bd4972502bb7dbf03cd185025
diff --git a/FQName.cpp b/FQName.cpp
index 0255995..8bd3cdc 100644
--- a/FQName.cpp
+++ b/FQName.cpp
@@ -356,19 +356,31 @@
return false;
}
- if (pos > 0) {
- // A match is only a match if it is preceded by a "boundary", i.e.
- // we perform a component-wise match from the end.
- // "az" is not a match for "android.hardware.foo@1.0::IFoo.bar.baz",
- // "baz", "bar.baz", "IFoo.bar.baz" are.
-
- char separator = s1[pos - 1];
- if (separator != '.' && separator != ':') {
- return false;
- }
+ // A match is only a match if it is preceded by a "boundary", i.e.
+ // we perform a component-wise match from the end.
+ // "az" is not a match for "android.hardware.foo@1.0::IFoo.bar.baz",
+ // "baz", "bar.baz", "IFoo.bar.baz", "@1.0::IFoo.bar.baz" are.
+ if (pos == 0) {
+ // matches "android.hardware.foo@1.0::IFoo.bar.baz"
+ return true;
}
- return true;
+ if (s1[pos - 1] == '.') {
+ // matches "baz" and "bar.baz"
+ return true;
+ }
+
+ if (s1[pos - 1] == ':') {
+ // matches "IFoo.bar.baz"
+ return true;
+ }
+
+ if (s1[pos] == '@') {
+ // matches "@1.0::IFoo.bar.baz"
+ return true;
+ }
+
+ return false;
}
} // namespace android