GCC fixes: things
This was SVN commit r1035.
This commit is contained in:
parent
6873de4ed0
commit
003bf13eb0
@ -14,11 +14,11 @@ using namespace I18n;
|
||||
namespace I18n {
|
||||
// These bits don't seem to work without the explicit namespace{}
|
||||
|
||||
BufferVariable* NewBufferVariable(int v) { return new BufferVariable_int(v); }
|
||||
BufferVariable* NewBufferVariable(double v) { return new BufferVariable_double(v); }
|
||||
BufferVariable* NewBufferVariable(const wchar_t* v) { return new BufferVariable_string(v); }
|
||||
BufferVariable* NewBufferVariable(const char* v) { return new BufferVariable_string(v); }
|
||||
BufferVariable* NewBufferVariable(I18n::Name v) { return new BufferVariable_rawstring(v.value); }
|
||||
template<> BufferVariable* NewBufferVariable<int>(int v) { return new BufferVariable_int(v); }
|
||||
template<> BufferVariable* NewBufferVariable<double>(double v) { return new BufferVariable_double(v); }
|
||||
template<> BufferVariable* NewBufferVariable<const wchar_t*>(const wchar_t* v) { return new BufferVariable_string(v); }
|
||||
template<> BufferVariable* NewBufferVariable<const char*>(const char* v) { return new BufferVariable_string(v); }
|
||||
template<> BufferVariable* NewBufferVariable<I18n::Name>(I18n::Name v) { return new BufferVariable_rawstring(v.value); }
|
||||
}
|
||||
|
||||
StrImW BufferVariable_int::ToString(CLocale*)
|
||||
|
@ -23,6 +23,23 @@ All other methods are used internally by other I18n components.
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef __GNUC__
|
||||
namespace __gnu_cxx
|
||||
{
|
||||
template<> struct hash<I18n::Str>
|
||||
{
|
||||
size_t operator()(const I18n::Str& s) const
|
||||
{
|
||||
const wchar_t* __s = s.c_str();
|
||||
unsigned long __h = 0;
|
||||
for ( ; *__s; ++__s)
|
||||
__h = 5*__h + *__s;
|
||||
return size_t(__h);
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // __GNUC__
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace I18n
|
||||
@ -30,7 +47,7 @@ namespace I18n
|
||||
|
||||
class CLocale : public CLocale_interface
|
||||
{
|
||||
friend StringBuffer;
|
||||
friend class StringBuffer;
|
||||
|
||||
private:
|
||||
typedef STL_HASH_MAP<Str, TranslatedString*> StringsType;
|
||||
|
@ -16,4 +16,4 @@ namespace I18n
|
||||
}
|
||||
|
||||
|
||||
#endif // I18N_DATATYPES_H
|
||||
#endif // I18N_DATATYPES_H
|
||||
|
@ -18,7 +18,11 @@ and 'variables' (dependent on the type passed with "translate(...) <<").
|
||||
ERROR_SUBGROUP(I18n, Script);
|
||||
ERROR_TYPE(I18n_Script, SetupFailed);
|
||||
|
||||
#ifdef XP_WIN // the Windows JS libraries are using '_W64 long' to avoid MSVC warnings
|
||||
typedef _W64 long jsval;
|
||||
#else
|
||||
typedef long jsval;
|
||||
#endif
|
||||
typedef unsigned short jschar;
|
||||
struct JSContext;
|
||||
struct JSObject;
|
||||
|
@ -30,7 +30,7 @@ namespace I18n
|
||||
// I'm lazy (elsewhere), so allow construction from a variety
|
||||
// of data types:
|
||||
|
||||
const StrImW(const wchar_t* s)
|
||||
StrImW(const wchar_t* s)
|
||||
{
|
||||
ref = new strImW_data;
|
||||
size_t len = wcslen(s)+1;
|
||||
@ -38,7 +38,7 @@ namespace I18n
|
||||
memcpy((void*)ref->data, s, len*sizeof(wchar_t));
|
||||
}
|
||||
|
||||
const StrImW(const char* s)
|
||||
StrImW(const char* s)
|
||||
{
|
||||
ref = new strImW_data;
|
||||
size_t len = strlen(s)+1;
|
||||
@ -49,7 +49,7 @@ namespace I18n
|
||||
|
||||
// On non-MSVC, or on MSVC with a native wchar_t type, define jschar separately
|
||||
#if !defined(_MSC_VER) || !defined(_WCHAR_T_DEFINED)
|
||||
const StrImW(const jschar* s)
|
||||
StrImW(const jschar* s)
|
||||
{
|
||||
ref = new strImW_data;
|
||||
size_t len = 0;
|
||||
@ -61,7 +61,7 @@ namespace I18n
|
||||
}
|
||||
#endif
|
||||
|
||||
const StrImW(const jschar* s, size_t len)
|
||||
StrImW(const jschar* s, size_t len)
|
||||
{
|
||||
ref = new strImW_data;
|
||||
ref->data = new wchar_t[len+1];
|
||||
@ -80,7 +80,7 @@ namespace I18n
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
const StrImW(const StrImW& s)
|
||||
StrImW(const StrImW& s)
|
||||
{
|
||||
ref = s.ref;
|
||||
++ref->refs;
|
||||
|
@ -10,6 +10,7 @@ before converting into a string.
|
||||
|
||||
#include "Common.h"
|
||||
#include "TranslatedString.h"
|
||||
#include "ps/CStr.h"
|
||||
|
||||
namespace I18n
|
||||
{
|
||||
@ -20,10 +21,12 @@ namespace I18n
|
||||
|
||||
class StringBuffer
|
||||
{
|
||||
friend CLocale;
|
||||
friend class CLocale;
|
||||
|
||||
public:
|
||||
// Builds and returns the finished string
|
||||
operator Str();
|
||||
operator CStrW() { return CStrW( (Str)*this ); }
|
||||
|
||||
// Stores the variable inside the StringBuffer,
|
||||
// for later conversion into a string
|
||||
@ -46,4 +49,4 @@ namespace I18n
|
||||
|
||||
}
|
||||
|
||||
#endif I18N_STRINGBUF_H
|
||||
#endif // I18N_STRINGBUF_H
|
||||
|
@ -70,4 +70,4 @@ namespace I18n
|
||||
|
||||
}
|
||||
|
||||
#endif // I18N_TSCOMPONENT_H
|
||||
#endif // I18N_TSCOMPONENT_H
|
||||
|
@ -9,4 +9,4 @@ TranslatedString::~TranslatedString()
|
||||
{
|
||||
for (std::vector<const TSComponent*>::iterator it = Parts.begin(); it != Parts.end(); ++it)
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
|
@ -25,4 +25,4 @@ namespace I18n
|
||||
|
||||
}
|
||||
|
||||
#endif // I18N_TSTRING_H
|
||||
#endif // I18N_TSTRING_H
|
||||
|
Loading…
Reference in New Issue
Block a user