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)  

RoutineClass.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.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 RoutineClass.cpp */
40 /* */
41 /* Primitive Routine Class */
42 /* */
43 /******************************************************************************/
44 #include <stdlib.h>
45 #include <stdio.h>
46 #include <string.h>
47 #include "RexxCore.h"
48 #include "StringClass.hpp"
49 #include "ArrayClass.hpp"
50 #include "RexxCode.hpp"
51 #include "RexxNativeCode.hpp"
52 #include "RexxActivity.hpp"
53 #include "RexxActivation.hpp"
54 #include "RexxNativeActivation.hpp"
55 #include "MethodClass.hpp"
56 #include "PackageClass.hpp"
57 #include "SourceFile.hpp"
58 #include "DirectoryClass.hpp"
59 #include "ProtectedObject.hpp"
60 #include "BufferClass.hpp"
61 #include "RexxInternalApis.h"
62 #include "RexxSmartBuffer.hpp"
63 #include "ProgramMetaData.hpp"
64 #include "Utilities.hpp"
65 #include "SystemInterpreter.hpp"
66 #include "PackageManager.hpp"
67 #include "InterpreterInstance.hpp"
68 #include <ctype.h>
69 
70 
71 // singleton class instance
73 
74 
79 {
80  CLASS_CREATE(Routine, "Routine", RexxClass);
81 }
82 
83 
92 {
93  OrefSet(this, this->code, codeObj); /* store the code */
94  OrefSet(this, this->executableName, name);
95 }
96 
97 
104 {
105  // we need to protect this object until the constructor completes.
106  // the code generation step will create lots of new objects, giving a
107  // pretty high probability that it will be collected.
108  ProtectedObject p(this);
109  OrefSet(this, this->executableName, name);
110  // get a source object to generat this from
111  RexxSource *_source = new RexxSource(name);
112  ProtectedObject p2(_source);
113  // generate our code object and make the file hook up.
114  RexxCode *codeObj = _source->generateCode(false);
115  OrefSet(this, this->code, codeObj);
116 }
117 
118 
126 {
127  // we need to protect this object until the constructor completes.
128  // the code generation step will create lots of new objects, giving a
129  // pretty high probability that it will be collected.
130  ProtectedObject p(this);
131  OrefSet(this, this->executableName, name);
132  // get a source object to generat this from
133  RexxSource *_source = new RexxSource(name, s);
134  ProtectedObject p2(_source);
135  // generate our code object and make the file hook up.
136  RexxCode *codeObj = _source->generateCode(false);
137  OrefSet(this, this->code, codeObj);
138 }
139 
140 
148 RoutineClass::RoutineClass(RexxString *name, const char *data, size_t length)
149 {
150  // we need to protect this object until the constructor completes.
151  // the code generation step will create lots of new objects, giving a
152  // pretty high probability that it will be collected.
153  ProtectedObject p(this);
154  OrefSet(this, this->executableName, name);
155  // get a source object to generat this from
156  RexxSource *_source = new RexxSource(name, data, length);
157  ProtectedObject p2(_source);
158  // generate our code object and make the file hook up.
159  RexxCode *codeObj = _source->generateCode(false);
160  OrefSet(this, this->code, codeObj);
161 }
162 
163 
171 {
172  // we need to protect this object until the constructor completes.
173  // the code generation step will create lots of new objects, giving a
174  // pretty high probability that it will be collected.
175  ProtectedObject p(this);
176  OrefSet(this, this->executableName, name);
177  // get a source object to generat this from
178  RexxSource *_source = new RexxSource(name, s);
179  ProtectedObject p2(_source);
180  // generate our code object and make the file hook up.
181  RexxCode *codeObj = _source->generateCode(false);
182  OrefSet(this, this->code, codeObj);
183 }
184 
185 
186 void RoutineClass::live(size_t liveMark)
187 /******************************************************************************/
188 /* Function: Normal garbage collection live marking */
189 /******************************************************************************/
190 {
191  memory_mark(this->code);
193  memory_mark(this->objectVariables);
194 }
195 
197 /******************************************************************************/
198 /* Function: Generalized object marking */
199 /******************************************************************************/
200 {
201  memory_mark_general(this->code);
203  memory_mark_general(this->objectVariables);
204 }
205 
207 /******************************************************************************/
208 /* Function: Flatten an object */
209 /******************************************************************************/
210 {
212 
213  flatten_reference(newThis->code, envelope);
214  flatten_reference(newThis->executableName, envelope);
215  flatten_reference(newThis->objectVariables, envelope);
216 
218 }
219 
220 
222  RexxActivity *activity, /* activity running under */
223  RexxString *msgname, /* message to be run */
224  RexxObject**argPtr, /* arguments to the method */
225  size_t argcount, /* the count of arguments */
226  ProtectedObject &result) // the method result
227 /******************************************************************************/
228 /* Function: Call a method as a top level program or external function call */
229 /******************************************************************************/
230 {
231  ProtectedObject p(this); // belt-and-braces to make sure this is protected
232  // just forward this to the code object
233  code->call(activity, this, msgname, argPtr, argcount, result);
234 }
235 
236 
238  RexxActivity *activity, /* activity running under */
239  RexxString *msgname, /* message to be run */
240  RexxObject**argPtr, /* arguments to the method */
241  size_t argcount, /* the count of arguments */
242  RexxString *calltype, /* COMMAND/ROUTINE/FUNCTION */
243  RexxString *environment, /* initial command environment */
244  int context, /* type of context */
245  ProtectedObject &result) // the method result
246 /******************************************************************************/
247 /* Function: Call a method as a top level program or external function call */
248 /******************************************************************************/
249 {
250  ProtectedObject p(this); // belt-and-braces to make sure this is protected
251  // just forward this to the code object
252  code->call(activity, this, msgname, argPtr, argcount, calltype, environment, context, result);
253 }
254 
255 
265 {
266  ProtectedObject result;
267 
268  code->call(ActivityManager::currentActivity, this, executableName, args, count, result);
269  return (RexxObject *)result;
270 }
271 
272 
281 {
282  // this is required and must be an array
283  args = arrayArgument(args, ARG_ONE);
284 
285  ProtectedObject result;
286 
287  code->call(ActivityManager::currentActivity, this, executableName, args->data(), args->size(), result);
288  return (RexxObject *)result;
289 }
290 
291 
292 
294  RexxActivity *activity,
295  RexxString * calltype, /* type of invocation */
296  RexxString * environment, /* initial address */
297  RexxObject **arguments, /* array of arguments */
298  size_t argCount, /* the number of arguments */
299  ProtectedObject &result) // the method result
300 /****************************************************************************/
301 /* Function: Run a method as a program */
302 /****************************************************************************/
303 {
304  ProtectedObject p(this); // belt-and-braces to make sure this is protected
305  code->call(activity, this, executableName, arguments, argCount, calltype, environment, PROGRAMCALL, result);
306 }
307 
308 
310  RexxActivity *activity,
311  RexxObject **arguments, /* array of arguments */
312  size_t argCount, /* the number of arguments */
313  ProtectedObject &result) // the method result
314 /****************************************************************************/
315 /* Function: Run a method as a program */
316 /****************************************************************************/
317 {
318  ProtectedObject p(this); // belt-and-braces to make sure this is protected
319  code->call(activity, this, executableName, arguments, argCount, OREF_COMMAND, activity->getInstance()->getDefaultEnvironment(), PROGRAMCALL, result);
320 }
321 
322 
324  RexxObject *manager) /* supplied security manager */
325 /******************************************************************************/
326 /* Function: Associate a security manager with a method's source */
327 /******************************************************************************/
328 {
329  return code->setSecurityManager(manager);
330 }
331 
332 
334 /******************************************************************************/
335 /* Function: Flatten translated method into a buffer for storage into EA's etc*/
336 /******************************************************************************/
337 {
338  /* Get new envelope object */
339  RexxEnvelope *envelope = new RexxEnvelope;
340  ProtectedObject p(envelope);
341  /* now pack up the envelope for */
342  /* saving. */
343  return envelope->pack(this);
344 }
345 
346 
353 {
354  ProtectedObject p(this);
355  RexxBuffer *methodBuffer = save(); /* flatten the routine */
356  // create a full buffer of the data, plus the information header.
357  ProgramMetaData *data = new (methodBuffer) ProgramMetaData(methodBuffer);
358  // we just hand this buffer of data right over...that's all, we're done.
359  outBuffer->strptr = (char *)data;
360  outBuffer->strlength = data->getDataSize();
361 }
362 
363 
369 void RoutineClass::save(const char *filename)
370 {
371  FILE *handle = fopen(filename, "wb");/* open the output file */
372  if (handle == NULL) /* get an open error? */
373  {
374  /* got an error here */
376  }
377  ProtectedObject p(this);
378 
379  // save to a flattened buffer
380  RexxBuffer *buffer = save();
381  ProtectedObject p2(buffer);
382 
383  // create an image header
384  ProgramMetaData metaData(buffer->getDataLength());
385  {
386  UnsafeBlock releaser;
387 
388  // write out the header information
389  metaData.write(handle, buffer);
390  fclose(handle);
391  }
392 }
393 
394 
395 void *RoutineClass::operator new (size_t size)
396 /******************************************************************************/
397 /* Function: create a new method instance */
398 /******************************************************************************/
399 {
400  /* get a new method object */
401  return new_object(size, T_Routine);
402 }
403 
404 
419 {
420  // request this as an array. If not convertable, then we'll use it as a string
421  RexxArray *newSourceArray = source->requestArray();
422  /* couldn't convert? */
423  if (newSourceArray == (RexxArray *)TheNilObject)
424  {
425  /* get the string representation */
426  RexxString *sourceString = source->makeString();
427  /* got back .nil? */
428  if (sourceString == (RexxString *)TheNilObject)
429  {
430  /* raise an error */
432  }
433  /* wrap an array around the value */
434  newSourceArray = new_array(sourceString);
435  }
436  else /* have an array, make sure all */
437  {
438  /* is it single dimensional? */
439  if (newSourceArray->getDimension() != 1)
440  {
441  /* raise an error */
443  }
444  /* element are strings. */
445  /* Make a source array safe. */
446  ProtectedObject p(newSourceArray);
447  /* Make sure all elements in array */
448  for (size_t counter = 1; counter <= newSourceArray->size(); counter++)
449  {
450  /* Get element as string object */
451  RexxString *sourceString = newSourceArray ->get(counter)->makeString();
452  /* Did it convert? */
453  if (sourceString == (RexxString *)TheNilObject)
454  {
455  /* and report the error. */
457  }
458  else
459  {
460  /* itsa string add to source array */
461  newSourceArray ->put(sourceString, counter);
462  }
463  }
464  }
465 
466  // create the routine
467  RoutineClass *result = new RoutineClass(pgmname, newSourceArray);
468  ProtectedObject p(result);
469 
470  p = result; // switch the protectiong
471 
472  // if we've been provided with a scope, use it
473  if (parentSource == OREF_NULL)
474  {
475  // see if we have an active context and use the current source as the basis for the lookup
477  if (currentContext != OREF_NULL)
478  {
479  parentSource = currentContext->getSourceObject();
480  }
481  }
482 
483  // if there is a parent source, then merge in the scope information
484  if (parentSource != OREF_NULL)
485  {
486  result->getSourceObject()->inheritSourceContext(parentSource);
487  }
488 
489  return result;
490 }
491 
492 
507 {
508  // request this as an array. If not convertable, then we'll use it as a string
509  RexxArray *newSourceArray = source->requestArray();
510  /* couldn't convert? */
511  if (newSourceArray == (RexxArray *)TheNilObject)
512  {
513  /* raise an error */
515  }
516  else /* have an array, make sure all */
517  {
518  /* is it single dimensional? */
519  if (newSourceArray->getDimension() != 1)
520  {
521  /* raise an error */
523  }
524  /* element are strings. */
525  /* Make a source array safe. */
526  ProtectedObject p(newSourceArray);
527  /* Make sure all elements in array */
528  for (size_t counter = 1; counter <= newSourceArray->size(); counter++)
529  {
530  /* Get element as string object */
531  RexxString *sourceString = newSourceArray ->get(counter)->makeString();
532  /* Did it convert? */
533  if (sourceString == (RexxString *)TheNilObject)
534  {
535  /* and report the error. */
537  }
538  else
539  {
540  /* itsa string add to source array */
541  newSourceArray ->put(sourceString, counter);
542  }
543  }
544  }
545  // create the routine
546  return new RoutineClass(pgmname, newSourceArray);
547 }
548 
549 
551  RexxObject **init_args, /* subclass init arguments */
552  size_t argCount) /* number of arguments passed */
553 /******************************************************************************/
554 /* Function: Create a new method from REXX code contained in a string or an */
555 /* array */
556 /******************************************************************************/
557 {
558  RexxObject *pgmname; /* method name */
559  RexxObject *_source; /* Array or string object */
560  RexxObject *option = OREF_NULL;
561  size_t initCount = 0; /* count of arguments we pass along */
562 
563  /* break up the arguments */
564 
565  RexxClass::processNewArgs(init_args, argCount, &init_args, &initCount, 2, (RexxObject **)&pgmname, (RexxObject **)&_source);
566  /* get the method name as a string */
567  RexxString *nameString = stringArgument(pgmname, ARG_ONE);
568  requiredArgument(_source, ARG_TWO); /* make sure we have the second too */
569 
570  RexxSource *sourceContext = OREF_NULL;
571  // retrieve extra parameter if exists
572  if (initCount != 0)
573  {
574  RexxClass::processNewArgs(init_args, initCount, &init_args, &initCount, 1, (RexxObject **)&option, NULL);
575  if (isOfClass(Method, option))
576  {
577  sourceContext = ((RexxMethod *)option)->getSourceObject();
578  }
579  if (isOfClass(Routine, option))
580  {
581  sourceContext = ((RoutineClass *)option)->getSourceObject();
582  }
583  else if (isOfClass(Package, option))
584  {
585  sourceContext = ((PackageClass *)option)->getSourceObject();
586  }
587  else
588  {
589  reportException(Error_Incorrect_method_argType, IntegerThree, "Method, Routine, or Package object");
590  }
591  }
592 
593  RoutineClass *newRoutine = newRoutineObject(nameString, _source, IntegerTwo, sourceContext);
594  ProtectedObject p(newRoutine);
595  /* Give new object its behaviour */
596  newRoutine->setBehaviour(((RexxClass *)this)->getInstanceBehaviour());
597  if (((RexxClass *)this)->hasUninitDefined())
598  {
599  newRoutine->hasUninit(); /* Make sure everyone is notified. */
600  }
601  /* now send an INIT message */
602  newRoutine->sendMessage(OREF_INIT, init_args, initCount);
603  return newRoutine; /* return the new method */
604 }
605 
606 
608  RexxString *filename) /* name of the target file */
609 /******************************************************************************/
610 /* Function: Create a method from a fully resolved file name */
611 /******************************************************************************/
612 {
613  /* get the method name as a string */
614  filename = stringArgument(filename, ARG_ONE);
615  /* finish up processing of this */
616  RoutineClass * newMethod = new RoutineClass(filename);
617  ProtectedObject p2(newMethod);
618  /* Give new object its behaviour */
619  newMethod->setBehaviour(((RexxClass *)this)->getInstanceBehaviour());
620  /* does object have an UNINT method */
621  if (((RexxClass *)this)->hasUninitDefined())
622  {
623  newMethod->hasUninit(); /* Make sure everyone is notified. */
624  }
625  /* now send an INIT message */
626  newMethod->sendMessage(OREF_INIT);
627  return newMethod;
628 }
629 
630 
639 {
640  RXSTRING buffer; /* instorage buffer */
641 
642  MAKERXSTRING(buffer, NULL, 0);
643  /* get the image of function */
644  RexxResolveMacroFunction(name->getStringData(), &buffer);
645  /* unflatten the method now */
646  RoutineClass *routine = restore(&buffer, name);
647  // release the buffer memory
649  return routine;
650 }
651 
652 
654 /******************************************************************************/
655 /* Function: Process instorage execution arguments */
656 /******************************************************************************/
657 {
658  // just a generic empty one indicating that we should check the macrospace?
659  if (instore[0].strptr == NULL && instore[1].strptr == NULL)
660  {
661  unsigned short temp;
662 
663  /* see if this exists */
664  if (!RexxQueryMacro(name->getStringData(), &temp))
665  {
666  return restoreFromMacroSpace(name);
667  }
668  return OREF_NULL; // not found
669  }
670  if (instore[1].strptr != NULL) /* have an image */
671  {
672  /* go convert into a method */
673  RoutineClass *routine = restore(&instore[1], name);
674  if (routine != OREF_NULL)
675  { /* did it unflatten successfully? */
676  if (instore[0].strptr != NULL) /* have source also? */
677  {
678  /* get a buffer object */
679  RexxBuffer *source_buffer = new_buffer(instore[0]);
680  /* reconnect this with the source */
681  routine->getSourceObject()->setBufferedSource(source_buffer);
682  }
683  return routine; /* go return it */
684  }
685  }
686  if (instore[0].strptr != NULL) /* have instorage source */
687  {
688  /* get a buffer object */
689  RexxBuffer *source_buffer = new_buffer(instore[0]);
690  if (source_buffer->getData()[0] == '#' && source_buffer->getData()[1] == '!')
691  {
692  memcpy(source_buffer->getData(), "--", 2);
693  }
694 
695  /* translate this source */
696  RoutineClass *routine = new RoutineClass(name, source_buffer);
697  ProtectedObject p(routine);
698  /* return this back in instore[1] */
699  routine->save(&instore[1]);
700  return routine; /* return translated source */
701  }
702  return OREF_NULL; /* processing failed */
703 }
704 
713 RoutineClass *RoutineClass::restore(const char *data, size_t length)
714 {
715  // create a buffer object and restore from it
716  RexxBuffer *buffer = new_buffer(data, length);
717  ProtectedObject p(buffer);
718  return restore(buffer, buffer->getData(), length);
719 }
720 
721 
723  RexxBuffer *buffer, /* buffer containing the method */
724  char *startPointer, /* first character of the method */
725  size_t length) // length of data to unflatten
726 /******************************************************************************/
727 /* Function: Unflatten a translated method. Passed a buffer object containing*/
728 /* the method */
729 /******************************************************************************/
730 {
731  /* Get new envelope object */
732  RexxEnvelope *envelope = new RexxEnvelope;
733  ProtectedObject p(envelope);
734  /* now puff up the method object */
735  envelope->puff(buffer, startPointer, length);
736  /* The receiver object is an envelope*/
737  /* whose receiver is the actual */
738  /* method object we're restoring */
739  return (RoutineClass *)envelope->getReceiver();
740 }
741 
742 
751 {
752  const char *data = buffer->getData();
753 
754  // does this start with a hash-bang? Need to scan forward to the first
755  // newline character
756  if (data[0] == '#' && data[1] == '!')
757  {
758  data = Utilities::strnchr(data, buffer->getDataLength(), '\n');
759  if (data == OREF_NULL)
760  {
761  return OREF_NULL;
762  }
763  // step over the linend
764  data++;
765  }
766 
767  ProgramMetaData *metaData = (ProgramMetaData *)data;
768  bool badVersion = false;
769  // make sure this is valid for interpreter
770  if (!metaData->validate(badVersion))
771  {
772  // if the failure was due to a version mismatch, this is an error condition.
773  if (badVersion)
774  {
776  }
777  return OREF_NULL;
778  }
779  // this should be valid...try to restore.
780  RoutineClass *routine = restore(buffer, metaData->getImageData(), metaData->getImageSize());
781  routine->getSourceObject()->setProgramName(fileName);
782  return routine;
783 }
784 
785 
794 {
795  const char *data = inData->strptr;
796 
797  // does this start with a hash-bang? Need to scan forward to the first
798  // newline character
799  if (data[0] == '#' && data[1] == '!')
800  {
801  data = Utilities::strnchr(data, inData->strlength, '\n');
802  if (data == OREF_NULL)
803  {
804  return OREF_NULL;
805  }
806  // step over the linend
807  data++;
808  }
809 
810 
811  ProgramMetaData *metaData = (ProgramMetaData *)data;
812  bool badVersion;
813  // make sure this is valid for interpreter
814  if (!metaData->validate(badVersion))
815  {
816  // if the failure was due to a version mismatch, this is an error condition.
817  if (badVersion)
818  {
820  }
821  return OREF_NULL;
822  }
823  RexxBuffer *bufferData = metaData->extractBufferData();
824  ProtectedObject p(bufferData);
825  // we're restoring from the beginning of this.
826  RoutineClass *routine = restore(bufferData, bufferData->getData(), metaData->getImageSize());
827  // if this restored properly (and it should), reconnect it to the source file
828  if (routine != OREF_NULL)
829  {
830  routine->getSourceObject()->setProgramName(name);
831  }
832  return routine;
833 }
834 
835 
846 {
847  /* load the program file */
848  RexxBuffer *program_buffer = SystemInterpreter::readProgram(filename->getStringData());
849  if (program_buffer == OREF_NULL) /* Program not found or read error? */
850  {
851  /* report this */
853  }
854 
855  // try to restore a flattened program first
856  RoutineClass *routine = restore(filename, program_buffer);
857  if (routine != OREF_NULL)
858  {
859  return routine;
860  }
861 
862  // process this from the source
863  return new RoutineClass(filename, program_buffer);
864 }
865 
866 
876 {
877  name = stringArgument(name, "name");
878  descriptor = stringArgument(descriptor, "descriptor");
879  /* convert external into words */
880  RexxArray *_words = StringUtil::words(descriptor->getStringData(), descriptor->getLength());
881  ProtectedObject p(_words);
882  // "LIBRARY libbar [foo]"
883  if (((RexxString *)(_words->get(1)))->strCompare(CHAR_LIBRARY))
884  {
885  RexxString *library = OREF_NULL;
886  // the default entry point name is the internal name
887  RexxString *entry = name;
888 
889  // full library with entry name version?
890  if (_words->size() == 3)
891  {
892  library = (RexxString *)_words->get(2);
893  entry = (RexxString *)_words->get(3);
894  }
895  else if (_words->size() == 2)
896  {
897  library = (RexxString *)_words->get(2);
898  }
899  else // wrong number of tokens
900  {
901  /* this is an error */
903  }
904 
905  /* create a new native method */
906  RoutineClass *routine = PackageManager::loadRoutine(library, entry);
907  // raise an exception if this entry point is not found.
908  if (routine == OREF_NULL)
909  {
910  return (RoutineClass *)TheNilObject;
911  }
912  return routine;
913  }
914  else
915  {
916  /* unknown external type */
918  }
919  return OREF_NULL;
920 }
921 
RexxObject::makeString
RexxString * makeString()
Definition: ObjectClass.cpp:1070
Error_Incorrect_method_noarray
#define Error_Incorrect_method_noarray
Definition: RexxErrorCodes.h:490
SystemInterpreter::releaseResultMemory
static void releaseResultMemory(void *)
Definition: MemorySupport.cpp:75
RexxObject::sendMessage
void sendMessage(RexxString *, RexxArray *, ProtectedObject &)
Definition: ObjectClass.cpp:668
RexxArray::getDimension
size_t getDimension()
Definition: ArrayClass.cpp:690
new_array
RexxArray * new_array(size_t s)
Definition: ArrayClass.hpp:250
RexxArray
Definition: ArrayClass.hpp:100
BaseExecutable::getSourceObject
RexxSource * getSourceObject()
Definition: MethodClass.hpp:85
BaseExecutable::source
RexxArray * source()
Definition: MethodClass.cpp:146
ProgramMetaData::getImageData
char * getImageData()
Definition: ProgramMetaData.cpp:169
RoutineClass::runProgram
void runProgram(RexxActivity *activity, RexxString *calltype, RexxString *environment, RexxObject **arguments, size_t argCount, ProtectedObject &result)
Definition: RoutineClass.cpp:293
MethodClass.hpp
RexxSource::setBufferedSource
void setBufferedSource(RexxBuffer *newSource)
Definition: SourceFile.hpp:148
PackageClass.hpp
memory_mark_general
#define memory_mark_general(oref)
Definition: RexxMemory.hpp:437
RexxActivation::getSourceObject
RexxSource * getSourceObject()
Definition: RexxActivation.hpp:325
RexxActivation.hpp
OrefSet
#define OrefSet(o, r, v)
Definition: RexxCore.h:94
ProgramMetaData.hpp
_RXSTRING::strlength
size_t strlength
Definition: rexx.h:157
RoutineClass::setSecurityManager
RexxObject * setSecurityManager(RexxObject *)
Definition: RoutineClass.cpp:323
RexxArray::data
RexxObject ** data()
Definition: ArrayClass.hpp:202
RoutineClass
Definition: RoutineClass.hpp:49
T_Routine
Definition: ClassTypeCodes.h:95
SystemInterpreter::readProgram
static RexxBuffer * readProgram(const char *file_name)
Definition: FileSystem.cpp:189
RexxNativeActivation.hpp
RexxString::getLength
size_t getLength()
Definition: StringClass.hpp:330
requiredArgument
void requiredArgument(RexxObject *object, size_t position)
Definition: RexxCore.h:284
RexxCode
Definition: RexxCode.hpp:58
_RXSTRING::strptr
char * strptr
Definition: rexx.h:158
RexxArray::size
size_t size()
Definition: ArrayClass.hpp:200
Error_Program_unreadable_name
#define Error_Program_unreadable_name
Definition: RexxErrorCodes.h:58
RoutineClass::save
RexxBuffer * save()
Definition: RoutineClass.cpp:333
RoutineClass::classInstance
static RexxClass * classInstance
Definition: RoutineClass.hpp:97
RexxSource::generateCode
RexxCode * generateCode(bool isMethod)
Definition: SourceFile.cpp:1198
UnsafeBlock
Definition: ActivityManager.hpp:280
ARG_TWO
const int ARG_TWO
Definition: RexxCore.h:81
RexxInternalObject::hasUninit
void hasUninit()
Definition: ObjectClass.cpp:1873
reportException
void reportException(wholenumber_t error)
Definition: ActivityManager.hpp:136
ProgramMetaData::getImageSize
size_t getImageSize()
Definition: ProgramMetaData.hpp:59
BaseExecutable::executableName
RexxString * executableName
Definition: MethodClass.hpp:96
RexxString::getStringData
const char * getStringData()
Definition: StringClass.hpp:333
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxBuffer
Definition: BufferClass.hpp:91
RexxSource::setProgramName
void setProgramName(RexxString *name)
Definition: SourceFile.cpp:335
RoutineClass::restore
static RoutineClass * restore(RexxBuffer *, char *, size_t length)
Definition: RoutineClass.cpp:722
RexxArray::get
RexxObject * get(size_t pos)
Definition: ArrayClass.hpp:201
ProgramMetaData::extractBufferData
RexxBuffer * extractBufferData()
Definition: ProgramMetaData.cpp:158
isOfClass
#define isOfClass(t, r)
Definition: RexxCore.h:211
Utilities::strnchr
static const char * strnchr(const char *, size_t n, char ch)
Definition: Utilities.cpp:172
RexxSource::inheritSourceContext
void inheritSourceContext(RexxSource *source)
Definition: SourceFile.cpp:1358
ProgramMetaData::validate
bool validate(bool &)
Definition: ProgramMetaData.cpp:184
BaseCode::call
virtual void call(RexxActivity *, RoutineClass *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &)
Definition: MethodClass.cpp:719
RexxSource
Definition: SourceFile.hpp:131
RexxActivity::getCurrentRexxFrame
RexxActivation * getCurrentRexxFrame()
Definition: RexxActivity.hpp:280
RexxEnvelope::getReceiver
RexxObject * getReceiver()
Definition: RexxEnvelope.hpp:74
RoutineClass::call
void call(RexxActivity *, RexxString *, RexxObject **, size_t, RexxString *, RexxString *, int, ProtectedObject &)
Definition: RoutineClass.cpp:237
RexxArray::makeString
RexxString * makeString(RexxString *, RexxString *)
Definition: ArrayClass.cpp:1519
MAKERXSTRING
#define MAKERXSTRING(r, p, l)
Definition: rexx.h:182
ProgramMetaData::getDataSize
size_t getDataSize()
Definition: ProgramMetaData.cpp:136
SystemInterpreter.hpp
RexxResolveMacroFunction
RexxReturnCode REXXENTRY RexxResolveMacroFunction(const char *, PRXSTRING)
Error_Incorrect_method_no_method
#define Error_Incorrect_method_no_method
Definition: RexxErrorCodes.h:501
ARG_ONE
const int ARG_ONE
Definition: RexxCore.h:80
OREF_NULL
#define OREF_NULL
Definition: RexxCore.h:60
ArrayClass.hpp
RexxActivity
Definition: RexxActivity.hpp:127
_RXSTRING
Definition: rexx.h:156
RexxArray::put
void put(RexxObject *eref, size_t pos)
Definition: ArrayClass.cpp:203
RoutineClass::RoutineClass
RoutineClass(RexxString *n, BaseCode *_code)
Definition: RoutineClass.cpp:91
Error_Incorrect_method_argType
#define Error_Incorrect_method_argType
Definition: RexxErrorCodes.h:502
arrayArgument
RexxArray * arrayArgument(RexxObject *object, size_t position)
Definition: RexxCore.h:376
IntegerTwo
#define IntegerTwo
Definition: RexxCore.h:190
RexxClass
Definition: ClassClass.hpp:49
RexxInternalObject::setBehaviour
void setBehaviour(RexxBehaviour *b)
Definition: ObjectClass.hpp:265
ProtectedObject.hpp
flatten_reference
#define flatten_reference(oref, envel)
Definition: RexxMemory.hpp:440
IntegerThree
#define IntegerThree
Definition: RexxCore.h:191
cleanUpFlatten
#define cleanUpFlatten
Definition: RexxMemory.hpp:432
ProtectedObject
Definition: ProtectedObject.hpp:46
StringClass.hpp
RoutineClass::restoreFromMacroSpace
static RoutineClass * restoreFromMacroSpace(RexxString *name)
Definition: RoutineClass.cpp:638
Error_Incorrect_method_nostring_inarray
#define Error_Incorrect_method_nostring_inarray
Definition: RexxErrorCodes.h:504
PackageClass
Definition: PackageClass.hpp:48
BaseCode
Definition: MethodClass.hpp:62
RexxNativeCode.hpp
CLASS_CREATE
#define CLASS_CREATE(name, id, className)
Definition: RexxMemory.hpp:445
RoutineClass::callRexx
RexxObject * callRexx(RexxObject **, size_t)
Definition: RoutineClass.cpp:264
memory_mark
#define memory_mark(oref)
Definition: RexxMemory.hpp:436
RexxCode.hpp
StringUtil::words
static RexxArray * words(const char *data, size_t length)
Definition: StringUtil.cpp:1645
RoutineClass::processInstore
static RoutineClass * processInstore(PRXSTRING instore, RexxString *name)
Definition: RoutineClass.cpp:653
RexxBuffer::getData
virtual char * getData()
Definition: BufferClass.hpp:105
RexxInternalApis.h
Error_Program_unreadable_version
#define Error_Program_unreadable_version
Definition: RexxErrorCodes.h:62
RexxActivation
Definition: RexxActivation.hpp:156
RoutineClass::loadExternalRoutine
RoutineClass * loadExternalRoutine(RexxString *name, RexxString *descriptor)
Definition: RoutineClass.cpp:875
RoutineClass::newRoutineObject
static RoutineClass * newRoutineObject(RexxString *, RexxObject *, RexxObject *, RexxSource *s)
Definition: RoutineClass.cpp:418
new_buffer
RexxBuffer * new_buffer(size_t s)
Definition: BufferClass.hpp:116
RoutineClass::flatten
void flatten(RexxEnvelope *)
Definition: RoutineClass.cpp:206
BaseCode::setSecurityManager
virtual RexxObject * setSecurityManager(RexxObject *manager)
Definition: MethodClass.cpp:765
RexxEnvelope::pack
RexxBuffer * pack(RexxObject *)
Definition: RexxEnvelope.cpp:168
setUpFlatten
#define setUpFlatten(type)
Definition: RexxMemory.hpp:427
TheNilObject
#define TheNilObject
Definition: RexxCore.h:180
ActivityManager::currentActivity
static RexxActivity *volatile currentActivity
Definition: ActivityManager.hpp:95
RoutineClass::createInstance
static void createInstance()
Definition: RoutineClass.cpp:78
RexxEnvelope::puff
void puff(RexxBuffer *, char *, size_t length)
Definition: RexxEnvelope.cpp:242
PackageManager::loadRoutine
static RoutineClass * loadRoutine(RexxString *packageName, RexxString *function)
Definition: PackageManager.cpp:379
RexxActivity.hpp
PROGRAMCALL
#define PROGRAMCALL
Definition: RexxActivation.hpp:140
stringArgument
RexxString * stringArgument(RexxObject *object, size_t position)
Definition: RexxCore.h:296
RoutineClass::liveGeneral
void liveGeneral(int reason)
Definition: RoutineClass.cpp:196
RexxObject::requestArray
RexxArray * requestArray()
Definition: ObjectClass.cpp:1461
RoutineClass::fromFile
static RoutineClass * fromFile(RexxString *filename)
Definition: RoutineClass.cpp:845
RexxClass::processNewArgs
static void processNewArgs(RexxObject **, size_t, RexxObject ***, size_t *, size_t, RexxObject **, RexxObject **)
Definition: ClassClass.cpp:1701
InterpreterInstance.hpp
RoutineClass::newRexx
RoutineClass * newRexx(RexxObject **, size_t)
Definition: RoutineClass.cpp:550
RexxCore.h
CHAR_LIBRARY
char CHAR_LIBRARY[]
RexxBufferBase::getDataLength
size_t getDataLength()
Definition: BufferClass.hpp:53
DirectoryClass.hpp
RexxMethod
Definition: MethodClass.hpp:101
InterpreterInstance::getDefaultEnvironment
RexxString * getDefaultEnvironment()
Definition: InterpreterInstance.hpp:73
new_object
RexxObject * new_object(size_t s)
Definition: RexxMemory.hpp:422
BaseExecutable::code
BaseCode * code
Definition: MethodClass.hpp:97
RexxSmartBuffer.hpp
Utilities.hpp
Error_Program_unreadable_output_error
#define Error_Program_unreadable_output_error
Definition: RexxErrorCodes.h:61
Error_Translation_bad_external
#define Error_Translation_bad_external
Definition: RexxErrorCodes.h:578
BufferClass.hpp
SourceFile.hpp
ProgramMetaData
Definition: ProgramMetaData.hpp:45
RexxObject
Definition: ObjectClass.hpp:311
PackageManager.hpp
RoutineClass::newFileRexx
RoutineClass * newFileRexx(RexxString *)
Definition: RoutineClass.cpp:607
RoutineClass::callWithRexx
RexxObject * callWithRexx(RexxArray *)
Definition: RoutineClass.cpp:280
RexxString
Definition: StringClass.hpp:119
RoutineClass::live
void live(size_t)
Definition: RoutineClass.cpp:186
RexxActivity::getInstance
InterpreterInstance * getInstance()
Definition: RexxActivity.hpp:250
RexxQueryMacro
RexxReturnCode REXXENTRY RexxQueryMacro(CSTRING, unsigned short *)