• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • kjs
scope_chain.cpp
1/*
2 * This file is part of the KDE libraries
3 * Copyright (C) 2003 Apple Computer, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22#include "scope_chain.h"
23
24#include "object.h"
25
26#include <assert.h>
27
28namespace KJS {
29
30inline void ScopeChain::ref() const
31{
32 for (ScopeChainNode *n = _node; n; n = n->next) {
33 if (n->refCount++ != 0)
34 break;
35 }
36}
37
38ScopeChain &ScopeChain::operator=(const ScopeChain &c)
39{
40 c.ref();
41 deref();
42 _node = c._node;
43 return *this;
44}
45
46void ScopeChain::push(ObjectImp *o)
47{
48 assert(o);
49 _node = new ScopeChainNode(_node, o);
50}
51
52void ScopeChain::pop()
53{
54 ScopeChainNode *oldNode = _node;
55 assert(oldNode);
56 ScopeChainNode *newNode = oldNode->next;
57 _node = newNode;
58
59 if (--oldNode->refCount != 0) {
60 if (newNode)
61 ++newNode->refCount;
62 } else {
63 delete oldNode;
64 }
65}
66
67void ScopeChain::release()
68{
69 // This function is only called by deref(),
70 // Deref ensures these conditions are true.
71 assert(_node && _node->refCount == 0);
72 ScopeChainNode *n = _node;
73 do {
74 ScopeChainNode *next = n->next;
75 delete n;
76 n = next;
77 } while (n && --n->refCount == 0);
78}
79
80void ScopeChain::mark()
81{
82 for (ScopeChainNode *n = _node; n; n = n->next) {
83 ObjectImp *o = n->object;
84 if (!o->marked())
85 o->mark();
86 }
87}
88
89} // namespace KJS
TDEStdAccel::next
const TDEShortcut & next()

kjs

Skip menu "kjs"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kjs

Skip menu "kjs"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.9.4
This website is maintained by Timothy Pearson.