Codechange: Use null pointer literal instead of the NULL macro
This commit is contained in:

committed by
Michael Lutz

parent
3b4f224c0b
commit
7c8e7c6b6e
@@ -22,7 +22,7 @@
|
||||
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
|
||||
/** Cached current locale. */
|
||||
static CFLocaleRef _osx_locale = NULL;
|
||||
static CFLocaleRef _osx_locale = nullptr;
|
||||
/** CoreText cache for font information, cleared when OTTD changes fonts. */
|
||||
static CTFontRef _font_cache[FS_END];
|
||||
|
||||
@@ -125,21 +125,21 @@ static CGFloat SpriteFontGetWidth(void *ref_con)
|
||||
}
|
||||
|
||||
static CTRunDelegateCallbacks _sprite_font_callback = {
|
||||
kCTRunDelegateCurrentVersion, NULL, NULL, NULL,
|
||||
kCTRunDelegateCurrentVersion, nullptr, nullptr, nullptr,
|
||||
&SpriteFontGetWidth
|
||||
};
|
||||
|
||||
/* static */ ParagraphLayouter *CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping)
|
||||
{
|
||||
if (!MacOSVersionIsAtLeast(10, 5, 0)) return NULL;
|
||||
if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr;
|
||||
|
||||
/* Can't layout an empty string. */
|
||||
ptrdiff_t length = buff_end - buff;
|
||||
if (length == 0) return NULL;
|
||||
if (length == 0) return nullptr;
|
||||
|
||||
/* Can't layout our in-built sprite fonts. */
|
||||
for (const auto &i : fontMapping) {
|
||||
if (i.second->fc->IsBuiltInFont()) return NULL;
|
||||
if (i.second->fc->IsBuiltInFont()) return nullptr;
|
||||
}
|
||||
|
||||
/* Make attributed string with embedded font information. */
|
||||
@@ -156,10 +156,10 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
||||
for (const auto &i : fontMapping) {
|
||||
if (i.first - last == 0) continue;
|
||||
|
||||
if (_font_cache[i.second->fc->GetSize()] == NULL) {
|
||||
if (_font_cache[i.second->fc->GetSize()] == nullptr) {
|
||||
/* Cache font information. */
|
||||
CFStringRef font_name = CFStringCreateWithCString(kCFAllocatorDefault, i.second->fc->GetFontName(), kCFStringEncodingUTF8);
|
||||
_font_cache[i.second->fc->GetSize()] = CTFontCreateWithName(font_name, i.second->fc->GetFontSize(), NULL);
|
||||
_font_cache[i.second->fc->GetSize()] = CTFontCreateWithName(font_name, i.second->fc->GetFontSize(), nullptr);
|
||||
CFRelease(font_name);
|
||||
}
|
||||
CFAttributedStringSetAttribute(str, CFRangeMake(last, i.first - last), kCTFontAttributeName, _font_cache[i.second->fc->GetSize()]);
|
||||
@@ -185,12 +185,12 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
||||
CTTypesetterRef typesetter = CTTypesetterCreateWithAttributedString(str);
|
||||
CFRelease(str);
|
||||
|
||||
return typesetter != NULL ? new CoreTextParagraphLayout(typesetter, buff, length, fontMapping) : NULL;
|
||||
return typesetter != nullptr ? new CoreTextParagraphLayout(typesetter, buff, length, fontMapping) : nullptr;
|
||||
}
|
||||
|
||||
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> CoreTextParagraphLayout::NextLine(int max_width)
|
||||
{
|
||||
if (this->cur_offset >= this->length) return NULL;
|
||||
if (this->cur_offset >= this->length) return nullptr;
|
||||
|
||||
/* Get line break position, trying word breaking first and breaking somewhere if that doesn't work. */
|
||||
CFIndex len = CTTypesetterSuggestLineBreak(this->typesetter, this->cur_offset, max_width);
|
||||
@@ -200,7 +200,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
||||
CTLineRef line = CTTypesetterCreateLine(this->typesetter, CFRangeMake(this->cur_offset, len));
|
||||
this->cur_offset += len;
|
||||
|
||||
return std::unique_ptr<const Line>(line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL);
|
||||
return std::unique_ptr<const Line>(line != nullptr ? new CoreTextLine(line, this->font_map, this->text_buffer) : nullptr);
|
||||
}
|
||||
|
||||
CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff) : font(font)
|
||||
@@ -233,7 +233,7 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font
|
||||
this->positions[i * 2 + 1] = pts[i].y;
|
||||
}
|
||||
}
|
||||
this->total_advance = (int)CTRunGetTypographicBounds(run, CFRangeMake(0, 0), NULL, NULL, NULL);
|
||||
this->total_advance = (int)CTRunGetTypographicBounds(run, CFRangeMake(0, 0), nullptr, nullptr, nullptr);
|
||||
this->positions[this->glyphs.size() * 2] = this->positions[0] + this->total_advance;
|
||||
}
|
||||
|
||||
@@ -271,9 +271,9 @@ int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
|
||||
/** Delete CoreText font reference for a specific font size. */
|
||||
void MacOSResetScriptCache(FontSize size)
|
||||
{
|
||||
if (_font_cache[size] != NULL) {
|
||||
if (_font_cache[size] != nullptr) {
|
||||
CFRelease(_font_cache[size]);
|
||||
_font_cache[size] = NULL;
|
||||
_font_cache[size] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ void MacOSSetCurrentLocaleName(const char *iso_code)
|
||||
{
|
||||
if (!MacOSVersionIsAtLeast(10, 5, 0)) return;
|
||||
|
||||
if (_osx_locale != NULL) CFRelease(_osx_locale);
|
||||
if (_osx_locale != nullptr) CFRelease(_osx_locale);
|
||||
|
||||
CFStringRef iso = CFStringCreateWithCString(kCFAllocatorNull, iso_code, kCFStringEncodingUTF8);
|
||||
_osx_locale = CFLocaleCreate(kCFAllocatorDefault, iso);
|
||||
@@ -425,7 +425,7 @@ int MacOSStringCompare(const char *s1, const char *s2)
|
||||
|
||||
/* static */ StringIterator *OSXStringIterator::Create()
|
||||
{
|
||||
if (!MacOSVersionIsAtLeast(10, 5, 0)) return NULL;
|
||||
if (!MacOSVersionIsAtLeast(10, 5, 0)) return nullptr;
|
||||
|
||||
return new OSXStringIterator();
|
||||
}
|
||||
@@ -441,11 +441,11 @@ int MacOSStringCompare(const char *s1, const char *s2)
|
||||
|
||||
/* static */ StringIterator *OSXStringIterator::Create()
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* static */ ParagraphLayouter *CoreTextParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping)
|
||||
{
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif /* (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) */
|
||||
|
Reference in New Issue
Block a user