Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /intern/locale
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'intern/locale')
-rw-r--r--intern/locale/CMakeLists.txt28
-rw-r--r--intern/locale/boost_locale_wrapper.cpp137
-rw-r--r--intern/locale/boost_locale_wrapper.h2
-rw-r--r--intern/locale/osx_user_locale.mm22
4 files changed, 95 insertions, 94 deletions
diff --git a/intern/locale/CMakeLists.txt b/intern/locale/CMakeLists.txt
index 31b9e690b29..5c5da31482d 100644
--- a/intern/locale/CMakeLists.txt
+++ b/intern/locale/CMakeLists.txt
@@ -19,42 +19,42 @@
# ***** END GPL LICENSE BLOCK *****
set(INC
- .
+ .
)
set(INC_SYS
)
set(SRC
- boost_locale_wrapper.cpp
+ boost_locale_wrapper.cpp
- boost_locale_wrapper.h
+ boost_locale_wrapper.h
)
set(LIB
)
if(APPLE)
- # Cocoa code to read the locale on OSX
- list(APPEND SRC
- osx_user_locale.mm
- )
+ # Cocoa code to read the locale on OSX
+ list(APPEND SRC
+ osx_user_locale.mm
+ )
endif()
if(WITH_HEADLESS)
- add_definitions(-DWITH_HEADLESS)
+ add_definitions(-DWITH_HEADLESS)
endif()
if(WITH_GHOST_SDL)
- add_definitions(-DWITH_GHOST_SDL)
+ add_definitions(-DWITH_GHOST_SDL)
endif()
if(WITH_INTERNATIONAL)
- list(APPEND INC_SYS
- ${BOOST_INCLUDE_DIR}
- )
- add_definitions(-DWITH_INTERNATIONAL)
- add_definitions(${BOOST_DEFINITIONS})
+ list(APPEND INC_SYS
+ ${BOOST_INCLUDE_DIR}
+ )
+ add_definitions(-DWITH_INTERNATIONAL)
+ add_definitions(${BOOST_DEFINITIONS})
endif()
blender_add_lib(bf_intern_locale "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/intern/locale/boost_locale_wrapper.cpp b/intern/locale/boost_locale_wrapper.cpp
index 04b106335bb..bb46f48a14f 100644
--- a/intern/locale/boost_locale_wrapper.cpp
+++ b/intern/locale/boost_locale_wrapper.cpp
@@ -35,104 +35,105 @@ static char_message_facet const *facet_global = NULL;
static void bl_locale_global_cache()
{
- /* Cache facet in global variable. Not only is it better for performance,
- * it also fixes crashes on macOS when doing translation from threads other
- * than main. Likely because of some internal thread local variables. */
- try {
- /* facet_global reference is valid as long as local_global exists,
- * so we store both. */
- locale_global = std::locale();
- facet_global = &std::use_facet<char_message_facet>(locale_global);
- }
- catch(const std::bad_cast &e) { /* if std::has_facet<char_message_facet>(l) == false, LC_ALL = "C" case */
+ /* Cache facet in global variable. Not only is it better for performance,
+ * it also fixes crashes on macOS when doing translation from threads other
+ * than main. Likely because of some internal thread local variables. */
+ try {
+ /* facet_global reference is valid as long as local_global exists,
+ * so we store both. */
+ locale_global = std::locale();
+ facet_global = &std::use_facet<char_message_facet>(locale_global);
+ }
+ catch (const std::bad_cast
+ &e) { /* if std::has_facet<char_message_facet>(l) == false, LC_ALL = "C" case */
#ifndef NDEBUG
- std::cout << "bl_locale_global_cache:" << e.what() << " \n";
+ std::cout << "bl_locale_global_cache:" << e.what() << " \n";
#endif
- (void)e;
- facet_global = NULL;
- }
- catch(const std::exception &e) {
+ (void)e;
+ facet_global = NULL;
+ }
+ catch (const std::exception &e) {
#ifndef NDEBUG
- std::cout << "bl_locale_global_cache:" << e.what() << " \n";
+ std::cout << "bl_locale_global_cache:" << e.what() << " \n";
#endif
- (void)e;
- facet_global = NULL;
- }
+ (void)e;
+ facet_global = NULL;
+ }
}
void bl_locale_init(const char *_messages_path, const char *_default_domain)
{
- // Avoid using ICU backend, we do not need its power and it's rather heavy!
- boost::locale::localization_backend_manager lman = boost::locale::localization_backend_manager::global();
-#if defined (_WIN32)
- lman.select("winapi");
+ // Avoid using ICU backend, we do not need its power and it's rather heavy!
+ boost::locale::localization_backend_manager lman =
+ boost::locale::localization_backend_manager::global();
+#if defined(_WIN32)
+ lman.select("winapi");
#else
- lman.select("posix");
+ lman.select("posix");
#endif
- boost::locale::localization_backend_manager::global(lman);
+ boost::locale::localization_backend_manager::global(lman);
- messages_path = _messages_path;
- default_domain = _default_domain;
+ messages_path = _messages_path;
+ default_domain = _default_domain;
}
void bl_locale_set(const char *locale)
{
- boost::locale::generator gen;
- std::locale _locale;
- // Specify location of dictionaries.
- gen.add_messages_path(messages_path);
- gen.add_messages_domain(default_domain);
- //gen.set_default_messages_domain(default_domain);
-
- try {
- if (locale && locale[0]) {
- _locale = gen(locale);
- }
- else {
+ boost::locale::generator gen;
+ std::locale _locale;
+ // Specify location of dictionaries.
+ gen.add_messages_path(messages_path);
+ gen.add_messages_domain(default_domain);
+ //gen.set_default_messages_domain(default_domain);
+
+ try {
+ if (locale && locale[0]) {
+ _locale = gen(locale);
+ }
+ else {
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
- std::string locale_osx = osx_user_locale() + std::string(".UTF-8");
- _locale = gen(locale_osx.c_str());
+ std::string locale_osx = osx_user_locale() + std::string(".UTF-8");
+ _locale = gen(locale_osx.c_str());
#else
- _locale = gen("");
+ _locale = gen("");
#endif
- }
- std::locale::global(_locale);
- // Note: boost always uses "C" LC_NUMERIC by default!
+ }
+ std::locale::global(_locale);
+ // Note: boost always uses "C" LC_NUMERIC by default!
- bl_locale_global_cache();
+ bl_locale_global_cache();
- // Generate the locale string (useful to know which locale we are actually using in case of "default" one).
+ // Generate the locale string (useful to know which locale we are actually using in case of "default" one).
#define LOCALE_INFO std::use_facet<boost::locale::info>(_locale)
- locale_str = LOCALE_INFO.language();
- if (LOCALE_INFO.country() != "") {
- locale_str += "_" + LOCALE_INFO.country();
- }
- if (LOCALE_INFO.variant() != "") {
- locale_str += "@" + LOCALE_INFO.variant();
- }
+ locale_str = LOCALE_INFO.language();
+ if (LOCALE_INFO.country() != "") {
+ locale_str += "_" + LOCALE_INFO.country();
+ }
+ if (LOCALE_INFO.variant() != "") {
+ locale_str += "@" + LOCALE_INFO.variant();
+ }
#undef LOCALE_INFO
-
- }
- catch(std::exception const &e) {
- std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n";
- }
+ }
+ catch (std::exception const &e) {
+ std::cout << "bl_locale_set(" << locale << "): " << e.what() << " \n";
+ }
}
const char *bl_locale_get(void)
{
- return locale_str.c_str();
+ return locale_str.c_str();
}
const char *bl_locale_pgettext(const char *msgctxt, const char *msgid)
{
- if (facet_global) {
- char const *r = facet_global->get(0, msgctxt, msgid);
- if (r) {
- return r;
- }
- }
-
- return msgid;
+ if (facet_global) {
+ char const *r = facet_global->get(0, msgctxt, msgid);
+ if (r) {
+ return r;
+ }
+ }
+
+ return msgid;
}
diff --git a/intern/locale/boost_locale_wrapper.h b/intern/locale/boost_locale_wrapper.h
index b438b1bf9cc..deb552e4871 100644
--- a/intern/locale/boost_locale_wrapper.h
+++ b/intern/locale/boost_locale_wrapper.h
@@ -35,7 +35,7 @@ const char *bl_locale_get(void);
const char *bl_locale_pgettext(const char *msgctxt, const char *msgid);
#if defined(__APPLE__) && !defined(WITH_HEADLESS) && !defined(WITH_GHOST_SDL)
-const char* osx_user_locale(void);
+const char *osx_user_locale(void);
#endif
#ifdef __cplusplus
diff --git a/intern/locale/osx_user_locale.mm b/intern/locale/osx_user_locale.mm
index 1ed33bb1713..e2f65d39df9 100644
--- a/intern/locale/osx_user_locale.mm
+++ b/intern/locale/osx_user_locale.mm
@@ -4,19 +4,19 @@
#include <cstdlib>
-static char* user_locale = NULL;
+static char *user_locale = NULL;
// get current locale
-const char* osx_user_locale()
+const char *osx_user_locale()
{
- ::free(user_locale);
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
- NSLocale * myNSLocale = (NSLocale *) myCFLocale;
- [myNSLocale autorelease];
- NSString *nsIdentifier = [myNSLocale localeIdentifier];
- user_locale = ::strdup([nsIdentifier UTF8String]);
- [pool drain];
+ ::free(user_locale);
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
+ NSLocale *myNSLocale = (NSLocale *)myCFLocale;
+ [myNSLocale autorelease];
+ NSString *nsIdentifier = [myNSLocale localeIdentifier];
+ user_locale = ::strdup([nsIdentifier UTF8String]);
+ [pool drain];
- return user_locale;
+ return user_locale;
}