<commit_before>// Copyright 2015-2018 <NAME>. All rights reserved.

#include "core/Setup.h"

#if OUZEL_PLATFORM_WINDOWS && OUZEL_COMPILE_OPENGL

#define GL_GLEXT_PROTOTYPES 1
#include "GL/glcorearb.h"
#include "GL/glext.h"
#include "GL/wglext.h"
#include "RenderDeviceOGLWin.hpp"
#include "core/windows/NativeWindowWin.hpp"
#include "utils/Errors.hpp"
#include "utils/Log.hpp"
#include "utils/Utils.hpp"

static const LPCWSTR TEMP_WINDOW_CLASS_NAME = L"TempWindow";

static LRESULT CALLBACK windowProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam)
{
    return DefWindowProc(window, msg, wParam, lParam);
}

namespace ouzel
{
    namespace graphics
    {
        class TempContext final
        {
        public:
            TempContext()
            {
                HINSTANCE hInstance = GetModuleHandleW(nullptr);

                WNDCLASSW wc;
                wc.style = CS_OWNDC;
                wc.lpfnWndProc = windowProc;
                wc.cbClsExtra = 0;
                wc.cbWndExtra = 0;
                wc.hInstance = hInstance;
                wc.hIcon = 0;
                wc.hCursor = 0;
                wc.hbrBackground = 0;
                wc.lpszMenuName = nullptr;
                wc.lpszClassName = TEMP_WINDOW_CLASS_NAME;

                windowClass = RegisterClassW(&wc);

                if (!windowClass)
                    throw SystemError("Failed to register window class");

                window = CreateWindowW(TEMP_WINDOW_CLASS_NAME, L"TempWindow", 0,
                                       CW_USEDEFAULT, CW_USEDEFAULT,
                                       CW_USEDEFAULT, CW_USEDEFAULT,
                                       0, 0, hInstance, 0);

                if (!window)
                    throw SystemError("Failed to create window");

                deviceContext = GetDC(window);

                PIXELFORMATDESCRIPTOR pixelFormatDesc;
                pixelFormatDesc.nSize = sizeof(pixelFormatDesc);
                pixelFormatDesc.nVersion = 1;
                pixelFormatDesc.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
                pixelFormatDesc.iPixelType = PFD_TYPE_RGBA;
                pixelFormatDesc.cColorBits = 24;
                pixelFormatDesc.cRedBits = 0;
                pixelFormatDesc.cRedShift = 0;
                pixelFormatDesc.cGreenBits = 0;
                pixelFormatDesc.cGreenShift = 0;
                pixelFormatDesc.cBlueBits = 0;
                pixelFormatDesc.cBlueShift = 0;
                pixelFormatDesc.cAlphaBits = 0;
                pixelFormatDesc.cAlphaShift = 0;
                pixelFormatDesc.cAccumBits = 0;
                pixelFormatDesc.cAccumRedBits = 0;
                pixelFormatDesc.cAccumGreenBits = 0;
                pixelFormatDesc.cAccumBlueBits = 0;
                pixelFormatDesc.cAccumAlphaBits = 0;
                pixelFormatDesc.cDepthBits = 0;
                pixelFormatDesc.cStencilBits = 0;
                pixelFormatDesc.cAuxBuffers = 0;
                pixelFormatDesc.iLayerType = PFD_MAIN_PLANE;
                pixelFormatDesc.bReserved = 0;
                pixelFormatDesc.dwLayerMask = 0;
                pixelFormatDesc.dwVisibleMask = 0;
                pixelFormatDesc.dwDamageMask = 0;

                int pixelFormat = ChoosePixelFormat(deviceContext, &pixelFormatDesc);

                if (!pixelFormat)
                    throw SystemError("Failed to choose pixel format");

                if (!SetPixelFormat(deviceContext, pixelFormat, &pixelFormatDesc))
                    throw SystemError("Failed to set pixel format");

                renderContext = wglCreateContext(deviceContext);

                if (!renderContext)
                    throw SystemError("Failed to create OpenGL context");

                if (!wglMakeCurrent(deviceContext, renderContext))
                    throw SystemError("Failed to set current OpenGL context");
            }

            ~TempContext()
            {
                if (renderContext)
                {
                    wglMakeCurrent(deviceContext, nullptr);
                    wglDeleteContext(renderContext);
                }

                if (window)
                    DestroyWindow(window);

                if (windowClass)
                    UnregisterClassW(TEMP_WINDOW_CLASS_NAME, GetModuleHandleW(nullptr));
            }

        private:
            ATOM windowClass = 0;
            HWND window = 0;
            HDC deviceContext = 0;
            HGLRC renderContext = 0;
        };

        RenderDeviceOGLWin::RenderDeviceOGLWin():
            running(false)
        {
        }

        RenderDeviceOGLWin::~RenderDeviceOGLWin()
        {
            running = false;
            flushCommands();

            if (renderThread.joinable()) renderThread.join();

            if (renderContext)
            {
                wglMakeCurrent(deviceContext, nullptr);
                wglDeleteContext(renderContext);
            }
        }

        void RenderDeviceOGLWin::init(Window* newWindow,
                                      const Size2& newSize,
                                      uint32_t newSampleCount,
                                      Texture::Filter newTextureFilter,
                                      uint32_t newMaxAnisotropy,
                                      bool newVerticalSync,
                                      bool newDepth,
                                      bool newDebugRenderer)
        {
            TempContext tempContext;

            PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatProc = reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC>(wglGetProcAddress("wglChoosePixelFormatARB"));

            NativeWindowWin* windowWin = static_cast<NativeWindowWin*>(newWindow->getNativeWindow());

            deviceContext = GetDC(windowWin->getNativeWindow());

            if (!deviceContext)
                throw SystemError("Failed to get window's device context");

            int pixelFormat = 0;

            PIXELFORMATDESCRIPTOR pixelFormatDesc;
            pixelFormatDesc.nSize = sizeof(pixelFormatDesc);
            pixelFormatDesc.nVersion = 1;
            pixelFormatDesc.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED;
            pixelFormatDesc.iPixelType = PFD_TYPE_RGBA;
            pixelFormatDesc.cColorBits = 24;
            pixelFormatDesc.cRedBits = 0;
            pixelFormatDesc.cRedShift = 0;
            pixelFormatDesc.cGreenBits = 0;
            pixelFormatDesc.cGreenShift = 0;
            pixelFormatDesc.cBlueBits = 0;
            pixelFormatDesc.cBlueShift = 0;
            pixelFormatDesc.cAlphaBits = 0;
            pixelFormatDesc.cAlphaShift = 0;
            pixelFormatDesc.cAccumBits = 0;
            pixelFormatDesc.cAccumRedBits = 0;
            pixelFormatDesc.cAccumGreenBits = 0;
            pixelFormatDesc.cAccumBlueBits = 0;
            pixelFormatDesc.cAccumAlphaBits = 0;
            pixelFormatDesc.cDepthBits = newDepth ? 24 : 0;
            pixelFormatDesc.cStencilBits = 0;
            pixelFormatDesc.cAuxBuffers = 0;
            pixelFormatDesc.iLayerType = PFD_MAIN_PLANE;
            pixelFormatDesc.bReserved = 0;
            pixelFormatDesc.dwLayerMask = 0;
            pixelFormatDesc.dwVisibleMask = 0;
            pixelFormatDesc.dwDamageMask = 0;

            if (wglChoosePixelFormatProc)
            {
                const int attributeList[] =
                {
                    WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
                    WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
                    WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
                    WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
                    WGL_COLOR_BITS_ARB, 24,
                    WGL_ALPHA_BITS_ARB, 8,
                    WGL_DEPTH_BITS_ARB, newDepth ? 24 : 0,
                    WGL_SAMPLE_BUFFERS_ARB, newSampleCount > 0 ? 1 : 0,
                    WGL_SAMPLES_ARB, static_cast<int>(newSampleCount),
                    0,
                };

                UINT numFormats;

                if (!wglChoosePixelFormatProc(deviceContext, attributeList, nullptr, 1, &pixelFormat, &numFormats))
                    throw SystemError("Failed to choose pixel format");
            }
            else
                pixelFormat = ChoosePixelFormat(deviceContext, &pixelFormatDesc);

            if (!pixelFormat)
                throw SystemError("Failed to choose pixel format");

            if (!SetPixelFormat(deviceContext, pixelFormat, &pixelFormatDesc))
                throw SystemError("Failed to set pixel format");

            PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsProc = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));

