<commit_before>#ifndef __CALLBACK_H__
#define __CALLBACK_H__

#include "base.h"

namespace native
{
    namespace internal
    {
        class callback_object_base
        {
        public:
            callback_object_base(void* data)
                : data_(data)
            {
                //printf("callback_object_base(): %x\n", this);
            }
            virtual ~callback_object_base()
            {
                //printf("~callback_object_base(): %x\n", this);
            }

            void* get_data() { return data_; }

        private:
            void* data_;
        };

        // SCO: serialized callback object
        template<typename callback_t>
        class callback_object : public callback_object_base
        {
        public:
            callback_object(const callback_t& callback, void* data)
                : callback_object_base(data)
                , callback_(callback)
            {
                //printf("callback_object<>(): %x\n", this);
            }

            virtual ~callback_object()
            {
                //printf("~callback_object<>(): %x\n", this);
            }

        public:
            template<typename ...A>
            void invoke(A&& ... args)
            {
                callback_(std::forward<A>(args)...);
            }

        private:
            callback_t callback_;
        };
    }

    typedef std::shared_ptr<internal::callback_object_base> callback_object_ptr;

    class callbacks
    {
    public:
        callbacks(int max_callbacks)
            : lut_(max_callbacks)
        {
            //printf("callbacks(): %x\n", this);
        }
        ~callbacks()
        {
            //printf("~callbacks(): %x\n", this);
        }

        template<typename callback_t>
        static void store(void* target, int cid, const callback_t& callback, void* data=nullptr)
        {
            reinterpret_cast<callbacks*>(target)->lut_[cid] = callback_object_ptr(new internal::callback_object<callback_t>(callback, data));
        }

        template<typename callback_t>
        static void get_data(void* target, int cid)<commit_msg>bug: return type of get_data(): void -> void*<commit_after>#ifndef __CALLBACK_H__
#define __CALLBACK_H__

#include "base.h"

namespace native
{
    namespace internal
    {
        class callback_object_base
        {
        public:
            callback_object_base(void* data)
                : data_(data)
            {
                //printf("callback_object_base(): %x\n", this);
            }
            virtual ~callback_object_base()
            {
                //printf("~callback_object_base(): %x\n", this);
            }

            void* get_data() { return data_; }

        private:
            void* data_;
        };

        // SCO: serialized callback object
        template<typename callback_t>
        class callback_object : public callback_object_base
        {
        public:
            callback_object(const callback_t& callback, void* data)
                : callback_object_base(data)
                , callback_(callback)
            {
                //printf("callback_object<>(): %x\n", this);
            }

            virtual ~callback_object()
            {
                //printf("~callback_object<>(): %x\n", this);
            }

        public:
            template<typename ...A>
            void invoke(A&& ... args)
            {
                callback_(std::forward<A>(args)...);
            }

        private:
            callback_t callback_;
        };
    }

    typedef std::shared_ptr<internal::callback_object_base> callback_object_ptr;

    class callbacks
    {
    public:
        callbacks(int max_callbacks)
            : lut_(max_callbacks)
        {
            //printf("callbacks(): %x\n", this);
        }
        ~callbacks()
        {
            //printf("~callbacks(): %x\n", this);
        }

        template<typename callback_t>
        static void store(void* target, int cid, const callback_t& callback, void* data=nullptr)
        {
            reinterpret_cast<callbacks*>(target)->lut_[cid] = callback_object_ptr(new internal::callback_object<callback_t>(callback, data));
        }

        template<typename callback_t>
        static void* get_data(void* target, int cid)
{'fraction_non_alphanumeric': 0.11383251691159318, 'fraction_numerical': 0.0, 'mean_word_length': 1.6130408287629494, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 26, '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': '7511854', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1142, 'n_words': 221}