File indexing completed on 2024-12-08 12:23:10
0001 /* This file is part of the KDE libraries 0002 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org> 0003 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com> 0004 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org> 0005 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Library General Public 0009 License as published by the Free Software Foundation; either 0010 version 2 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Library General Public License for more details. 0016 0017 You should have received a copy of the GNU Library General Public License 0018 along with this library; see the file COPYING.LIB. If not, write to 0019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 Boston, MA 02110-1301, USA. 0021 */ 0022 #include "value_binding.h" 0023 0024 using namespace KJSEmbed; 0025 0026 const KJS::ClassInfo ValueBinding::info = { "ValueBinding", nullptr, nullptr, nullptr }; 0027 0028 KJS::JSValue *callValueType(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args) 0029 { 0030 Q_UNUSED(args); 0031 KJSEmbed::ValueBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ValueBinding>(exec, self); 0032 if (imp) { 0033 return KJS::jsString(imp->className().ascii()); 0034 } 0035 return KJS::jsNull(); 0036 } 0037 0038 const Method ValueFactory::ValueMethods[] = { 0039 {"type", 0, KJS::DontDelete | KJS::ReadOnly, &callValueType }, 0040 //{"cast", 1, KJS::DontDelete|KJS::ReadOnly, &callPointerCast }, 0041 //{"toString", 0, KJS::DontDelete|KJS::ReadOnly, &callPointerToString }, 0042 {nullptr, 0, 0, nullptr } 0043 }; 0044 0045 const Method *ValueFactory::methods() 0046 { 0047 return ValueMethods; 0048 } 0049 0050 ValueBinding::ValueBinding(KJS::ExecState *exec, const char *typeName) 0051 : ProxyBinding(exec), 0052 m_value(nullptr), 0053 m_name(typeName) 0054 { 0055 StaticBinding::publish(exec, this, ValueFactory::methods()); 0056 } 0057 0058 ValueBinding::~ValueBinding() 0059 { 0060 delete m_value; 0061 } 0062 0063 KJS::UString ValueBinding::toString(KJS::ExecState *exec) const 0064 { 0065 Q_UNUSED(exec); 0066 return m_value->type().name(); 0067 } 0068