            if (wglCreateContextAttribsProc)
            {
                for (int openGLVersion = 4; openGLVersion >= 2; --openGLVersion)
                {
                    std::vector<int> contextAttribs = {
                        WGL_CONTEXT_MAJOR_VERSION_ARB, openGLVersion,
                        WGL_CONTEXT_MINOR_VERSION_ARB, 0,
                    };

                    if (newDebugRenderer)
                    {
                        contextAttribs.push_back(WGL_CONTEXT_FLAGS_ARB);
                        contextAttribs.push_back(WGL_CONTEXT_DEBUG_BIT_ARB);
                    }

                    contextAttribs.push_back(0);

                    renderContext = wglCreateContextAttribsProc(deviceContext, 0, contextAttribs.data());

                    if (renderContext)
                    {
                        Log(Log::Level::INFO) << "OpenGL " << openGLVersion << " context created";
                        break;
                    }
                }
            }
            else
                renderContext = wglCreateContext(deviceContext);

            if (!renderContext)
                throw SystemError("Failed to create OpenGL context");

            if (!wglMakeCurrent(deviceContext, renderContext))
                throw SystemError("Failed to set current OpenGL context");

            const GLubyte* versionPtr = glGetString(GL_VERSION);

            if (!versionPtr)
                throw SystemError("Failed to get OpenGL version");

            std::string version(reinterpret_cast<const char*>(versionPtr));
            std::string majorVersion;
            std::string minorVersion;
            uint32_t part = 0;

            for (char c : version)
            {
                if (c == '.' || c == ' ')
                {
                    if (++part > 1) break;
                }
                else if (part == 0)
                    majorVersion += c;
                else if (part == 1)
                    minorVersion += c;
            }

            apiMajorVersion = static_cast<uint16_t>(stoi(majorVersion));
            apiMinorVersion = static_cast<uint16_t>(stoi(minorVersion));

            if (apiMajorVersion < 2 ||
                apiMajorVersion > 4)
                throw SystemError("Unsupported OpenGL version");

            RenderDeviceOGL::init(newWindow,
                                  newSize,
                                  newSampleCount,
                                  newTextureFilter,
                                  newMaxAnisotropy,
                                  newVerticalSync,
                                  newDepth,
                                  newDebugRenderer);

            if (!wglMakeCurrent(deviceContext, nullptr))
                throw SystemError("Failed to unset OpenGL context");

            running = true;
            renderThread = std::thread(&RenderDeviceOGLWin::main, this);
        }

        void RenderDeviceOGLWin::present()
        {
            if (!SwapBuffers(deviceContext))
                throw SystemError("Failed to swap buffers");
        }

        void RenderDeviceOGLWin::main()
        {
            setCurrentThreadName("Render");

            if (!wglMakeCurrent(deviceContext, renderContext))
                throw SystemError("Failed to set current OpenGL context");

            while (running)
            {
                try
                {
                    process();
                }
                catch (const std::exception& e)
                {
                    Log(Log::Level::ERR) << e.what();
                }
                catch (...)
                {
                    Log(Log::Level::ERR) << "Unknown error occurred";
                }
            }
        }
    } // namespace graphics
} // namespace ouzel

#endif
<commit_msg>Add missing include<commit_after>// Copyright 2015-2018 <NAME>. All rights reserved.

#include "core/Setup.h"

