
#ifndef tjsObjectExtendableH
#define tjsObjectExtendableH

#include "tjsObject.h"

namespace TJS {
    // ½dp³ÍT|[gµÈ¢
    class tTJSExtendableObject : public tTJSCustomObject {
        typedef tTJSCustomObject inherited;

    protected:
        iTJSDispatch2 *SuperClass;

        /**
         * @param global :
         * ùèNXðõ·éIuWFNg(ÊÍO[o)
         * @param classname : ùèNX¼
         */
        void ExtendsClass(iTJSDispatch2 *global, const ttstr &classname);

    public:
        tTJSExtendableObject() : SuperClass(nullptr) {}

        ~tTJSExtendableObject() override;

        iTJSDispatch2 *GetSuper() { return SuperClass; }

        [[nodiscard]] const iTJSDispatch2 *GetSuper() const {
            return SuperClass;
        }

        void SetSuper(iTJSDispatch2 *dsp);

        tjs_error FuncCall(tjs_uint32 flag, const tjs_char *membername,
                           tjs_uint32 *hint, tTJSVariant *result,
                           tjs_int numparams, tTJSVariant **param,
                           iTJSDispatch2 *objthis) override;

        tjs_error CreateNew(tjs_uint32 flag, const tjs_char *membername,
                            tjs_uint32 *hint, iTJSDispatch2 **result,
                            tjs_int numparams, tTJSVariant **param,
                            iTJSDispatch2 *objthis) override;

        tjs_error PropGet(tjs_uint32 flag, const tjs_char *membername,
                          tjs_uint32 *hint, tTJSVariant *result,
                          iTJSDispatch2 *objthis) override;

        tjs_error PropSet(tjs_uint32 flag, const tjs_char *membername,
                          tjs_uint32 *hint, const tTJSVariant *param,
                          iTJSDispatch2 *objthis) override;

        tjs_error IsInstanceOf(tjs_uint32 flag, const tjs_char *membername,
                               tjs_uint32 *hint, const tjs_char *classname,
                               iTJSDispatch2 *objthis) override;

        tjs_error GetCount(tjs_int *result, const tjs_char *membername,
                           tjs_uint32 *hint, iTJSDispatch2 *objthis) override;

        tjs_error DeleteMember(tjs_uint32 flag, const tjs_char *membername,
                               tjs_uint32 *hint,
                               iTJSDispatch2 *objthis) override;

        tjs_error Invalidate(tjs_uint32 flag, const tjs_char *membername,
                             tjs_uint32 *hint, iTJSDispatch2 *objthis) override;

        tjs_error IsValid(tjs_uint32 flag, const tjs_char *membername,
                          tjs_uint32 *hint, iTJSDispatch2 *objthis) override;

        tjs_error Operation(tjs_uint32 flag, const tjs_char *membername,
                            tjs_uint32 *hint, tTJSVariant *result,
                            const tTJSVariant *param,
                            iTJSDispatch2 *objthis) override;

        tjs_error NativeInstanceSupport(tjs_uint32 flag, tjs_int32 classid,
                                        iTJSNativeInstance **pointer) override;

        // X[p[NXÌo^Ææ¾ðT|[g
        tjs_error ClassInstanceInfo(tjs_uint32 flag, tjs_uint num,
                                    tTJSVariant *value) override;
    };
} // namespace TJS
#endif // tjsObjectExtendableH
