zeroc-ice 3.8.0 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/dist/IceRuby/Operation.cpp +22 -6
  3. data/dist/IceRuby/Slice.cpp +1 -1
  4. data/dist/ice/cpp/include/Ice/Communicator.h +4 -4
  5. data/dist/ice/cpp/include/Ice/Config.h +2 -2
  6. data/dist/ice/cpp/include/Ice/Connection.h +3 -3
  7. data/dist/ice/cpp/include/Ice/Endpoint.h +2 -2
  8. data/dist/ice/cpp/include/Ice/Exception.h +1 -1
  9. data/dist/ice/cpp/include/Ice/Initialize.h +1 -1
  10. data/dist/ice/cpp/include/Ice/LocalExceptions.h +22 -1
  11. data/dist/ice/cpp/include/Ice/Logger.h +3 -3
  12. data/dist/ice/cpp/include/Ice/NativePropertiesAdmin.h +2 -0
  13. data/dist/ice/cpp/include/Ice/ObjectAdapter.h +3 -3
  14. data/dist/ice/cpp/include/Ice/ObserverHelper.h +1 -0
  15. data/dist/ice/cpp/include/Ice/OutputStream.h +27 -5
  16. data/dist/ice/cpp/include/Ice/Properties.h +3 -3
  17. data/dist/ice/cpp/include/Ice/Proxy.h +1 -1
  18. data/dist/ice/cpp/include/Ice/SSL/ClientAuthenticationOptions.h +10 -2
  19. data/dist/ice/cpp/include/Ice/SSL/ServerAuthenticationOptions.h +10 -2
  20. data/dist/ice/cpp/include/generated/Ice/BuiltinSequences.h +2 -2
  21. data/dist/ice/cpp/include/generated/Ice/Context.h +2 -2
  22. data/dist/ice/cpp/include/generated/Ice/EndpointTypes.h +2 -2
  23. data/dist/ice/cpp/include/generated/Ice/Identity.h +2 -2
  24. data/dist/ice/cpp/include/generated/Ice/Locator.h +9 -11
  25. data/dist/ice/cpp/include/generated/Ice/LocatorRegistry.h +2 -2
  26. data/dist/ice/cpp/include/generated/Ice/Metrics.h +7 -7
  27. data/dist/ice/cpp/include/generated/Ice/OperationMode.h +2 -2
  28. data/dist/ice/cpp/include/generated/Ice/Process.h +2 -2
  29. data/dist/ice/cpp/include/generated/Ice/PropertiesAdmin.h +2 -2
  30. data/dist/ice/cpp/include/generated/Ice/PropertyDict.h +2 -2
  31. data/dist/ice/cpp/include/generated/Ice/RemoteLogger.h +2 -2
  32. data/dist/ice/cpp/include/generated/Ice/ReplyStatus.h +8 -4
  33. data/dist/ice/cpp/include/generated/Ice/Router.h +7 -7
  34. data/dist/ice/cpp/include/generated/Ice/SliceChecksumDict.h +2 -2
  35. data/dist/ice/cpp/include/generated/Ice/Version.h +2 -2
  36. data/dist/ice/cpp/include/generated/IceDiscovery/Lookup.h +2 -2
  37. data/dist/ice/cpp/include/generated/IceLocatorDiscovery/Lookup.h +2 -2
  38. data/dist/ice/cpp/src/Ice/CollocatedRequestHandler.cpp +5 -3
  39. data/dist/ice/cpp/src/Ice/ConnectionFactory.h +8 -8
  40. data/dist/ice/cpp/src/Ice/ConnectionI.cpp +28 -11
  41. data/dist/ice/cpp/src/Ice/ConnectionI.h +1 -1
  42. data/dist/ice/cpp/src/Ice/Demangle.cpp +1 -0
  43. data/dist/ice/cpp/src/Ice/FileUtil.cpp +3 -67
  44. data/dist/ice/cpp/src/Ice/FileUtil.h +0 -3
  45. data/dist/ice/cpp/src/Ice/IPEndpointI.cpp +4 -0
  46. data/dist/ice/cpp/src/Ice/IncomingRequest.cpp +1 -1
  47. data/dist/ice/cpp/src/Ice/InputStream.cpp +28 -17
  48. data/dist/ice/cpp/src/Ice/LocalException.cpp +1 -1
  49. data/dist/ice/cpp/src/Ice/LocalExceptions.cpp +6 -0
  50. data/dist/ice/cpp/src/Ice/OutgoingAsync.cpp +1 -1
  51. data/dist/ice/cpp/src/Ice/OutgoingResponse.cpp +127 -127
  52. data/dist/ice/cpp/src/Ice/OutgoingResponseInternal.h +21 -0
  53. data/dist/ice/cpp/src/Ice/OutputStream.cpp +80 -115
  54. data/dist/ice/cpp/src/Ice/PropertyNames.cpp +3 -2
  55. data/dist/ice/cpp/src/Ice/ProxyFunctions.cpp +4 -4
  56. data/dist/ice/cpp/src/Ice/Reference.cpp +15 -15
  57. data/dist/ice/cpp/src/Ice/ReferenceFactory.cpp +16 -13
  58. data/dist/ice/cpp/src/Ice/ResourceConfig.h +2 -2
  59. data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.cpp +29 -20
  60. data/dist/ice/cpp/src/Ice/SSL/OpenSSLEngine.h +1 -2
  61. data/dist/ice/cpp/src/Ice/SSL/OpenSSLTransceiverI.cpp +14 -3
  62. data/dist/ice/cpp/src/Ice/SSL/RFC2253.cpp +3 -3
  63. data/dist/ice/cpp/src/Ice/SSL/SSLEndpointI.cpp +1 -1
  64. data/dist/ice/cpp/src/Ice/SSL/SSLEngine.h +4 -10
  65. data/dist/ice/cpp/src/Ice/SSL/SSLUtil.cpp +21 -2
  66. data/dist/ice/cpp/src/Ice/SSL/SSLUtil.h +15 -1
  67. data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.cpp +67 -48
  68. data/dist/ice/cpp/src/Ice/SSL/SchannelEngine.h +1 -5
  69. data/dist/ice/cpp/src/Ice/SSL/SchannelTransceiverI.cpp +14 -2
  70. data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.cpp +111 -15
  71. data/dist/ice/cpp/src/Ice/SSL/SecureTransportEngine.h +7 -2
  72. data/dist/ice/cpp/src/Ice/SSL/SecureTransportTransceiverI.h +1 -1
  73. data/dist/ice/cpp/src/Ice/SSL/SecureTransportUtil.cpp +3 -16
  74. data/dist/ice/cpp/src/Ice/SSL/TrustManager.cpp +12 -1
  75. data/dist/ice/cpp/src/Ice/ServantManager.h +1 -1
  76. data/dist/ice/cpp/src/Ice/StringConverter.cpp +4 -0
  77. data/dist/ice/cpp/src/Ice/TcpEndpointI.cpp +2 -2
  78. data/dist/ice/cpp/src/Ice/UdpEndpointI.cpp +2 -2
  79. data/dist/ice/cpp/src/Ice/WSAcceptor.cpp +8 -3
  80. data/dist/ice/cpp/src/Ice/WSAcceptor.h +5 -1
  81. data/dist/ice/cpp/src/Ice/WSEndpoint.cpp +45 -2
  82. data/dist/ice/cpp/src/Ice/WSTransceiver.cpp +118 -7
  83. data/dist/ice/cpp/src/Ice/WSTransceiver.h +12 -1
  84. data/dist/ice/cpp/src/Ice/generated/BuiltinSequences.cpp +2 -2
  85. data/dist/ice/cpp/src/Ice/generated/Context.cpp +2 -2
  86. data/dist/ice/cpp/src/Ice/generated/EndpointTypes.cpp +2 -2
  87. data/dist/ice/cpp/src/Ice/generated/Identity.cpp +2 -2
  88. data/dist/ice/cpp/src/Ice/generated/Locator.cpp +2 -2
  89. data/dist/ice/cpp/src/Ice/generated/LocatorRegistry.cpp +2 -2
  90. data/dist/ice/cpp/src/Ice/generated/Metrics.cpp +2 -2
  91. data/dist/ice/cpp/src/Ice/generated/OperationMode.cpp +2 -2
  92. data/dist/ice/cpp/src/Ice/generated/Process.cpp +2 -2
  93. data/dist/ice/cpp/src/Ice/generated/PropertiesAdmin.cpp +2 -2
  94. data/dist/ice/cpp/src/Ice/generated/PropertyDict.cpp +2 -2
  95. data/dist/ice/cpp/src/Ice/generated/RemoteLogger.cpp +2 -2
  96. data/dist/ice/cpp/src/Ice/generated/ReplyStatus.cpp +4 -2
  97. data/dist/ice/cpp/src/Ice/generated/Router.cpp +2 -2
  98. data/dist/ice/cpp/src/Ice/generated/SliceChecksumDict.cpp +2 -2
  99. data/dist/ice/cpp/src/Ice/generated/Version.cpp +2 -2
  100. data/dist/ice/cpp/src/IceDiscovery/LocatorI.cpp +2 -2
  101. data/dist/ice/cpp/src/IceDiscovery/LookupI.cpp +4 -3
  102. data/dist/ice/cpp/src/IceDiscovery/LookupI.h +2 -1
  103. data/dist/ice/cpp/src/IceDiscovery/generated/Lookup.cpp +2 -2
  104. data/dist/ice/cpp/src/IceLocatorDiscovery/PluginI.cpp +6 -18
  105. data/dist/ice/cpp/src/IceLocatorDiscovery/generated/Lookup.cpp +2 -2
  106. data/dist/ice/cpp/src/Slice/DocCommentParser.cpp +6 -6
  107. data/dist/ice/cpp/src/Slice/DocCommentParser.h +4 -2
  108. data/dist/ice/cpp/src/Slice/FileTracker.h +1 -0
  109. data/dist/ice/cpp/src/Slice/Grammar.cpp +261 -264
  110. data/dist/ice/cpp/src/Slice/MetadataValidation.cpp +39 -7
  111. data/dist/ice/cpp/src/Slice/MetadataValidation.h +3 -2
  112. data/dist/ice/cpp/src/Slice/Parser.cpp +192 -155
  113. data/dist/ice/cpp/src/Slice/Parser.h +44 -9
  114. data/dist/ice/cpp/src/Slice/Preprocessor.cpp +76 -20
  115. data/dist/ice/cpp/src/Slice/Preprocessor.h +0 -1
  116. data/dist/ice/cpp/src/Slice/Scanner.cpp +1 -1
  117. data/dist/ice/cpp/src/Slice/SliceUtil.cpp +44 -58
  118. data/dist/ice/cpp/src/Slice/StringLiteralUtil.cpp +3 -10
  119. data/dist/ice/cpp/src/Slice/Util.h +7 -3
  120. data/dist/ice/cpp/src/slice2rb/Main.cpp +2 -2
  121. data/dist/ice/cpp/src/slice2rb/Ruby.cpp +1 -1
  122. data/dist/ice/cpp/src/slice2rb/RubyUtil.cpp +10 -8
  123. data/dist/ice/cpp/src/slice2rb/RubyUtil.h +10 -13
  124. data/dist/ice/mcpp/directive.c +5 -2
  125. data/dist/ice/mcpp/mcpp_main.c +1 -1
  126. data/dist/ice/mcpp/support.c +6 -6
  127. data/dist/ice/mcpp/system.c +5 -5
  128. data/dist/ice/slice/Ice/Identity.ice +3 -0
  129. data/dist/ice/slice/Ice/Locator.ice +6 -5
  130. data/dist/ice/slice/Ice/LocatorRegistry.ice +3 -0
  131. data/dist/ice/slice/Ice/Metrics.ice +1 -1
  132. data/dist/ice/slice/Ice/OperationMode.ice +8 -0
  133. data/dist/ice/slice/Ice/Process.ice +3 -0
  134. data/dist/ice/slice/Ice/ReplyStatus.ice +13 -0
  135. data/dist/lib/Glacier2/Metrics.rb +1 -1
  136. data/dist/lib/Glacier2/PermissionsVerifier.rb +3 -3
  137. data/dist/lib/Glacier2/Router.rb +8 -8
  138. data/dist/lib/Glacier2/SSLInfo.rb +1 -1
  139. data/dist/lib/Glacier2/Session.rb +15 -15
  140. data/dist/lib/Ice/BuiltinSequences.rb +1 -1
  141. data/dist/lib/Ice/Context.rb +1 -1
  142. data/dist/lib/Ice/EndpointTypes.rb +1 -1
  143. data/dist/lib/Ice/Identity.rb +1 -1
  144. data/dist/lib/Ice/LocalExceptions.rb +3 -0
  145. data/dist/lib/Ice/Locator.rb +5 -5
  146. data/dist/lib/Ice/LocatorRegistry.rb +4 -4
  147. data/dist/lib/Ice/Metrics.rb +7 -7
  148. data/dist/lib/Ice/OperationMode.rb +1 -1
  149. data/dist/lib/Ice/Process.rb +3 -3
  150. data/dist/lib/Ice/PropertiesAdmin.rb +4 -4
  151. data/dist/lib/Ice/PropertyDict.rb +1 -1
  152. data/dist/lib/Ice/ProxyFunctions.rb +8 -4
  153. data/dist/lib/Ice/RemoteLogger.rb +6 -6
  154. data/dist/lib/Ice/ReplyStatus.rb +3 -2
  155. data/dist/lib/Ice/Router.rb +5 -5
  156. data/dist/lib/Ice/SliceChecksumDict.rb +1 -1
  157. data/dist/lib/Ice/Version.rb +1 -1
  158. data/dist/lib/IceBox/ServiceManager.rb +8 -8
  159. data/dist/lib/IceGrid/Admin.rb +83 -83
  160. data/dist/lib/IceGrid/Descriptor.rb +1 -1
  161. data/dist/lib/IceGrid/Exception.rb +1 -1
  162. data/dist/lib/IceGrid/FileParser.rb +2 -2
  163. data/dist/lib/IceGrid/Registry.rb +13 -13
  164. data/dist/lib/IceGrid/Session.rb +6 -6
  165. data/dist/lib/IceGrid/UserAccountMapper.rb +2 -2
  166. data/dist/lib/IceStorm/IceStorm.rb +16 -16
  167. data/dist/lib/IceStorm/Metrics.rb +1 -1
  168. data/ice.gemspec +1 -1
  169. metadata +2 -1
