<commit_before>#include <float.h>
#include <stdio.h>
#include <time.h>

#include <celib/hashlib.h>
#include <celib/config.h>
#include <celib/memory.h>
#include <celib/api_system.h>
#include <celib/ydb.h>
#include <celib/array.inl>
#include <celib/module.h>

#include <cetech/editor/command_system.h>
#include <celib/hash.inl>
#include <celib/cdb.h>
#include <cetech/gfx/debugui.h>
#include <celib/fmath.inl>
#include <cetech/editor/asset_browser.h>
#include <cetech/resource/builddb.h>
#include <celib/os.h>
#include <cetech/editor/property_editor.h>
#include <cetech/resource/resource.h>
#include <cetech/resource/sourcedb.h>
#include <cetech/gfx/private/iconfontheaders/icons_font_awesome.h>

#include "cetech/editor/editor_ui.h"

#define _SET_BOOL \
    CE_ID64_0("set_bool", 0xc7b18e7df0217558ULL)

#define _SET_STR \
    CE_ID64_0("set_str", 0x5096c6f990f09debULL)

#define _SET_UINT64 \
    CE_ID64_0("set_uint64", 0xdf40f6493b54f476ULL)

#define _SET_VEC3 \
    CE_ID64_0("set_vec3", 0xc9710c4624eccfb0ULL)

#define _SET_VEC4 \
    CE_ID64_0("set_vec4", 0x5d3fca6c7467c890ULL)

#define _SET_FLOAT \
    CE_ID64_0("set_float", 0x3a22b9e23704ab12ULL)

#define _NEW_VALUE \
    CE_ID64_0("new_value", 0x1d77a29c912111fULL)

#define _OLD_VALUE \
    CE_ID64_0("old_value", 0x8115d649f2a9636aULL)

#define _KEYS \
    CE_ID64_0("keys", 0xa62f9297dc969e85ULL)

#define _PROP \
    CE_ID64_0("property", 0xcbd168fb77919b23ULL)


//static bool ui_select_asset(char *buffer,
//                            const char *id,
//                            uint32_t asset_type,
//                            uint64_t key) {
//    char id_str[512] = {};
//    sprintf(id_str, ">>##%s", id);
//
//    if (ct_debugui_a0->Button(id_str, (float[2]) {0.0f})) {
//        if (ct_asset_browser_a0->get_selected_asset_type() != asset_type) {
//            return false;
//        }
//
//        char selected_asset[128] = {};
//        ct_asset_browser_a0->get_selected_asset_name(selected_asset);
//
//        strcpy(buffer, selected_asset);
//
//        return true;
//    }
//
//    return false;
//}


static void _collect_keys(struct ct_resource_id rid,
                          uint64_t obj,
                          ce_cdb_obj_o *w,
                          uint32_t idx) {
    if (ce_cdb_a0->read_uint64(obj, ASSET_NAME, 0) == rid.name) {
        return;
    }

    uint64_t k = ce_cdb_a0->key(obj);
    ce_cdb_a0->set_uint64(w, idx, k);

    uint64_t parent = ce_cdb_a0->parent(obj);
    _collect_keys(rid, parent, w, idx + 1);
}

static uint64_t _find_recursive(uint64_t obj,
                                uint64_t keys) {
    uint64_t n = ce_cdb_a0->prop_count(keys);

    uint64_t it_obj = obj;
    for (int i = 0; i < n; ++i) {
        uint64_t k = ce_cdb_a0->read_uint64(keys, n - 1 - i, 0);
        it_obj = ce_cdb_a0->read_subobject(it_obj, k, 0);
    }

    return it_obj;
}


static uint64_t _create_recursive(uint64_t obj,
                                  uint64_t keys,
                                  uint64_t kidx) {
    uint64_t k = ce_cdb_a0->read_uint64(keys, kidx, 0);
    if (!k) {
        return obj;
    }

    uint64_t root = ce_cdb_a0->read_subobject(obj, k, 0);

    uint64_t new_obj = ce_cdb_a0->create_from(ce_cdb_a0->db(), root);
    ce_cdb_obj_o *w = ce_cdb_a0->write_begin(obj);
    ce_cdb_a0->set_subobject(w, k, new_obj);
    ce_cdb_a0->write_commit(w);

    return _create_recursive(new_obj, keys, kidx - 1);
}

static uint64_t _find_recursive_create(uint64_t obj,
                                       uint64_t keys) {
    uint64_t n = ce_cdb_a0->prop_count(keys);

    uint64_t it_obj = obj;
    for (int i = 0; i < n; ++i) {
        uint64_t kidx = n - 1 - i;
        uint64_t k = ce_cdb_a0->read_uint64(keys, kidx, 0);

        if (!ce_cdb_a0->prop_exist_norecursive(it_obj, k)) {
            it_obj = _create_recursive(it_obj, keys, kidx);
            break;
        } else {
            it_obj = ce_cdb_a0->read_subobject(it_obj, k, 0);
        }
    }

    return it_obj;
}


