kjsembed
object_binding.cpp
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 #include "object_binding.h"
00024
00025 #include <QtCore/QArgument>
00026 #include <QtCore/QDebug>
00027
00028 #include "static_binding.h"
00029 #include "variant_binding.h"
00030
00031 using namespace KJSEmbed;
00032
00033 const KJS::ClassInfo ObjectBinding::info = { "ObjectBinding", 0, 0, 0 };
00034
00035 ObjectBinding::~ObjectBinding()
00036 {
00037 if( m_owner == JSOwned )
00038 {
00039 m_value->cleanup();
00040 }
00041
00042 delete m_value;
00043 }
00044
00045 const char *ObjectBinding::typeName() const
00046 {
00047 return m_name;
00048 }
00049
00050 KJS::UString ObjectBinding::toString(KJS::ExecState * ) const
00051 {
00052 return KJS::UString( typeName() );
00053 }
00054
00055 KJS::UString ObjectBinding::className() const
00056 {
00057 return KJS::UString( typeName() );
00058 }
00059
00060 KJS::JSType ObjectBinding::type() const
00061 {
00062 return KJS::ObjectType;
00063 }
00064
00065 ObjectBinding::Ownership ObjectBinding::ownership() const
00066 {
00067 return m_owner;
00068 }
00069
00070 void ObjectBinding::setOwnership( ObjectBinding::Ownership owner )
00071 {
00072 m_owner = owner;
00073 }
00074
00075 KJS::JSValue *callPointerName( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List & )
00076 {
00077 KJSEmbed::ObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ObjectBinding>(exec, self );
00078 if( imp )
00079 {
00080 return KJS::jsString( imp->typeName() );
00081 }
00082 return KJS::jsNull();
00083 }
00084
00085 KJS::JSValue *callPointerCast( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List & )
00086 {
00087 KJSEmbed::ObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ObjectBinding>(exec, self );
00088 if( imp )
00089 {
00090 return KJS::jsBoolean(false);
00091 }
00092 return KJS::jsNull();
00093 }
00094
00095 KJS::JSValue *callPointerToString( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List & )
00096 {
00097 KJSEmbed::ObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ObjectBinding>(exec, self );
00098 if( imp )
00099 {
00100 qDebug("Object to string");
00101 return KJS::jsString( imp->typeName() );
00102 }
00103 return KJS::jsNull();
00104 }
00105
00106 const Method ObjectFactory::ObjectMethods[] =
00107 {
00108 {"type", 0, KJS::DontDelete|KJS::ReadOnly, &callPointerName },
00109 {"cast", 1, KJS::DontDelete|KJS::ReadOnly, &callPointerCast },
00110 {"toString", 0, KJS::DontDelete|KJS::ReadOnly, &callPointerToString },
00111 {0, 0, 0, 0 }
00112 };
00113
00114