@@ -11,7 +11,6 @@
11
11
  #include <cassert>
12
12
  #include <cstring>
13
13
  #include <iterator>
14
- #include <limits>
15
14
 
16
15
  using namespace std;
17
16
  using namespace Slice;
@@ -49,7 +48,7 @@ namespace
49
48
  DataMemberList filterOrderedOptionalDataMembers(const DataMemberList& members)
50
49
  {
51
50
  DataMemberList result;
52
- copy_if(members.begin(), members.end(), back_inserter(result), [](const auto& p) { return p->optional(); });
51
+ copy_if(members.begin(), members.end(), back_inserter(result), [](const auto& p) { return p->isOptional(); });
53
52
  result.sort(compareTag<DataMemberPtr>);
54
53
  return result;
55
54
  }
@@ -112,6 +111,58 @@ namespace
112
111
  }
113
112
  return true;
114
113
  }
114
+
115
+ /// Checks an identifier for illegal syntax and reports any errors that are present.
116
+ bool reportIllegalSuffixOrUnderscore(const string& identifier)
117
+ {
118
+ // check whether the identifier is scoped
119
+ size_t scopeIndex = identifier.rfind("::");
120
+ bool isScoped = scopeIndex != string::npos;
121
+ string name;
122
+ if (isScoped)
123
+ {
124
+ name = identifier.substr(scopeIndex + 2); // Only check the unscoped identifier for syntax
125
+ }
126
+ else
127
+ {
128
+ name = identifier;
129
+ }
130
+
131
+ assert(!name.empty());
132
+ bool isValid = true;
133
+
134
+ // check the identifier for reserved suffixes
135
+ static const string suffixBlacklist[] = {"Helper", "Holder", "Prx", "Ptr"};
136
+ for (const auto& i : suffixBlacklist)
137
+ {
138
+ if (name.find(i, name.size() - i.size()) != string::npos)
139
+ {
140
+ currentUnit->error("illegal identifier '" + name + "': '" + i + "' suffix is reserved");
141
+ isValid = false;
142
+ break;
143
+ }
144
+ }
145
+
146
+ // check the identifier for illegal underscores
147
+ size_t index = name.find('_');
148
+ if (index == 0)
149
+ {
150
+ currentUnit->error("illegal leading underscore in identifier '" + name + "'");
151
+ isValid = false;
152
+ }
153
+ else if (name.rfind('_') == (name.size() - 1))
154
+ {
155
+ currentUnit->error("illegal trailing underscore in identifier '" + name + "'");
156
+ isValid = false;
157
+ }
158
+ else if (name.find("__") != string::npos)
159
+ {
160
+ currentUnit->error("illegal double underscore in identifier '" + name + "'");
161
+ isValid = false;
162
+ }
163
+
164
+ return isValid;
165
+ }
115
166
  }
