/**
 * Add a handler for a registered subcom handler to the
 * address handler list.
 *
 * @param name   The environment name of the handler.
 * @param registeredName
 *               The name of the registered subcom handler.
 */
void InterpreterInstance::addCommandHandler(const char *name, const char *registeredName)
{
    RexxString *handlerName = new_upper_string(name);
    CommandHandler *handler = new CommandHandler(registeredName);
    // it's possible we were give a bogus name, so validate this first
    if (handler->isResolved())
    {
        commandHandlers->put((RexxObject *)handler, handlerName);
    }
}
RexxClassObject RexxEntry FindContextClass(RexxMethodContext *c, CSTRING n)
{
    ApiContext context(c);
    try
    {
        // convert the name to a string instance, and check the environments.
        RexxString *name = new_upper_string(n);
        return (RexxClassObject)context.ret(context.context->findClass(name));
    }
    catch (NativeActivation *)
    {
    }
    return NULLOBJECT;
}
RexxObjectPtr RexxEntry ForwardMessage(RexxMethodContext *c, RexxObjectPtr o, CSTRING n, RexxClassObject clazz, RexxArrayObject a)
{
    ApiContext context(c);
    try
    {
        RexxString *message = n == NULL ? OREF_NULL : new_upper_string(n);
        ProtectedObject result(context.activity);
        context.context->forwardMessage((RexxObject *)o, message, (RexxClass *)clazz, (ArrayClass *)a, result);
        return context.ret((RexxObject *)result);
    }
    catch (NativeActivation *)
    {
    }
    return NULLOBJECT;
}
Beispiel #4
0
/**
 * Load all of the routines in a package, registering them with
 * the package manager.
 *
 * @param table   The package table describing this package.
 */
void LibraryPackage::loadRoutines(RexxRoutineEntry *table)
{
    // no routines exported by this package?  Just return without
    // doing anything.
    if (table == NULL)
    {
        return;
    }

    // create a directory of loaded routines
    setField(routines, new_string_table());
    // and a version using an uppercase name map
    setField(publicRoutines, new_string_table());

    while (table->style != 0)
    {
        // table names tend to be specified in friendly form, we need to
        // convert them to uppercase because "normal" Rexx function names
        // tend to be uppercase.
        Protected<RexxString> target = new_upper_string(table->name);
        Protected<RexxString> routineName = new_string(table->name);

        Protected<BaseNativeRoutine> func;
        if (table->style == ROUTINE_CLASSIC_STYLE)
        {
            func = new RegisteredRoutine(libraryName, routineName, (RexxRoutineHandler *)table->entryPoint);
        }
        else
        {
            func = new NativeRoutine(libraryName, routineName, (PNATIVEROUTINE)table->entryPoint);
        }

        Protected<RoutineClass> routine = new RoutineClass(routineName, func);
        // add this to our local table.  Our local table needs to keep the original case,
        // since those will be referenced by ::ROUTINE statements.
        routines->put(routine, routineName);
        // and also keep an upper case version for merging with packages
        publicRoutines->put(routine, target);

        // add this to the global function pool
        PackageManager::addPackageRoutine(target, routine);
        // step to the next table entry
        table++;
    }
}
/**
 * Add a handler to the environment list.
 *
 * @param name       The name of the address environment this services.
 * @param entryPoint The entry point address of the handler.
 */
void InterpreterInstance::addCommandHandler(const char *name, REXXPFN entryPoint)
{
    RexxString *handlerName = new_upper_string(name);
    commandHandlers->put((RexxObject *)new CommandHandler(entryPoint), handlerName);
}
Beispiel #6
0
inline RexxString *new_upper_string(const char *string)
{
    return new_upper_string(string, strlen(string), -1);
}