#if OUZEL_PLATFORM_WINDOWS && OUZEL_COMPILE_OPENGL

#define GL_GLEXT_PROTOTYPES 1
#include "GL/glcorearb.h"
#include "GL/glext.h"
#include "GL/wglext.h"
#include "RenderDeviceOGLWin.hpp"
#include "core/Window.hpp"
#include "core/windows/NativeWindowWin.hpp"
#include "utils/Errors.hpp"
#include "utils/Log.hpp"
#include "utils/Utils.hpp"

static const LPCWSTR TEMP_WINDOW_CLASS_NAME = L"TempWindow";

static LRESULT CALLBACK windowProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam)
{
    return DefWindowProc(window, msg, wParam, lParam);
}

namespace ouzel
{
    namespace graphics
    {
        class TempContext final
        {
        public:
            TempContext()
            {
                HINSTANCE hInstance = GetModuleHandleW(nullptr);

                WNDCLASSW wc;
                wc.style = CS_OWNDC;
                wc.lpfnWndProc = windowProc;
                wc.cbClsExtra = 0;
                wc.cbWndExtra = 0;
                wc.hInstance = hInstance;
                wc.hIcon = 0;
                wc.hCursor = 0;
                wc.hbrBackground = 0;
                wc.lpszMenuName = nullptr;
                wc.lpszClassName = TEMP_WINDOW_CLASS_NAME;

                windowClass = RegisterClassW(&wc);

                if (!windowClass)
                    throw SystemError("Failed to register window class");

                window = CreateWindowW(TEMP_WINDOW_CLASS_NAME, L"TempWindow", 0,
                                       CW_USEDEFAULT, CW_USEDEFAULT,
                                       CW_USEDEFAULT, CW_USEDEFAULT,
                                       0, 0, hInstance, 0);

                if (!window)
                    throw SystemError("Failed to create window");

                deviceContext = GetDC(window);

                PIXELFORMATDESCRIPTOR pixelFormatDesc;
                pixelFormatDesc.nSize = sizeof(pixelFormatDesc);
                pixelFormatDesc.nVersion = 1;
                pixelFormatDesc.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
                pixelFormatDesc.iPixelType = PFD_TYPE_RGBA;
                pixelFormatDesc.cColorBits = 24;
                pixelFormatDesc.cRedBits = 0;
                pixelFormatDesc.cRedShift = 0;
                pixelFormatDesc.cGreenBits = 0;
                pixelFormatDesc.cGreenShift = 0;
                pixelFormatDesc.cBlueBits = 0;
                pixelFormatDesc.cBlueShift = 0;
                pixelFormatDesc.cAlphaBits = 0;
                pixelFormatDesc.cAlphaShift = 0;
                pixelFormatDesc.cAccumBits = 0;
                pixelFormatDesc.cAccumRedBits = 0;
                pixelFormatDesc.cAccumGreenBits = 0;
                pixelFormatDesc.cAccumBlueBits = 0;
                pixelFormatDesc.cAccumAlphaBits = 0;
                pixelFormatDesc.cDepthBits = 0;
                pixelFormatDesc.cStencilBits = 0;
                pixelFormatDesc.cAuxBuffers = 0;
                pixelFormatDesc.iLayerType = PFD_MAIN_PLANE;
                pixelFormatDesc.bReserved = 0;
                pixelFormatDesc.dwLayerMask = 0;
                pixelFormatDesc.dwVisibleMask = 0;
                pixelFormatDesc.dwDamageMask = 0;

                int pixelFormat = ChoosePixelFormat(deviceContext, &pixelFormatDesc);

                if (!pixelFormat)
                    throw SystemError("Failed to choose pixel format");

                if (!SetPixelFormat(deviceContext, pixelFormat, &pixelFormatDesc))
                    throw SystemError("Failed to set pixel format");

                renderContext = wglCreateContext(deviceContext);

                if (!renderContext)
                    throw SystemError("Failed to create OpenGL context");

                if (!wglMakeCurrent(deviceContext, renderContext))
                    throw SystemError("Failed to set current OpenGL context");
            }

            ~TempContext()
            {
                if (renderContext)
                {
                    wglMakeCurrent(deviceContext, nullptr);
                    wglDeleteContext(renderContext);
                }

                if (window)
                    DestroyWindow(window);

                if (windowClass)
                    UnregisterClassW(TEMP_WINDOW_CLASS_NAME, GetModuleHandleW(nullptr));
            }

        private:
            ATOM windowClass = 0;
            HWND window = 0;
            HDC deviceContext = 0;
            HGLRC renderContext = 0;
        };

        RenderDeviceOGLWin::RenderDeviceOGLWin():
            running(false)
        {
        }

        RenderDeviceOGLWin::~RenderDeviceOGLWin()
        {
            running = false;
            flushCommands();

            if (renderThread.joinable()) renderThread.join();

            if (renderContext)
            {
                wglMakeCurrent(deviceContext, nullptr);
                wglDeleteContext(renderContext);
            }
        }

        void RenderDeviceOGLWin::init(Window* newWindow,
                                      const Size2& newSize,
                                      uint32_t newSampleCount,
                                      Texture::Filter newTextureFilter,
                                      uint32_t newMaxAnisotropy,
                                      bool newVerticalSync,
                                      bool newDepth,
                                      bool newDebugRenderer)
        {
            TempContext tempContext;

            PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatProc = reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC>(wglGetProcAddress("wglChoosePixelFormatARB"));

            NativeWindowWin* windowWin = static_cast<NativeWindowWin*>(newWindow->getNativeWindow());

            deviceContext = GetDC(windowWin->getNativeWindow());

            if (!deviceContext)
                throw SystemError("Failed to get window's device context");

            int pixelFormat = 0;

            PIXELFORMATDESCRIPTOR pixelFormatDesc;
            pixelFormatDesc.nSize = sizeof(pixelFormatDesc);
            pixelFormatDesc.nVersion = 1;
            pixelFormatDesc.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED;
            pixelFormatDesc.iPixelType = PFD_TYPE_RGBA;
            pixelFormatDesc.cColorBits = 24;
            pixelFormatDesc.cRedBits = 0;
            pixelFormatDesc.cRedShift = 0;
            pixelFormatDesc.cGreenBits = 0;
            pixelFormatDesc.cGreenShift = 0;
            pixelFormatDesc.cBlueBits = 0;
            pixelFormatDesc.cBlueShift = 0;
            pixelFormatDesc.cAlphaBits = 0;
            pixelFormatDesc.cAlphaShift = 0;
            pixelFormatDesc.cAccumBits = 0;
            pixelFormatDesc.cAccumRedBits = 0;
            pixelFormatDesc.cAccumGreenBits = 0;
            pixelFormatDesc.cAccumBlueBits = 0;
            pixelFormatDesc.cAccumAlphaBits = 0;
            pixelFormatDesc.cDepthBits = newDepth ? 24 : 0;
            pixelFormatDesc.cStencilBits = 0;
            pixelFormatDesc.cAuxBuffers = 0;
            pixelFormatDesc.iLayerType = PFD_MAIN_PLANE;
            pixelFormatDesc.bReserved = 0;
            pixelFormatDesc.dwLayerMask = 0;
            pixelFormatDesc.dwVisibleMask = 0;
            pixelFormatDesc.dwDamageMask = 0;

            if (wglChoosePixelFormatProc)
            {
                const int attributeList[] =
                {
                    WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
                    WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
                    WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
                    WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
                    WGL_COLOR_BITS_ARB, 24,
                    WGL_ALPHA_BITS_ARB, 8,
                    WGL_DEPTH_BITS_ARB, newDepth ? 24 : 0,
                    WGL_SAMPLE_BUFFERS_ARB, newSampleCount > 0 ? 1 : 0,
                    WGL_SAMPLES_ARB, static_cast<int>(newSampleCount),
                    0,
                };

                UINT numFormats;

                if (!wglChoosePixelFormatProc(deviceContext, attributeList, nullptr, 1, &pixelFormat, &numFormats))
                    throw SystemError("Failed to choose pixel format");
            }
            else
                pixelFormat = ChoosePixelFormat(deviceContext, &pixelFormatDesc);

            if (!pixelFormat)
                throw SystemError("Failed to choose pixel format");

            if (!SetPixelFormat(deviceContext, pixelFormat, &pixelFormatDesc))
                throw SystemError("Failed to set pixel format");

            PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsProc = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));

            if (wglCreateContextAttribsProc)
            {
                for (int openGLVersion = 4; openGLVersion >= 2; --openGLVersion)
                {
                    std::vector<int> contextAttribs = {
                        WGL_CONTEXT_MAJOR_VERSION_ARB, openGLVersion,
                        WGL_CONTEXT_MINOR_VERSION_ARB, 0,
                    };

                    if (newDebugRenderer)
                    {
                        contextAttribs.push_back(WGL_CONTEXT_FLAGS_ARB);
                        contextAttribs.push_back(WGL_CONTEXT_DEBUG_BIT_ARB);
                    }

                    contextAttribs.push_back(0);

                    renderContext = wglCreateContextAttribsProc(deviceContext, 0, contextAttribs.data());

                    if (renderContext)
                    {
                        Log(Log::Level::INFO) << "OpenGL " << openGLVersion << " context created";
                        break;
                    }
                }
            }
            else
                renderContext = wglCreateContext(deviceContext);

            if (!renderContext)
                throw SystemError("Failed to create OpenGL context");

            if (!wglMakeCurrent(deviceContext, renderContext))
                throw SystemError("Failed to set current OpenGL context");

            const GLubyte* versionPtr = glGetString(GL_VERSION);

            if (!versionPtr)
                throw SystemError("Failed to get OpenGL version");

            std::string version(reinterpret_cast<const char*>(versionPtr));
            std::string majorVersion;
            std::string minorVersion;
            uint32_t part = 0;

            for (char c : version)
            {
                if (c == '.' || c == ' ')
                {
                    if (++part > 1) break;
                }
                else if (part == 0)
                    majorVersion += c;
                else if (part == 1)
                    minorVersion += c;
            }

            apiMajorVersion = static_cast<uint16_t>(stoi(majorVersion));
            apiMinorVersion = static_cast<uint16_t>(stoi(minorVersion));

            if (apiMajorVersion < 2 ||
                apiMajorVersion > 4)
                throw SystemError("Unsupported OpenGL version");

            RenderDeviceOGL::init(newWindow,
                                  newSize,
                                  newSampleCount,
                                  newTextureFilter,
                                  newMaxAnisotropy,
                                  newVerticalSync,
                                  newDepth,
                                  newDebugRenderer);

            if (!wglMakeCurrent(deviceContext, nullptr))
                throw SystemError("Failed to unset OpenGL context");

            running = true;
            renderThread = std::thread(&RenderDeviceOGLWin::main, this);
        }

        void RenderDeviceOGLWin::present()
        {
            if (!SwapBuffers(deviceContext))
                throw SystemError("Failed to swap buffers");
        }

        void RenderDeviceOGLWin::main()
        {
            setCurrentThreadName("Render");

            if (!wglMakeCurrent(deviceContext, renderContext))
                throw SystemError("Failed to set current OpenGL context");

            while (running)
            {
                try
                {
                    process();
                }
                catch (const std::exception& e)
                {
                    Log(Log::Level::ERR) << e.what();
                }
                catch (...)
                {
                    Log(Log::Level::ERR) << "Unknown error occurred";
                }
            }
        }
    } // namespace graphics
} // namespace ouzel

#endif

{'fraction_non_alphanumeric': 0.07398473644667643, 'fraction_numerical': 0.008224919925659378, 'mean_word_length': 1.469003221712389, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3429936', 'n_tokens_mistral': 6845, 'n_tokens_neox': 6294, 'n_words': 1200}