116
167
 
117
168
  namespace Slice
@@ -564,7 +615,7 @@ Slice::Builtin::kindAsString() const
564
615
  return builtinTable[_kind];
565
616
  }
566
617
 
567
- optional<Slice::Builtin::Kind>
618
+ optional<Builtin::Kind>
568
619
  Slice::Builtin::kindFromString(string_view str)
569
620
  {
570
621
  // Object is an alias for Value that we don't put in the builtinTable.
@@ -640,15 +691,13 @@ Slice::Contained::scope() const
640
691
  string
641
692
  Slice::Contained::mappedName() const
642
693
  {
643
- // First check if any 'xxx:identifier' has been applied to this element.
644
- // If so, we return that instead of the element's Slice identifier.
645
- const string metadata = unit()->languageName() + ":identifier";
646
- if (auto customName = getMetadataArgs(metadata))
647
- {
648
- return *customName;
649
- }
694
+ return customMappedName().value_or(unit()->defaultMappedName(*this));
695
+ }
650
696
 
651
- return _name;
697
+ optional<string>
698
+ Slice::Contained::customMappedName() const
699
+ {
700
+ return getMetadataArgs(unit()->languageName() + ":identifier");
652
701
  }
653
702
 
654
703
  string
@@ -752,7 +801,7 @@ Slice::Contained::getMetadataArgs(string_view directive) const
752
801
  return nullopt;
753
802
  }
