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)  

ClassClass.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.oorexx.org/license.html */
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 /******************************************************************************/
39 /* REXX Kernel ClassClass.hpp */
40 /* */
41 /* Primitive Class Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxClass
45 #define Included_RexxClass
46 
47 
48 
49  class RexxClass : public RexxObject {
50  public:
51  void *operator new(size_t, size_t, const char *, RexxBehaviour *, RexxBehaviour *);
52  inline void *operator new(size_t size, void *ptr) {return ptr;};
53  inline void operator delete(void *) { }
54  inline void operator delete(void *, void *) { }
55  inline void operator delete(void *, size_t, const char *, RexxBehaviour *, RexxBehaviour *) { }
56 
57  inline RexxClass(){;};
58  inline RexxClass(RESTORETYPE restoreType) { ; };
59 
60  void live(size_t);
61  void liveGeneral(int reason);
62  void flatten(RexxEnvelope*);
65  bool isEqual(RexxObject *);
66 
67  HashCode hash();
74  RexxString *getId();
81  void defmeths(RexxTable *);
86  void subClassable(bool);
87  void subClassable(RexxClass *superClass, bool restricted);
88  void mergeSuperClassScopes(RexxBehaviour *target_instance_behaviour);
92  RexxObject *defineClassMethod(RexxString *method_name, RexxMethod *newMethod);
93  void removeClassMethod(RexxString *method_name);
96  void updateSubClasses();
104  RexxObject *enhanced(RexxObject **, size_t);
107  RexxClass *newRexx(RexxObject **args, size_t argCount);
108  void setMetaClass(RexxClass *);
109  bool isCompatibleWith(RexxClass *other);
112 
113 
114  inline bool isRexxDefined() { return (classFlags & REXX_DEFINED) != 0; };
115  inline bool isMixinClass() { return (classFlags & MIXIN) != 0; };
116  inline bool isMetaClass() { return (classFlags & META_CLASS) != 0; };
117  inline bool hasUninitDefined() { return (classFlags & HAS_UNINIT) != 0; };
120  // NB: This clears every flag BUT the UNINIT flag
122  inline bool parentHasUninitDefined() { return (classFlags & PARENT_HAS_UNINIT) != 0; };
124  inline bool isPrimitiveClass() { return (classFlags & PRIMITIVE_CLASS) != 0; }
125  inline void setMixinClass() { classFlags |= MIXIN; }
128  inline void setMetaClass() { classFlags |= META_CLASS; }
129  void addSubClass(RexxClass *);
130  void removeSubclass(RexxClass *c);
131 
132  static void processNewArgs(RexxObject **, size_t, RexxObject ***, size_t *, size_t, RexxObject **, RexxObject **);
133 
134  static void createInstance();
135  // singleton class instance;
137 
138  protected:
139  enum
140  {
141  REXX_DEFINED = 0x00000001, // this class is a native rexx class
142  MIXIN = 0x00000004, // this is a mixin class
143  HAS_UNINIT = 0x00000008, // this class has an uninit method
144  META_CLASS = 0x00000010, // this class is a meta class
145  PRIMITIVE_CLASS = 0x00000020, // this is a primitive class
146  PARENT_HAS_UNINIT = 0x00000040
147  };
148 
149  /* Subclassable and subclassed */
150  RexxString *id; /* classes will have a name string */
151  /* class methods specific to this */
152  /* class */
154  /* instances of this class inherit */
155  RexxBehaviour *instanceBehaviour; /* this behaviour */
156  /* methods added to this class */
158  RexxClass *baseClass; /* Baseclass of this class */
159  RexxArray *metaClass; /* Metaclass of this class */
160  /* Metaclass mdict */
162  RexxIdentityTable *metaClassScopes; /* Metaclass scopes */
163  /* The superclass and any inherited */
164  RexxArray *classSuperClasses; /* mixins for class behaviour */
165  /* The superclass and any inherited */
166  /* mixins for instance behaviour */
168  /* class specific information */
169  /* defines for this field are at the */
170  uint32_t classFlags; /* top of this header file */
171 
172  RexxList *subClasses; // our list of weak referenced subclasses
173  };
174  #endif
RexxClass::mixinclass
RexxClass * mixinclass(RexxString *, RexxClass *, RexxTable *)
Definition: ClassClass.cpp:1332
RexxClass::enhanced
RexxObject * enhanced(RexxObject **, size_t)
Definition: ClassClass.cpp:1287
RexxArray
Definition: ArrayClass.hpp:100
RexxClass::defmeths
void defmeths(RexxTable *)
Definition: ClassClass.cpp:344
RexxClass::mergeSuperClassScopes
void mergeSuperClassScopes(RexxBehaviour *target_instance_behaviour)
Definition: ClassClass.cpp:1013
RexxClass::getInstanceBehaviour
RexxBehaviour * getInstanceBehaviour()
Definition: ClassClass.hpp:127
RexxClass::classMethodDictionary
RexxTable * classMethodDictionary
Definition: ClassClass.hpp:153
RexxClass::hash
HashCode hash()
Definition: ClassClass.cpp:141
RexxClass::method
RexxMethod * method(RexxString *)
Definition: ClassClass.cpp:782
RexxClass::classSuperClasses
RexxArray * classSuperClasses
Definition: ClassClass.hpp:164
RexxClass::getId
RexxString * getId()
Definition: ClassClass.cpp:250
RexxClass::getBehaviourDictionary
RexxTable * getBehaviourDictionary()
Definition: ClassClass.cpp:400
RexxClass::clearHasUninitDefined
void clearHasUninitDefined()
Definition: ClassClass.hpp:119
RexxClass::methodDictionaryMerge
void methodDictionaryMerge(RexxTable *, RexxTable *)
Definition: ClassClass.cpp:1039
RexxClass::defineMethod
RexxObject * defineMethod(RexxString *, RexxMethod *)
Definition: ClassClass.cpp:618
RexxClass::setMixinClass
void setMixinClass()
Definition: ClassClass.hpp:125
RexxClass::defineClassMethod
RexxObject * defineClassMethod(RexxString *method_name, RexxMethod *newMethod)
Definition: ClassClass.cpp:722
RexxClass::defaultNameRexx
RexxString * defaultNameRexx()
Definition: ClassClass.cpp:1531
RexxClass::subClassable
void subClassable(bool)
Definition: ClassClass.cpp:427
RexxClass::baseClass
RexxClass * baseClass
Definition: ClassClass.hpp:158
RexxClass::isEqual
bool isEqual(RexxObject *)
Definition: ClassClass.cpp:173
RexxClass::queryMixinClass
RexxInteger * queryMixinClass()
Definition: ClassClass.cpp:241
RexxClass::unflatten
RexxObject * unflatten(RexxEnvelope *)
Definition: ClassClass.cpp:112
RexxClass::subclass
RexxClass * subclass(RexxString *, RexxClass *, RexxTable *)
Definition: ClassClass.cpp:1357
RexxSupplier
Definition: SupplierClass.hpp:47
RexxClass::parentHasUninitDefined
bool parentHasUninitDefined()
Definition: ClassClass.hpp:122
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxClass::getClassSuperClasses
RexxArray * getClassSuperClasses()
Definition: ClassClass.hpp:79
RexxClass::addSubClass
void addSubClass(RexxClass *)
Definition: ClassClass.cpp:333
RexxClass::getSubClasses
RexxArray * getSubClasses()
Definition: ClassClass.cpp:324
RexxClass::HAS_UNINIT
Definition: ClassClass.hpp:143
RexxBehaviour
Definition: RexxBehaviour.hpp:49
RexxClass::methods
RexxSupplier * methods(RexxClass *)
Definition: ClassClass.cpp:800
RexxClass::REXX_DEFINED
Definition: ClassClass.hpp:141
RexxClass::strictEqual
RexxObject * strictEqual(RexxObject *)
Definition: ClassClass.cpp:164
RexxClass::getHashValue
HashCode getHashValue()
Definition: ClassClass.cpp:155
RexxClass::RexxClass
RexxClass(RESTORETYPE restoreType)
Definition: ClassClass.hpp:58
RexxClass::getSuperClass
RexxClass * getSuperClass()
Definition: ClassClass.cpp:299
RexxClass::hasUninitDefined
bool hasUninitDefined()
Definition: ClassClass.hpp:117
RexxClass::flatten
void flatten(RexxEnvelope *)
Definition: ClassClass.cpp:104
HashCode
size_t HashCode
Definition: ObjectClass.hpp:77
RexxClass::MIXIN
Definition: ClassClass.hpp:142
RexxClass::subClasses
RexxList * subClasses
Definition: ClassClass.hpp:172
RexxClass::PARENT_HAS_UNINIT
Definition: ClassClass.hpp:146
RexxClass::setParentHasUninitDefined
void setParentHasUninitDefined()
Definition: ClassClass.hpp:123
RexxClass
Definition: ClassClass.hpp:49
RexxClass::metaClassScopes
RexxIdentityTable * metaClassScopes
Definition: ClassClass.hpp:162
RexxClass::classInstance
static RexxClass * classInstance
Definition: ClassClass.hpp:136
RexxClass::setHasUninitDefined
void setHasUninitDefined()
Definition: ClassClass.hpp:118
RexxClass::classFlags
uint32_t classFlags
Definition: ClassClass.hpp:170
RexxClass::instanceMethodDictionary
RexxTable * instanceMethodDictionary
Definition: ClassClass.hpp:157
RexxClass::newRexx
RexxClass * newRexx(RexxObject **args, size_t argCount)
Definition: ClassClass.cpp:1578
RexxClass::metaClassMethodDictionary
RexxArray * metaClassMethodDictionary
Definition: ClassClass.hpp:161
RexxClass::id
RexxString * id
Definition: ClassClass.hpp:150
RexxClass::live
void live(size_t)
Definition: ClassClass.cpp:66
RexxClass::createInstance
static void createInstance()
Definition: ClassClass.cpp:1678
RexxClass::createInstanceBehaviour
void createInstanceBehaviour(RexxBehaviour *)
Definition: ClassClass.cpp:969
RexxClass::RexxClass
RexxClass()
Definition: ClassClass.hpp:57
RexxClass::liveGeneral
void liveGeneral(int reason)
Definition: ClassClass.cpp:85
RexxClass::defaultName
RexxString * defaultName()
Definition: ClassClass.cpp:369
RexxClass::inherit
RexxObject * inherit(RexxClass *, RexxClass *)
Definition: ClassClass.cpp:1118
RexxClass::getMetaClass
RexxClass * getMetaClass()
Definition: ClassClass.cpp:275
RexxClass::META_CLASS
Definition: ClassClass.hpp:144
RexxClass::setInitialFlagState
void setInitialFlagState()
Definition: ClassClass.hpp:121
RexxClass::getSuperClasses
RexxArray * getSuperClasses()
Definition: ClassClass.cpp:314
RexxClass::instanceBehaviour
RexxBehaviour * instanceBehaviour
Definition: ClassClass.hpp:155
RexxClass::createClassBehaviour
void createClassBehaviour(RexxBehaviour *)
Definition: ClassClass.cpp:894
RexxClass::isPrimitiveClass
bool isPrimitiveClass()
Definition: ClassClass.hpp:124
RexxClass::makeProxy
RexxObject * makeProxy(RexxEnvelope *)
Definition: ClassClass.cpp:120
RexxClass::isRexxDefined
bool isRexxDefined()
Definition: ClassClass.hpp:114
RexxClass::equal
RexxObject * equal(RexxObject *)
Definition: ClassClass.cpp:197
RexxClass::instanceSuperClasses
RexxArray * instanceSuperClasses
Definition: ClassClass.hpp:167
RexxTable
Definition: TableClass.hpp:49
RexxClass::updateSubClasses
void updateSubClasses()
Definition: ClassClass.cpp:840
RexxClass::setInstanceBehaviour
void setInstanceBehaviour(RexxBehaviour *)
Definition: ClassClass.cpp:290
RexxClass::getBaseClass
RexxClass * getBaseClass()
Definition: ClassClass.cpp:267
RexxClass::deleteMethod
RexxObject * deleteMethod(RexxString *)
Definition: ClassClass.cpp:754
RexxClass::isCompatibleWith
bool isCompatibleWith(RexxClass *other)
Definition: ClassClass.cpp:1493
RexxClass::setNonPrimitive
void setNonPrimitive()
Definition: ClassClass.hpp:126
RexxClass::defineMethods
RexxObject * defineMethods(RexxTable *)
Definition: ClassClass.cpp:676
RexxClass::isMetaClass
bool isMetaClass()
Definition: ClassClass.hpp:116
RexxClass::removeClassMethod
void removeClassMethod(RexxString *method_name)
Definition: ClassClass.cpp:740
RexxClass::setRexxDefined
RexxObject * setRexxDefined()
Definition: ClassClass.cpp:258
RexxClass::updateInstanceSubClasses
void updateInstanceSubClasses()
Definition: ClassClass.cpp:872
RexxIdentityTable
Definition: IdentityTableClass.hpp:49
RexxClass::metaClass
RexxArray * metaClass
Definition: ClassClass.hpp:159
RexxClass::getInstanceBehaviourDictionary
RexxTable * getInstanceBehaviourDictionary()
Definition: ClassClass.cpp:382
RexxClass::setMetaClass
void setMetaClass()
Definition: ClassClass.hpp:128
RexxClass::isSubclassOf
RexxObject * isSubclassOf(RexxClass *other)
Definition: ClassClass.cpp:1525
RexxClass::notEqual
RexxObject * notEqual(RexxObject *)
Definition: ClassClass.cpp:219
RexxClass::processNewArgs
static void processNewArgs(RexxObject **, size_t, RexxObject ***, size_t *, size_t, RexxObject **, RexxObject **)
Definition: ClassClass.cpp:1701
RESTORETYPE
RESTORETYPE
Definition: ObjectClass.hpp:80
RexxList
Definition: ListClass.hpp:63
RexxMethod
Definition: MethodClass.hpp:101
RexxClass::methodDictionaryCreate
RexxTable * methodDictionaryCreate(RexxTable *, RexxClass *)
Definition: ClassClass.cpp:1071
RexxInteger
Definition: IntegerClass.hpp:56
RexxClass::removeSubclass
void removeSubclass(RexxClass *c)
Definition: ClassClass.cpp:1270
RexxClass::PRIMITIVE_CLASS
Definition: ClassClass.hpp:145
RexxObject
Definition: ObjectClass.hpp:311
RexxClass::uninherit
RexxObject * uninherit(RexxClass *)
Definition: ClassClass.cpp:1221
RexxString
Definition: StringClass.hpp:119
RexxClass::isMixinClass
bool isMixinClass()
Definition: ClassClass.hpp:115