C++ containers.undefined
| @@ -21,9 +21,9 @@ namespace lol | |||
| * Safe enum helpers | |||
| */ | |||
| Map<int64_t, String> BuildEnumMap(char const *str, char const **custom) | |||
| map<int64_t, String> BuildEnumMap(char const *str, char const **custom) | |||
| { | |||
| Map<int64_t, String> ret; | |||
| map<int64_t, String> ret; | |||
| char const *parser = str; | |||
| int64_t next_value = 0; | |||
| int64_t cur_idx = 0; | |||
| @@ -18,7 +18,7 @@ namespace lol | |||
| { | |||
| /* | |||
| * Hash implementations | |||
| * hash implementations | |||
| */ | |||
| static class HashData | |||
| @@ -87,42 +87,42 @@ static inline uint32_t Hash64(uint64_t x) | |||
| * Integer hash functions | |||
| */ | |||
| uint32_t Hash<int8_t>::operator ()(int8_t x) const | |||
| uint32_t hash<int8_t>::operator ()(int8_t x) const | |||
| { | |||
| return Hash8((uint8_t)x); | |||
| } | |||
| uint32_t Hash<uint8_t>::operator ()(uint8_t x) const | |||
| uint32_t hash<uint8_t>::operator ()(uint8_t x) const | |||
| { | |||
| return Hash8(x); | |||
| } | |||
| uint32_t Hash<int16_t>::operator ()(int16_t x) const | |||
| uint32_t hash<int16_t>::operator ()(int16_t x) const | |||
| { | |||
| return Hash16((uint16_t)x); | |||
| } | |||
| uint32_t Hash<uint16_t>::operator ()(uint16_t x) const | |||
| uint32_t hash<uint16_t>::operator ()(uint16_t x) const | |||
| { | |||
| return Hash16(x); | |||
| } | |||
| uint32_t Hash<int32_t>::operator ()(int32_t x) const | |||
| uint32_t hash<int32_t>::operator ()(int32_t x) const | |||
| { | |||
| return Hash32((uint32_t)x); | |||
| } | |||
| uint32_t Hash<uint32_t>::operator ()(uint32_t x) const | |||
| uint32_t hash<uint32_t>::operator ()(uint32_t x) const | |||
| { | |||
| return Hash32(x); | |||
| } | |||
| uint32_t Hash<int64_t>::operator ()(int64_t x) const | |||
| uint32_t hash<int64_t>::operator ()(int64_t x) const | |||
| { | |||
| return Hash64((uint64_t)x); | |||
| } | |||
| uint32_t Hash<uint64_t>::operator ()(uint64_t x) const | |||
| uint32_t hash<uint64_t>::operator ()(uint64_t x) const | |||
| { | |||
| return Hash64(x); | |||
| } | |||
| @@ -131,18 +131,18 @@ uint32_t Hash<uint64_t>::operator ()(uint64_t x) const | |||
| * Floating-point hash functions | |||
| */ | |||
| uint32_t Hash<half>::operator ()(half f) const | |||
| uint32_t hash<half>::operator ()(half f) const | |||
| { | |||
| return Hash16(f.bits); | |||
| } | |||
| uint32_t Hash<float>::operator ()(float f) const | |||
| uint32_t hash<float>::operator ()(float f) const | |||
| { | |||
| union { float tmp; uint32_t x; } u = { f }; | |||
| return Hash32(u.x); | |||
| } | |||
| uint32_t Hash<double>::operator ()(double f) const | |||
| uint32_t hash<double>::operator ()(double f) const | |||
| { | |||
| union { double tmp; uint64_t x; } u = { f }; | |||
| return Hash64(u.x); | |||
| @@ -162,22 +162,22 @@ static uint32_t HashCharString(char const *s) | |||
| return ret ^ 0xffffffffu; | |||
| } | |||
| uint32_t Hash<char const *>::operator ()(char const *s) const | |||
| uint32_t hash<char const *>::operator ()(char const *s) const | |||
| { | |||
| return HashCharString(s); | |||
| } | |||
| uint32_t Hash<char const *>::operator ()(String const &s) const | |||
| uint32_t hash<char const *>::operator ()(String const &s) const | |||
| { | |||
| return HashCharString(&s[0]); | |||
| } | |||
| uint32_t Hash<String>::operator ()(String const &s) const | |||
| uint32_t hash<String>::operator ()(String const &s) const | |||
| { | |||
| return HashCharString(&s[0]); | |||
| } | |||
| uint32_t Hash<String>::operator ()(char const *s) const | |||
| uint32_t hash<String>::operator ()(char const *s) const | |||
| { | |||
| return HashCharString(s); | |||
| } | |||
| @@ -38,7 +38,7 @@ public: | |||
| private: | |||
| bool IsExpressionTrue(char const *buf); | |||
| Map<String, String> m_pp_defines; | |||
| map<String, String> m_pp_defines; | |||
| enum | |||
| { | |||
| @@ -99,8 +99,8 @@ private: | |||
| #elif !defined __CELLOS_LV2__ | |||
| GLuint prog_id, vert_id, frag_id; | |||
| // Benlitz: using a simple array could be faster since there is never more than a few attribute locations to store | |||
| Map<uint64_t, GLint> attrib_locations; | |||
| Map<uint64_t, bool> attrib_errors; | |||
| map<uint64_t, GLint> attrib_locations; | |||
| map<uint64_t, bool> attrib_errors; | |||
| #else | |||
| CGprogram vert_id, frag_id; | |||
| #endif | |||
| @@ -112,12 +112,12 @@ private: | |||
| /* Global shader cache */ | |||
| static Shader *shaders[]; | |||
| static Hash<char const *> hash; | |||
| static hash<char const *> Hash; | |||
| static int nshaders; | |||
| }; | |||
| Shader *ShaderData::shaders[256]; | |||
| Hash<char const *> ShaderData::hash; | |||
| hash<char const *> ShaderData::Hash; | |||
| int ShaderData::nshaders = 0; | |||
| /* | |||
| @@ -180,8 +180,8 @@ Shader *Shader::Create(String const &name, String const &code) | |||
| Log::Error("no fragment shader found in %s… sorry, I’m gonna crash now.\n", | |||
| name.C()); | |||
| uint32_t new_vert_crc = ShaderData::hash(vert); | |||
| uint32_t new_frag_crc = ShaderData::hash(frag); | |||
| uint32_t new_vert_crc = ShaderData::Hash(vert); | |||
| uint32_t new_frag_crc = ShaderData::Hash(frag); | |||
| for (int n = 0; n < ShaderData::nshaders; n++) | |||
| { | |||
| @@ -234,7 +234,7 @@ Shader::Shader(String const &name, | |||
| #endif | |||
| /* Compile vertex shader */ | |||
| data->vert_crc = ShaderData::hash(vert); | |||
| data->vert_crc = ShaderData::Hash(vert); | |||
| #if defined USE_D3D9 || defined _XBOX | |||
| # if defined USE_D3D9 | |||
| data->m_dev = (IDirect3DDevice9 *)g_renderer->GetDevice(); | |||
| @@ -286,7 +286,7 @@ Shader::Shader(String const &name, | |||
| #endif | |||
| /* Compile fragment shader */ | |||
| data->frag_crc = ShaderData::hash(frag); | |||
| data->frag_crc = ShaderData::Hash(frag); | |||
| #if defined USE_D3D9 || defined _XBOX | |||
| hr = D3DXCompileShader(frag, (UINT)strlen(frag), macros, nullptr, "main", | |||
| "ps_3_0", 0, &shader_code, &error_msg, | |||
| @@ -472,7 +472,7 @@ void OricImageCodec::WriteScreen(Image &image, Array<uint8_t> &result) | |||
| int stride = (size.x + 1); | |||
| Array2D<ivec3> src, dst; | |||
| array2d<ivec3> src, dst; | |||
| src.SetSize(size + ivec2(1)); | |||
| dst.SetSize(size + ivec2(1)); | |||
| @@ -33,7 +33,7 @@ Image Image::DitherDbs() const | |||
| ivec2 size = GetSize(); | |||
| /* Build our human visual system kernel. */ | |||
| Array2D<float> kernel; | |||
| array2d<float> kernel; | |||
| kernel.SetSize(ivec2(NN, NN)); | |||
| float t = 0.f; | |||
| for (int j = 0; j < NN; j++) | |||
| @@ -52,7 +52,7 @@ Image Image::DitherDbs() const | |||
| /* A list of cells in our picture. If no change is done to a cell | |||
| * for two iterations, we stop considering changes to it. */ | |||
| ivec2 csize = (size + ivec2(CELL - 1)) / CELL; | |||
| Array2D<int> changelist; | |||
| array2d<int> changelist; | |||
| changelist.SetSize(csize); | |||
| memset(changelist.Data(), 0, changelist.Bytes()); | |||
| @@ -27,7 +27,7 @@ namespace lol | |||
| * Making the matrix generic is not terribly slower: the performance | |||
| * hit is around 4% for Floyd-Steinberg and 13% for JaJuNi, with the | |||
| * benefit of a lot less code. */ | |||
| Image Image::DitherEdiff(Array2D<float> const &kernel, ScanMode scan) const | |||
| Image Image::DitherEdiff(array2d<float> const &kernel, ScanMode scan) const | |||
| { | |||
| Image dst = *this; | |||
| @@ -21,10 +21,10 @@ | |||
| namespace lol | |||
| { | |||
| static Image DitherHelper(Image const &image, Array2D<float> const &kernel, | |||
| static Image DitherHelper(Image const &image, array2d<float> const &kernel, | |||
| float scale, float angle); | |||
| Image Image::DitherOrdered(Array2D<float> const &kernel) const | |||
| Image Image::DitherOrdered(array2d<float> const &kernel) const | |||
| { | |||
| return DitherHelper(*this, kernel, 1.0f, 0.0f); | |||
| } | |||
| @@ -36,12 +36,12 @@ Image Image::DitherHalftone(float radius, float angle) const | |||
| * the ditherer to scale it by 1/PRECISION. */ | |||
| float const PRECISION = 4.f; | |||
| int k = (radius * PRECISION * lol::sqrt(2.f) + 0.5f); | |||
| Array2D<float> kernel = Image::HalftoneKernel(ivec2(k, k)); | |||
| array2d<float> kernel = Image::HalftoneKernel(ivec2(k, k)); | |||
| return DitherHelper(*this, kernel, 1.f / PRECISION, angle + F_PI / 4.f); | |||
| } | |||
| static Image DitherHelper(Image const &image, Array2D<float> const &kernel, | |||
| static Image DitherHelper(Image const &image, array2d<float> const &kernel, | |||
| float scale, float angle) | |||
| { | |||
| ivec2 size = image.GetSize(); | |||
| @@ -23,9 +23,9 @@ namespace lol | |||
| static Image SepConv(Image &src, Array<float> const &hvec, | |||
| Array<float> const &vvec); | |||
| static Image NonSepConv(Image &src, Array2D<float> const &kernel); | |||
| static Image NonSepConv(Image &src, array2d<float> const &kernel); | |||
| Image Image::Convolution(Array2D<float> const &kernel) | |||
| Image Image::Convolution(array2d<float> const &kernel) | |||
| { | |||
| /* Find the cell with the largest value */ | |||
| ivec2 ksize = kernel.GetSize(); | |||
| @@ -83,10 +83,10 @@ Image Image::Convolution(Array2D<float> const &kernel) | |||
| } | |||
| } | |||
| Image Image::Sharpen(Array2D<float> const &kernel) | |||
| Image Image::Sharpen(array2d<float> const &kernel) | |||
| { | |||
| ivec2 ksize = kernel.GetSize(); | |||
| Array2D<float> newkernel(ksize); | |||
| array2d<float> newkernel(ksize); | |||
| for (int dy = 0; dy < ksize.y; ++dy) | |||
| for (int dx = 0; dx < ksize.x; ++dx) | |||
| @@ -100,7 +100,7 @@ Image Image::Sharpen(Array2D<float> const &kernel) | |||
| } | |||
| template<PixelFormat FORMAT, int WRAP_X, int WRAP_Y> | |||
| static Image NonSepConv(Image &src, Array2D<float> const &kernel) | |||
| static Image NonSepConv(Image &src, array2d<float> const &kernel) | |||
| { | |||
| typedef typename PixelType<FORMAT>::type pixel_t; | |||
| @@ -108,8 +108,8 @@ static Image NonSepConv(Image &src, Array2D<float> const &kernel) | |||
| ivec2 const ksize = kernel.GetSize(); | |||
| Image dst(size); | |||
| Array2D<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | |||
| Array2D<pixel_t> &dstp = dst.Lock2D<FORMAT>(); | |||
| array2d<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | |||
| array2d<pixel_t> &dstp = dst.Lock2D<FORMAT>(); | |||
| for (int y = 0; y < size.y; y++) | |||
| { | |||
| @@ -149,7 +149,7 @@ static Image NonSepConv(Image &src, Array2D<float> const &kernel) | |||
| return dst; | |||
| } | |||
| static Image NonSepConv(Image &src, Array2D<float> const &kernel) | |||
| static Image NonSepConv(Image &src, array2d<float> const &kernel) | |||
| { | |||
| bool const wrap_x = src.GetWrapX() == WrapMode::Repeat; | |||
| bool const wrap_y = src.GetWrapY() == WrapMode::Repeat; | |||
| @@ -201,10 +201,10 @@ static Image SepConv(Image &src, Array<float> const &hvec, | |||
| ivec2 const ksize(hvec.Count(), vvec.Count()); | |||
| Image dst(size); | |||
| Array2D<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | |||
| Array2D<pixel_t> &dstp = dst.Lock2D<FORMAT>(); | |||
| array2d<pixel_t> const &srcp = src.Lock2D<FORMAT>(); | |||
| array2d<pixel_t> &dstp = dst.Lock2D<FORMAT>(); | |||
| Array2D<pixel_t> tmp(size); | |||
| array2d<pixel_t> tmp(size); | |||
| for (int y = 0; y < size.y; y++) | |||
| { | |||
| @@ -46,7 +46,7 @@ Image Image::Median(ivec2 ksize) const | |||
| if (GetFormat() == PixelFormat::Y_8 || GetFormat() == PixelFormat::Y_F32) | |||
| { | |||
| ivec2 const lsize = 2 * ksize + ivec2(1); | |||
| Array2D<float> list(lsize); | |||
| array2d<float> list(lsize); | |||
| float *srcp = tmp.Lock<PixelFormat::Y_F32>(); | |||
| float *dstp = ret.Lock<PixelFormat::Y_F32>(); | |||
| @@ -86,7 +86,7 @@ Image Image::Median(ivec2 ksize) const | |||
| else | |||
| { | |||
| ivec2 const lsize = 2 * ksize + ivec2(1); | |||
| Array2D<vec3> list(lsize); | |||
| array2d<vec3> list(lsize); | |||
| vec4 *srcp = tmp.Lock<PixelFormat::RGBA_F32>(); | |||
| vec4 *dstp = ret.Lock<PixelFormat::RGBA_F32>(); | |||
| @@ -154,7 +154,7 @@ Image Image::Median(ivec2 ksize) const | |||
| return ret; | |||
| } | |||
| Image Image::Median(Array2D<float> const &kernel) const | |||
| Image Image::Median(array2d<float> const &kernel) const | |||
| { | |||
| ivec2 const size = GetSize(); | |||
| Image tmp = *this; | |||
| @@ -169,7 +169,7 @@ Image Image::Median(Array2D<float> const &kernel) const | |||
| #endif | |||
| { | |||
| ivec2 const ksize = kernel.GetSize(); | |||
| Array2D<vec3> list(ksize); | |||
| array2d<vec3> list(ksize); | |||
| vec4 *srcp = tmp.Lock<PixelFormat::RGBA_F32>(); | |||
| vec4 *dstp = ret.Lock<PixelFormat::RGBA_F32>(); | |||
| @@ -41,7 +41,7 @@ public: | |||
| virtual void *Data2D() { return &m_array2d; } | |||
| virtual void const *Data2D() const { return &m_array2d; } | |||
| Array2D<typename PixelType<T>::type> m_array2d; | |||
| array2d<typename PixelType<T>::type> m_array2d; | |||
| }; | |||
| class ImageData | |||
| @@ -62,7 +62,7 @@ public: | |||
| WrapMode m_wrap_x, m_wrap_y; | |||
| /* A map of the various available bitplanes */ | |||
| Map<int, PixelDataBase *> m_pixels; | |||
| map<int, PixelDataBase *> m_pixels; | |||
| /* The last bitplane being accessed for writing */ | |||
| PixelFormat m_format; | |||
| }; | |||
| @@ -74,7 +74,7 @@ public: | |||
| private: | |||
| Array<ImageCodec *> m_codecs; | |||
| Map<String, Image *> m_images; | |||
| map<String, Image *> m_images; | |||
| } | |||
| g_image_loader; | |||
| @@ -197,15 +197,15 @@ template<PixelFormat T> typename PixelType<T>::type *Image::Lock() | |||
| } | |||
| /* The Lock2D() method */ | |||
| template<PixelFormat T> Array2D<typename PixelType<T>::type> &Image::Lock2D() | |||
| template<PixelFormat T> array2d<typename PixelType<T>::type> &Image::Lock2D() | |||
| { | |||
| SetFormat(T); | |||
| return *(Array2D<typename PixelType<T>::type> *)m_data->m_pixels[(int)T]->Data2D(); | |||
| return *(array2d<typename PixelType<T>::type> *)m_data->m_pixels[(int)T]->Data2D(); | |||
| } | |||
| template<typename T> | |||
| void Image::Unlock2D(Array2D<T> const &array) | |||
| void Image::Unlock2D(array2d<T> const &array) | |||
| { | |||
| ASSERT(m_data->m_pixels.HasKey((int)m_data->m_format)); | |||
| ASSERT(array.Data() == m_data->m_pixels[(int)m_data->m_format]->Data()); | |||
| @@ -214,8 +214,8 @@ void Image::Unlock2D(Array2D<T> const &array) | |||
| /* Explicit specialisations for the above templates */ | |||
| #define _T(T) \ | |||
| template PixelType<T>::type *Image::Lock<T>(); \ | |||
| template Array2D<PixelType<T>::type> &Image::Lock2D<T>(); \ | |||
| template void Image::Unlock2D(Array2D<PixelType<T>::type> const &array); | |||
| template array2d<PixelType<T>::type> &Image::Lock2D<T>(); \ | |||
| template void Image::Unlock2D(array2d<PixelType<T>::type> const &array); | |||
| _T(PixelFormat::Y_8) | |||
| _T(PixelFormat::RGB_8) | |||
| _T(PixelFormat::RGBA_8) | |||
| @@ -21,9 +21,9 @@ | |||
| namespace lol | |||
| { | |||
| Array2D<float> Image::BayerKernel(ivec2 size) | |||
| array2d<float> Image::BayerKernel(ivec2 size) | |||
| { | |||
| Array2D<float> ret(size); | |||
| array2d<float> ret(size); | |||
| int n = 1; | |||
| while (n < size.x || n < size.y) | |||
| @@ -50,9 +50,9 @@ Array2D<float> Image::BayerKernel(ivec2 size) | |||
| return ret; | |||
| } | |||
| Array2D<float> Image::HalftoneKernel(ivec2 size) | |||
| array2d<float> Image::HalftoneKernel(ivec2 size) | |||
| { | |||
| Array2D<float> ret(size); | |||
| array2d<float> ret(size); | |||
| for (int y = 0; y < size.y; y++) | |||
| for (int x = 0; x < size.x; x++) | |||
| @@ -79,16 +79,16 @@ Array2D<float> Image::HalftoneKernel(ivec2 size) | |||
| return NormalizeKernel(ret); | |||
| } | |||
| Array2D<float> Image::BlueNoiseKernel(ivec2 size, ivec2 gsize) | |||
| array2d<float> Image::BlueNoiseKernel(ivec2 size, ivec2 gsize) | |||
| { | |||
| float const epsilon = 1.f / (size.x * size.y + 1); | |||
| gsize = lol::min(size, gsize); | |||
| Array2D<float> ret(size); | |||
| Array2D<vec2> dots(size); | |||
| array2d<float> ret(size); | |||
| array2d<vec2> dots(size); | |||
| /* Create a small Gaussian kernel for filtering */ | |||
| Array2D<float> gaussian(gsize); | |||
| array2d<float> gaussian(gsize); | |||
| for (int j = 0; j < gsize.y; ++j) | |||
| for (int i = 0; i < gsize.x; ++i) | |||
| { | |||
| @@ -184,7 +184,7 @@ static int cmpdot(const void *p1, const void *p2) | |||
| return ((Dot const *)p1)->val > ((Dot const *)p2)->val; | |||
| } | |||
| Array2D<float> Image::NormalizeKernel(Array2D<float> const &kernel) | |||
| array2d<float> Image::NormalizeKernel(array2d<float> const &kernel) | |||
| { | |||
| ivec2 size = kernel.GetSize(); | |||
| @@ -200,7 +200,7 @@ Array2D<float> Image::NormalizeKernel(Array2D<float> const &kernel) | |||
| } | |||
| std::qsort(tmp.Data(), size.x * size.y, sizeof(Dot), cmpdot); | |||
| Array2D<float> dst(size); | |||
| array2d<float> dst(size); | |||
| float const epsilon = 1.f / (size.x * size.y + 1); | |||
| for (int n = 0; n < size.x * size.y; n++) | |||
| @@ -213,9 +213,9 @@ Array2D<float> Image::NormalizeKernel(Array2D<float> const &kernel) | |||
| return dst; | |||
| } | |||
| Array2D<float> Image::EdiffKernel(EdiffAlgorithm algorithm) | |||
| array2d<float> Image::EdiffKernel(EdiffAlgorithm algorithm) | |||
| { | |||
| Array2D<float> ret; | |||
| array2d<float> ret; | |||
| switch(algorithm) | |||
| { | |||
| @@ -354,9 +354,9 @@ Array2D<float> Image::EdiffKernel(EdiffAlgorithm algorithm) | |||
| * there is little chance that any value below 0.2 will be useful. */ | |||
| #define BLUR_EPSILON 0.2f | |||
| Array2D<float> Image::GaussianKernel(vec2 radius, float angle, vec2 delta) | |||
| array2d<float> Image::GaussianKernel(vec2 radius, float angle, vec2 delta) | |||
| { | |||
| Array2D<float> kernel; | |||
| array2d<float> kernel; | |||
| if (radius.x < BLUR_EPSILON) | |||
| radius.x = BLUR_EPSILON; | |||
| @@ -14,7 +14,7 @@ | |||
| namespace lol | |||
| { | |||
| extern Map<int64_t, String> BuildEnumMap(char const *str, char const **custom); | |||
| extern map<int64_t, String> BuildEnumMap(char const *str, char const **custom); | |||
| template<typename BASE, typename T = typename BASE::Type> | |||
| class SafeEnum : public BASE | |||
| @@ -35,7 +35,7 @@ public: | |||
| { | |||
| /* FIXME: we all know this isn’t thread safe. But is it really | |||
| * a big deal? */ | |||
| static Map<int64_t, String> map; | |||
| static map<int64_t, String> map; | |||
| static bool ready = false; | |||
| if (!ready) | |||
| @@ -1,7 +1,7 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
| // Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| @@ -9,9 +9,9 @@ | |||
| // | |||
| // | |||
| // The Hash class | |||
| // The hash class | |||
| // -------------- | |||
| // A very simple Hash class. | |||
| // A very simple hash class. | |||
| // | |||
| #if !defined __LOL_BASE_HASH_H__ | |||
| @@ -20,32 +20,30 @@ | |||
| namespace lol | |||
| { | |||
| template<typename T> class Hash; | |||
| template<typename T> struct hash; | |||
| template<> class Hash<int8_t> { public: uint32_t operator()(int8_t) const; }; | |||
| template<> class Hash<uint8_t> { public: uint32_t operator()(uint8_t) const; }; | |||
| template<> class Hash<int16_t> { public: uint32_t operator()(int16_t) const; }; | |||
| template<> class Hash<uint16_t> { public: uint32_t operator()(uint16_t) const; }; | |||
| template<> class Hash<int32_t> { public: uint32_t operator()(int32_t) const; }; | |||
| template<> class Hash<uint32_t> { public: uint32_t operator()(uint32_t) const; }; | |||
| template<> class Hash<int64_t> { public: uint32_t operator()(int64_t) const; }; | |||
| template<> class Hash<uint64_t> { public: uint32_t operator()(uint64_t) const; }; | |||
| template<> struct hash<int8_t> { uint32_t operator()(int8_t) const; }; | |||
| template<> struct hash<uint8_t> { uint32_t operator()(uint8_t) const; }; | |||
| template<> struct hash<int16_t> { uint32_t operator()(int16_t) const; }; | |||
| template<> struct hash<uint16_t> { uint32_t operator()(uint16_t) const; }; | |||
| template<> struct hash<int32_t> { uint32_t operator()(int32_t) const; }; | |||
| template<> struct hash<uint32_t> { uint32_t operator()(uint32_t) const; }; | |||
| template<> struct hash<int64_t> { uint32_t operator()(int64_t) const; }; | |||
| template<> struct hash<uint64_t> { uint32_t operator()(uint64_t) const; }; | |||
| template<> class Hash<half> { public: uint32_t operator()(half) const; }; | |||
| template<> class Hash<float> { public: uint32_t operator()(float) const; }; | |||
| template<> class Hash<double> { public: uint32_t operator()(double) const; }; | |||
| template<> class Hash<ldouble> { public: uint32_t operator()(ldouble) const; }; | |||
| template<> struct hash<half> { uint32_t operator()(half) const; }; | |||
| template<> struct hash<float> { uint32_t operator()(float) const; }; | |||
| template<> struct hash<double> { uint32_t operator()(double) const; }; | |||
| template<> struct hash<ldouble> { uint32_t operator()(ldouble) const; }; | |||
| template<> class Hash<char const *> | |||
| template<> struct hash<char const *> | |||
| { | |||
| public: | |||
| uint32_t operator()(char const *x) const; | |||
| uint32_t operator()(String const &s) const; | |||
| }; | |||
| template<> class Hash<String> | |||
| template<> struct hash<String> | |||
| { | |||
| public: | |||
| uint32_t operator()(String const &s) const; | |||
| uint32_t operator()(char const *x) const; | |||
| }; | |||
| @@ -9,9 +9,9 @@ | |||
| // | |||
| // | |||
| // The Map class | |||
| // The map class | |||
| // ------------- | |||
| // A very simple Map class. | |||
| // A very simple map class. | |||
| // | |||
| #if !defined __LOL_BASE_MAP_H__ | |||
| @@ -21,10 +21,10 @@ namespace lol | |||
| { | |||
| /* A stupidly linear map for now. */ | |||
| template<typename K, typename V> class Map : protected Hash<K> | |||
| template<typename K, typename V> class map : protected hash<K> | |||
| { | |||
| public: | |||
| /* If E is different from K, Hash<K> must implement operator()(E const&) | |||
| /* If E is different from K, hash<K> must implement operator()(E const&) | |||
| * and an equality operator between K and E must exist in order to use | |||
| * this method. */ | |||
| @@ -43,13 +43,13 @@ public: | |||
| inline V & operator[] (E const &key) | |||
| { | |||
| /* Look for the hash in our table and return the value if found. */ | |||
| uint32_t hash = ((Hash<K> const &)*this)(key); | |||
| int i = FindIndex(key, hash); | |||
| uint32_t hashed = ((hash<K> const &)*this)(key); | |||
| int i = FindIndex(key, hashed); | |||
| if (i >= 0) | |||
| return m_array[i].m3; | |||
| /* If not found, insert a new value. */ | |||
| m_array.Push(hash, key, V()); | |||
| m_array.Push(hashed, key, V()); | |||
| return m_array.Last().m3; | |||
| } | |||
| @@ -95,10 +95,10 @@ public: | |||
| private: | |||
| template <typename E> | |||
| inline int FindIndex(E const &key, uint32_t hash) | |||
| inline int FindIndex(E const &key, uint32_t hashed) | |||
| { | |||
| for (int i = 0; i < m_array.Count(); ++i) | |||
| if (m_array[i].m1 == hash) | |||
| if (m_array[i].m1 == hashed) | |||
| if (m_array[i].m2 == key) | |||
| return i; | |||
| return -1; | |||
| @@ -107,8 +107,8 @@ private: | |||
| template <typename E> | |||
| inline int FindIndex(E const &key) | |||
| { | |||
| uint32_t hash = ((Hash<K> const &)*this)(key); | |||
| return FindIndex(key, hash); | |||
| uint32_t hashed = ((hash<K> const &)*this)(key); | |||
| return FindIndex(key, hashed); | |||
| } | |||
| Array<uint32_t, K, V> m_array; | |||
| @@ -87,20 +87,20 @@ public: | |||
| void Unlock(void const *pixels); | |||
| template<PixelFormat T> | |||
| Array2D<typename PixelType<T>::type> &Lock2D(); | |||
| array2d<typename PixelType<T>::type> &Lock2D(); | |||
| template<typename T> | |||
| void Unlock2D(Array2D<T> const &); | |||
| void Unlock2D(array2d<T> const &); | |||
| bool RetrieveTiles(Array<ivec2, ivec2>& tiles) const; | |||
| /* Image processing kernels */ | |||
| static Array2D<float> BayerKernel(ivec2 size); | |||
| static Array2D<float> HalftoneKernel(ivec2 size); | |||
| static Array2D<float> BlueNoiseKernel(ivec2 size, | |||
| static array2d<float> BayerKernel(ivec2 size); | |||
| static array2d<float> HalftoneKernel(ivec2 size); | |||
| static array2d<float> BlueNoiseKernel(ivec2 size, | |||
| ivec2 gsize = ivec2(7, 7)); | |||
| static Array2D<float> EdiffKernel(EdiffAlgorithm algorithm); | |||
| static Array2D<float> NormalizeKernel(Array2D<float> const &kernel); | |||
| static Array2D<float> GaussianKernel(vec2 radius, | |||
| static array2d<float> EdiffKernel(EdiffAlgorithm algorithm); | |||
| static array2d<float> NormalizeKernel(array2d<float> const &kernel); | |||
| static array2d<float> GaussianKernel(vec2 radius, | |||
| float angle = 0.f, | |||
| vec2 delta = vec2(0.f, 0.f)); | |||
| @@ -115,13 +115,13 @@ public: | |||
| Image AutoContrast() const; | |||
| Image Brightness(float val) const; | |||
| Image Contrast(float val) const; | |||
| Image Convolution(Array2D<float> const &kernel); | |||
| Image Convolution(array2d<float> const &kernel); | |||
| Image Dilate(); | |||
| Image Erode(); | |||
| Image Invert() const; | |||
| Image Median(ivec2 radii) const; | |||
| Image Median(Array2D<float> const &kernel) const; | |||
| Image Sharpen(Array2D<float> const &kernel); | |||
| Image Median(array2d<float> const &kernel) const; | |||
| Image Sharpen(array2d<float> const &kernel); | |||
| Image Threshold(float val) const; | |||
| Image Threshold(vec3 val) const; | |||
| Image RGBToYUV() const; | |||
| @@ -129,10 +129,10 @@ public: | |||
| /* Dithering */ | |||
| Image DitherRandom() const; | |||
| Image DitherEdiff(Array2D<float> const &kernel, | |||
| Image DitherEdiff(array2d<float> const &kernel, | |||
| ScanMode scan = ScanMode::Raster) const; | |||
| Image DitherOstromoukhov(ScanMode scan = ScanMode::Raster) const; | |||
| Image DitherOrdered(Array2D<float> const &kernel) const; | |||
| Image DitherOrdered(array2d<float> const &kernel) const; | |||
| Image DitherHalftone(float radius, float angle) const; | |||
| Image DitherDbs() const; | |||
| @@ -10,10 +10,10 @@ | |||
| // | |||
| // | |||
| // The Array2D class | |||
| // The array2d class | |||
| // ----------------- | |||
| // A very simple 2D array class allowing var[i][j] indexing, with some nice | |||
| // additional features, eg. Array2D<int,float> for automatic arrays of tuples. | |||
| // additional features, eg. array2d<int,float> for automatic arrays of tuples. | |||
| // | |||
| // | |||
| @@ -33,18 +33,18 @@ namespace lol | |||
| template<typename T1, typename T2 = void, typename T3 = void, | |||
| typename T4 = void, typename T5 = void, typename T6 = void, | |||
| typename T7 = void, typename T8 = void> | |||
| class Array2D : protected Array<T1, T2, T3, T4, T5, T6, T7, T8> | |||
| class array2d : protected Array<T1, T2, T3, T4, T5, T6, T7, T8> | |||
| { | |||
| public: | |||
| typedef Array<T1, T2, T3, T4, T5, T6, T7, T8> Super; | |||
| typedef typename Super::Element Element; | |||
| inline Array2D() | |||
| inline array2d() | |||
| : m_size(0, 0) | |||
| { | |||
| } | |||
| inline Array2D(std::initializer_list< | |||
| inline array2d(std::initializer_list< | |||
| std::initializer_list<Element>> const &list) | |||
| : m_size(list.size() ? (int)(*list.begin()).size() : 0, | |||
| (int)list.size()) | |||
| @@ -55,12 +55,12 @@ public: | |||
| Super::Push(elem); | |||
| } | |||
| inline Array2D(int w, int h) | |||
| inline array2d(int w, int h) | |||
| { | |||
| SetSize(ivec2(w, h)); | |||
| } | |||
| inline Array2D(ivec2 size) | |||
| inline array2d(ivec2 size) | |||
| { | |||
| SetSize(size); | |||
| } | |||
| @@ -97,7 +97,7 @@ public: | |||
| class Column | |||
| { | |||
| public: | |||
| inline Column(Array2D &array, int i) | |||
| inline Column(array2d &array, int i) | |||
| : m_array(array), | |||
| m_column(i) | |||
| { | |||
| @@ -111,14 +111,14 @@ public: | |||
| } | |||
| private: | |||
| Array2D<T1, T2, T3, T4, T5, T6, T7, T8> &m_array; | |||
| array2d<T1, T2, T3, T4, T5, T6, T7, T8> &m_array; | |||
| int m_column; | |||
| }; | |||
| class ConstColumn | |||
| { | |||
| public: | |||
| inline ConstColumn(Array2D const &array, int i) | |||
| inline ConstColumn(array2d const &array, int i) | |||
| : m_array(array), | |||
| m_column(i) | |||
| { | |||
| @@ -132,7 +132,7 @@ public: | |||
| } | |||
| private: | |||
| Array2D<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array; | |||
| array2d<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array; | |||
| int m_column; | |||
| }; | |||
| @@ -10,10 +10,10 @@ | |||
| // | |||
| // | |||
| // The Array3D class | |||
| // The array3d class | |||
| // ----------------- | |||
| // A very simple 3D array class allowing var[i][j][k] indexing, with some nice | |||
| // additional features, eg. Array3D<int,float> for automatic arrays of tuples. | |||
| // additional features, eg. array3d<int,float> for automatic arrays of tuples. | |||
| // | |||
| // | |||
| @@ -33,18 +33,18 @@ namespace lol | |||
| template<typename T1, typename T2 = void, typename T3 = void, | |||
| typename T4 = void, typename T5 = void, typename T6 = void, | |||
| typename T7 = void, typename T8 = void> | |||
| class Array3D : protected Array<T1, T2, T3, T4, T5, T6, T7, T8> | |||
| class array3d : protected Array<T1, T2, T3, T4, T5, T6, T7, T8> | |||
| { | |||
| public: | |||
| typedef Array<T1, T2, T3, T4, T5, T6, T7, T8> Super; | |||
| typedef typename Super::Element Element; | |||
| inline Array3D() | |||
| inline array3d() | |||
| : m_size(0, 0, 0) | |||
| { | |||
| } | |||
| inline Array3D(std::initializer_list< | |||
| inline array3d(std::initializer_list< | |||
| std::initializer_list< | |||
| std::initializer_list<Element>>> const &list) | |||
| : m_size(list.size() && (*list.begin()).size() ? | |||
| @@ -59,12 +59,12 @@ public: | |||
| Super::Push(elem); | |||
| } | |||
| inline Array3D(int w, int h, int d) | |||
| inline array3d(int w, int h, int d) | |||
| { | |||
| SetSize(ivec3(w, h, d)); | |||
| } | |||
| inline Array3D(ivec3 size) | |||
| inline array3d(ivec3 size) | |||
| { | |||
| SetSize(size); | |||
| } | |||
| @@ -105,7 +105,7 @@ public: | |||
| class Slice | |||
| { | |||
| public: | |||
| inline Slice(Array3D &array, int i) | |||
| inline Slice(array3d &array, int i) | |||
| : m_array(array), | |||
| m_slice(i) | |||
| { | |||
| @@ -114,7 +114,7 @@ public: | |||
| class Line | |||
| { | |||
| public: | |||
| inline Line(Array3D &array, ivec2 ij) | |||
| inline Line(array3d &array, ivec2 ij) | |||
| : m_array(array), | |||
| m_line(ij) | |||
| { | |||
| @@ -128,7 +128,7 @@ public: | |||
| } | |||
| private: | |||
| Array3D<T1, T2, T3, T4, T5, T6, T7, T8> &m_array; | |||
| array3d<T1, T2, T3, T4, T5, T6, T7, T8> &m_array; | |||
| ivec2 m_line; | |||
| }; | |||
| @@ -140,14 +140,14 @@ public: | |||
| } | |||
| private: | |||
| Array3D<T1, T2, T3, T4, T5, T6, T7, T8> &m_array; | |||
| array3d<T1, T2, T3, T4, T5, T6, T7, T8> &m_array; | |||
| int m_slice; | |||
| }; | |||
| class ConstSlice | |||
| { | |||
| public: | |||
| inline ConstSlice(Array3D const &array, int i) | |||
| inline ConstSlice(array3d const &array, int i) | |||
| : m_array(array), | |||
| m_slice(i) | |||
| { | |||
| @@ -156,7 +156,7 @@ public: | |||
| class Line | |||
| { | |||
| public: | |||
| inline Line(Array3D const &array, ivec2 ij) | |||
| inline Line(array3d const &array, ivec2 ij) | |||
| : m_array(array), | |||
| m_line(ij) | |||
| { | |||
| @@ -170,7 +170,7 @@ public: | |||
| } | |||
| private: | |||
| Array3D<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array; | |||
| array3d<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array; | |||
| ivec2 m_line; | |||
| }; | |||
| @@ -182,7 +182,7 @@ public: | |||
| } | |||
| private: | |||
| Array3D<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array; | |||
| array3d<T1, T2, T3, T4, T5, T6, T7, T8> const &m_array; | |||
| int m_slice; | |||
| }; | |||
| @@ -26,7 +26,7 @@ LOLUNIT_FIXTURE(Array2DTest) | |||
| LOLUNIT_TEST(Array2DCreate) | |||
| { | |||
| Array2D<int> a(ivec2(10, 10)); | |||
| array2d<int> a(ivec2(10, 10)); | |||
| a[0][0] = 2; | |||
| a[9][0] = 4; | |||
| @@ -38,7 +38,7 @@ LOLUNIT_FIXTURE(Array2DTest) | |||
| LOLUNIT_ASSERT_EQUAL(a[0][9], 6); | |||
| LOLUNIT_ASSERT_EQUAL(a[9][9], 8); | |||
| Array2D<int> const &b = a; | |||
| array2d<int> const &b = a; | |||
| LOLUNIT_ASSERT_EQUAL(b[0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[9][0], 4); | |||
| @@ -48,7 +48,7 @@ LOLUNIT_FIXTURE(Array2DTest) | |||
| LOLUNIT_TEST(Array2DInit) | |||
| { | |||
| Array2D<int> a = { { 1, 2, 3, 4 }, | |||
| array2d<int> a = { { 1, 2, 3, 4 }, | |||
| { 5, 6, 7, 8 }, | |||
| { 9, 8, 7, 6 } }; | |||
| @@ -26,7 +26,7 @@ LOLUNIT_FIXTURE(Array3DTest) | |||
| LOLUNIT_TEST(Array3DCreate) | |||
| { | |||
| Array3D<int> a(ivec3(10, 10, 10)); | |||
| array3d<int> a(ivec3(10, 10, 10)); | |||
| a[0][0][0] = 2; | |||
| a[9][0][0] = 4; | |||
| @@ -38,7 +38,7 @@ LOLUNIT_FIXTURE(Array3DTest) | |||
| LOLUNIT_ASSERT_EQUAL(a[0][9][9], 6); | |||
| LOLUNIT_ASSERT_EQUAL(a[9][9][9], 8); | |||
| Array3D<int> const &b = a; | |||
| array3d<int> const &b = a; | |||
| LOLUNIT_ASSERT_EQUAL(b[0][0][0], 2); | |||
| LOLUNIT_ASSERT_EQUAL(b[9][0][0], 4); | |||
| @@ -48,7 +48,7 @@ LOLUNIT_FIXTURE(Array3DTest) | |||
| LOLUNIT_TEST(Array3DInit) | |||
| { | |||
| Array3D<int> a = { { { 1, 2, 3, 4 }, | |||
| array3d<int> a = { { { 1, 2, 3, 4 }, | |||
| { 5, 6, 7, 8 }, | |||
| { 9, 8, 7, 6 } }, | |||
| { { -1, -2, -3, -4 }, | |||
| @@ -26,15 +26,15 @@ LOLUNIT_FIXTURE(MapTest) | |||
| LOLUNIT_TEST(MapDeclare) | |||
| { | |||
| Map<uint8_t, uint8_t> m1; | |||
| Map<int, int> m2; | |||
| Map<float, float> m3; | |||
| Map<char const *, char const *> m4; | |||
| map<uint8_t, uint8_t> m1; | |||
| map<int, int> m2; | |||
| map<float, float> m3; | |||
| map<char const *, char const *> m4; | |||
| } | |||
| LOLUNIT_TEST(MapSet) | |||
| { | |||
| Map<int, int> map; | |||
| map<int, int> map; | |||
| for (int i = 0; i < 1000; i++) | |||
| map[i] = -1; | |||
| @@ -48,7 +48,7 @@ LOLUNIT_FIXTURE(MapTest) | |||
| LOLUNIT_TEST(MapHasKey) | |||
| { | |||
| Map<int, int> map; | |||
| map<int, int> map; | |||
| map[0] = 1; | |||
| map[2] = 2; | |||
| @@ -60,7 +60,7 @@ LOLUNIT_FIXTURE(MapTest) | |||
| LOLUNIT_TEST(StringMap) | |||
| { | |||
| Map<char const *, int> map; | |||
| map<char const *, int> map; | |||
| map["foo"] = 42; | |||
| map["bar"] = 12; | |||
| @@ -15,6 +15,11 @@ au Syntax cpp | |||
| \ syn keyword cType | |||
| \ half ldouble lldouble real uint | |||
| " Some custom container types | |||
| au Syntax cpp | |||
| \ syn keyword cType | |||
| \ hash map array2d array3d | |||
| " GLSL types and the Lol Engine extensions | |||
| au Syntax cpp | |||
| \ syn keyword cType | |||