<commit_before>#include <string>
#include <SDL.h>
#include <lua.hpp>
#include "src/debug.h"
#include "src/image.h"
#include "src/animatedimage.h"
#include "src/text.h"
#include "src/window.h"
#include "luacscript.h"
#include "luacimage.h"
#include "luacrectf.h"
#include "luacvector2f.h"
#include "luacwindow.h"

int LuaC::WindowLib::luaopen_window(lua_State *l){
    //Stack: lib name
    //Register the library as global table "Window"
    luaL_register(l, windowClass.c_str(), luaWindowLib);
    openFlipEnum(l);
    return 0;
}
void LuaC::WindowLib::openFlipEnum(lua_State *l){
    //Stack: lib name, table
    lua_pushinteger(l, SDL_FLIP_NONE);
    lua_setfield(l, -2, "FLIP_NONE");
    lua_pushinteger(l, SDL_FLIP_HORIZONTAL);
    lua_setfield(l, -2, "FLIP_HORIZONTAL");
    lua_pushinteger(l, SDL_FLIP_VERTICAL);
    lua_setfield(l, -2, "FLIP_VERTICAL");
}
const struct luaL_reg LuaC::WindowLib::luaWindowLib[] = {
    { "draw", draw },
    { "box", getBox },
    { NULL, NULL }
};
int LuaC::WindowLib::draw(lua_State *l){
    /*
    *  Multiple possible stacks, the 3 we check here are:
    *  1. Image, other params
    *  2. AnimatedImage, other params
    *  3. Text, other params
    */
    std::string type = LuaScriptLib::readType(l, 1);
    //Case 1
    if (type.at(0) == 'I')
        DrawImage(l);
    else if (type.at(0) == 'A')
        DrawAnimatedImage(l);
    else if (type.at(0) == 'T')
        DrawText(l);
    else
        Debug::Log("WindowLib:draw Error: " + type + " is not drawable");
    return 0;
}
int LuaC::WindowLib::getBox(lua_State *l){
    Rectf r = Window::Box();
    RectfLib::Push(&r, l);
    return 1;
}
void LuaC::WindowLib::DrawImage(lua_State *l){
    /**
    *  3 Possible stacks:
    *  1. Image, Rectf destination
    *  2. Image, Rectf destination, Rectf clip
    *  3. Image, Rectf destination, Rectf clip, float rotation,
    *     Vector2f pivot, int flip value
    */
    std::shared_ptr<Image> *img = ImageLib::Check(l, 1);
    //Case 1:<commit_msg>I need a conversion for Recti *r = Rectf* rb<commit_after>#include <string>
#include <SDL.h>
#include <lua.hpp>
#include "src/debug.h"
#include "src/image.h"
#include "src/animatedimage.h"
#include "src/text.h"
#include "src/window.h"
#include "luacscript.h"
#include "luacimage.h"
#include "luacrectf.h"
#include "luacvector2f.h"
#include "luacwindow.h"

int LuaC::WindowLib::luaopen_window(lua_State *l){
    //Stack: lib name
    //Register the library as global table "Window"
    luaL_register(l, windowClass.c_str(), luaWindowLib);
    openFlipEnum(l);
    return 0;
}
void LuaC::WindowLib::openFlipEnum(lua_State *l){
    //Stack: lib name, table
    lua_pushinteger(l, SDL_FLIP_NONE);
    lua_setfield(l, -2, "FLIP_NONE");
    lua_pushinteger(l, SDL_FLIP_HORIZONTAL);
    lua_setfield(l, -2, "FLIP_HORIZONTAL");
    lua_pushinteger(l, SDL_FLIP_VERTICAL);
    lua_setfield(l, -2, "FLIP_VERTICAL");
}
const struct luaL_reg LuaC::WindowLib::luaWindowLib[] = {
    { "draw", draw },
    { "box", getBox },
    { NULL, NULL }
};
int LuaC::WindowLib::draw(lua_State *l){
    /*
    *  Multiple possible stacks, the 3 we check here are:
    *  1. Image, other params
    *  2. AnimatedImage, other params
    *  3. Text, other params
    */
    std::string type = LuaScriptLib::readType(l, 1);
    //Case 1
    if (type.at(0) == 'I')
        DrawImage(l);
    //Case 2
    else if (type.at(0) == 'A')
        DrawAnimatedImage(l);
    //Case 3
    else if (type.at(0) == 'T')
        DrawText(l);
    else
        Debug::Log("WindowLib:draw Error: " + type + " is not drawable");

    return 0;
}
int LuaC::WindowLib::getBox(lua_State *l){
    RectfLib::Push(&Window::Box(), l);
    return 1;
}
void LuaC::WindowLib::DrawImage(lua_State *l){
    /**
    *  3 Possible stacks:
    *  1. Image, Rectf destination
    *  2. Image, Rectf destination, Rectf clip
    *  3. Image, Rectf destination, Rectf clip, float rotation,
    *     Vector2f pivot, int flip value
    */
    std::shared_ptr<Image> *img = ImageLib::Check(l, 1);
    //Case 1:
{'fraction_non_alphanumeric': 0.15713932195001237, 'fraction_numerical': 0.011878247958426132, 'mean_word_length': 3.313767342582711, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6301379', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1527, 'n_words': 358}