kjsembed
static_binding.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org> 00003 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com> 00004 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org> 00005 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef STATIC_BINDING_H 00024 #define STATIC_BINDING_H 00025 #include <QtCore/QHash> 00026 00027 #include <kdemacros.h> 00028 #include <kjs/function.h> 00029 00030 #include "binding_support.h" 00031 00032 #define LengthFlags KJS::DontDelete|KJS::ReadOnly|KJS::DontEnum 00033 00034 namespace KJSEmbed 00035 { 00039 class KJSEMBED_EXPORT StaticBinding : public KJS::InternalFunctionImp 00040 { 00041 public: 00045 StaticBinding(KJS::ExecState *exec, const Method *method ); 00049 KJS::JSValue *callAsFunction( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args ); 00050 bool implementsConstruct() const { return false; } 00051 00058 static void publish( KJS::ExecState *exec, KJS::JSObject *object, const Method *methods ); 00059 00060 protected: 00061 const Method *m_method; 00062 }; 00063 00068 class KJSEMBED_EXPORT StaticConstructor : public KJS::InternalFunctionImp 00069 { 00070 public: 00074 StaticConstructor(KJS::ExecState *exec, const Constructor *constructor ); 00075 00083 void addStaticMethods( KJS::ExecState *exec, const Method *methods ); 00084 00085 00086 bool implementsConstruct() const { return true; } 00091 KJS::JSObject *construct( KJS::ExecState *exec, const KJS::List &args ); 00092 00093 KJS::JSValue *callAsFunction( KJS::ExecState *exec, KJS::JSObject * /*self*/, const KJS::List &args ) { 00094 return construct(exec, args); 00095 } 00096 00097 void setDefaultValue( KJS::JSValue *value ); 00098 KJS::JSValue *defaultValue( KJS::ExecState *exec, KJS::JSType hint ) const; 00099 00103 static KJS::JSObject *add( KJS::ExecState *exec, KJS::JSObject *object, const Constructor *constructor ); 00116 static KJS::JSObject *construct( KJS::ExecState *exec, KJS::JSObject *parent, 00117 const KJS::UString &className, const KJS::List &args = KJS::List() ); 00118 00119 static KJS::JSObject* bind(KJS::ExecState* exec, const QString &className, PointerBase& objPtr); 00120 static const Method *methods( const KJS::UString &className ); 00121 static const Constructor *constructor( const KJS::UString &className ); 00122 00123 protected: 00124 const Constructor *m_constructor; 00125 00126 private: 00127 KJS::JSValue *m_default; 00128 00129 }; 00130 00131 } 00132 00133 #endif 00134 00135 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KDE 4.6 API Reference