(namingStyle: NamingStyle)
| 89 | const legalizeName = legalizeCharacters(cp => isAscii(cp) && isLetterOrUnderscoreOrDigit(cp)); |
| 90 | |
| 91 | function cppNameStyle(namingStyle: NamingStyle): (rawName: string) => string { |
| 92 | let separator: string; |
| 93 | let firstWordStyle: WordStyle; |
| 94 | let restWordStyle: WordStyle; |
| 95 | let firstWordAcronymStyle: WordStyle; |
| 96 | let restAcronymStyle: WordStyle; |
| 97 | |
| 98 | if (namingStyle === "pascal" || namingStyle === "camel") { |
| 99 | separator = ""; |
| 100 | restWordStyle = firstUpperWordStyle; |
| 101 | restAcronymStyle = allUpperWordStyle; |
| 102 | } else { |
| 103 | separator = "_"; |
| 104 | } |
| 105 | switch (namingStyle) { |
| 106 | case "pascal": |
| 107 | firstWordStyle = firstWordAcronymStyle = firstUpperWordStyle; |
| 108 | break; |
| 109 | case "camel": |
| 110 | firstWordStyle = firstWordAcronymStyle = allLowerWordStyle; |
| 111 | break; |
| 112 | case "underscore": |
| 113 | firstWordStyle = restWordStyle = firstWordAcronymStyle = restAcronymStyle = allLowerWordStyle; |
| 114 | break; |
| 115 | case "upper-underscore": |
| 116 | firstWordStyle = restWordStyle = firstWordAcronymStyle = restAcronymStyle = allUpperWordStyle; |
| 117 | break; |
| 118 | default: |
| 119 | return assertNever(namingStyle); |
| 120 | } |
| 121 | |
| 122 | return (original: string) => { |
| 123 | const words = splitIntoWords(original); |
| 124 | return combineWords( |
| 125 | words, |
| 126 | legalizeName, |
| 127 | firstWordStyle, |
| 128 | restWordStyle, |
| 129 | firstWordAcronymStyle, |
| 130 | restAcronymStyle, |
| 131 | separator, |
| 132 | isLetterOrUnderscore |
| 133 | ); |
| 134 | }; |
| 135 | } |
| 136 | |
| 137 | const keywords = [ |
| 138 | "alignas", |
no test coverage detected
searching dependent graphs…