<commit_before>#include "script/TextureHandle.h"

#include "canvas/Texture.h"
#include "script/util.h"

JSPropertySpec TextureHandle::jsProperties[] = {
    { "width", 0, JSPROP_ENUMERATE | JSPROP_READONLY,
        TextureHandle::bindProperty<&TextureHandle::getWidth>, NULL },
    { "height", 0, JSPROP_ENUMERATE | JSPROP_READONLY,
        TextureHandle::bindProperty<&TextureHandle::getHeight>, NULL },
    { NULL }
};
DEFINE_HANDLE_JSCLASS(TextureHandle, "Texture");

TextureHandle::~TextureHandle ()
{
    delete _texture;
}

SCRIPT_PROPERTY (TextureHandle::getWidth, jsCtx, obj, id, vp)
{
    JS_SET_RVAL(jsCtx, vp, INT_TO_JSVAL(_texture->getWidth()));
    return JS_TRUE;
}

SCRIPT_PROPERTY (TextureHandle::getHeight, jsCtx, obj, id, vp)
{
    JS_SET_RVAL(jsCtx, vp, INT_TO_JSVAL(_texture->getHeight()));
    return JS_TRUE;
}

SCRIPT_FUNCTION (amity_createTexture, jsCtx, argc, vp)
{
    const char* assetName;
    if (!JS_ConvertArguments(jsCtx, 1, JS_ARGV(jsCtx, vp), "s", &assetName)) {
        return JS_FALSE;
    }

    Texture* texture = Texture::fromAsset(assetName);
    if (texture == NULL) {
        return JS_FALSE;
    }

    TextureHandle* textureHandle = TextureHandle::create(jsCtx);
    textureHandle->setTexture(texture);
    JS_SET_RVAL(jsCtx, vp, OBJECT_TO_JSVAL(textureHandle->getJSObject()));

    return JS_TRUE;
}
<commit_msg>Tell Spidermonkey not to store these values in JS, we'll store them in C++.<commit_after>#include "script/TextureHandle.h"

#include "canvas/Texture.h"
#include "script/util.h"

JSPropertySpec TextureHandle::jsProperties[] = {
    { "width", 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED,
        TextureHandle::bindProperty<&TextureHandle::getWidth>, NULL },
    { "height", 0, JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_SHARED,
        TextureHandle::bindProperty<&TextureHandle::getHeight>, NULL },
    { NULL }
};
DEFINE_HANDLE_JSCLASS(TextureHandle, "Texture");

TextureHandle::~TextureHandle ()
{
    delete _texture;
}

SCRIPT_PROPERTY (TextureHandle::getWidth, jsCtx, obj, id, vp)
{
    JS_SET_RVAL(jsCtx, vp, INT_TO_JSVAL(_texture->getWidth()));
    return JS_TRUE;
}

SCRIPT_PROPERTY (TextureHandle::getHeight, jsCtx, obj, id, vp)
{
    JS_SET_RVAL(jsCtx, vp, INT_TO_JSVAL(_texture->getHeight()));
    return JS_TRUE;
}

SCRIPT_FUNCTION (amity_createTexture, jsCtx, argc, vp)
{
    const char* assetName;
    if (!JS_ConvertArguments(jsCtx, 1, JS_ARGV(jsCtx, vp), "s", &assetName)) {
        return JS_FALSE;
    }

    Texture* texture = Texture::fromAsset(assetName);
    if (texture == NULL) {
        return JS_FALSE;
    }

    TextureHandle* textureHandle = TextureHandle::create(jsCtx);
    textureHandle->setTexture(texture);
    JS_SET_RVAL(jsCtx, vp, OBJECT_TO_JSVAL(textureHandle->getJSObject()));

    return JS_TRUE;
}

{'fraction_non_alphanumeric': 0.1331693605059733, 'fraction_numerical': 0.0021082220660576245, 'mean_word_length': 4.84599589322382, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '5259411', 'n_tokens_mistral': 1020, 'n_tokens_neox': 1006, 'n_words': 181}