stackOverflow.cpp File Reference
#include "oorexxapi.h"
#include <stdio.h>
#include <string.h>
Include dependency graph for stackOverflow.cpp:

Go to the source code of this file.

Macros

#define _CDECL
 
#define RECURSIVE_ROUTINE1
 
#define RECURSIVE_ROUTINE2
 

Functions

bool checkForCondition (RexxThreadContext *c, bool clear)
 
void printInterpreterVersion (RexxInstance *)
 
int _CDECL main (int argc, char **argv)
 
wholenumber_t conditionSubCode (RexxCondition *condition)
 
void standardConditionMsg (RexxThreadContext *c, RexxDirectoryObject condObj, RexxCondition *condition)
 

Macro Definition Documentation

◆ _CDECL

#define _CDECL

A simple example that creates an instance of the interpreter and uses that instance to execute a Rexx routine defined in this program.

Both routines cause an infinite recursion. One version of the routine traps any error, the other does not. This shows how to handle conditions raised inside the interpreter execution, i.e., outside of your native code execution.

To have the second routine execute, specify any argument on the command line. For example:

stackOverflow 1

With no argument, the first routine is used:

starckOverflow

Definition at line 64 of file stackOverflow.cpp.

◆ RECURSIVE_ROUTINE1

#define RECURSIVE_ROUTINE1
Value:
"signal on any name error\n\n" \
"say 'Starting infinite recursison'\n" \
"line = 'interpret line'\n" \
"interpret line\n" \
"return 0\n\n" \
"error:\n" \
"obj = condition('O')\n" \
"say 'Trapped error:' obj~code '('obj~errorText')'\n" \
"return -9"

Definition at line 67 of file stackOverflow.cpp.

◆ RECURSIVE_ROUTINE2

#define RECURSIVE_ROUTINE2
Value:
"say 'Starting infinite recursison'\n" \
"line = 'interpret line'\n" \
"interpret line\n" \
"return 0\n\n" \

Definition at line 78 of file stackOverflow.cpp.

Function Documentation

◆ checkForCondition()

bool checkForCondition ( RexxThreadContext c,
bool  clear 
)

Given a thread context, checks for a raised condition, and prints out the standard condition message if there is a condition.

Parameters
cThread context we are operating in.
clearWhether to clear the condition or not.
Returns
True if there was a condition, otherwise false.

Definition at line 222 of file stackOverflow.cpp.

References NULLOBJECT, and standardConditionMsg().

Referenced by main().

◆ conditionSubCode()

wholenumber_t conditionSubCode ( RexxCondition condition)
inline

Given a condition object, extracts and returns as a whole number the subcode of the condition.

Definition at line 166 of file stackOverflow.cpp.

References RexxCondition::code, and RexxCondition::rc.

Referenced by standardConditionMsg().

◆ main()

int _CDECL main ( int  argc,
char **  argv 
)

◆ printInterpreterVersion()

void printInterpreterVersion ( RexxInstance interpreter)

Below are several helper functions that demonstrate how to use some of the different C++ native APIs. Given an interpreter instance, prints out the interpreter version and language version. The documentation in the ooRexx programming guide explains the byte encoding of the version numbers.

Definition at line 153 of file stackOverflow.cpp.

Referenced by main().

◆ standardConditionMsg()

void standardConditionMsg ( RexxThreadContext c,
RexxDirectoryObject  condObj,
RexxCondition condition 
)

Outputs the typical condition message. For example:

 4 *-* say dt~number

Error 97 running C:\work\qTest.rex line 4: Object method not found Error 97.1: Object "a DateTime" does not understand message "NUMBER"

Parameters
cThe thread context we are operating in.
condObjThe condition information object. The object returned from the C++ API GetConditionInfo()
conditionThe RexxCondition struct. The filled in struct from the C++ API DecodeConditionInfo().

@assumes There is a condition and that condObj and condition are valid.

Definition at line 187 of file stackOverflow.cpp.

References conditionSubCode(), RexxCondition::errortext, RexxCondition::message, NULLOBJECT, RexxCondition::position, RexxCondition::program, and RexxCondition::rc.

Referenced by checkForCondition().