CPPCode.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 #ifndef Included_CPPCode
39 #define Included_CPPCode
40 
41 
42 #include "MethodClass.hpp"
43 
44 
45 /**
46  * Class for a method-wrappered CPP internal method.
47  */
48 class CPPCode : public BaseCode
49 {
50 public:
51  void *operator new(size_t);
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  CPPCode(size_t, PCPPM, size_t, bool);
56  inline CPPCode(RESTORETYPE restoreType) { ; };
57  void liveGeneral(int reason);
58  RexxObject *unflatten(RexxEnvelope *envelope);
59 
60  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
61 
62  static CPPCode *resolveExportedMethod(const char *, PCPPM targetMethod, size_t argcount, bool passNamedArgs);
63  // The table of exported methods.
65 
66 protected:
67  uint16_t methodIndex; // kernel method number
68  uint16_t argumentCount; // argument count
70  PCPPM cppEntry; // C++ Method entry point.
71 };
72 
73 
74 /**
75  * Class for an attribute getter method
76  */
78 {
79 public:
80  void *operator new(size_t);
81  inline void *operator new(size_t size, void *ptr) { return ptr; };
82  inline void operator delete(void *) { }
83  inline void operator delete(void *, void *) { }
85  inline AttributeGetterCode(RESTORETYPE restoreType) { ; };
86  void live(size_t);
87  void liveGeneral(int reason);
88  void flatten(RexxEnvelope*);
89 
90  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
91  inline BaseCode *setSourceObject(RexxSource *s) { source = s; return this; }
92  inline RexxSource *getSourceObject() { return source; }
93 
94 protected:
95  RexxVariableBase *attribute; /* method attribute info */
97 };
98 
99 
100 /**
101  * Class for an attribute setter method.
102  */
104 {
105 public:
106  void *operator new(size_t);
107  inline void *operator new(size_t size, void *ptr) { return ptr; };
108  inline void operator delete(void *) { }
109  inline void operator delete(void *, void *) { }
111  inline AttributeSetterCode(RESTORETYPE restoreType) : AttributeGetterCode(restoreType) { }
112 
113  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
114 };
115 
116 
117 /**
118  * Class for a constant retriever method
119  */
121 {
122 public:
123  void *operator new(size_t);
124  inline void *operator new(size_t size, void *ptr) { return ptr; };
125  inline void operator delete(void *) { }
126  inline void operator delete(void *, void *) { }
128  inline ConstantGetterCode(RESTORETYPE restoreType) { }
129  void live(size_t);
130  void liveGeneral(int reason);
131  void flatten(RexxEnvelope*);
132 
133  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
134  inline BaseCode *setSourceObject(RexxSource *s) { source = s; return this; }
135  inline RexxSource *getSourceObject() { return source; }
136 
137 protected:
138  RexxObject *constantValue; // the returned constant value
140 };
141 
142 
143 /**
144  * Class for a constant retriever method
145  */
146 class AbstractCode : public BaseCode
147 {
148 public:
149  void *operator new(size_t);
150  inline void *operator new(size_t size, void *ptr) { return ptr; };
151  inline void operator delete(void *) { }
152  inline void operator delete(void *, void *) { }
153  inline AbstractCode() { }
154  inline AbstractCode(RESTORETYPE restoreType) { }
155  void live(size_t);
156  void liveGeneral(int reason);
157  void flatten(RexxEnvelope*);
158 
159  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
160  inline BaseCode *setSourceObject(RexxSource *s) { source = s; return this; }
161  inline RexxSource *getSourceObject() { return source; }
162 
163 protected:
165 };
166 
167 #endif
RESTORETYPE
Definition: ObjectClass.hpp:82
RexxObject *(RexxObject::* PCPPM)()
void live(size_t)
Definition: CPPCode.cpp:493
void liveGeneral(int reason)
Definition: CPPCode.cpp:501
RexxSource * source
Definition: CPPCode.hpp:164
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:539
void flatten(RexxEnvelope *)
Definition: CPPCode.cpp:514
AbstractCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:154
BaseCode * setSourceObject(RexxSource *s)
Definition: CPPCode.hpp:160
RexxSource * getSourceObject()
Definition: CPPCode.hpp:161
AttributeGetterCode(RexxVariableBase *a)
Definition: CPPCode.hpp:84
void liveGeneral(int reason)
Definition: CPPCode.cpp:284
BaseCode * setSourceObject(RexxSource *s)
Definition: CPPCode.hpp:91
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:324
RexxSource * source
Definition: CPPCode.hpp:96
void live(size_t)
Definition: CPPCode.cpp:275
RexxSource * getSourceObject()
Definition: CPPCode.hpp:92
RexxVariableBase * attribute
Definition: CPPCode.hpp:95
AttributeGetterCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:85
void flatten(RexxEnvelope *)
Definition: CPPCode.cpp:298
AttributeSetterCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:111
AttributeSetterCode(RexxVariableBase *a)
Definition: CPPCode.hpp:110
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:374
static CPPCode * resolveExportedMethod(const char *, PCPPM targetMethod, size_t argcount, bool passNamedArgs)
Definition: CPPCode.cpp:1218
uint16_t methodIndex
Definition: CPPCode.hpp:67
bool passNamedArguments
Definition: CPPCode.hpp:69
CPPCode(size_t, PCPPM, size_t, bool)
Definition: CPPCode.cpp:71
uint16_t argumentCount
Definition: CPPCode.hpp:68
RexxObject * unflatten(RexxEnvelope *envelope)
Definition: CPPCode.cpp:97
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:119
PCPPM cppEntry
Definition: CPPCode.hpp:70
static PCPPM exportedMethods[]
Definition: CPPCode.hpp:64
void liveGeneral(int reason)
Definition: CPPCode.cpp:80
CPPCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:56
ConstantGetterCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:128
BaseCode * setSourceObject(RexxSource *s)
Definition: CPPCode.hpp:134
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:468
void liveGeneral(int reason)
Definition: CPPCode.cpp:428
void live(size_t)
Definition: CPPCode.cpp:419
ConstantGetterCode(RexxObject *v)
Definition: CPPCode.hpp:127
void flatten(RexxEnvelope *)
Definition: CPPCode.cpp:442
RexxSource * getSourceObject()
Definition: CPPCode.hpp:135
RexxSource * source
Definition: CPPCode.hpp:139
RexxObject * constantValue
Definition: CPPCode.hpp:138
unsigned short uint16_t