Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
GrAutoLocaleSetter Class Reference

#include <GrAutoLocaleSetter.h>

Inheritance diagram for GrAutoLocaleSetter:
SkNoncopyable

Public Member Functions

 GrAutoLocaleSetter (const char *name)
 
 ~GrAutoLocaleSetter ()
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Detailed Description

Helper class for ensuring that we don't use the wrong locale when building shaders. Android doesn't support locale in the NDK, so this is a no-op there.

Definition at line 40 of file GrAutoLocaleSetter.h.

Constructor & Destructor Documentation

◆ GrAutoLocaleSetter()

GrAutoLocaleSetter::GrAutoLocaleSetter ( const char *  name)
inline

Definition at line 42 of file GrAutoLocaleSetter.h.

42 {
43#if defined(SK_BUILD_FOR_WIN)
44 fOldPerThreadLocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
45 char* oldLocale = setlocale(LC_ALL, name);
46 if (oldLocale) {
47 fOldLocale = oldLocale;
48 fShouldRestoreLocale = true;
49 } else {
50 fShouldRestoreLocale = false;
51 }
52#elif HAVE_LOCALE_T
53#if HAVE_XLOCALE
54 // In xlocale nullptr means the C locale.
55 if (0 == strcmp(name, "C")) {
56 name = nullptr;
57 }
58#endif
59 fLocale = newlocale(LC_ALL_MASK, name, nullptr);
60 if (fLocale) {
61 fOldLocale = uselocale(fLocale);
62 } else {
63 fOldLocale = static_cast<locale_t>(nullptr);
64 }
65#else
66 (void) name; // suppress unused param warning.
67#endif
68 }
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32

◆ ~GrAutoLocaleSetter()

GrAutoLocaleSetter::~GrAutoLocaleSetter ( )
inline

Definition at line 70 of file GrAutoLocaleSetter.h.

70 {
71#if defined(SK_BUILD_FOR_WIN)
72 if (fShouldRestoreLocale) {
73 setlocale(LC_ALL, fOldLocale.c_str());
74 }
75 _configthreadlocale(fOldPerThreadLocale);
76#elif HAVE_LOCALE_T
77 if (fLocale) {
78 uselocale(fOldLocale);
79 freelocale(fLocale);
80 }
81#endif
82 }

The documentation for this class was generated from the following file: