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 
92 protected:
93  RexxVariableBase *attribute; /* method attribute info */
94 };
95 
96 
97 /**
98  * Class for an attribute setter method.
99  */
101 {
102 public:
103  void *operator new(size_t);
104  inline void *operator new(size_t size, void *ptr) { return ptr; };
105  inline void operator delete(void *) { }
106  inline void operator delete(void *, void *) { }
108  inline AttributeSetterCode(RESTORETYPE restoreType) : AttributeGetterCode(restoreType) { }
109 
110  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
111 };
112 
113 
114 /**
115  * Class for a constant retriever method
116  */
118 {
119 public:
120  void *operator new(size_t);
121  inline void *operator new(size_t size, void *ptr) { return ptr; };
122  inline void operator delete(void *) { }
123  inline void operator delete(void *, void *) { }
125  inline ConstantGetterCode(RESTORETYPE restoreType) { }
126  void live(size_t);
127  void liveGeneral(int reason);
128  void flatten(RexxEnvelope*);
129 
130  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
131 
132 protected:
133  RexxObject *constantValue; // the returned constant value
134 };
135 
136 
137 /**
138  * Class for a constant retriever method
139  */
140 class AbstractCode : public BaseCode
141 {
142 public:
143  void *operator new(size_t);
144  inline void *operator new(size_t size, void *ptr) { return ptr; };
145  inline void operator delete(void *) { }
146  inline void operator delete(void *, void *) { }
147  inline AbstractCode() { }
148  inline AbstractCode(RESTORETYPE restoreType) { }
149 
150  void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &);
151 };
152 
153 #endif
RESTORETYPE
Definition: ObjectClass.hpp:80
RexxObject *(RexxObject::* PCPPM)()
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:477
AbstractCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:148
AttributeGetterCode(RexxVariableBase *a)
Definition: CPPCode.hpp:84
void liveGeneral(int reason)
Definition: CPPCode.cpp:270
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:303
void live(size_t)
Definition: CPPCode.cpp:262
RexxVariableBase * attribute
Definition: CPPCode.hpp:93
AttributeGetterCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:85
void flatten(RexxEnvelope *)
Definition: CPPCode.cpp:278
AttributeSetterCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:108
AttributeSetterCode(RexxVariableBase *a)
Definition: CPPCode.hpp:107
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:353
static CPPCode * resolveExportedMethod(const char *, PCPPM targetMethod, size_t argcount, bool passNamedArgs)
Definition: CPPCode.cpp:1113
uint16_t methodIndex
Definition: CPPCode.hpp:67
bool passNamedArguments
Definition: CPPCode.hpp:69
CPPCode(size_t, PCPPM, size_t, bool)
Definition: CPPCode.cpp:70
uint16_t argumentCount
Definition: CPPCode.hpp:68
RexxObject * unflatten(RexxEnvelope *envelope)
Definition: CPPCode.cpp:91
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:113
PCPPM cppEntry
Definition: CPPCode.hpp:70
static PCPPM exportedMethods[]
Definition: CPPCode.hpp:64
void liveGeneral(int reason)
Definition: CPPCode.cpp:79
CPPCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:56
ConstantGetterCode(RESTORETYPE restoreType)
Definition: CPPCode.hpp:125
void run(RexxActivity *, RexxMethod *, RexxObject *, RexxString *, RexxObject **, size_t, size_t, ProtectedObject &)
Definition: CPPCode.cpp:439
void liveGeneral(int reason)
Definition: CPPCode.cpp:406
void live(size_t)
Definition: CPPCode.cpp:398
ConstantGetterCode(RexxObject *v)
Definition: CPPCode.hpp:124
void flatten(RexxEnvelope *)
Definition: CPPCode.cpp:414
RexxObject * constantValue
Definition: CPPCode.hpp:133
unsigned short uint16_t