Implementing RFC#126: Allow Op names of the form RepoName>OpName

This change maps '>' in the op names to underscores in the generated python op function names and export names.

Getting '.' in the names instead is theoretically doable but would add too much complexity to the whole codegen loop to be worthwhile.
(It would require analyzing the op names to group ops by their respective nested namespaces, code-gen'ing nested python classes that match the namespaces, then indenting the codegen'd python ops inside of the nested classes w/ the names set correctly).
This commit is contained in:
Tomer Kaftan 2019-09-06 15:09:31 -07:00 committed by GitHub
parent b6e4c89267
commit 2e35d26a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -472,6 +472,12 @@ void GenerateLowerCaseOpName(const string& str, string* result) {
const int last_index = str.size() - 1;
for (int i = 0; i <= last_index; ++i) {
const char c = str[i];
// Convert namespace separators ('>' characters) to joiners
if (c == '>') {
result->push_back(joiner);
continue;
}
// Emit a joiner only if a previous-lower-to-now-upper or a
// now-upper-to-next-lower transition happens.
if (isupper(c) && (i > 0)) {