754
803
 
755
- std::optional<FormatType>
804
+ optional<FormatType>
756
805
  Slice::Contained::parseFormatMetadata() const
757
806
  {
758
807
  if (auto metadata = getMetadataArgs("format"))
@@ -784,6 +833,8 @@ Slice::Contained::isDeprecated() const
784
833
  optional<string>
785
834
  Slice::Contained::getDeprecationReason() const
786
835
  {
836
+ // The compiler doesn't allow both 'deprecate' and 'deprecated' to be applied to the same element.
837
+ // If both are present, 'deprecated' will be kept, and 'deprecate' will be thrown away.
787
838
  string reasonMessage;
788
839
  if (auto reason = getMetadataArgs("deprecate"))
789
840
  {
@@ -1419,7 +1470,7 @@ Slice::Container::createConst(
1419
1470
  return p;
1420
1471
  }
1421
1472
 
1422
- TypeList
1473
+ TypePtr
1423
1474
  Slice::Container::lookupType(const string& identifier)
1424
1475
  {
1425
1476
  // Remove whitespace.
@@ -1434,14 +1485,14 @@ Slice::Container::lookupType(const string& identifier)
1434
1485
  auto kind = Builtin::kindFromString(sc);
1435
1486
  if (kind)
1436
1487
  {
1437
- return {unit()->createBuiltin(*kind)};
1488
+ return unit()->createBuiltin(*kind);
1438
1489
  }
1439
1490
 
1440
1491
  // Not a builtin type, try to look up a user-defined type.
1441
1492
  return lookupTypeNoBuiltin(identifier, true);
1442
1493
  }
1443
1494
 
1444
- TypeList
1495
+ TypePtr
1445
1496
  Slice::Container::lookupTypeNoBuiltin(const string& identifier, bool emitErrors, bool ignoreUndefined)
1446
1497
  {
1447
1498
  // Remove whitespace.
@@ -1458,7 +1509,7 @@ Slice::Container::lookupTypeNoBuiltin(const string& identifier, bool emitErrors,
1458
1509
  return unit()->lookupTypeNoBuiltin(sc.substr(2), emitErrors);
1459
1510
  }
1460
1511
 
1461
- TypeList results;
1512
+ optional<TypePtr> resolvedType;
1462
1513
  bool typeError = false;
1463
1514
  vector<string> errors;
1464
1515
 
@@ -1470,70 +1521,66 @@ Slice::Container::lookupTypeNoBuiltin(const string& identifier, bool emitErrors,
1470
1521
  continue; // Ignore interface and class definitions.
1471
1522
  }
1472
1523
 
1473
- if (emitErrors && matches.front()->scoped() != (thisScope() + sc))
1524
+ if (p->scoped() != (thisScope() + sc))
1474
1525
  {
1475
1526
  ostringstream os;
1476
1527
  os << p->kindOf() << " name '" << identifier << "' is capitalized inconsistently with its previous name: '"
1477
- << matches.front()->scoped() << "'";
1528
+ << p->scoped() << "'";
1478
1529
  errors.push_back(os.str());
1479
1530
  }
1480
1531
 
1481
- ExceptionPtr ex = dynamic_pointer_cast<Exception>(p);
1482
- if (ex)
1532
+ if (TypePtr type = dynamic_pointer_cast<Type>(p))
1483
1533
  {
1484
- if (emitErrors)
1485
- {
1486
- ostringstream os;
1487
- os << "'" << sc << "' is an exception, which cannot be used as a type";
1488
- unit()->error(os.str());
1489
- }
1490
- return {};
1534
+ resolvedType = type;
1491
1535
  }
1536
+ else if (ExceptionPtr ex = dynamic_pointer_cast<Exception>(p))
1537
+ {
1538
+ resolvedType = nullptr;
1492
1539
 
1493
- TypePtr type = dynamic_pointer_cast<Type>(p);
1494
- if (!type)
1540
+ ostringstream os;
1541
+ os << "'" << sc << "' is an exception, which cannot be used as a type";
1542
+ errors.push_back(os.str());
1543
+ }
1544
+ else
1495
1545
  {
1496
1546
  typeError = true;
1497
- if (emitErrors)
1498
- {
1499
- ostringstream os;
1500
- os << "'" << sc << "' is not a type";
1501
- errors.push_back(os.str());
1502
- }
1503
- break; // Possible that correct match is higher in scope
1547
+
1548
+ ostringstream os;
1549
+ os << "'" << sc << "' is not a type";
1550
+ errors.push_back(os.str());
1504
1551
  }
1505
- results.push_back(type);
1552
+ break;
1506
1553
  }
1507
1554
 
1508
- if (results.empty())
1555
+ if (!resolvedType.has_value())
1509
1556
  {
1510
1557
  ContainedPtr contained = dynamic_pointer_cast<Contained>(shared_from_this());
1511
1558
  if (contained)
1512
1559
  {
1513
- results = contained->container()->lookupTypeNoBuiltin(sc, emitErrors, typeError || ignoreUndefined);
1514
- }
1515
- else if (!typeError)
1516
- {
1517
- if (emitErrors && !ignoreUndefined)
1560
+ TypePtr parent = contained->container()->lookupTypeNoBuiltin(sc, emitErrors, typeError || ignoreUndefined);
1561
+ if (parent)
1518
1562
  {
1519
- ostringstream os;
1520
- os << "'" << sc << "' is not defined";
1521
- unit()->error(os.str());
1563
+ resolvedType = parent;
1522
1564
  }
1523
- return {};
1565
+ }
1566
+ else if (!typeError && !ignoreUndefined)
1567
+ {
1568
+ ostringstream os;
1569
+ os << "'" << sc << "' is not defined";
1570
+ errors.push_back(os.str());
1524
1571
  }
1525
1572
  }
1526
1573
 
1527
1574
  // Do not emit errors if there was a type error but a match was found in a higher scope.
1528
- // TODO The second part of this check looks funny to me.
1529
- if (emitErrors && !(typeError && !results.empty()))
1575
+ if (emitErrors && (!typeError || !resolvedType.has_value()))
1530
1576
  {
1531
1577
  for (const auto& error : errors)
1532
1578
  {
1533
1579
  unit()->error(error);
1534
1580
  }
1535
1581
  }
1536
- return results;
1582
+
1583
+ return resolvedType.value_or(nullptr);
1537
1584
  }
1538
1585
 
1539
1586
  ContainedList
@@ -1597,32 +1644,24 @@ Slice::Container::lookupContained(const string& identifier, bool emitErrors)
1597
1644
  InterfaceDefPtr
1598
1645
  Slice::Container::lookupInterfaceDef(const string& identifier, bool emitErrors)
1599
1646
  {
1600
- TypeList types = lookupType(identifier);
1601
- if (!types.empty())
1647
+ TypePtr resolvedType = lookupType(identifier);
1648
+ if (resolvedType)
1602
1649
  {
1603
- auto interface = dynamic_pointer_cast<InterfaceDecl>(types.front());
1604
- if (!interface)
1650
+ if (auto interfaceDecl = dynamic_pointer_cast<InterfaceDecl>(resolvedType))
1605
1651
  {
1606
- if (emitErrors)
1652
+ if (InterfaceDefPtr def = interfaceDecl->definition())
1607
1653
  {
1608
- unit()->error("'" + identifier + "' is not an interface");
1609
- }
1610
- }
1611
- else
1612
- {
1613
- InterfaceDefPtr def = interface->definition();
1614
- if (!def)
1615
- {
1616
- if (emitErrors)
1617
- {
1618
- unit()->error("'" + identifier + "' has been declared but not defined");
1619
- }
1654
+ return def;
1620
1655
  }
1621
- else
1656
+ else if (emitErrors)
1622
1657
  {
1623
- return def;
1658
+ unit()->error("'" + identifier + "' has been declared but not defined");
1624
1659
  }
1625
1660
  }
1661
+ else if (emitErrors)
1662
+ {
1663
+ unit()->error("'" + identifier + "' is not an interface");
1664
+ }
1626
1665
  }
1627
1666
 
1628
1667
  // If we failed to find a valid interface with the specified name.
@@ -2160,13 +2199,13 @@ Slice::Module::getTopLevelModule() const
2160
2199
  return parent->getTopLevelModule();
2161
2200
  }
2162
2201
  // Reaching here means that this module is at the top-level! We return it.
2163
- return dynamic_pointer_cast<Module>(const_pointer_cast<Container>(shared_from_this()));
2202
+ return static_pointer_cast<Module>(const_pointer_cast<Container>(shared_from_this()));
2164
2203
  }
2165
2204
 
2166
2205
  void
2167
2206
  Slice::Module::visit(ParserVisitor* visitor)
2168
2207
  {
2169
- auto self = dynamic_pointer_cast<Module>(shared_from_this());
2208
+ auto self = static_pointer_cast<Module>(shared_from_this());
2170
2209
  if (visitor->visitModuleStart(self))
2171
2210
  {
2172
2211
  visitContents(visitor);
@@ -2211,7 +2250,7 @@ Slice::ClassDecl::isClassType() const
2211
2250
  size_t
2212
2251
  Slice::ClassDecl::minWireSize() const
2213
2252
  {
2214
- return 1; // At least four bytes for an instance, if the instance is marshaled as an index.
2253
+ return 1; // A class can be marshaled as an index, which uses the size encoding, which uses either 1 or 5 bytes.
2215
2254
  }
2216
2255
 
2217
2256
  string
@@ -2323,7 +2362,7 @@ Slice::ClassDef::createDataMember(
2323
2362
  // Validate the tag.
2324
2363
  for (const auto& q : dataMembers())
2325
2364
  {
2326
- if (q->optional() && tag == q->tag())
2365
+ if (q->isOptional() && tag == q->tag())
2327
2366
  {
2328
2367
  unit()->error("tag for optional data member '" + name + "' is already in use");
2329
2368
  break;
@@ -2441,7 +2480,7 @@ Slice::ClassDef::kindOf() const
2441
2480
  void
2442
2481
  Slice::ClassDef::visit(ParserVisitor* visitor)
2443
2482
  {
2444
- auto self = dynamic_pointer_cast<ClassDef>(shared_from_this());
2483
+ auto self = static_pointer_cast<ClassDef>(shared_from_this());
2445
2484
  if (visitor->visitClassDefStart(self))
2446
2485
  {
2447
2486
  visitContents(visitor);
@@ -2628,7 +2667,7 @@ Slice::InterfaceDecl::addPartition(
2628
2667
  // list of lists, with each member list containing the operation
2629
2668
  // names defined by the interfaces in each partition.
2630
2669
  //
2631
- Slice::InterfaceDecl::StringPartitionList
2670
+ InterfaceDecl::StringPartitionList
2632
2671
  Slice::InterfaceDecl::toStringPartitionList(const GraphPartitionList& partitions)
2633
2672
  {
2634
2673
  StringPartitionList spl;
@@ -2751,8 +2790,9 @@ Slice::InterfaceDef::createOperation(
2751
2790
  break;
2752
2791
  }
2753
2792
  }
2754
- // Check the operations of the Object pseudo-interface.
2755
- if (!checkBaseOperationNames(name, {"ice_id", "ice_ids", "ice_ping", "ice_isA"}))
2793
+
2794
+ // Check the operations of the Object pseudo-interface unless we're generating code for Object itself.
2795
+ if (scoped() != "::Ice::Object" && !checkBaseOperationNames(name, {"ice_id", "ice_ids", "ice_ping", "ice_isA"}))
2756
2796
  {
2757
2797
  hasConflictingIdentifier = true;
2758
2798
  }
@@ -2840,6 +2880,24 @@ Slice::InterfaceDef::operations() const
2840
2880
 
2841
2881
  OperationList
2842
2882
  Slice::InterfaceDef::allOperations() const
2883
+ {
2884
+ OperationList result = allInheritedOperations();
2885
+
2886
+ for (const auto& q : operations())
2887
+ {
2888
+ if (none_of(
2889
+ result.begin(),
2890
+ result.end(),
2891
+ [name = q->name()](const auto& other) { return other->name() == name; }))
2892
+ {
2893
+ result.push_back(q);
2894
+ }
2895
+ }
2896
+ return result;
2897
+ }
2898
+
2899
+ OperationList
2900
+ Slice::InterfaceDef::allInheritedOperations() const
2843
2901
  {
2844
2902
  OperationList result;
2845
2903
  for (const auto& p : _bases)
@@ -2855,17 +2913,6 @@ Slice::InterfaceDef::allOperations() const
2855
2913
  }
2856
2914
  }
2857
2915
  }
2858
-
2859
- for (const auto& q : operations())
2860
- {
2861
- if (none_of(
2862
- result.begin(),
2863
- result.end(),
2864
- [name = q->name()](const auto& other) { return other->name() == name; }))
2865
- {
2866
- result.push_back(q);
2867
- }
2868
- }
2869
2916
  return result;
2870
2917
  }
2871
2918
 
@@ -2878,7 +2925,7 @@ Slice::InterfaceDef::kindOf() const
2878
2925
  void
2879
2926
  Slice::InterfaceDef::visit(ParserVisitor* visitor)
2880
2927
  {
2881
- auto self = dynamic_pointer_cast<InterfaceDef>(shared_from_this());
2928
+ auto self = static_pointer_cast<InterfaceDef>(shared_from_this());
2882
2929
  if (visitor->visitInterfaceDefStart(self))
2883
2930
  {
2884
2931
  visitContents(visitor);
@@ -2928,7 +2975,7 @@ Slice::InterfaceDef::InterfaceDef(const ContainerPtr& container, const string& n
2928
2975
  // ----------------------------------------------------------------------
2929
2976
 
2930
2977
  InterfaceDefPtr
2931
- Slice::Operation::interface() const
2978
+ Slice::Operation::parentInterface() const
2932
2979
  {
2933
2980
  return dynamic_pointer_cast<InterfaceDef>(_container);
2934
2981
  }
@@ -2960,7 +3007,7 @@ Slice::Operation::mode() const
2960
3007
  bool
2961
3008
  Slice::Operation::hasMarshaledResult() const
2962
3009
  {
2963
- InterfaceDefPtr intf = interface();
3010
+ InterfaceDefPtr intf = parentInterface();
2964
3011
  assert(intf);
2965
3012
  if (intf->hasMetadata("marshaled-result") || hasMetadata("marshaled-result"))
2966
3013
  {
@@ -2969,10 +3016,9 @@ Slice::Operation::hasMarshaledResult() const
2969
3016
  return true;
2970
3017
  }
2971
3018
 
2972
- for (const auto& p : _contents)
3019
+ for (const auto& p : outParameters())
2973
3020
  {
2974
- ParameterPtr q = dynamic_pointer_cast<Parameter>(p);
2975
- if (q->isOutParam() && isMutableAfterReturnType(q->type()))
3021
+ if (isMutableAfterReturnType(p->type()))
2976
3022
  {
2977
3023
  return true;
2978
3024
  }
@@ -3010,7 +3056,7 @@ Slice::Operation::createParameter(const string& name, const TypePtr& type, bool
3010
3056
  {
3011
3057
  for (const auto& param : parameters())
3012
3058
  {
3013
- if (param->optional() && param->tag() == tag)
3059
+ if (param->isOptional() && param->tag() == tag)
3014
3060
  {
3015
3061
  unit()->error(msg);
3016
3062
  break;
@@ -3042,12 +3088,11 @@ ParameterList
3042
3088
  Slice::Operation::inParameters() const
3043
3089
  {
3044
3090
  ParameterList result;
3045
- for (const auto& p : _contents)
3091
+ for (const auto& p : parameters())
3046
3092
  {
3047
- ParameterPtr q = dynamic_pointer_cast<Parameter>(p);
3048
- if (q && !q->isOutParam())
3093
+ if (!p->isOutParam())
3049
3094
  {
3050
- result.push_back(q);
3095
+ result.push_back(p);
3051
3096
  }
3052
3097
  }
3053
3098
  return result;
@@ -3060,7 +3105,7 @@ Slice::Operation::sortedInParameters() const
3060
3105
  ParameterList required, optional;
3061
3106
  for (const auto& param : inParameters())
3062
3107
  {
3063
- if (param->optional())
3108
+ if (param->isOptional())
3064
3109
  {
3065
3110
  optional.push_back(param);
3066
3111
  }
@@ -3082,13 +3127,11 @@ ParameterList
3082
3127
  Slice::Operation::outParameters() const
3083
3128
  {
3084
3129
  ParameterList result;
3085
-
3086
- for (const auto& p : _contents)
3130
+ for (const auto& p : parameters())
3087
3131
  {
3088
- ParameterPtr q = dynamic_pointer_cast<Parameter>(p);
3089
- if (q && q->isOutParam())
3132
+ if (p->isOutParam())
3090
3133
  {
3091
- result.push_back(q);
3134
+ result.push_back(p);
3092
3135
  }
3093
3136
  }
3094
3137
  return result;
@@ -3137,7 +3180,7 @@ Slice::Operation::sortedReturnAndOutParameters(const string& returnName)
3137
3180
  // First sort each parameter into either 'required' or 'optional'.
3138
3181
  for (auto i = required.begin(); i != required.end();)
3139
3182
  {
3140
- if ((*i)->optional())
3183
+ if ((*i)->isOptional())
3141
3184
  {
3142
3185
  optional.push_back(*i);
3143
3186
  i = required.erase(i);
@@ -3208,9 +3251,9 @@ Slice::Operation::setExceptionList(const ExceptionList& exceptions)
3208
3251
  bool
3209
3252
  Slice::Operation::sendsClasses() const
3210
3253
  {
3211
- for (const auto& i : parameters())
3254
+ for (const auto& i : inParameters())
3212
3255
  {
3213
- if (!i->isOutParam() && i->type()->usesClasses())
3256
+ if (i->type()->usesClasses())
3214
3257
  {
3215
3258
  return true;
3216
3259
  }
@@ -3227,9 +3270,9 @@ Slice::Operation::returnsClasses() const
3227
3270
  return true;
3228
3271
  }
3229
3272
 
3230
- for (const auto& i : parameters())
3273
+ for (const auto& i : outParameters())
3231
3274
  {
3232
- if (i->isOutParam() && i->type()->usesClasses())
3275
+ if (i->type()->usesClasses())
3233
3276
  {
3234
3277
  return true;
3235
3278
  }
@@ -3240,25 +3283,7 @@ Slice::Operation::returnsClasses() const
3240
3283
  bool
3241
3284
  Slice::Operation::returnsData() const
3242
3285
  {
3243
- TypePtr t = returnType();
3244
- if (t)
3245
- {
3246
- return true;
3247
- }
3248
-
3249
- for (const auto& i : parameters())
3250
- {
3251
- if (i->isOutParam())
3252
- {
3253
- return true;
3254
- }
3255
- }
3256
-
3257
- if (!throws().empty())
3258
- {
3259
- return true;
3260
- }
3261
- return false;
3286
+ return returnsAnyValues() || !throws().empty();
3262
3287
  }
3263
3288
 
3264
3289
  bool
@@ -3285,7 +3310,7 @@ Slice::Operation::sendsOptionals() const
3285
3310
  {
3286
3311
  for (const auto& i : inParameters())
3287
3312
  {
3288
- if (i->optional())
3313
+ if (i->isOptional())
3289
3314
  {
3290
3315
  return true;
3291
3316
  }
@@ -3298,7 +3323,7 @@ Slice::Operation::receivesOptionals() const
3298
3323
  {
3299
3324
  for (const auto& i : outParameters())
3300
3325
  {
3301
- if (i->optional())
3326
+ if (i->isOptional())
3302
3327
  {
3303
3328
  return true;
3304
3329
  }
@@ -3306,10 +3331,10 @@ Slice::Operation::receivesOptionals() const
3306
3331
  return returnIsOptional();
3307
3332
  }
3308
3333
 
3309
- std::optional<FormatType>
3334
+ optional<FormatType>
3310
3335
  Slice::Operation::format() const
3311
3336
  {
3312
- std::optional<FormatType> format = parseFormatMetadata();
3337
+ optional<FormatType> format = parseFormatMetadata();
3313
3338
  if (!format)
3314
3339
  {
3315
3340
  ContainedPtr cont = dynamic_pointer_cast<Contained>(container());
@@ -3328,7 +3353,7 @@ Slice::Operation::kindOf() const
3328
3353
  void
3329
3354
  Slice::Operation::visit(ParserVisitor* visitor)
3330
3355
  {
3331
- visitor->visitOperation(dynamic_pointer_cast<Operation>(shared_from_this()));
3356
+ visitor->visitOperation(static_pointer_cast<Operation>(shared_from_this()));
3332
3357
  }
3333
3358
 
3334
3359
  void
@@ -3434,7 +3459,7 @@ Slice::Exception::createDataMember(
3434
3459
  // Validate the tag.
3435
3460
  for (const auto& q : dataMembers())
3436
3461
  {
3437
- if (q->optional() && tag == q->tag())
3462
+ if (q->isOptional() && tag == q->tag())
3438
3463
  {
3439
3464
  unit()->error("tag for optional data member '" + name + "' is already in use");
3440
3465
  break;
@@ -3564,7 +3589,7 @@ Slice::Exception::kindOf() const
3564
3589
  void
3565
3590
  Slice::Exception::visit(ParserVisitor* visitor)
3566
3591
  {
3567
- auto self = dynamic_pointer_cast<Exception>(shared_from_this());
3592
+ auto self = static_pointer_cast<Exception>(shared_from_this());
3568
3593
  if (visitor->visitExceptionStart(self))
3569
3594
  {
3570
3595
  visitContents(visitor);
@@ -3719,7 +3744,7 @@ Slice::Struct::kindOf() const
3719
3744
  void
3720
3745
  Slice::Struct::visit(ParserVisitor* visitor)
3721
3746
  {
3722
- auto self = dynamic_pointer_cast<Struct>(shared_from_this());
3747
+ auto self = static_pointer_cast<Struct>(shared_from_this());
3723
3748
  if (visitor->visitStructStart(self))
3724
3749
  {
3725
3750
  visitContents(visitor);
@@ -4053,7 +4078,7 @@ Slice::Enum::kindOf() const
4053
4078
  void
4054
4079
  Slice::Enum::visit(ParserVisitor* visitor)
4055
4080
  {
4056
- visitor->visitEnum(dynamic_pointer_cast<Enum>(shared_from_this()));
4081
+ visitor->visitEnum(static_pointer_cast<Enum>(shared_from_this()));
4057
4082
  }
4058
4083
 
4059
4084
  void
@@ -4062,11 +4087,7 @@ Slice::Enum::destroy()
4062
4087
  destroyContents();
4063
4088
  }
4064
4089
 
4065
- Slice::Enum::Enum(const ContainerPtr& container, const string& name)
4066
- : Contained(container, name),
4067
- _minValue(numeric_limits<int32_t>::max())
4068
- {
4069
- }
4090
+ Slice::Enum::Enum(const ContainerPtr& container, const string& name) : Contained(container, name) {}
4070
4091
 
4071
4092
  // ----------------------------------------------------------------------
4072
4093
  // Enumerator
@@ -4198,7 +4219,7 @@ Slice::Parameter::setIsOutParam()
4198
4219
  }
4199
4220
 
4200
4221
  bool
4201
- Slice::Parameter::optional() const
4222
+ Slice::Parameter::isOptional() const
4202
4223
  {
4203
4224
  return _optional;
4204
4225
  }
@@ -4245,7 +4266,7 @@ Slice::DataMember::type() const
4245
4266
  }
4246
4267
 
4247
4268
  bool
4248
- Slice::DataMember::optional() const
4269
+ Slice::DataMember::isOptional() const
4249
4270
  {
4250
4271
  return _optional;
4251
4272
  }
@@ -4287,7 +4308,7 @@ Slice::DataMember::DataMember(
4287
4308
  bool isOptional,
4288
4309
  int32_t tag,
4289
4310
  SyntaxTreeBasePtr defaultValueType,
4290
- std::optional<string> defaultValueString)
4311
+ optional<string> defaultValueString)
4291
4312
  : Contained(container, name),
4292
4313
  _type(std::move(type)),
4293
4314
  _optional(isOptional),
@@ -4304,9 +4325,9 @@ Slice::DataMember::DataMember(
4304
4325
  // ----------------------------------------------------------------------
4305
4326
 
4306
4327
  UnitPtr
4307
- Slice::Unit::createUnit(string languageName, bool all)
4328
+ Slice::Unit::createUnit(string languageName, UnitOptions options)
4308
4329
  {
4309
- return make_shared<Unit>(std::move(languageName), all);
4330
+ return make_shared<Unit>(std::move(languageName), std::move(options));
4310
4331
  }
4311
4332
 
4312
4333
  string
@@ -4315,6 +4336,19 @@ Slice::Unit::languageName() const
4315
4336
  return _languageName;
4316
4337
  }
4317
4338
 
4339
+ string
4340
+ Slice::Unit::defaultMappedName(const Contained& contained) const
4341
+ {
4342
+ if (_defaultMappedName)
4343
+ {
4344
+ return _defaultMappedName(contained);
4345
+ }
4346
+ else
4347
+ {
4348
+ return contained.name();
4349
+ }
4350
+ }
4351
+
4318
4352
  void
4319
4353
  Slice::Unit::setDocComment(const string& comment)
4320
4354
  {
@@ -4409,7 +4443,7 @@ Slice::Unit::currentLine() const
4409
4443
  }
4410
4444
 
4411
4445
  int
4412
- Slice::Unit::setCurrentFile(std::string currentFile, int lineNumber)
4446
+ Slice::Unit::setCurrentFile(string currentFile, int lineNumber)
4413
4447
  {
4414
4448
  assert(!currentFile.empty());
4415
4449
 
@@ -4695,12 +4729,12 @@ Slice::Unit::findContents(const string& scopedName) const
4695
4729
  }
4696
4730
 
4697
4731
  void
4698
- Slice::Unit::addTypeId(int32_t compactId, const std::string& typeId)
4732
+ Slice::Unit::addTypeId(int32_t compactId, const string& typeId)
4699
4733
  {
4700
4734
  _typeIds.insert(make_pair(compactId, typeId));
4701
4735
  }
4702
4736
 
4703
- std::string
4737
+ string
4704
4738
  Slice::Unit::getTypeId(int32_t compactId) const
4705
4739
  {
4706
4740
  auto p = _typeIds.find(compactId);
@@ -4790,7 +4824,7 @@ Slice::Unit::destroy()
4790
4824
  void
4791
4825
  Slice::Unit::visit(ParserVisitor* visitor)
4792
4826
  {
4793
- auto self = dynamic_pointer_cast<Unit>(shared_from_this());
4827
+ auto self = static_pointer_cast<Unit>(shared_from_this());
4794
4828
  if (visitor->visitUnitStart(self))
4795
4829
  {
4796
4830
  visitContents(visitor);
@@ -4819,7 +4853,7 @@ Slice::Unit::createBuiltin(Builtin::Kind kind)
4819
4853
  {
4820
4854
  return p->second;
4821
4855
  }
4822
- auto builtin = make_shared<Builtin>(dynamic_pointer_cast<Unit>(shared_from_this()), kind);
4856
+ auto builtin = make_shared<Builtin>(static_pointer_cast<Unit>(shared_from_this()), kind);
4823
4857
  _builtins.insert(make_pair(kind, builtin));
4824
4858
  return builtin;
4825
4859
  }
@@ -4854,9 +4888,12 @@ Slice::Unit::getTopLevelModules(const string& file) const
4854
4888
  }
4855
4889
  }
4856
4890
 
4857
- Slice::Unit::Unit(string languageName, bool all) : _languageName(std::move(languageName)), _all(all)
4891
+ Slice::Unit::Unit(string languageName, UnitOptions options)
4892
+ : _languageName(std::move(languageName)),
4893
+ _all(options.all),
4894
+ _defaultMappedName(std::move(options.defaultMappedName))
4858
4895
  {
4859
- if (!languageName.empty())
4896
+ if (!_languageName.empty())
4860
4897
  {
4861
4898
  assert(binary_search(&languages[0], &languages[sizeof(languages) / sizeof(*languages)], _languageName));
4862
4899
  }