ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ProtectedObject.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.ibm.com/developerworks/oss/CPLv1.0.htm */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 #ifndef ProtectedObject_Included
39 #define ProtectedObject_Included
40 
41 #include "RexxActivity.hpp"
42 #include "ActivityManager.hpp"
43 
44 class RexxInstruction;
45 
47 {
48 friend class RexxActivity;
49 public:
51  {
52  // save the activity
54 
55  // it would be better to have the activity class do this, but because
56  // we're doing this with inline methods, we run into a bit of a
57  // circular reference problem
59  activity->protectedObjects = this;
60  }
61 
63  {
64  // it would be better to have the activity class do this, but because
65  // we're doing this with inline methods, we run into a bit of a
66  // circular reference problem
68  activity->protectedObjects = this;
69  }
70 
72  {
73  // save the activity
76  activity->protectedObjects = this;
77  }
78 
80  {
82  activity->protectedObjects = this;
83  }
84 
86  {
87  // save the activity
90  activity->protectedObjects = this;
91  }
92 
94  {
96  activity->protectedObjects = this;
97  }
98 
100  {
101  // remove ourselves from the list and give this object a
102  // little hold protection.
104  if (protectedObject != OREF_NULL)
105  {
107  }
108  }
109 
111  {
112  protectedObject = o;
113  return *this;
114  }
115 
116  inline bool operator == (RexxObject *o)
117  {
118  return protectedObject == o;
119  }
120 
121  inline bool operator != (RexxObject *o)
122  {
123  return protectedObject != o;
124  }
125 
126  // cast conversion operators for some very common uses of protected object.
127  inline operator RexxObject *()
128  {
129  return protectedObject;
130  }
131 
132  inline operator RexxObjectPtr ()
133  {
135  }
136 
137  inline operator RexxString *()
138  {
139  return (RexxString *)protectedObject;
140  }
141 
142  inline operator RexxMethod *()
143  {
144  return (RexxMethod *)protectedObject;
145  }
146 
147  inline operator RexxArray *()
148  {
149  return (RexxArray *)protectedObject;
150  }
151 
152  // this conversion helps the parsing process protect objects
153  inline operator RexxInstruction *()
154  {
156  }
157 
158  inline operator void *()
159  {
160  return (void *)protectedObject;
161  }
162 
163 protected:
164  RexxObject *protectedObject; // next in the chain of protected object
165  ProtectedObject *next; // the pointer protected by the object
166  RexxActivity *activity; // the activity we're running on
167 };
168 
169 
171 {
172 public:
173  inline ProtectedSet() : ProtectedObject() { }
175  inline ~ProtectedSet() { }
176 
177  void add(RexxObject *);
178 };
179 
180 
181 #endif
RexxArray
Definition: ArrayClass.hpp:100
RexxInternalObject
Definition: ObjectClass.hpp:206
ProtectedObject::operator!=
bool operator!=(RexxObject *o)
Definition: ProtectedObject.hpp:121
ProtectedObject::activity
RexxActivity * activity
Definition: ProtectedObject.hpp:166
ActivityManager.hpp
ProtectedObject::protectedObject
RexxObject * protectedObject
Definition: ProtectedObject.hpp:164
RexxInstruction
Definition: RexxInstruction.hpp:54
ProtectedObject::ProtectedObject
ProtectedObject(RexxInternalObject *o, RexxActivity *a)
Definition: ProtectedObject.hpp:93
ProtectedObject::next
ProtectedObject * next
Definition: ProtectedObject.hpp:165
ProtectedObject::ProtectedObject
ProtectedObject(RexxObject *o, RexxActivity *a)
Definition: ProtectedObject.hpp:79
ProtectedObject::ProtectedObject
ProtectedObject(RexxInternalObject *o)
Definition: ProtectedObject.hpp:85
ProtectedSet
Definition: ProtectedObject.hpp:170
ProtectedSet::add
void add(RexxObject *)
Definition: ProtectedObject.cpp:44
holdObject
void holdObject(RexxInternalObject *o)
Definition: RexxMemory.hpp:418
RexxActivity::protectedObjects
ProtectedObject * protectedObjects
Definition: RexxActivity.hpp:386
OREF_NULL
#define OREF_NULL
Definition: RexxCore.h:60
RexxActivity
Definition: RexxActivity.hpp:127
ProtectedObject
Definition: ProtectedObject.hpp:46
ProtectedObject::ProtectedObject
ProtectedObject()
Definition: ProtectedObject.hpp:50
ProtectedSet::ProtectedSet
ProtectedSet(RexxActivity *a)
Definition: ProtectedObject.hpp:174
ProtectedSet::~ProtectedSet
~ProtectedSet()
Definition: ProtectedObject.hpp:175
ProtectedObject::ProtectedObject
ProtectedObject(RexxActivity *a)
Definition: ProtectedObject.hpp:62
ProtectedObject::ProtectedObject
ProtectedObject(RexxObject *o)
Definition: ProtectedObject.hpp:71
ActivityManager::currentActivity
static RexxActivity *volatile currentActivity
Definition: ActivityManager.hpp:95
ProtectedObject::~ProtectedObject
~ProtectedObject()
Definition: ProtectedObject.hpp:99
RexxActivity.hpp
ProtectedObject::operator=
ProtectedObject & operator=(RexxObject *o)
Definition: ProtectedObject.hpp:110
RexxMethod
Definition: MethodClass.hpp:101
ProtectedSet::ProtectedSet
ProtectedSet()
Definition: ProtectedObject.hpp:173
ProtectedObject::operator==
bool operator==(RexxObject *o)
Definition: ProtectedObject.hpp:116
RexxObject
Definition: ObjectClass.hpp:311
RexxString
Definition: StringClass.hpp:119
RexxObjectPtr
struct _RexxObjectPtr * RexxObjectPtr
Definition: rexx.h:127