Skip to content

Conversation

grhoten
Copy link
Member

@grhoten grhoten commented Jan 11, 2025

These changes fully remove the Core Foundation dependency. It took a fair amount of time to refactor the arguments and map them to ICU compatible types. Here is a summary of the changes.

  • CFError has been replaced by UErrorCode.
  • CFLocale has been replaced by const char *
  • CFString has been replaced by getters with a destination buffer, or as const char16_t *.
  • CFArray has been replaced with UEnumeration
  • The CFDictionary has been replaced with arrays of IDDisplayValue_Constraint. The keys aren't guaranteed to be unique.
  • The createPropertyNames in DictionaryMetaData didn't make the transition. It doesn't fit well with the memory management of UEnumeration, but the functionality still exists. It just requires the caller to use a non-trivial loop iddmd_getPropertyName instead.

Now that the Core Foundation dependency has been removed, I also made the code compile cleanly (no compiler warnings) with clang, and it passes the tests with gcc now. There are a large number of warnings coming from Catch2 due to the -Weffc++ compiler option being used with gcc, and none of this code in the shared library have any compiler warnings with gcc.

It's also worth mentioning that this code currently depends on C23 instead of C11. It's needed to define the exact size of ILogLevel. N3030

Comment on lines 47 to 48
} else if (dynamic_cast<const ::inflection::exception::NullPointerException*>(&e) != nullptr) {
*status = U_MEMORY_ALLOCATION_ERROR;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A direct correlation of this error does not exist in ICU. There are a lot of scenarios where null is provided, and it's not allowed. I recommend that ICU adds such a value to UErrorCode. The meaning of this error is compatible with Java's NullPointerException.

CONFIGURE_COMMAND "" INSTALL_COMMAND "" LOG_DOWNLOAD ON EXCLUDE_FROM_ALL TRUE DOWNLOAD_NO_EXTRACT TRUE
BUILD_COMMAND ${CMAKE_CURRENT_LIST_DIR}/patch.sh ${CMAKE_CURRENT_BINARY_DIR}/marisa-trie ${CMAKE_CURRENT_LIST_DIR}/Exception.patch
CONFIGURE_COMMAND "" INSTALL_COMMAND "" LOG_DOWNLOAD ON EXCLUDE_FROM_ALL TRUE
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/marisa-trie
Copy link
Contributor

@nciric nciric Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like getting rid of Exception warning, but this means that if marisa-trie-original/include/marisa/exception.h changes once we upgrade the MARISA_VERSION we need to recreate the patch. Maybe leave a comment in this block for future maintenance:

If you are upgrading the Marisa version, you may need to recreate the patch in inflection/ext/lib/Marisa/Exception.patch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have doubts that a new version will be created anytime soon. The last commit was about 5 years ago, and the owner hasn't been active for several years. Though a fair number of people are opening pull requests and adding issues to it.

It's more likely that the patch will be extended to incorporate some minor optimizations. I'll add some commentary here in any case. This specific issue has a longer discussion here: s-yata/marisa-trie#50

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added some commentary around these lines about the patch

Copy link
Contributor

@nciric nciric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C changes look good - not much can be done there wrt containers or ICU UErrorCode.

Copy link
Contributor

@nciric nciric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge.

@grhoten grhoten merged commit 71393a2 into unicode-org:main Jan 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants