diff --git a/src/base/enum.cpp b/src/base/enum.cpp index 03c22136..2d6ac658 100644 --- a/src/base/enum.cpp +++ b/src/base/enum.cpp @@ -21,9 +21,9 @@ namespace lol * Safe enum helpers */ -Map BuildEnumMap(char const *str, char const **custom) +map BuildEnumMap(char const *str, char const **custom) { - Map ret; + map ret; char const *parser = str; int64_t next_value = 0; int64_t cur_idx = 0; diff --git a/src/base/hash.cpp b/src/base/hash.cpp index b38861d8..0ca51f14 100644 --- a/src/base/hash.cpp +++ b/src/base/hash.cpp @@ -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::operator ()(int8_t x) const +uint32_t hash::operator ()(int8_t x) const { return Hash8((uint8_t)x); } -uint32_t Hash::operator ()(uint8_t x) const +uint32_t hash::operator ()(uint8_t x) const { return Hash8(x); } -uint32_t Hash::operator ()(int16_t x) const +uint32_t hash::operator ()(int16_t x) const { return Hash16((uint16_t)x); } -uint32_t Hash::operator ()(uint16_t x) const +uint32_t hash::operator ()(uint16_t x) const { return Hash16(x); } -uint32_t Hash::operator ()(int32_t x) const +uint32_t hash::operator ()(int32_t x) const { return Hash32((uint32_t)x); } -uint32_t Hash::operator ()(uint32_t x) const +uint32_t hash::operator ()(uint32_t x) const { return Hash32(x); } -uint32_t Hash::operator ()(int64_t x) const +uint32_t hash::operator ()(int64_t x) const { return Hash64((uint64_t)x); } -uint32_t Hash::operator ()(uint64_t x) const +uint32_t hash::operator ()(uint64_t x) const { return Hash64(x); } @@ -131,18 +131,18 @@ uint32_t Hash::operator ()(uint64_t x) const * Floating-point hash functions */ -uint32_t Hash::operator ()(half f) const +uint32_t hash::operator ()(half f) const { return Hash16(f.bits); } -uint32_t Hash::operator ()(float f) const +uint32_t hash::operator ()(float f) const { union { float tmp; uint32_t x; } u = { f }; return Hash32(u.x); } -uint32_t Hash::operator ()(double f) const +uint32_t hash::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::operator ()(char const *s) const +uint32_t hash::operator ()(char const *s) const { return HashCharString(s); } -uint32_t Hash::operator ()(String const &s) const +uint32_t hash::operator ()(String const &s) const { return HashCharString(&s[0]); } -uint32_t Hash::operator ()(String const &s) const +uint32_t hash::operator ()(String const &s) const { return HashCharString(&s[0]); } -uint32_t Hash::operator ()(char const *s) const +uint32_t hash::operator ()(char const *s) const { return HashCharString(s); } diff --git a/src/gpu/lolfx-compiler.h b/src/gpu/lolfx-compiler.h index 958bf349..c2fafe30 100644 --- a/src/gpu/lolfx-compiler.h +++ b/src/gpu/lolfx-compiler.h @@ -38,7 +38,7 @@ public: private: bool IsExpressionTrue(char const *buf); - Map m_pp_defines; + map m_pp_defines; enum { diff --git a/src/gpu/shader.cpp b/src/gpu/shader.cpp index 119ecf38..6bac0aa6 100644 --- a/src/gpu/shader.cpp +++ b/src/gpu/shader.cpp @@ -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 attrib_locations; - Map attrib_errors; + map attrib_locations; + map attrib_errors; #else CGprogram vert_id, frag_id; #endif @@ -112,12 +112,12 @@ private: /* Global shader cache */ static Shader *shaders[]; - static Hash hash; + static hash Hash; static int nshaders; }; Shader *ShaderData::shaders[256]; -Hash ShaderData::hash; +hash 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, diff --git a/src/image/codec/oric-image.cpp b/src/image/codec/oric-image.cpp index e16920d3..1c962635 100644 --- a/src/image/codec/oric-image.cpp +++ b/src/image/codec/oric-image.cpp @@ -472,7 +472,7 @@ void OricImageCodec::WriteScreen(Image &image, Array &result) int stride = (size.x + 1); - Array2D src, dst; + array2d src, dst; src.SetSize(size + ivec2(1)); dst.SetSize(size + ivec2(1)); diff --git a/src/image/dither/dbs.cpp b/src/image/dither/dbs.cpp index b4e4806d..a25a0ff8 100644 --- a/src/image/dither/dbs.cpp +++ b/src/image/dither/dbs.cpp @@ -33,7 +33,7 @@ Image Image::DitherDbs() const ivec2 size = GetSize(); /* Build our human visual system kernel. */ - Array2D kernel; + array2d 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 changelist; + array2d changelist; changelist.SetSize(csize); memset(changelist.Data(), 0, changelist.Bytes()); diff --git a/src/image/dither/ediff.cpp b/src/image/dither/ediff.cpp index 61636eae..58ec2d77 100644 --- a/src/image/dither/ediff.cpp +++ b/src/image/dither/ediff.cpp @@ -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 const &kernel, ScanMode scan) const +Image Image::DitherEdiff(array2d const &kernel, ScanMode scan) const { Image dst = *this; diff --git a/src/image/dither/ordered.cpp b/src/image/dither/ordered.cpp index 0e23c452..73d954ee 100644 --- a/src/image/dither/ordered.cpp +++ b/src/image/dither/ordered.cpp @@ -21,10 +21,10 @@ namespace lol { -static Image DitherHelper(Image const &image, Array2D const &kernel, +static Image DitherHelper(Image const &image, array2d const &kernel, float scale, float angle); -Image Image::DitherOrdered(Array2D const &kernel) const +Image Image::DitherOrdered(array2d 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 kernel = Image::HalftoneKernel(ivec2(k, k)); + array2d 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 const &kernel, +static Image DitherHelper(Image const &image, array2d const &kernel, float scale, float angle) { ivec2 size = image.GetSize(); diff --git a/src/image/filter/convolution.cpp b/src/image/filter/convolution.cpp index 9acf6863..f8ead747 100644 --- a/src/image/filter/convolution.cpp +++ b/src/image/filter/convolution.cpp @@ -23,9 +23,9 @@ namespace lol static Image SepConv(Image &src, Array const &hvec, Array const &vvec); -static Image NonSepConv(Image &src, Array2D const &kernel); +static Image NonSepConv(Image &src, array2d const &kernel); -Image Image::Convolution(Array2D const &kernel) +Image Image::Convolution(array2d const &kernel) { /* Find the cell with the largest value */ ivec2 ksize = kernel.GetSize(); @@ -83,10 +83,10 @@ Image Image::Convolution(Array2D const &kernel) } } -Image Image::Sharpen(Array2D const &kernel) +Image Image::Sharpen(array2d const &kernel) { ivec2 ksize = kernel.GetSize(); - Array2D newkernel(ksize); + array2d 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 const &kernel) } template -static Image NonSepConv(Image &src, Array2D const &kernel) +static Image NonSepConv(Image &src, array2d const &kernel) { typedef typename PixelType::type pixel_t; @@ -108,8 +108,8 @@ static Image NonSepConv(Image &src, Array2D const &kernel) ivec2 const ksize = kernel.GetSize(); Image dst(size); - Array2D const &srcp = src.Lock2D(); - Array2D &dstp = dst.Lock2D(); + array2d const &srcp = src.Lock2D(); + array2d &dstp = dst.Lock2D(); for (int y = 0; y < size.y; y++) { @@ -149,7 +149,7 @@ static Image NonSepConv(Image &src, Array2D const &kernel) return dst; } -static Image NonSepConv(Image &src, Array2D const &kernel) +static Image NonSepConv(Image &src, array2d 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 const &hvec, ivec2 const ksize(hvec.Count(), vvec.Count()); Image dst(size); - Array2D const &srcp = src.Lock2D(); - Array2D &dstp = dst.Lock2D(); + array2d const &srcp = src.Lock2D(); + array2d &dstp = dst.Lock2D(); - Array2D tmp(size); + array2d tmp(size); for (int y = 0; y < size.y; y++) { diff --git a/src/image/filter/median.cpp b/src/image/filter/median.cpp index 917b8f18..5310f9bf 100644 --- a/src/image/filter/median.cpp +++ b/src/image/filter/median.cpp @@ -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 list(lsize); + array2d list(lsize); float *srcp = tmp.Lock(); float *dstp = ret.Lock(); @@ -86,7 +86,7 @@ Image Image::Median(ivec2 ksize) const else { ivec2 const lsize = 2 * ksize + ivec2(1); - Array2D list(lsize); + array2d list(lsize); vec4 *srcp = tmp.Lock(); vec4 *dstp = ret.Lock(); @@ -154,7 +154,7 @@ Image Image::Median(ivec2 ksize) const return ret; } -Image Image::Median(Array2D const &kernel) const +Image Image::Median(array2d const &kernel) const { ivec2 const size = GetSize(); Image tmp = *this; @@ -169,7 +169,7 @@ Image Image::Median(Array2D const &kernel) const #endif { ivec2 const ksize = kernel.GetSize(); - Array2D list(ksize); + array2d list(ksize); vec4 *srcp = tmp.Lock(); vec4 *dstp = ret.Lock(); diff --git a/src/image/image-private.h b/src/image/image-private.h index 52752076..a22b61e3 100644 --- a/src/image/image-private.h +++ b/src/image/image-private.h @@ -41,7 +41,7 @@ public: virtual void *Data2D() { return &m_array2d; } virtual void const *Data2D() const { return &m_array2d; } - Array2D::type> m_array2d; + array2d::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 m_pixels; + map m_pixels; /* The last bitplane being accessed for writing */ PixelFormat m_format; }; diff --git a/src/image/image.cpp b/src/image/image.cpp index 71a4f78e..f3d15efc 100644 --- a/src/image/image.cpp +++ b/src/image/image.cpp @@ -74,7 +74,7 @@ public: private: Array m_codecs; - Map m_images; + map m_images; } g_image_loader; @@ -197,15 +197,15 @@ template typename PixelType::type *Image::Lock() } /* The Lock2D() method */ -template Array2D::type> &Image::Lock2D() +template array2d::type> &Image::Lock2D() { SetFormat(T); - return *(Array2D::type> *)m_data->m_pixels[(int)T]->Data2D(); + return *(array2d::type> *)m_data->m_pixels[(int)T]->Data2D(); } template -void Image::Unlock2D(Array2D const &array) +void Image::Unlock2D(array2d 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 const &array) /* Explicit specialisations for the above templates */ #define _T(T) \ template PixelType::type *Image::Lock(); \ - template Array2D::type> &Image::Lock2D(); \ - template void Image::Unlock2D(Array2D::type> const &array); + template array2d::type> &Image::Lock2D(); \ + template void Image::Unlock2D(array2d::type> const &array); _T(PixelFormat::Y_8) _T(PixelFormat::RGB_8) _T(PixelFormat::RGBA_8) diff --git a/src/image/kernel.cpp b/src/image/kernel.cpp index b3822329..f6dcdc83 100644 --- a/src/image/kernel.cpp +++ b/src/image/kernel.cpp @@ -21,9 +21,9 @@ namespace lol { -Array2D Image::BayerKernel(ivec2 size) +array2d Image::BayerKernel(ivec2 size) { - Array2D ret(size); + array2d ret(size); int n = 1; while (n < size.x || n < size.y) @@ -50,9 +50,9 @@ Array2D Image::BayerKernel(ivec2 size) return ret; } -Array2D Image::HalftoneKernel(ivec2 size) +array2d Image::HalftoneKernel(ivec2 size) { - Array2D ret(size); + array2d ret(size); for (int y = 0; y < size.y; y++) for (int x = 0; x < size.x; x++) @@ -79,16 +79,16 @@ Array2D Image::HalftoneKernel(ivec2 size) return NormalizeKernel(ret); } -Array2D Image::BlueNoiseKernel(ivec2 size, ivec2 gsize) +array2d Image::BlueNoiseKernel(ivec2 size, ivec2 gsize) { float const epsilon = 1.f / (size.x * size.y + 1); gsize = lol::min(size, gsize); - Array2D ret(size); - Array2D dots(size); + array2d ret(size); + array2d dots(size); /* Create a small Gaussian kernel for filtering */ - Array2D gaussian(gsize); + array2d 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 Image::NormalizeKernel(Array2D const &kernel) +array2d Image::NormalizeKernel(array2d const &kernel) { ivec2 size = kernel.GetSize(); @@ -200,7 +200,7 @@ Array2D Image::NormalizeKernel(Array2D const &kernel) } std::qsort(tmp.Data(), size.x * size.y, sizeof(Dot), cmpdot); - Array2D dst(size); + array2d 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 Image::NormalizeKernel(Array2D const &kernel) return dst; } -Array2D Image::EdiffKernel(EdiffAlgorithm algorithm) +array2d Image::EdiffKernel(EdiffAlgorithm algorithm) { - Array2D ret; + array2d ret; switch(algorithm) { @@ -354,9 +354,9 @@ Array2D Image::EdiffKernel(EdiffAlgorithm algorithm) * there is little chance that any value below 0.2 will be useful. */ #define BLUR_EPSILON 0.2f -Array2D Image::GaussianKernel(vec2 radius, float angle, vec2 delta) +array2d Image::GaussianKernel(vec2 radius, float angle, vec2 delta) { - Array2D kernel; + array2d kernel; if (radius.x < BLUR_EPSILON) radius.x = BLUR_EPSILON; diff --git a/src/lol/base/enum.h b/src/lol/base/enum.h index c0653d11..ae4c71f2 100644 --- a/src/lol/base/enum.h +++ b/src/lol/base/enum.h @@ -14,7 +14,7 @@ namespace lol { -extern Map BuildEnumMap(char const *str, char const **custom); +extern map BuildEnumMap(char const *str, char const **custom); template 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 map; + static map map; static bool ready = false; if (!ready) diff --git a/src/lol/base/hash.h b/src/lol/base/hash.h index 95e0ec42..c8c8a884 100644 --- a/src/lol/base/hash.h +++ b/src/lol/base/hash.h @@ -1,7 +1,7 @@ // // Lol Engine // -// Copyright: (c) 2010-2013 Sam Hocevar +// Copyright: (c) 2010-2014 Sam Hocevar // 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 class Hash; +template struct hash; -template<> class Hash { public: uint32_t operator()(int8_t) const; }; -template<> class Hash { public: uint32_t operator()(uint8_t) const; }; -template<> class Hash { public: uint32_t operator()(int16_t) const; }; -template<> class Hash { public: uint32_t operator()(uint16_t) const; }; -template<> class Hash { public: uint32_t operator()(int32_t) const; }; -template<> class Hash { public: uint32_t operator()(uint32_t) const; }; -template<> class Hash { public: uint32_t operator()(int64_t) const; }; -template<> class Hash { public: uint32_t operator()(uint64_t) const; }; +template<> struct hash { uint32_t operator()(int8_t) const; }; +template<> struct hash { uint32_t operator()(uint8_t) const; }; +template<> struct hash { uint32_t operator()(int16_t) const; }; +template<> struct hash { uint32_t operator()(uint16_t) const; }; +template<> struct hash { uint32_t operator()(int32_t) const; }; +template<> struct hash { uint32_t operator()(uint32_t) const; }; +template<> struct hash { uint32_t operator()(int64_t) const; }; +template<> struct hash { uint32_t operator()(uint64_t) const; }; -template<> class Hash { public: uint32_t operator()(half) const; }; -template<> class Hash { public: uint32_t operator()(float) const; }; -template<> class Hash { public: uint32_t operator()(double) const; }; -template<> class Hash { public: uint32_t operator()(ldouble) const; }; +template<> struct hash { uint32_t operator()(half) const; }; +template<> struct hash { uint32_t operator()(float) const; }; +template<> struct hash { uint32_t operator()(double) const; }; +template<> struct hash { uint32_t operator()(ldouble) const; }; -template<> class Hash +template<> struct hash { -public: uint32_t operator()(char const *x) const; uint32_t operator()(String const &s) const; }; -template<> class Hash +template<> struct hash { -public: uint32_t operator()(String const &s) const; uint32_t operator()(char const *x) const; }; diff --git a/src/lol/base/map.h b/src/lol/base/map.h index df520110..81df9b48 100644 --- a/src/lol/base/map.h +++ b/src/lol/base/map.h @@ -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 class Map : protected Hash +template class map : protected hash { public: - /* If E is different from K, Hash must implement operator()(E const&) + /* If E is different from K, hash 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 const &)*this)(key); - int i = FindIndex(key, hash); + uint32_t hashed = ((hash 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 - 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 inline int FindIndex(E const &key) { - uint32_t hash = ((Hash const &)*this)(key); - return FindIndex(key, hash); + uint32_t hashed = ((hash const &)*this)(key); + return FindIndex(key, hashed); } Array m_array; diff --git a/src/lol/image/image.h b/src/lol/image/image.h index 8b273c37..0b8b9fd6 100644 --- a/src/lol/image/image.h +++ b/src/lol/image/image.h @@ -87,20 +87,20 @@ public: void Unlock(void const *pixels); template - Array2D::type> &Lock2D(); + array2d::type> &Lock2D(); template - void Unlock2D(Array2D const &); + void Unlock2D(array2d const &); bool RetrieveTiles(Array& tiles) const; /* Image processing kernels */ - static Array2D BayerKernel(ivec2 size); - static Array2D HalftoneKernel(ivec2 size); - static Array2D BlueNoiseKernel(ivec2 size, + static array2d BayerKernel(ivec2 size); + static array2d HalftoneKernel(ivec2 size); + static array2d BlueNoiseKernel(ivec2 size, ivec2 gsize = ivec2(7, 7)); - static Array2D EdiffKernel(EdiffAlgorithm algorithm); - static Array2D NormalizeKernel(Array2D const &kernel); - static Array2D GaussianKernel(vec2 radius, + static array2d EdiffKernel(EdiffAlgorithm algorithm); + static array2d NormalizeKernel(array2d const &kernel); + static array2d 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 const &kernel); + Image Convolution(array2d const &kernel); Image Dilate(); Image Erode(); Image Invert() const; Image Median(ivec2 radii) const; - Image Median(Array2D const &kernel) const; - Image Sharpen(Array2D const &kernel); + Image Median(array2d const &kernel) const; + Image Sharpen(array2d 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 const &kernel, + Image DitherEdiff(array2d const &kernel, ScanMode scan = ScanMode::Raster) const; Image DitherOstromoukhov(ScanMode scan = ScanMode::Raster) const; - Image DitherOrdered(Array2D const &kernel) const; + Image DitherOrdered(array2d const &kernel) const; Image DitherHalftone(float radius, float angle) const; Image DitherDbs() const; diff --git a/src/lol/math/array2d.h b/src/lol/math/array2d.h index 4f390b92..e7179466 100644 --- a/src/lol/math/array2d.h +++ b/src/lol/math/array2d.h @@ -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 for automatic arrays of tuples. +// additional features, eg. array2d for automatic arrays of tuples. // // @@ -33,18 +33,18 @@ namespace lol template -class Array2D : protected Array +class array2d : protected Array { public: typedef Array 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> 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 &m_array; + array2d &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 const &m_array; + array2d const &m_array; int m_column; }; diff --git a/src/lol/math/array3d.h b/src/lol/math/array3d.h index f6700a29..a1c30db5 100644 --- a/src/lol/math/array3d.h +++ b/src/lol/math/array3d.h @@ -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 for automatic arrays of tuples. +// additional features, eg. array3d for automatic arrays of tuples. // // @@ -33,18 +33,18 @@ namespace lol template -class Array3D : protected Array +class array3d : protected Array { public: typedef Array 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>> 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 &m_array; + array3d &m_array; ivec2 m_line; }; @@ -140,14 +140,14 @@ public: } private: - Array3D &m_array; + array3d &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 const &m_array; + array3d const &m_array; ivec2 m_line; }; @@ -182,7 +182,7 @@ public: } private: - Array3D const &m_array; + array3d const &m_array; int m_slice; }; diff --git a/test/unit/array2d.cpp b/test/unit/array2d.cpp index 4e32bb1e..227432c9 100644 --- a/test/unit/array2d.cpp +++ b/test/unit/array2d.cpp @@ -26,7 +26,7 @@ LOLUNIT_FIXTURE(Array2DTest) LOLUNIT_TEST(Array2DCreate) { - Array2D a(ivec2(10, 10)); + array2d 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 const &b = a; + array2d 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 a = { { 1, 2, 3, 4 }, + array2d a = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 8, 7, 6 } }; diff --git a/test/unit/array3d.cpp b/test/unit/array3d.cpp index 198f60f3..82679bd9 100644 --- a/test/unit/array3d.cpp +++ b/test/unit/array3d.cpp @@ -26,7 +26,7 @@ LOLUNIT_FIXTURE(Array3DTest) LOLUNIT_TEST(Array3DCreate) { - Array3D a(ivec3(10, 10, 10)); + array3d 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 const &b = a; + array3d 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 a = { { { 1, 2, 3, 4 }, + array3d a = { { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 8, 7, 6 } }, { { -1, -2, -3, -4 }, diff --git a/test/unit/map.cpp b/test/unit/map.cpp index 4fff9c29..a3bd5775 100644 --- a/test/unit/map.cpp +++ b/test/unit/map.cpp @@ -26,15 +26,15 @@ LOLUNIT_FIXTURE(MapTest) LOLUNIT_TEST(MapDeclare) { - Map m1; - Map m2; - Map m3; - Map m4; + map m1; + map m2; + map m3; + map m4; } LOLUNIT_TEST(MapSet) { - Map map; + map map; for (int i = 0; i < 1000; i++) map[i] = -1; @@ -48,7 +48,7 @@ LOLUNIT_FIXTURE(MapTest) LOLUNIT_TEST(MapHasKey) { - Map map; + map map; map[0] = 1; map[2] = 2; @@ -60,7 +60,7 @@ LOLUNIT_FIXTURE(MapTest) LOLUNIT_TEST(StringMap) { - Map map; + map map; map["foo"] = 42; map["bar"] = 12; diff --git a/tools/vimlol/vimlol.vim b/tools/vimlol/vimlol.vim index 38734253..c50c81a1 100644 --- a/tools/vimlol/vimlol.vim +++ b/tools/vimlol/vimlol.vim @@ -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