CallContextStubs.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 
45 #include "RexxCore.h"
46 #include "ContextApi.hpp"
47 #include "RexxNativeActivation.hpp"
48 #include "SupplierClass.hpp"
49 #include "Interpreter.hpp"
50 #include "MethodClass.hpp"
51 #include "PackageClass.hpp"
52 #include "DirectoryClass.hpp"
53 
55 
57 {
58  ApiContext context(c);
59  try
60  {
62  }
63  catch (RexxNativeActivation *)
64  {
65  }
66  return NULLOBJECT;
67 }
68 
70 {
71  ApiContext context(c);
72  try
73  {
74  return (RexxObjectPtr)context.context->getPositionalArgument(i);
75  }
76  catch (RexxNativeActivation *)
77  {
78  }
79  return NULLOBJECT;
80 }
81 
83 {
84  ApiContext context(c);
85  try
86  {
87  return (CSTRING)context.context->getMessageName()->getStringData();
88  }
89  catch (RexxNativeActivation *)
90  {
91  }
92  return NULL;
93 }
94 
96 {
97  ApiContext context(c);
98  try
99  {
100  return (RexxRoutineObject)context.context->getExecutable();
101  }
102  catch (RexxNativeActivation *)
103  {
104  }
105  return NULL;
106 }
107 
109 {
110  ApiContext context(c);
111  try
112  {
113  context.context->setContextVariable((const char *)n, (RexxObject *)v);
114  }
115  catch (RexxNativeActivation *)
116  {
117  }
118 }
119 
121 {
122  ApiContext context(c);
123  try
124  {
125  return (RexxObjectPtr)context.context->getContextVariable((const char *)n);
126  }
127  catch (RexxNativeActivation *)
128  {
129  }
130  return NULLOBJECT;
131 }
132 
134 {
135  ApiContext context(c);
136  try
137  {
138  context.context->dropContextVariable((const char *)n);
139  }
140  catch (RexxNativeActivation *)
141  {
142  }
143 }
144 
146 {
147  ApiContext context(c);
148  try
149  {
150  return (RexxDirectoryObject)context.ret(context.context->getAllContextVariables());
151  }
152  catch (RexxNativeActivation *)
153  {
154  }
155  return NULLOBJECT;
156 }
157 
159 {
160  ApiContext context(c);
161  try
162  {
163  return (RexxStemObject)context.context->resolveStemVariable((RexxObject *)s);
164  }
165  catch (RexxNativeActivation *)
166  {
167  // this may throw an exception, so clear it out. The null return is the
168  // failure indication.
169  context.context->clearException();
170  }
171  return NULLOBJECT;
172 }
173 
175 {
176  ApiContext context(c);
177  try
178  {
179  // raise an exception which will be reraised when the caller returns.
181  }
182  catch (RexxNativeActivation *)
183  {
184  }
185 }
186 
188 {
189  ApiContext context(c);
190  try
191  {
192  context.context->setContextVariable((const char *)n, (RexxObject *)v);
193  }
194  catch (RexxNativeActivation *)
195  {
196  }
197 }
198 
200 {
201  ApiContext context(c);
202  try
203  {
204  return (RexxObjectPtr)context.context->getContextVariable((const char *)n);
205  }
206  catch (RexxNativeActivation *)
207  {
208  }
209  return NULLOBJECT;
210 }
211 
213 {
214  ApiContext context(c);
215  try
216  {
217  context.context->dropContextVariable((const char *)n);
218  }
219  catch (RexxNativeActivation *)
220  {
221  }
222 }
223 
225 {
226  ApiContext context(c);
227  try
228  {
229  return (RexxDirectoryObject)context.ret(context.context->getAllContextVariables());
230  }
231  catch (RexxNativeActivation *)
232  {
233  }
234  return NULLOBJECT;
235 }
236 
237 
239 {
240  ApiContext context(c);
241  try
242  {
243  return (RexxObjectPtr)context.ret(context.context->getRexxContextObject());
244  }
245  catch (RexxNativeActivation *)
246  {
247  }
248  return NULLOBJECT;
249 }
250 
252 {
253  ApiContext context(c);
254  try
255  {
256  return context.context->digits();
257  }
258  catch (RexxNativeActivation *)
259  {
260  }
261  return 0;
262 }
263 
265 {
266  ApiContext context(c);
267  try
268  {
269  return context.context->fuzz();
270  }
271  catch (RexxNativeActivation *)
272  {
273  }
274  return 0;
275 
276 }
278 {
279  ApiContext context(c);
280  try
281  {
282  return context.context->form() ? true : false;
283  }
284  catch (RexxNativeActivation *)
285  {
286  }
287  return false;
288 }
289 
291 {
292  ApiContext context(c);
293  try
294  {
295  return (RexxObjectPtr)context.ret(context.context->getRexxContextObject());
296  }
297  catch (RexxNativeActivation *)
298  {
299  }
300  return NULLOBJECT;
301 }
302 
303 
305 {
306  ApiContext context(c);
307  try
308  {
309  // convert the name to a string instance, and check the environments.
310  RexxString *name = new_upper_string(n);
311  return (RexxClassObject)context.ret(context.context->findCallerClass(name));
312  }
313  catch (RexxNativeActivation *)
314  {
315  }
316  return NULLOBJECT;
317 }
318 
319 
320 END_EXTERN_C()
321 
322 CallContextInterface RexxActivity::callContextFunctions =
323 {
340 };
341 
343 {
350 };
351 
void reportException(wholenumber_t error)
RexxObjectPtr RexxEntry GetCallerContext(RexxCallContext *c)
RexxObjectPtr RexxEntry GetExitContextVariable(RexxExitContext *c, CSTRING n)
void RexxEntry InvalidRoutine(RexxCallContext *c)
RexxDirectoryObject RexxEntry GetAllContextVariables(RexxCallContext *c)
RexxStemObject RexxEntry ResolveStemVariable(RexxCallContext *c, RexxObjectPtr s)
RexxObjectPtr RexxEntry GetContextVariable(RexxCallContext *c, CSTRING n)
RexxClassObject RexxEntry FindCallContextClass(RexxCallContext *c, CSTRING n)
CSTRING RexxEntry GetRoutineName(RexxCallContext *c)
void RexxEntry DropContextVariable(RexxCallContext *c, CSTRING n)
stringsize_t RexxEntry GetContextDigits(RexxCallContext *c)
RexxRoutineObject RexxEntry GetCurrentRoutine(RexxCallContext *c)
RexxDirectoryObject RexxEntry GetAllExitContextVariables(RexxExitContext *c)
void RexxEntry SetExitContextVariable(RexxExitContext *c, CSTRING n, RexxObjectPtr v)
RexxObjectPtr RexxEntry GetExitCallerContext(RexxExitContext *c)
RexxObjectPtr RexxEntry GetCallArgument(RexxCallContext *c, stringsize_t i)
RexxArrayObject RexxEntry GetCallArguments(RexxCallContext *c)
void RexxEntry DropExitContextVariable(RexxExitContext *c, CSTRING n)
logical_t RexxEntry GetContextForm(RexxCallContext *c)
stringsize_t RexxEntry GetContextFuzz(RexxCallContext *c)
void RexxEntry SetContextVariable(RexxCallContext *c, CSTRING n, RexxObjectPtr v)
#define Error_Incorrect_call_external
RexxString * new_upper_string(const char *s, stringsize_t l)
RexxNativeActivation * context
Definition: ContextApi.hpp:181
RexxObjectPtr ret(RexxObject *o)
Definition: ContextApi.hpp:168
BaseExecutable * getExecutable()
static ExitContextInterface exitContextFunctions
RexxObject * getContextVariable(const char *name)
RexxDirectory * getAllContextVariables()
void dropContextVariable(const char *name)
RexxStem * resolveStemVariable(RexxObject *s)
void setContextVariable(const char *name, RexxObject *value)
RexxObject * getPositionalArgument(size_t index)
RexxClass * findCallerClass(RexxString *className)
const char * getStringData()
#define EXIT_INTERFACE_VERSION
Definition: oorexxapi.h:667
#define CALL_INTERFACE_VERSION
Definition: oorexxapi.h:644
#define END_EXTERN_C()
Definition: rexx.h:61
struct _RexxClassObject * RexxClassObject
Definition: rexx.h:136
const char * CSTRING
Definition: rexx.h:78
size_t logical_t
Definition: rexx.h:231
struct _RexxArrayObject * RexxArrayObject
Definition: rexx.h:130
struct _RexxObjectPtr * RexxObjectPtr
Definition: rexx.h:127
#define NULLOBJECT
Definition: rexx.h:147
struct _RexxRoutineObject * RexxRoutineObject
Definition: rexx.h:134
struct _RexxDirectoryObject * RexxDirectoryObject
Definition: rexx.h:137
size_t stringsize_t
Definition: rexx.h:228
#define RexxEntry
Definition: rexx.h:235
struct _RexxStemObject * RexxStemObject
Definition: rexx.h:139
#define BEGIN_EXTERN_C()
Definition: rexx.h:60