<commit_before>#include "graphics/texture.h"
#include "script/scriptengine.h"
#include "script/scriptobject.h"
#include "graphics/window.h"

#include "freeimage.h"
#include <vector>

using namespace v8;

// Helps with setting up the script object.
class Texture::ScriptTexture : public ScriptObject<ScriptTexture> {

public:

  void Setup()
  {
    AddAccessor("width", GetWidth);
    AddAccessor("height", GetHeight);
  }

  static void New(const FunctionCallbackInfo<Value>& args)
  {
    HandleScope scope(GetIsolate());
    try {
      auto filename = GetString(args[0]);
      filename = ScriptEngine::GetCurrent().GetExecutionPath() + filename;
      auto object = Wrap(new Texture(filename));
      args.GetReturnValue().Set(object);
    }
    catch (std::exception& ex) {
      ScriptEngine::GetCurrent().ThrowTypeError(ex.what());
    }
  }

  static void GetWidth(
    Local<String> name, const PropertyCallbackInfo<Value>& args)
  {
    HandleScope scope(GetIsolate());
    auto self = Unwrap<Texture>(args.Holder());
    args.GetReturnValue().Set(self->GetWidth());
  }

  static void GetHeight(
    Local<String> name, const PropertyCallbackInfo<Value>& args)
  {
    HandleScope scope(GetIsolate());
    auto self = Unwrap<Texture>(args.Holder());
    args.GetReturnValue().Set(self->GetHeight());
  }

};

Texture::Texture(std::string filename)
{
  Window::EnsureCurrentContext();

  // Load the image for the texture.
  auto img = FreeImage_ConvertTo32Bits(
   FreeImage_Load(FreeImage_GetFileType(filename.c_str()), filename.c_str()));
<commit_msg>Flip texture<commit_after>#include "graphics/texture.h"
#include "script/scriptengine.h"
#include "script/scriptobject.h"
#include "graphics/window.h"

#include "freeimage.h"
#include <vector>

using namespace v8;

// Helps with setting up the script object.
class Texture::ScriptTexture : public ScriptObject<ScriptTexture> {

public:

  void Setup()
  {
    AddAccessor("width", GetWidth);
    AddAccessor("height", GetHeight);
  }

  static void New(const FunctionCallbackInfo<Value>& args)
  {
    HandleScope scope(GetIsolate());
    try {
      auto filename = GetString(args[0]);
      filename = ScriptEngine::GetCurrent().GetExecutionPath() + filename;
      auto object = Wrap(new Texture(filename));
      args.GetReturnValue().Set(object);
    }
    catch (std::exception& ex) {
      ScriptEngine::GetCurrent().ThrowTypeError(ex.what());
    }
  }

  static void GetWidth(
    Local<String> name, const PropertyCallbackInfo<Value>& args)
  {
    HandleScope scope(GetIsolate());
    auto self = Unwrap<Texture>(args.Holder());
    args.GetReturnValue().Set(self->GetWidth());
  }

  static void GetHeight(
    Local<String> name, const PropertyCallbackInfo<Value>& args)
  {
    HandleScope scope(GetIsolate());
    auto self = Unwrap<Texture>(args.Holder());
    args.GetReturnValue().Set(self->GetHeight());
  }

};

Texture::Texture(std::string filename)
{
  Window::EnsureCurrentContext();

  // Load the image for the texture.
  auto fileType = FreeImage_GetFileType(filename.c_str());
  auto img = FreeImage_ConvertTo32Bits(
    FreeImage_Load(fileType, filename.c_str()));
  FreeImage_FlipVertical(img);

{'fraction_non_alphanumeric': 0.13954217623079335, 'fraction_numerical': 0.002508623392913139, 'mean_word_length': 4.4436860068259385, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5867273', 'n_tokens_mistral': 977, 'n_tokens_neox': 964, 'n_words': 201}