kjsembed
static_binding.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 * , 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