MethodContextStubs.cpp
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 /******************************************************************************/
39 /* REXX API support */
40 /* */
41 /* Stub functions for all APIs accessed via the NativeMethodContext */
42 /* */
43 /******************************************************************************/
44 #include "RexxCore.h"
45 #include "ContextApi.hpp"
46 #include "RexxNativeActivation.hpp"
47 #include "ProtectedObject.hpp"
48 #include "MethodClass.hpp"
49 
51 
53 {
54  ApiContext context(c);
55  try
56  {
58  }
59  catch (RexxNativeActivation *)
60  {
61  }
62  return NULLOBJECT;
63 }
64 
66 {
67  ApiContext context(c);
68  try
69  {
70  return (RexxObjectPtr)context.context->getPositionalArgument(i);
71  }
72  catch (RexxNativeActivation *)
73  {
74  }
75  return NULLOBJECT;
76 }
77 
79 {
80  ApiContext context(c);
81  try
82  {
83  return (RexxMethodObject)context.context->getExecutable();
84  }
85  catch (RexxNativeActivation *)
86  {
87  }
88  return NULL;
89 }
90 
92 {
93  ApiContext context(c);
94  try
95  {
96  return (CSTRING)context.context->getMessageName()->getStringData();
97  }
98  catch (RexxNativeActivation *)
99  {
100  }
101  return NULL;
102 }
103 
105 {
106  ApiContext context(c);
107  try
108  {
109  return (RexxObjectPtr)context.context->getSelf();
110  }
111  catch (RexxNativeActivation *)
112  {
113  }
114  return NULLOBJECT;
115 }
116 
118 {
119  ApiContext context(c);
120  try
121  {
122  return context.context->cself();
123  }
124  catch (RexxNativeActivation *)
125  {
126  }
127  return NULLOBJECT;
128 }
129 
131 {
132  ApiContext context(c);
133  try
134  {
135  return (RexxClassObject)context.context->getSuper();
136  }
137  catch (RexxNativeActivation *)
138  {
139  }
140  return NULLOBJECT;
141 }
142 
144 {
145  ApiContext context(c);
146  try
147  {
148  return (RexxObjectPtr)context.context->getScope();
149  }
150  catch (RexxNativeActivation *)
151  {
152  }
153  return NULLOBJECT;
154 }
155 
157 {
158  ApiContext context(c);
159  try
160  {
161  context.context->setObjectVariable(n, (RexxObject *)v);
162  }
163  catch (RexxNativeActivation *)
164  {
165  }
166 }
167 
169 {
170  ApiContext context(c);
171  try
172  {
173  return (RexxObjectPtr)context.context->getObjectVariable(n);
174  }
175  catch (RexxNativeActivation *)
176  {
177  }
178  return NULLOBJECT;
179 }
180 
182 {
183  ApiContext context(c);
184  try
185  {
186  context.context->dropObjectVariable(n);
187  }
188  catch (RexxNativeActivation *)
189  {
190  }
191 }
192 
194 {
195  ApiContext context(c);
196  try
197  {
198  RexxString *message = n == NULL ? OREF_NULL : new_upper_string(n);
199  ProtectedObject result(context.activity);
200  context.context->forwardMessage((RexxObject *)o, message, (RexxClass *)clazz, (RexxArray *)a, (RexxDirectory *)d, result);
201  return context.ret((RexxObject *)result);
202  }
203  catch (RexxNativeActivation *)
204  {
205  }
206  return NULLOBJECT;
207 }
208 
210 {
211  ApiContext context(c);
212  try
213  {
214  context.context->guardOn();
215  }
216  catch (RexxNativeActivation *)
217  {
218  }
219 }
220 
222 {
223  ApiContext context(c);
224  try
225  {
226  context.context->guardOff();
227  }
228  catch (RexxNativeActivation *)
229  {
230  }
231 }
232 
234 {
235  ApiContext context(c);
236  try
237  {
238  // convert the name to a string instance, and check the environments.
239  RexxString *name = new_upper_string(n);
240  return (RexxClassObject)context.ret(context.context->findClass(name));
241  }
242  catch (RexxNativeActivation *)
243  {
244  }
245  return NULLOBJECT;
246 }
247 
248 END_EXTERN_C()
249 
250 
251 MethodContextInterface RexxActivity::methodContextFunctions =
252 {
258  GetSelf,
259  GetSuper,
260  GetScope,
265  SetGuardOn,
266  SetGuardOff,
268  GetCSelf,
269 };
270 
271 
void RexxEntry SetObjectVariable(RexxMethodContext *c, CSTRING n, RexxObjectPtr v)
void RexxEntry SetGuardOff(RexxMethodContext *c)
RexxObjectPtr RexxEntry GetScope(RexxMethodContext *c)
RexxObjectPtr RexxEntry GetSelf(RexxMethodContext *c)
void RexxEntry SetGuardOn(RexxMethodContext *c)
RexxObjectPtr RexxEntry GetObjectVariable(RexxMethodContext *c, CSTRING n)
POINTER RexxEntry GetCSelf(RexxMethodContext *c)
RexxMethodObject RexxEntry GetCurrentMethod(RexxMethodContext *c)
RexxObjectPtr RexxEntry GetMethodArgument(RexxMethodContext *c, stringsize_t i)
void RexxEntry DropObjectVariable(RexxMethodContext *c, CSTRING n)
RexxObjectPtr RexxEntry ForwardMessage(RexxMethodContext *c, RexxObjectPtr o, CSTRING n, RexxClassObject clazz, RexxArrayObject a, RexxDirectoryObject d)
RexxClassObject RexxEntry GetSuper(RexxMethodContext *c)
RexxArrayObject RexxEntry GetMethodArguments(RexxMethodContext *c)
CSTRING RexxEntry GetMessageName(RexxMethodContext *c)
RexxClassObject RexxEntry FindContextClass(RexxMethodContext *c, CSTRING n)
#define OREF_NULL
Definition: RexxCore.h:60
RexxString * new_upper_string(const char *s, stringsizeB_t bl, stringsizeC_t cl=-1)
RexxActivity * activity
Definition: ContextApi.hpp:177
RexxNativeActivation * context
Definition: ContextApi.hpp:181
RexxObjectPtr ret(RexxObject *o)
Definition: ContextApi.hpp:168
BaseExecutable * getExecutable()
void dropObjectVariable(const char *name)
RexxClass * findClass(RexxString *className)
void setObjectVariable(const char *name, RexxObject *value)
RexxObject * getObjectVariable(const char *name)
RexxObject * getPositionalArgument(size_t index)
void forwardMessage(RexxObject *to, RexxString *msg, RexxClass *super, RexxArray *positionalArgs, RexxDirectory *namedArgs, ProtectedObject &result)
const char * getStringData()
#define METHOD_INTERFACE_VERSION
Definition: oorexxapi.h:621
#define END_EXTERN_C()
Definition: rexx.h:61
struct _RexxClassObject * RexxClassObject
Definition: rexx.h:136
const char * CSTRING
Definition: rexx.h:78
struct _RexxArrayObject * RexxArrayObject
Definition: rexx.h:130
struct _RexxObjectPtr * RexxObjectPtr
Definition: rexx.h:127
#define NULLOBJECT
Definition: rexx.h:147
struct _RexxDirectoryObject * RexxDirectoryObject
Definition: rexx.h:137
struct _RexxMethodObject * RexxMethodObject
Definition: rexx.h:133
void * POINTER
Definition: rexx.h:79
size_t stringsize_t
Definition: rexx.h:228
#define RexxEntry
Definition: rexx.h:412
#define BEGIN_EXTERN_C()
Definition: rexx.h:60