<commit_before>/* This file is part of the KDE libraries
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifndef BINDING_SUPPORT_H
#define BINDING_SUPPORT_H

#include <QDate>
#include <QStringList>

#include <kjsembed/kjseglobal.h>
#include <kjsembed/pointer.h>
#include <kjs/object.h>

#define KJS_BINDING( NAME ) \
    class NAME \
    { \
    public: \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
        static const KJS::JSObject *construct(KJS::ExecState *exec, const KJS::List &args)\
        { return (*p_constructor.construct)(exec,args); } \
    };

#define KJSO_BINDING( NAME, TYPE, BASENAME ) \
    class KJSEMBED_EXPORT NAME : public BASENAME \
    { \
    public: \
        NAME(KJS::ExecState *exec, TYPE * obj); \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
    };

#define KJSO_BINDING_NOEXP( NAME, TYPE, BASENAME ) \
    class NAME : public BASENAME \
    { \
    public: \
        NAME(KJS::ExecState *exec, TYPE * obj); \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
    };

#define KJSO_VALUE_BINDING( NAME, TYPE, BASENAME ) \
    class KJSEMBED_EXPORT NAME : public BASENAME \
    { \
    public: \
        NAME(KJS::ExecState *exec, const TYPE & val ); \
        NAME(KJS::ExecState *exec, const char *typeName ); \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
    };

#define KJSO_START_BINDING_CTOR( NAME, TYPE, BASENAME ) \
    NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
        : BASENAME( exec, obj ) \
    { \
        StaticBinding::publish( exec, this, NAME::methods() );

#define KJSO_END_BINDING_CTOR \
    }

#define KJSO_SIMPLE_BINDING_CTOR( NAME, TYPE, BASENAME ) \
    NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
        : BASENAME( exec, obj ) \
    { \
        StaticBinding::publish( exec, this, NAME::methods() ); \
    }

#define KJSV_SIMPLE_BINDING_CTOR( NAME, JSNAME, TYPE, BASENAME )        \
    NAME::NAME(KJS::ExecState *exec, const TYPE & value) \
        : BASENAME( exec, #JSNAME , value )                    \
    { \
        StaticBinding::publish( exec, this, NAME::methods() ); \
    }

#define START_METHOD_LUT( TYPE ) \
    const Method TYPE::p_methods[] = \
                                     {

#define START_STATIC_METHOD_LUT( TYPE ) \
    const Method TYPE::p_statics[] = \
                                     {

#define END_METHOD_LUT \
    ,{0, 0, 0, 0 }\
    };

#define START_ENUM_LUT( TYPE) \
    const Enumerator TYPE::p_enums[] =\
                                      {

#define END_ENUM_LUT \
    ,{0, 0 }\
    };

#define NO_ENUMS( TYPE ) \
    const Enumerator TYPE::p_enums[] = {{0, 0 }};

#define NO_METHODS( TYPE )\
    const Method TYPE::p_methods[] = { {0, 0, 0, 0 } };

#define NO_STATICS( TYPE )\
    const Method TYPE::p_statics[] = { {0, 0, 0, 0 } };

#define START_CTOR( TYPE, JSNAME, ARGS )\
    const Constructor TYPE::p_constructor = \
                                            { \
                                              #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, 0, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
    KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
    {\
        Q_UNUSED(exec);\
        Q_UNUSED(args);

#define END_CTOR \
    }

#define KJSO_START_CTOR( TYPE, JSNAME, ARGS )\
    const Constructor TYPE::p_constructor = \
                                            { \
                                              #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, &TYPE::bindMethod, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
    KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
    {\
        Q_UNUSED(exec);\
        Q_UNUSED(args);

#define KJSO_END_CTOR \
    }

#define KJSO_START_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        Q_UNUSED(ptrObj); \
         
#define KJSO_END_BIND \
    }

#define KJSO_QOBJECT_START_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        QObject* qobj = pointer_cast<QObject>(&ptrObj); \
        if (! qobj ) \
            return 0; \
        TYPE* object = qobject_cast<TYPE*>(qobj); \
        if (! object ) \
            return 0; \
         
#define KJSO_QOBJECT_END_BIND \
    }

#define KJSO_QOBJECT_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        QObject* qobj = pointer_cast<QObject>(&ptrObj); \
        if (! qobj ) \
            return 0; \
        TYPE* object = qobject_cast<TYPE*>(qobj); \
        if (! object ) \
            return 0; \
        return new NAME(exec, object); \
    }

#define KJSO_VALUE_START_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        TYPE* object = pointer_cast<TYPE>(&ptrObj); \
        if (! object ) \
            return 0; \
         
#define KJSO_VALUE_END_BIND \
    }

#define KJSO_VALUE_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        TYPE* object = pointer_cast<TYPE>(&ptrObj); \
        if (! object ) \
            return 0; \
        return new NAME(exec, *object); \
    }

namespace KJS
{
inline JSObject *throwError(ExecState *e, ErrorType t, const QString &m)
{
    return throwError(e, t, KJSEmbed::toUString(m));
}
}

namespace KJSEmbed
{
class KJSEMBED_EXPORT ProxyBinding : public KJS::JSObject
{
public:
    ProxyBinding(KJS::ExecState *exec);<commit_msg>Use more nullptr<commit_after>/* This file is part of the KDE libraries
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>
    Copyright (C) 2005, 2006 <NAME> <<EMAIL>>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#ifndef BINDING_SUPPORT_H
#define BINDING_SUPPORT_H

#include <QDate>
#include <QStringList>

#include <kjsembed/kjseglobal.h>
#include <kjsembed/pointer.h>
#include <kjs/object.h>

#define KJS_BINDING( NAME ) \
    class NAME \
    { \
    public: \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
        static const KJS::JSObject *construct(KJS::ExecState *exec, const KJS::List &args)\
        { return (*p_constructor.construct)(exec,args); } \
    };

#define KJSO_BINDING( NAME, TYPE, BASENAME ) \
    class KJSEMBED_EXPORT NAME : public BASENAME \
    { \
    public: \
        NAME(KJS::ExecState *exec, TYPE * obj); \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
    };

#define KJSO_BINDING_NOEXP( NAME, TYPE, BASENAME ) \
    class NAME : public BASENAME \
    { \
    public: \
        NAME(KJS::ExecState *exec, TYPE * obj); \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
    };

#define KJSO_VALUE_BINDING( NAME, TYPE, BASENAME ) \
    class KJSEMBED_EXPORT NAME : public BASENAME \
    { \
    public: \
        NAME(KJS::ExecState *exec, const TYPE & val ); \
        NAME(KJS::ExecState *exec, const char *typeName ); \
        static const KJSEmbed::Method p_methods[]; \
        static const KJSEmbed::Method p_statics[]; \
        static const KJSEmbed::Enumerator p_enums[]; \
        static const KJSEmbed::Constructor p_constructor; \
        static KJS::JSObject *bindMethod( KJS::ExecState *exec, PointerBase& ptrObj );\
        static KJS::JSObject *ctorMethod( KJS::ExecState *exec, const KJS::List &args );\
        static const KJSEmbed::Enumerator *enums() { return p_enums;} \
        static const KJSEmbed::Method *methods() { return p_methods;} \
        static const KJSEmbed::Method *statics() { return p_statics;} \
        static const KJSEmbed::Constructor *constructor() { return &p_constructor;} \
    };

#define KJSO_START_BINDING_CTOR( NAME, TYPE, BASENAME ) \
    NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
        : BASENAME( exec, obj ) \
    { \
        StaticBinding::publish( exec, this, NAME::methods() );

#define KJSO_END_BINDING_CTOR \
    }

#define KJSO_SIMPLE_BINDING_CTOR( NAME, TYPE, BASENAME ) \
    NAME::NAME(KJS::ExecState *exec, TYPE * obj) \
        : BASENAME( exec, obj ) \
    { \
        StaticBinding::publish( exec, this, NAME::methods() ); \
    }

#define KJSV_SIMPLE_BINDING_CTOR( NAME, JSNAME, TYPE, BASENAME )        \
    NAME::NAME(KJS::ExecState *exec, const TYPE & value) \
        : BASENAME( exec, #JSNAME , value )                    \
    { \
        StaticBinding::publish( exec, this, NAME::methods() ); \
    }

#define START_METHOD_LUT( TYPE ) \
    const Method TYPE::p_methods[] = \
                                     {

#define START_STATIC_METHOD_LUT( TYPE ) \
    const Method TYPE::p_statics[] = \
                                     {

#define END_METHOD_LUT \
    ,{nullptr, 0, 0, nullptr }\
    };

#define START_ENUM_LUT( TYPE) \
    const Enumerator TYPE::p_enums[] =\
                                      {

#define END_ENUM_LUT \
    ,{nullptr, 0 }\
    };

#define NO_ENUMS( TYPE ) \
    const Enumerator TYPE::p_enums[] = {{nullptr, 0 }};

#define NO_METHODS( TYPE )\
    const Method TYPE::p_methods[] = { {nullptr, 0, 0, nullptr } };

#define NO_STATICS( TYPE )\
    const Method TYPE::p_statics[] = { {nullptr, 0, 0, nullptr } };

#define START_CTOR( TYPE, JSNAME, ARGS )\
    const Constructor TYPE::p_constructor = \
                                            { \
                                              #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, nullptr, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
    KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
    {\
        Q_UNUSED(exec);\
        Q_UNUSED(args);

#define END_CTOR \
    }

#define KJSO_START_CTOR( TYPE, JSNAME, ARGS )\
    const Constructor TYPE::p_constructor = \
                                            { \
                                              #JSNAME, ARGS, KJS::DontDelete|KJS::ReadOnly, &TYPE::bindMethod, &TYPE::ctorMethod, p_statics, p_enums, p_methods };\
    KJS::JSObject *TYPE::ctorMethod( KJS::ExecState *exec, const KJS::List &args )\
    {\
        Q_UNUSED(exec);\
        Q_UNUSED(args);

#define KJSO_END_CTOR \
    }

#define KJSO_START_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        Q_UNUSED(ptrObj); \
         
#define KJSO_END_BIND \
    }

#define KJSO_QOBJECT_START_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        QObject* qobj = pointer_cast<QObject>(&ptrObj); \
        if (! qobj ) \
            return nullptr; \
        TYPE* object = qobject_cast<TYPE*>(qobj); \
        if (! object ) \
            return nullptr; \
         
#define KJSO_QOBJECT_END_BIND \
    }

#define KJSO_QOBJECT_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        QObject* qobj = pointer_cast<QObject>(&ptrObj); \
        if (! qobj ) \
            return nullptr; \
        TYPE* object = qobject_cast<TYPE*>(qobj); \
        if (! object ) \
            return nullptr; \
        return new NAME(exec, object); \
    }

#define KJSO_VALUE_START_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        TYPE* object = pointer_cast<TYPE>(&ptrObj); \
        if (! object ) \
            return nullptr; \
         
#define KJSO_VALUE_END_BIND \
    }

#define KJSO_VALUE_BIND( NAME, TYPE )\
    KJS::JSObject *NAME::bindMethod( KJS::ExecState *exec, PointerBase& ptrObj )\
    {\
        Q_UNUSED(exec);\
        TYPE* object = pointer_cast<TYPE>(&ptrObj); \
        if (! object ) \
            return nullptr; \
        return new NAME(exec, *object); \
    }

namespace KJS
{
inline JSObject *throwError(ExecState *e, ErrorType t, const QString &m)
{
    return throwError(e, t, KJSEmbed::toUString(m));
}
}

namespace KJSEmbed
{
class KJSEMBED_EXPORT ProxyBinding : public KJS::JSObject
{
public:
    ProxyBinding(KJS::ExecState *exec);
{'fraction_non_alphanumeric': 0.12404799737000713, 'fraction_numerical': 0.00652019067448359, 'mean_word_length': 2.6064018968583285, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6621742', 'n_tokens_mistral': 6081, 'n_tokens_neox': 5891, 'n_words': 1493}