// -*- c++ -*-

/*
 *  Copyright (C) 2001-2003, Richard J. Moore <rich@kde.org>
 *
 *  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., 59 Temple Place - Suite 330,
 *  Boston, MA 02111-1307, USA.
 */

#ifndef KJSEMBEDJSOBJECTPROXYIMP_H
#define KJSEMBEDJSOBJECTPROXYIMP_H

#include <kjs/object.h>
#include <kjsembed/jsbinding.h>

class QObject;

namespace KJS { class Interpreter; };

namespace KJSEmbed {
namespace Bindings {

/**
 * Implements the JS methods of KJSEmbed::ObjectProxy.
 */
class JSObjectProxyImp : public KJS::ObjectImp
{
public:
    enum MethodId {
	MethodCreate,
	MethodChildren, MethodSlots, MethodProps,
	MethodParent, MethodFindChild, MethodChild, MethodChildCount, MethodChildAt,

	MethodSlot, MethodSlotInt, MethodSlotBool, MethodSlotString, MethodSlotDouble,
	MethodSlotIntInt, MethodSlotStringInt,
	
	MethodCustom = 0x1000
    };

    JSObjectProxyImp( int id, const JSObjectProxy *parent );
    JSObjectProxyImp( int id, const QCString &name, const JSObjectProxy *parent );
    ~JSObjectProxyImp() {}

    KJS::Value childAt( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
    KJS::Value findChild( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );

    KJS::Value children( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
    KJS::Value properties( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
    KJS::Value slotz( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );

    KJS::Value callSlot( KJS::ExecState *state, KJS::Object &self, const KJS::List &args );

    static int findSignature( const QString &sig );

    virtual bool implementsCall() const { return true; }
    virtual KJS::Value call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args );
    
private:
    int id;
    QCString slotname;
    const JSObjectProxy *proxy;
    QObject *obj;
    class Private *d;
};

} // namespace KJSEmbed::Bindings
}; // namespace KJSEmbed

#endif // KJSEMBEDJSOBJECTPROXYIMP_H

// Local Variables:
// c-basic-offset: 4
// End:
