• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

kjsembed

  • kjsembed
  • kjsembed
object_binding.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2005, 2006 Ian Reinhart Geiser <geiseri@kde.org>
3 Copyright (C) 2005, 2006 Matt Broadstone <mbroadst@gmail.com>
4 Copyright (C) 2005, 2006 Richard J. Moore <rich@kde.org>
5 Copyright (C) 2005, 2006 Erik L. Bunce <kde@bunce.us>
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
23#include "object_binding.h"
24
25#include <QtCore/QArgument>
26#include <QtCore/QDebug>
27
28#include "static_binding.h"
29#include "variant_binding.h"
30
31using namespace KJSEmbed;
32
33const KJS::ClassInfo ObjectBinding::info = { "ObjectBinding", 0, 0, 0 };
34
35ObjectBinding::~ObjectBinding()
36{
37 if( m_owner == JSOwned )
38 {
39 m_value->cleanup();
40 }
41
42 delete m_value;
43}
44
45const char *ObjectBinding::typeName() const
46{
47 return m_name;
48}
49
50KJS::UString ObjectBinding::toString(KJS::ExecState * /*exec*/) const
51{
52 return KJS::UString( typeName() );
53}
54
55KJS::UString ObjectBinding::className() const
56{
57 return KJS::UString( typeName() );
58}
59
60KJS::JSType ObjectBinding::type() const
61{
62 return KJS::ObjectType;
63}
64
65ObjectBinding::Ownership ObjectBinding::ownership() const
66{
67 return m_owner;
68}
69
70void ObjectBinding::setOwnership( ObjectBinding::Ownership owner )
71{
72 m_owner = owner;
73}
74
75KJS::JSValue *callPointerName( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &/*args*/ )
76{
77 KJSEmbed::ObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ObjectBinding>(exec, self );
78 if( imp )
79 {
80 return KJS::jsString( imp->typeName() );
81 }
82 return KJS::jsNull();
83}
84
85KJS::JSValue *callPointerCast( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &/*args*/ )
86{
87 KJSEmbed::ObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ObjectBinding>(exec, self );
88 if( imp )
89 {
90 return KJS::jsBoolean(false);
91 }
92 return KJS::jsNull();
93}
94
95KJS::JSValue *callPointerToString( KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &/*args*/ )
96{
97 KJSEmbed::ObjectBinding *imp = KJSEmbed::extractBindingImp<KJSEmbed::ObjectBinding>(exec, self );
98 if( imp )
99 {
100 qDebug("Object to string");
101 return KJS::jsString( imp->typeName() );
102 }
103 return KJS::jsNull();
104}
105
106const Method ObjectFactory::ObjectMethods[] =
107{
108 {"type", 0, KJS::DontDelete|KJS::ReadOnly, &callPointerName },
109 {"cast", 1, KJS::DontDelete|KJS::ReadOnly, &callPointerCast },
110 {"toString", 0, KJS::DontDelete|KJS::ReadOnly, &callPointerToString },
111 {0, 0, 0, 0 }
112};
113
114//kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KJSEmbed::ObjectBinding
Definition: object_binding.h:89
KJSEmbed::ObjectBinding::~ObjectBinding
virtual ~ObjectBinding()
Definition: object_binding.cpp:35
KJSEmbed::ObjectBinding::typeName
const char * typeName() const
Definition: object_binding.cpp:45
KJSEmbed::ObjectBinding::info
static const KJS::ClassInfo info
Definition: object_binding.h:92
KJSEmbed::ObjectBinding::setOwnership
void setOwnership(Ownership owner)
Definition: object_binding.cpp:70
KJSEmbed::ObjectBinding::Ownership
Ownership
Definition: object_binding.h:91
KJSEmbed::ObjectBinding::JSOwned
@ JSOwned
Definition: object_binding.h:91
KJSEmbed::ObjectBinding::className
KJS::UString className() const
Definition: object_binding.cpp:55
KJSEmbed::ObjectBinding::type
KJS::JSType type() const
Definition: object_binding.cpp:60
KJSEmbed::ObjectBinding::ownership
Ownership ownership() const
Definition: object_binding.cpp:65
KJSEmbed::ObjectBinding::toString
KJS::UString toString(KJS::ExecState *exec) const
Definition: object_binding.cpp:50
KJSEmbed::ObjectFactory::ObjectMethods
static const Method ObjectMethods[]
Definition: object_binding.h:84
KJSEmbed
Definition: application.h:33
KJS::jsString
KJS::JSCell * jsString(const QString &s)
Definition: kjseglobal.h:73
callPointerName
KJS::JSValue * callPointerName(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &)
Definition: object_binding.cpp:75
callPointerCast
KJS::JSValue * callPointerCast(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &)
Definition: object_binding.cpp:85
callPointerToString
KJS::JSValue * callPointerToString(KJS::ExecState *exec, KJS::JSObject *self, const KJS::List &)
Definition: object_binding.cpp:95
object_binding.h
static_binding.h
KJSEmbed::Method
Method structure.
Definition: binding_support.h:295
PointerBase::cleanup
virtual void cleanup()=0
variant_binding.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kjsembed

Skip menu "kjsembed"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal