KJsEmbed

value_binding.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2005, 2006 Ian Reinhart Geiser <[email protected]>
3  Copyright (C) 2005, 2006 Matt Broadstone <[email protected]>
4  Copyright (C) 2005, 2006 Richard J. Moore <[email protected]>
5  Copyright (C) 2005, 2006 Erik L. Bunce <[email protected]>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #include "value_binding.h"
23 
24 using namespace KJSEmbed;
25 
26 const KJS::ClassInfo ValueBinding::info = { "ValueBinding", nullptr, nullptr, nullptr };
27 
28 KJS::JSValue *callValueType(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &args)
29 {
30  Q_UNUSED(args);
31  KJSEmbed::ValueBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ValueBinding>(exec, self);
32  if (imp) {
33  return KJS::jsString(imp->className().ascii());
34  }
35  return KJS::jsNull();
36 }
37 
38 const Method ValueFactory::ValueMethods[] = {
39  {"type", 0, KJS::DontDelete | KJS::ReadOnly, &callValueType },
40  //{"cast", 1, KJS::DontDelete|KJS::ReadOnly, &callPointerCast },
41  //{"toString", 0, KJS::DontDelete|KJS::ReadOnly, &callPointerToString },
42  {nullptr, 0, 0, nullptr }
43 };
44 
45 const Method *ValueFactory::methods()
46 {
47  return ValueMethods;
48 }
49 
50 ValueBinding::ValueBinding(KJS::ExecState *exec, const char *typeName)
51  : ProxyBinding(exec),
52  m_value(nullptr),
53  m_name(typeName)
54 {
55  StaticBinding::publish(exec, this, ValueFactory::methods());
56 }
57 
58 ValueBinding::~ValueBinding()
59 {
60  delete m_value;
61 }
62 
63 KJS::UString ValueBinding::toString(KJS::ExecState *exec) const
64 {
65  Q_UNUSED(exec);
66  return m_value->type().name();
67 }
68 
Value binding implementation.
char * ascii() const
QString typeName(const QJsonObject &obj)
static void publish(KJS::ExecState *exec, KJS::JSObject *object, const Method *methods)
Publishes an array of Methods to an object.
Method structure.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 10 2023 03:59:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.