Change rules for RS name reflection.
We now keep any alphanumeric or underscore characters unchanged for
the classname. Nonmatching characters (like hyphens) get stripped
out (as they were previously). We no longer camel-case the reflected
names. Resource names are converted to lowercase, since that is a
system requirement.
Change-Id: Idf7a7c3f9442bb58789769d58088c2038a074455
diff --git a/slang_rs_reflect_utils.cpp b/slang_rs_reflect_utils.cpp
index 1c7cc4d..12245d6 100644
--- a/slang_rs_reflect_utils.cpp
+++ b/slang_rs_reflect_utils.cpp
@@ -28,7 +28,7 @@
return packaged_path;
}
-static string InternalFileNameConvert(const char* rsFileName, bool camelCase) {
+static string InternalFileNameConvert(const char* rsFileName, bool toLower) {
const char* dot = rsFileName + strlen(rsFileName);
const char* slash = dot - 1;
while (slash >= rsFileName) {
@@ -42,19 +42,15 @@
}
++slash;
char ret[256];
- bool need_cap = true;
int i = 0;
for (; (i < 255) && (slash < dot); ++slash) {
- if (isalnum(*slash)) {
- if (need_cap && camelCase) {
- ret[i] = toupper(*slash);
+ if (isalnum(*slash) || *slash == '_') {
+ if (toLower) {
+ ret[i] = tolower(*slash);
} else {
ret[i] = *slash;
}
- need_cap = false;
++i;
- } else {
- need_cap = true;
}
}
ret[i] = 0;
@@ -63,13 +59,13 @@
std::string RSSlangReflectUtils::JavaClassNameFromRSFileName(
const char* rsFileName) {
- return InternalFileNameConvert(rsFileName, true);
+ return InternalFileNameConvert(rsFileName, false);
}
std::string RSSlangReflectUtils::BCFileNameFromRSFileName(
const char* rsFileName) {
- return InternalFileNameConvert(rsFileName, false);
+ return InternalFileNameConvert(rsFileName, true);
}
bool RSSlangReflectUtils::mkdir_p(const char* path) {