|
2 | 2 | * Copyright 2021-2024 Apple Inc. All rights reserved. |
3 | 3 | */ |
4 | 4 | #include <inflection/dialog/InflectableStringConcept.h> |
5 | | - |
| 5 | +#include <inflection/npc.hpp> |
6 | 6 | #include <inflection/dialog/InflectableStringConcept.hpp> |
7 | 7 | #include <inflection/dialog/SemanticFeatureConcept.h> |
8 | 8 | #include <inflection/exception/ClassCastException.hpp> |
9 | 9 | #include <inflection/util/ULocale.hpp> |
10 | 10 | #include <inflection/dialog/SemanticFeature.hpp> |
| 11 | +#include <inflection/dialog/SemanticUtils.hpp> |
| 12 | +#include <inflection/dialog/SemanticFeatureModel.hpp> |
11 | 13 | #include <inflection/util/TypeConversionUtils.hpp> |
12 | 14 | #include <inflection/util/Validate.hpp> |
13 | 15 |
|
| 16 | + |
14 | 17 | INFLECTION_CAPI IDSemanticFeatureConcept* iinf_toSemanticFeatureConcept(IDInflectableStringConcept* thisObject, UErrorCode*) |
15 | 18 | { |
16 | 19 | return (IDSemanticFeatureConcept*)thisObject; |
@@ -49,21 +52,16 @@ iinf_create(const IDSemanticFeatureModel* model, const IDSpeakableString* value, |
49 | 52 | } |
50 | 53 |
|
51 | 54 | INFLECTION_CAPI IDInflectableStringConcept* |
52 | | -iinf_createWithConstraints(const IDSemanticFeatureModel* model, const IDSpeakableString* value, |
53 | | - const ::inflection::dialog::SemanticFeature* features, const char16_t** values, int32_t SemanticFeaturesLen, UErrorCode* status) { |
| 55 | +iinf_createWithDefaults(const IDSemanticFeatureModel* model, const IDSpeakableString* value, |
| 56 | + const IDDisplayValue_Constraint* defaultConstraints, int32_t defaultConstraintsLen, UErrorCode* status) { |
54 | 57 | if (status != nullptr && U_SUCCESS(*status)) { |
55 | 58 | try { |
56 | | - inflection::util::Validate::notNull(value); |
57 | | - |
58 | | - ::std::map< ::inflection::dialog::SemanticFeature, ::std::u16string> initialConstraints; |
59 | | - for (int32_t i = 0; i < SemanticFeaturesLen; ++i) { |
60 | | - initialConstraints.emplace(features[i], ::std::u16string(values[i])); |
61 | | - } |
| 59 | + auto defaultConstraintsMap(inflection::dialog::SemanticUtils::to_constraintMap(*npc((const inflection::dialog::SemanticFeatureModel*)model), defaultConstraints, defaultConstraintsLen)); |
62 | 60 |
|
63 | 61 | return (IDInflectableStringConcept*) new ::inflection::dialog::InflectableStringConcept( |
64 | 62 | (const ::inflection::dialog::SemanticFeatureModel*)model, |
65 | 63 | *((const ::inflection::dialog::SpeakableString*)value), |
66 | | - initialConstraints |
| 64 | + defaultConstraintsMap |
67 | 65 | ); |
68 | 66 | } |
69 | 67 | catch (const ::std::exception& e) { |
|
0 commit comments