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)  

MethodClass.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 MethodClass.hpp */
40 /* */
41 /* Primitive Kernel Method Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_RexxMethod
45 #define Included_RexxMethod
46 
47 #include "RexxCore.h"
48 
49 class RexxSource;
50 class RexxActivity;
51 class RexxMethod;
52 class ProtectedObject;
53 class RexxArray;
54 class RexxClass;
55 class PackageClass;
56 
57 
63 {
64 public:
65  virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, ProtectedObject &);
66  virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &);
67  virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, ProtectedObject &);
68  virtual RexxArray *getSource();
69  virtual RexxObject *setSecurityManager(RexxObject *manager);
70  virtual RexxSource *getSourceObject();
71  virtual RexxClass *findClass(RexxString *className);
72  virtual BaseCode *setSourceObject(RexxSource *s);
73  virtual PackageClass *getPackage();
74 };
75  /* pointer to native method function */
77  /* pointer to native function function*/
79 
80 typedef size_t (RexxEntry *PREGISTEREDROUTINE)(const char *, size_t, PCONSTRXSTRING, const char *, PRXSTRING);
81 
82 class BaseExecutable : public RexxObject
83 {
84 public:
85  inline RexxSource *getSourceObject() { return code->getSourceObject(); };
86  inline BaseCode *getCode() { return code; }
87  RexxArray *getSource() { return code->getSource(); }
89 
90  RexxArray *source();
91  RexxClass *findClass(RexxString *className);
94 
95 protected:
96  RexxString *executableName; // the created name of this routine
97  BaseCode *code; // the backing code object
98 };
99 
100 
101  class RexxMethod : public BaseExecutable
102  {
103  public:
104  void *operator new(size_t);
105  inline void *operator new(size_t size, void *ptr) { return ptr; };
106  RexxMethod(RexxString *name, BaseCode *_code);
108  RexxMethod(RexxString *name);
110  RexxMethod(RexxString *name, const char *data, size_t length);
112  inline RexxMethod(RESTORETYPE restoreType) { ; };
113 
114  void execute(RexxObject *, RexxObject *);
115  void live(size_t);
116  void liveGeneral(int reason);
117  void flatten(RexxEnvelope*);
118 
119  void run(RexxActivity *, RexxObject *, RexxString *, RexxObject **, size_t, ProtectedObject &);
121  void setScope(RexxClass *);
128 
132 
133  inline bool isGuarded() {return (this->methodFlags & UNGUARDED_FLAG) == 0; };
134  inline bool isPrivate() {return (this->methodFlags & PRIVATE_FLAG) != 0;}
135  inline bool isProtected() {return (this->methodFlags & PROTECTED_FLAG) != 0;}
136  inline bool isSpecial() {return (this->methodFlags & (PROTECTED_FLAG | PRIVATE_FLAG)) != 0;}
137 
138  inline void setUnguarded() {this->methodFlags |= UNGUARDED_FLAG;};
139  inline void setGuarded() {this->methodFlags &= ~UNGUARDED_FLAG;};
140  inline void setPrivate() {this->methodFlags |= (PRIVATE_FLAG | PROTECTED_FLAG);};
141  inline void setProtected() {this->methodFlags |= PROTECTED_FLAG;};
142  void setAttributes(bool _private, bool _protected, bool _guarded);
143  inline RexxClass *getScope() {return this->scope;}
144 
145  inline BaseCode *getCode() { return this->code; }
146  RexxMethod *newRexx(RexxObject **, size_t);
148  RexxMethod *loadExternalMethod(RexxString *name, RexxString *descriptor);
149 
151  static RexxMethod *restore(RexxBuffer *, char *, size_t length);
152 
153  static void createInstance();
155 
156  protected:
157  enum
158  {
159  PRIVATE_FLAG = 0x01, // private method
160  UNGUARDED_FLAG = 0x02, // Method can run with GUARD OFF
161  PROTECTED_FLAG = 0x40, // method is protected
162  };
163 
164  size_t methodFlags; // method status flags
165  RexxClass *scope; /* pointer to the method scope */
166 };
167 
168 #endif
PNATIVEMETHOD
uint16_t *(RexxEntry * PNATIVEMETHOD)(RexxMethodContext *, ValueDescriptor *)
Definition: MethodClass.hpp:76
RexxMethod::setUnguardedRexx
RexxObject * setUnguardedRexx()
Definition: MethodClass.cpp:370
BaseExecutable::getName
RexxString * getName()
Definition: MethodClass.hpp:93
RexxMethod::liveGeneral
void liveGeneral(int reason)
Definition: MethodClass.cpp:284
BaseExecutable::findClass
RexxClass * findClass(RexxString *className)
Definition: MethodClass.cpp:87
RexxMethod::isGuarded
bool isGuarded()
Definition: MethodClass.hpp:133
RexxMethod::setGuarded
void setGuarded()
Definition: MethodClass.hpp:139
RexxMethod::setAttributes
void setAttributes(bool _private, bool _protected, bool _guarded)
Definition: MethodClass.cpp:445
RexxArray
Definition: ArrayClass.hpp:100
BaseExecutable::getSourceObject
RexxSource * getSourceObject()
Definition: MethodClass.hpp:85
BaseExecutable::source
RexxArray * source()
Definition: MethodClass.cpp:146
RexxMethod::UNGUARDED_FLAG
Definition: MethodClass.hpp:160
BaseCode::getPackage
virtual PackageClass * getPackage()
Definition: MethodClass.cpp:825
RexxInternalObject
Definition: ObjectClass.hpp:206
BaseExecutable::getPackage
PackageClass * getPackage()
Definition: MethodClass.cpp:130
RexxMethod::RexxMethod
RexxMethod(RexxString *name, BaseCode *_code)
Definition: MethodClass.cpp:179
RexxMethod::scope
RexxClass * scope
Definition: MethodClass.hpp:165
RexxMethod::run
void run(RexxActivity *, RexxObject *, RexxString *, RexxObject **, size_t, ProtectedObject &)
Definition: MethodClass.cpp:311
RexxMethod::newScope
RexxMethod * newScope(RexxClass *)
Definition: MethodClass.cpp:328
RexxMethod::getScope
RexxClass * getScope()
Definition: MethodClass.hpp:143
RoutineClass
Definition: RoutineClass.hpp:49
RexxMethod::setProtected
void setProtected()
Definition: MethodClass.hpp:141
BaseExecutable::setSourceObject
BaseExecutable * setSourceObject(RexxSource *s)
Definition: MethodClass.cpp:106
RexxMethod::createInstance
static void createInstance()
Definition: MethodClass.cpp:74
BaseCode::run
virtual void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, ProtectedObject &)
Definition: MethodClass.cpp:697
ValueDescriptor
Definition: oorexxapi.h:261
RexxMethod::isProtectedRexx
RexxObject * isProtectedRexx()
Definition: MethodClass.cpp:431
RexxSmartBuffer
Definition: RexxSmartBuffer.hpp:47
RexxMethod::setGuardedRexx
RexxObject * setGuardedRexx()
Definition: MethodClass.cpp:379
PCONSTRXSTRING
CONSTRXSTRING * PCONSTRXSTRING
Definition: rexx.h:186
BaseExecutable::executableName
RexxString * executableName
Definition: MethodClass.hpp:96
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxMethod::saveMethod
RexxSmartBuffer * saveMethod()
Definition: MethodClass.cpp:463
RexxBuffer
Definition: BufferClass.hpp:91
RexxMethod::methodFlags
size_t methodFlags
Definition: MethodClass.hpp:164
RexxMethod::restore
static RexxMethod * restore(RexxBuffer *, char *, size_t length)
Definition: MethodClass.cpp:665
BaseExecutable::getCode
BaseCode * getCode()
Definition: MethodClass.hpp:86
RexxMethod::PROTECTED_FLAG
Definition: MethodClass.hpp:161
RexxMethod::flatten
void flatten(RexxEnvelope *)
Definition: MethodClass.cpp:295
RexxMethod::setScope
void setScope(RexxClass *)
Definition: MethodClass.cpp:360
RexxMethod::setProtectedRexx
RexxObject * setProtectedRexx()
Definition: MethodClass.cpp:397
RexxMethod::isPrivateRexx
RexxObject * isPrivateRexx()
Definition: MethodClass.cpp:421
BaseExecutable::getSource
RexxArray * getSource()
Definition: MethodClass.hpp:87
BaseCode::call
virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &)
Definition: MethodClass.cpp:719
PNATIVEROUTINE
uint16_t *(RexxEntry * PNATIVEROUTINE)(RexxCallContext *, ValueDescriptor *)
Definition: MethodClass.hpp:78
RexxSource
Definition: SourceFile.hpp:131
RexxMethodContext_
Definition: oorexxapi.h:1404
RexxMethod::newMethodObject
static RexxMethod * newMethodObject(RexxString *, RexxObject *, RexxObject *, RexxSource *a)
Definition: MethodClass.cpp:503
RexxActivity
Definition: RexxActivity.hpp:127
RexxMethod::isProtected
bool isProtected()
Definition: MethodClass.hpp:135
RexxMethod::setUnguarded
void setUnguarded()
Definition: MethodClass.hpp:138
PRXSTRING
RXSTRING * PRXSTRING
Definition: rexx.h:185
RexxClass
Definition: ClassClass.hpp:49
ProtectedObject
Definition: ProtectedObject.hpp:46
RexxMethod::newRexx
RexxMethod * newRexx(RexxObject **, size_t)
Definition: MethodClass.cpp:574
PackageClass
Definition: PackageClass.hpp:48
BaseCode
Definition: MethodClass.hpp:62
RexxMethod::live
void live(size_t)
Definition: MethodClass.cpp:273
BaseCode::getSource
virtual RexxArray * getSource()
Definition: MethodClass.cpp:750
RexxMethod::RexxMethod
RexxMethod(RESTORETYPE restoreType)
Definition: MethodClass.hpp:112
RexxMethod::isGuardedRexx
RexxObject * isGuardedRexx()
Definition: MethodClass.cpp:411
RexxMethod::getCode
BaseCode * getCode()
Definition: MethodClass.hpp:145
BaseExecutable
Definition: MethodClass.hpp:82
BaseCode::findClass
virtual RexxClass * findClass(RexxString *className)
Definition: MethodClass.cpp:794
PREGISTEREDROUTINE
size_t(RexxEntry * PREGISTEREDROUTINE)(const char *, size_t, PCONSTRXSTRING, const char *, PRXSTRING)
Definition: MethodClass.hpp:80
BaseCode::setSourceObject
virtual BaseCode * setSourceObject(RexxSource *s)
Definition: MethodClass.cpp:813
RexxMethod::execute
void execute(RexxObject *, RexxObject *)
BaseCode::setSecurityManager
virtual RexxObject * setSecurityManager(RexxObject *manager)
Definition: MethodClass.cpp:765
RexxMethod::newFileRexx
RexxMethod * newFileRexx(RexxString *)
Definition: MethodClass.cpp:642
RexxMethod::isPrivate
bool isPrivate()
Definition: MethodClass.hpp:134
RexxMethod::PRIVATE_FLAG
Definition: MethodClass.hpp:159
RexxMethod::classInstance
static RexxClass * classInstance
Definition: MethodClass.hpp:154
RexxMethod::isSpecial
bool isSpecial()
Definition: MethodClass.hpp:136
BaseCode::getSourceObject
virtual RexxSource * getSourceObject()
Definition: MethodClass.cpp:780
RexxMethod::setPrivate
void setPrivate()
Definition: MethodClass.hpp:140
RexxCallContext_
Definition: oorexxapi.h:2154
RexxCore.h
RESTORETYPE
RESTORETYPE
Definition: ObjectClass.hpp:80
RexxMethod
Definition: MethodClass.hpp:101
BaseExecutable::code
BaseCode * code
Definition: MethodClass.hpp:97
RexxMethod::setPrivateRexx
RexxObject * setPrivateRexx()
Definition: MethodClass.cpp:388
RexxEntry
#define RexxEntry
Definition: rexx.h:233
RexxObject
Definition: ObjectClass.hpp:311
RexxMethod::setSecurityManager
RexxObject * setSecurityManager(RexxObject *)
Definition: MethodClass.cpp:351
RexxMethod::loadExternalMethod
RexxMethod * loadExternalMethod(RexxString *name, RexxString *descriptor)
Definition: MethodClass.cpp:845
RexxString
Definition: StringClass.hpp:119