static void _prop_label(const char* label, uint64_t _obj, uint64_t prop_key_hash) {
    if (ce_cdb_a0->prefab(_obj)
        && ce_cdb_a0->prop_exist_norecursive(_obj, prop_key_hash)) {
        bool remove_change = ct_debugui_a0->Button(ICON_FA_RECYCLE,
                                                   (float[2]) {});
        if (remove_change) {
            ce_cdb_obj_o *w = ce_cdb_a0->write_begin(_obj);
            ce_cdb_a0->delete_property(w, prop_key_hash);
            ce_cdb_a0->write_commit(w);
        }<commit_msg>fix revert btn label<commit_after>#include <float.h>
#include <stdio.h>
#include <time.h>

#include <celib/hashlib.h>
#include <celib/config.h>
#include <celib/memory.h>
#include <celib/api_system.h>
#include <celib/ydb.h>
#include <celib/array.inl>
#include <celib/module.h>

#include <cetech/editor/command_system.h>
#include <celib/hash.inl>
#include <celib/cdb.h>
#include <cetech/gfx/debugui.h>
#include <celib/fmath.inl>
#include <cetech/editor/asset_browser.h>
#include <cetech/resource/builddb.h>
#include <celib/os.h>
#include <cetech/editor/property_editor.h>
#include <cetech/resource/resource.h>
#include <cetech/resource/sourcedb.h>
#include <cetech/gfx/private/iconfontheaders/icons_font_awesome.h>

#include "cetech/editor/editor_ui.h"

#define _SET_BOOL \
    CE_ID64_0("set_bool", 0xc7b18e7df0217558ULL)

#define _SET_STR \
    CE_ID64_0("set_str", 0x5096c6f990f09debULL)

#define _SET_UINT64 \
    CE_ID64_0("set_uint64", 0xdf40f6493b54f476ULL)

#define _SET_VEC3 \
    CE_ID64_0("set_vec3", 0xc9710c4624eccfb0ULL)

#define _SET_VEC4 \
    CE_ID64_0("set_vec4", 0x5d3fca6c7467c890ULL)

#define _SET_FLOAT \
    CE_ID64_0("set_float", 0x3a22b9e23704ab12ULL)

#define _NEW_VALUE \
    CE_ID64_0("new_value", 0x1d77a29c912111fULL)

#define _OLD_VALUE \
    CE_ID64_0("old_value", 0x8115d649f2a9636aULL)

#define _KEYS \
    CE_ID64_0("keys", 0xa62f9297dc969e85ULL)

#define _PROP \
    CE_ID64_0("property", 0xcbd168fb77919b23ULL)


static void _collect_keys(struct ct_resource_id rid,
                          uint64_t obj,
                          ce_cdb_obj_o *w,
                          uint32_t idx) {
    if (ce_cdb_a0->read_uint64(obj, ASSET_NAME, 0) == rid.name) {
        return;
    }

    uint64_t k = ce_cdb_a0->key(obj);
    ce_cdb_a0->set_uint64(w, idx, k);

    uint64_t parent = ce_cdb_a0->parent(obj);
    _collect_keys(rid, parent, w, idx + 1);
}

static uint64_t _find_recursive(uint64_t obj,
                                uint64_t keys) {
    uint64_t n = ce_cdb_a0->prop_count(keys);

    uint64_t it_obj = obj;
    for (int i = 0; i < n; ++i) {
        uint64_t k = ce_cdb_a0->read_uint64(keys, n - 1 - i, 0);
        it_obj = ce_cdb_a0->read_subobject(it_obj, k, 0);
    }

    return it_obj;
}


static uint64_t _create_recursive(uint64_t obj,
                                  uint64_t keys,
                                  uint64_t kidx) {
    uint64_t k = ce_cdb_a0->read_uint64(keys, kidx, 0);
    if (!k) {
        return obj;
    }

    uint64_t root = ce_cdb_a0->read_subobject(obj, k, 0);

    uint64_t new_obj = ce_cdb_a0->create_from(ce_cdb_a0->db(), root);
    ce_cdb_obj_o *w = ce_cdb_a0->write_begin(obj);
    ce_cdb_a0->set_subobject(w, k, new_obj);
    ce_cdb_a0->write_commit(w);

    return _create_recursive(new_obj, keys, kidx - 1);
}

static uint64_t _find_recursive_create(uint64_t obj,
                                       uint64_t keys) {
    uint64_t n = ce_cdb_a0->prop_count(keys);

    uint64_t it_obj = obj;
    for (int i = 0; i < n; ++i) {
        uint64_t kidx = n - 1 - i;
        uint64_t k = ce_cdb_a0->read_uint64(keys, kidx, 0);

        if (!ce_cdb_a0->prop_exist_norecursive(it_obj, k)) {
            it_obj = _create_recursive(it_obj, keys, kidx);
            break;
        } else {
            it_obj = ce_cdb_a0->read_subobject(it_obj, k, 0);
        }
    }

    return it_obj;
}


static void _prop_label(const char *label,
                        uint64_t _obj,
                        uint64_t prop_key_hash) {
    if (ce_cdb_a0->prefab(_obj)
        && ce_cdb_a0->prop_exist_norecursive(_obj, prop_key_hash)) {

        char lbl[256] = {};
        snprintf(lbl, CE_ARRAY_LEN(lbl), "%s##revert_%llu_%llu",
                 ICON_FA_RECYCLE, _obj, prop_key_hash);

        bool remove_change = ct_debugui_a0->Button(lbl,
                                                   (float[2]) {});
        if (remove_change) {
            ce_cdb_obj_o *w = ce_cdb_a0->write_begin(_obj);
            ce_cdb_a0->delete_property(w, prop_key_hash);
            ce_cdb_a0->write_commit(w);
        }
{'fraction_non_alphanumeric': 0.12459396751740139, 'fraction_numerical': 0.0611368909512761, 'mean_word_length': 2.5521219612690564, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 100, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '959316', 'n_tokens_mistral': 3849, 'n_tokens_neox': 3546, 'n_words': 557}