mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 06:25:30 +00:00
ICU-21545 fix Unicode properties Bazel build
This commit is contained in:
parent
4af7d969df
commit
109a830ed2
4 changed files with 48 additions and 9 deletions
|
@ -34,6 +34,20 @@ void handleError(ErrorCode& status, const char* context) {
|
|||
}
|
||||
}
|
||||
|
||||
class PropertyValueNameGetter : public ValueNameGetter {
|
||||
public:
|
||||
PropertyValueNameGetter(UProperty prop) : property(prop) {}
|
||||
~PropertyValueNameGetter() override;
|
||||
const char *getName(uint32_t value) override {
|
||||
return u_getPropertyValueName(property, value, U_SHORT_PROPERTY_NAME);
|
||||
}
|
||||
|
||||
private:
|
||||
UProperty property;
|
||||
};
|
||||
|
||||
PropertyValueNameGetter::~PropertyValueNameGetter() {}
|
||||
|
||||
void dumpBinaryProperty(UProperty uproperty, FILE* f) {
|
||||
IcuToolErrorCode status("icuexportdata: dumpBinaryProperty");
|
||||
const char* fullPropName = u_getPropertyName(uproperty, U_LONG_PROPERTY_NAME);
|
||||
|
@ -57,7 +71,8 @@ void dumpEnumeratedProperty(UProperty uproperty, FILE* f) {
|
|||
fputs("[[enum_property]]\n", f);
|
||||
fprintf(f, "long_name = \"%s\"\n", fullPropName);
|
||||
if (shortPropName) fprintf(f, "short_name = \"%s\"\n", shortPropName);
|
||||
usrc_writeUCPMap(f, umap, uproperty, UPRV_TARGET_SYNTAX_TOML);
|
||||
PropertyValueNameGetter valueNameGetter(uproperty);
|
||||
usrc_writeUCPMap(f, umap, &valueNameGetter, UPRV_TARGET_SYNTAX_TOML);
|
||||
fputs("\n", f);
|
||||
|
||||
U_ASSERT(u_getIntPropertyMinValue(uproperty) >= 0);
|
||||
|
|
|
@ -54,7 +54,11 @@ cc_library(
|
|||
local_defines = [
|
||||
"U_TOOLUTIL_IMPLEMENTATION",
|
||||
],
|
||||
deps = ["//icu4c/source/common:platform"],
|
||||
deps = [
|
||||
"//icu4c/source/common:bytestream",
|
||||
"//icu4c/source/common:platform",
|
||||
"//icu4c/source/common:uniset_core",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
|
|
|
@ -32,6 +32,12 @@
|
|||
#include "writesrc.h"
|
||||
#include "util.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
ValueNameGetter::~ValueNameGetter() {}
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
U_NAMESPACE_USE
|
||||
|
||||
static FILE *
|
||||
|
@ -401,7 +407,7 @@ U_CAPI void U_EXPORT2
|
|||
usrc_writeUCPMap(
|
||||
FILE *f,
|
||||
const UCPMap *pMap,
|
||||
UProperty uproperty,
|
||||
icu::ValueNameGetter *valueNameGetter,
|
||||
UTargetSyntax syntax) {
|
||||
// ccode is not yet supported
|
||||
U_ASSERT(syntax == UPRV_TARGET_SYNTAX_TOML);
|
||||
|
@ -413,9 +419,9 @@ usrc_writeUCPMap(
|
|||
fprintf(f, "# Code points `a` through `b` have value `v`, corresponding to `name`.\n");
|
||||
fprintf(f, "ranges = [\n");
|
||||
while ((end = ucpmap_getRange(pMap, start, UCPMAP_RANGE_NORMAL, 0, nullptr, nullptr, &value)) >= 0) {
|
||||
if (uproperty != UCHAR_INVALID_CODE) {
|
||||
const char* short_name = u_getPropertyValueName(uproperty, value, U_SHORT_PROPERTY_NAME);
|
||||
fprintf(f, " {a=0x%x, b=0x%x, v=%u, name=\"%s\"},\n", start, end, value, short_name);
|
||||
if (valueNameGetter != nullptr) {
|
||||
const char *name = valueNameGetter->getName(value);
|
||||
fprintf(f, " {a=0x%x, b=0x%x, v=%u, name=\"%s\"},\n", start, end, value, name);
|
||||
} else {
|
||||
fprintf(f, " {a=0x%x, b=0x%x, v=%u},\n", start, end, value);
|
||||
}
|
||||
|
|
|
@ -143,19 +143,33 @@ usrc_writeUnicodeSet(
|
|||
const USet *pSet,
|
||||
UTargetSyntax syntax);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
||||
class U_TOOLUTIL_API ValueNameGetter {
|
||||
public:
|
||||
virtual ~ValueNameGetter();
|
||||
virtual const char *getName(uint32_t value) = 0;
|
||||
};
|
||||
|
||||
U_NAMESPACE_END
|
||||
|
||||
/**
|
||||
* Writes the UCPMap ranges list.
|
||||
*
|
||||
* The "uproperty" argument is optional; ignored if UCHAR_INVALID_CODE. If present, it will be used
|
||||
* to look up the property value name strings.
|
||||
* The "valueNameGetter" argument is optional; ignored if nullptr.
|
||||
* If present, it will be used to look up value name strings.
|
||||
*/
|
||||
U_CAPI void U_EXPORT2
|
||||
usrc_writeUCPMap(
|
||||
FILE *f,
|
||||
const UCPMap *pMap,
|
||||
UProperty uproperty,
|
||||
icu::ValueNameGetter *valueNameGetter,
|
||||
UTargetSyntax syntax);
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
/**
|
||||
* Writes the contents of an array of mostly invariant characters.
|
||||
* Characters 0..0x1f are printed as numbers,
|
||||
|
|
Loading…
Add table
Reference in a new issue