@@ -312,7 +312,20 @@ async function asObjectiveCType(type, cluster, options) {
312
312
}
313
313
314
314
function asStructPropertyName ( prop ) {
315
- prop = appHelper . asLowerCamelCase ( prop ) ;
315
+ prop = appHelper . asLowerCamelCase ( prop , { hash : { preserveAcronyms : true } } ) ;
316
+
317
+ // If prop is now all-uppercase (which can happen, because we are preserving
318
+ // acronyms), lowercase it.
319
+ if ( prop . match ( / ^ [ A - Z 0 - 9 ] + $ / ) ) {
320
+ prop = prop . toLowerCase ( ) ;
321
+ }
322
+
323
+ // If prop is now all-uppercase, with at least two capital letters followed by
324
+ // a lowercase "s" (probably acronym being pluralized), just lowercase the
325
+ // whole thing.
326
+ if ( prop . match ( / ^ [ A - Z ] [ A - Z ] + s $ / ) ) {
327
+ prop = prop . toLowerCase ( ) ;
328
+ }
316
329
317
330
// If prop is now "description", we need to rename it, because that's
318
331
// reserved.
@@ -322,8 +335,8 @@ function asStructPropertyName(prop) {
322
335
323
336
// If prop starts with a sequence of capital letters (which can happen for
324
337
// output of asLowerCamelCase if the original string started that way),
325
- // lowercase all but the last one .
326
- return prop . replace ( / ^ ( [ A - Z ] + ) ( [ A - Z ] ) / , ( match , p1 , p2 ) => {
338
+ // followed by a lowercase letter, lowercase all but the last capital letter .
339
+ return prop . replace ( / ^ ( [ A - Z ] + ) ( [ A - Z ] [ a - z ] ) / , ( match , p1 , p2 ) => {
327
340
return p1 . toLowerCase ( ) + p2 ;
328
341
} ) ;
329
342
}
0 commit comments