PackageManager Class Reference

#include <PackageManager.hpp>

Static Public Member Functions

static void live (size_t liveMark)
 
static void liveGeneral (int reason)
 
static void initialize ()
 
static RexxArraygetImageData ()
 
static void restore (RexxArray *imageArray)
 
static void restore ()
 
static LibraryPackagegetLibrary (RexxString *name)
 
static LibraryPackageloadLibrary (RexxString *name)
 
static void unload ()
 
static RexxNativeMethodresolveMethod (RexxString *packageName, RexxString *methodName)
 
static RexxNativeMethodloadMethod (RexxString *packageName, RexxString *methodName)
 
static RoutineClassresolveRoutine (RexxString *function, RexxString *packageName, RexxString *procedure)
 
static RoutineClassresolveRoutine (RexxString *packageName, RexxString *function)
 
static RoutineClassloadRoutine (RexxString *packageName, RexxString *function)
 
static RoutineClassresolveRoutine (RexxString *function)
 
static RoutineClasscreateRegisteredRoutine (RexxString *function)
 
static RoutineClassgetLoadedRoutine (RexxString *function)
 
static PNATIVEMETHOD resolveMethodEntry (RexxString *package, RexxString *name)
 
static PNATIVEROUTINE resolveRoutineEntry (RexxString *package, RexxString *name)
 
static PREGISTEREDROUTINE resolveRegisteredRoutineEntry (RexxString *package, RexxString *name)
 
static void addPackageRoutine (RexxString *name, RoutineClass *func)
 
static void loadInternalPackage (RexxString *name, RexxPackageEntry *p)
 
static bool registerPackage (RexxString *name, RexxPackageEntry *p)
 
static RexxObjectaddRegisteredRoutine (RexxString *name, RexxString *module, RexxString *proc)
 
static RexxObjectdropRegisteredRoutine (RexxString *name)
 
static RexxObjectqueryRegisteredRoutine (RexxString *name)
 
static bool callNativeRoutine (RexxActivity *activity, RexxString *name, RexxObject **arguments, size_t argcount, size_t named_argcount, ProtectedObject &result)
 
static RoutineClassloadRequires (RexxActivity *activity, RexxString *shortName, RexxString *resolvedName, ProtectedObject &result)
 
static RoutineClassgetMacroSpaceRequires (RexxActivity *activity, RexxString *name, ProtectedObject &result, RexxObject *securityManager)
 
static RoutineClassgetRequiresFile (RexxActivity *activity, RexxString *name, RexxObject *securityManager, ProtectedObject &result)
 
static RoutineClassloadRequires (RexxActivity *activity, RexxString *name, const char *data, size_t length, ProtectedObject &result)
 
static RoutineClassloadRequires (RexxActivity *activity, RexxString *name, RexxArray *data, ProtectedObject &result)
 

Protected Types

enum  {
  IMAGE_PACKAGES = 1 , IMAGE_PACKAGE_ROUTINES , IMAGE_REGISTERED_ROUTINES , IMAGE_REQUIRES ,
  IMAGE_ARRAY_SIZE = IMAGE_REQUIRES
}
 

Static Protected Member Functions

static RoutineClasscheckRequiresCache (RexxString *name, ProtectedObject &result)
 

Static Protected Attributes

static RexxDirectoryimagePackages = OREF_NULL
 
static RexxDirectoryimagePackageRoutines = OREF_NULL
 
static RexxDirectoryimageRegisteredRoutines = OREF_NULL
 
static RexxDirectoryimageLoadedRequires = OREF_NULL
 
static RexxDirectorypackages = OREF_NULL
 
static RexxDirectorypackageRoutines = OREF_NULL
 
static RexxDirectoryregisteredRoutines = OREF_NULL
 
static RexxDirectoryloadedRequires = OREF_NULL
 
static RexxPackageEntryrexxPackage = &rexx_package_entry
 

Detailed Description

Definition at line 59 of file PackageManager.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
IMAGE_PACKAGES 
IMAGE_PACKAGE_ROUTINES 
IMAGE_REGISTERED_ROUTINES 
IMAGE_REQUIRES 
IMAGE_ARRAY_SIZE 

Definition at line 102 of file PackageManager.hpp.

Member Function Documentation

◆ addPackageRoutine()

void PackageManager::addPackageRoutine ( RexxString name,
RoutineClass func 
)
static

Add a function to the package-defined functions table.

Parameters
nameThe name of the function.
func

Definition at line 505 of file PackageManager.cpp.

References packageRoutines, and RexxDirectory::put().

Referenced by LibraryPackage::loadRoutines().

◆ addRegisteredRoutine()

RexxObject * PackageManager::addRegisteredRoutine ( RexxString name,
RexxString module,
RexxString proc 
)
static

Process the basics of RxFuncAdd(). This will return 0 if the function can be resolved and is callable, 1 otherwise. If the target function is not in a loadable package file, this will also do the global registration.

Parameters
nameThe name of the registered function.
moduleThe name of the library containing the function.
procThe target procedure name (ignored if the target library is a self-loading one).
Returns
0 if the function registration worked and the function is callable. 1 otherwise.
Remarks
Note that we return TheFalseObject (0) if the function is resolved and callable and TheTrueObject (1) for failure. This is because RxFuncAdd() directly returns this result. RxFuncAdd() is documented to return 0 on success and 1 on failure.

Definition at line 529 of file PackageManager.cpp.

References getLoadedRoutine(), OREF_NULL, resolveRoutine(), TheFalseObject, TheTrueObject, and RexxString::upper().

Referenced by BUILTIN().

◆ callNativeRoutine()

bool PackageManager::callNativeRoutine ( RexxActivity activity,
RexxString name,
RexxObject **  arguments,
size_t  argcount,
size_t  named_argcount,
ProtectedObject result 
)
static

Attempt to call a native code function. This will call either new-style package functions or old-style registered functions.

Parameters
activityThe activity we're running under.
nameThe target name of the routine.
argumentsThe function arguments.
argcountThe argument count.
resultThe return result.
Returns
true if we located and successfully called this function. false means the function is not located as a native function.

Definition at line 657 of file PackageManager.cpp.

References RexxDirectory::at(), OREF_NULL, packageRoutines, resolveRoutine(), and RexxString::upper().

Referenced by SystemInterpreter::invokeExternalFunction().

◆ checkRequiresCache()

RoutineClass * PackageManager::checkRequiresCache ( RexxString name,
ProtectedObject result 
)
staticprotected

Check for a package already in the requires cache.

Parameters
nameThe name of the target.
Returns
The PackageClass instance, if any.

Definition at line 900 of file PackageManager.cpp.

References WeakReference::get(), RexxHashTableCollection::get(), loadedRequires, OREF_NULL, and RexxDirectory::remove().

Referenced by loadRequires().

◆ createRegisteredRoutine()

RoutineClass * PackageManager::createRegisteredRoutine ( RexxString function)
static

Create a new registered function entry and add to the function cache.

Parameters
function
Returns

Definition at line 427 of file PackageManager.cpp.

References OREF_NULL, RexxDirectory::put(), registeredRoutines, and RexxResolveRoutine().

Referenced by resolveRoutine().

◆ dropRegisteredRoutine()

RexxObject * PackageManager::dropRegisteredRoutine ( RexxString name)
static

Drop a registered function.

Parameters
nameName of the registered function.
Returns
True if this was deregistered from the global table, false otherwise.

Definition at line 567 of file PackageManager.cpp.

References RexxString::getStringData(), registeredRoutines, RexxDirectory::remove(), RexxDeregisterFunction(), TheFalseObject, TheTrueObject, and RexxString::upper().

Referenced by BUILTIN().

◆ getImageData()

RexxArray * PackageManager::getImageData ( )
static

Return the information that needs to be saved in the saved image.

Returns
An array of the items added to the saved image.

Definition at line 93 of file PackageManager.cpp.

References IMAGE_ARRAY_SIZE, IMAGE_PACKAGE_ROUTINES, IMAGE_PACKAGES, IMAGE_REGISTERED_ROUTINES, IMAGE_REQUIRES, loadedRequires, new_array(), packageRoutines, packages, RexxArray::put(), and registeredRoutines.

Referenced by RexxMemory::saveImage().

◆ getLibrary()

LibraryPackage * PackageManager::getLibrary ( RexxString name)
static

Resolve a named package, dynamically loading the package if not already in the table.

Parameters
nameThe name of the library associated with this package.
Returns
A resolved package...throws an exception if the package is not loadable.

Definition at line 185 of file PackageManager.cpp.

References Error_Execution_library, and reportException().

Referenced by RexxActivation::loadLibrary(), and InterpreterInstance::processOptions().

◆ getLoadedRoutine()

RoutineClass * PackageManager::getLoadedRoutine ( RexxString function)
static

Locate an already loaded function.

Parameters
functionThe function name.
Returns
A function activator for this function, if it can be resolved.

Definition at line 403 of file PackageManager.cpp.

References RexxDirectory::at(), OREF_NULL, packageRoutines, and registeredRoutines.

Referenced by addRegisteredRoutine(), queryRegisteredRoutine(), and resolveRoutine().

◆ getMacroSpaceRequires()

RoutineClass * PackageManager::getMacroSpaceRequires ( RexxActivity activity,
RexxString name,
ProtectedObject result,
RexxObject securityManager 
)
static

Retrieve a ::REQUIRES file from the macrospace.

Parameters
activityThe current activity.
nameThe target name.
resultThe returned Routine object for the package.
securityManagerA security manager to associated with the package.
Returns
The located ::REQUIRES file.

Definition at line 782 of file PackageManager.cpp.

References RexxActivity::checkRequires(), RexxActivation::getMacroCode(), loadedRequires, OREF_NULL, RexxDirectory::put(), and RoutineClass::setSecurityManager().

Referenced by loadRequires().

◆ getRequiresFile()

RoutineClass * PackageManager::getRequiresFile ( RexxActivity activity,
RexxString name,
RexxObject securityManager,
ProtectedObject result 
)
static

Retrieve a file version of a ::REQUIRES file.

Parameters
activityThe current activity.
nameThe fully resolved file name.
resultThe return routine object.
Returns
The return Routine instance.

Definition at line 814 of file PackageManager.cpp.

References RexxActivity::checkRequires(), RoutineClass::fromFile(), OREF_NULL, and RoutineClass::setSecurityManager().

Referenced by loadRequires().

◆ initialize()

void PackageManager::initialize ( )
static

Initialize the package manager global state.

Definition at line 75 of file PackageManager.cpp.

References loadedRequires, loadInternalPackage(), loadLibrary(), new_directory(), packageRoutines, packages, registeredRoutines, and rexxPackage.

Referenced by RexxMemory::createImage().

◆ live()

void PackageManager::live ( size_t  liveMark)
static

Normal live marking.

Definition at line 156 of file PackageManager.cpp.

References loadedRequires, memory_mark, packageRoutines, packages, and registeredRoutines.

Referenced by RexxMemory::live().

◆ liveGeneral()

void PackageManager::liveGeneral ( int  reason)
static

Generalized live marking.

Definition at line 167 of file PackageManager.cpp.

References loadedRequires, memory_mark_general, packageRoutines, packages, and registeredRoutines.

Referenced by RexxMemory::liveGeneral().

◆ loadInternalPackage()

void PackageManager::loadInternalPackage ( RexxString name,
RexxPackageEntry p 
)
static

Load an internal package into our list. This does not load a library, but links package routines ones already contained inside the interpreter.

Parameters
nameName of the package...this is probably "REXX" or "REXXUTIL".
pThe package descriptor with the method and function list.

Definition at line 463 of file PackageManager.cpp.

References packages, and RexxDirectory::put().

Referenced by initialize(), and registerPackage().

◆ loadLibrary()

LibraryPackage * PackageManager::loadLibrary ( RexxString name)
static

Attempt to load a library without raising an error. Returns a LibraryPackage object for the library if the load was successful.

Parameters
nameThe target library name.
Returns
A LibraryPackage object for the library, or OREF_NULL if was not resolvable.

Definition at line 208 of file PackageManager.cpp.

References OREF_NULL, packages, RexxDirectory::put(), and RexxDirectory::remove().

Referenced by initialize(), and LoadLibraryPackage().

◆ loadMethod()

RexxNativeMethod * PackageManager::loadMethod ( RexxString packageName,
RexxString methodName 
)
static

Quietly create a Native method from a registered package.

Parameters
packageNameThe name of the package the library is loaded from.
methodNameThe name of the procedure to resolve from the package.
Returns
A Native method that represents this package entry. Returns NULL if not found.

Definition at line 263 of file PackageManager.cpp.

References OREF_NULL.

Referenced by RexxMethod::loadExternalMethod().

◆ loadRequires() [1/3]

RoutineClass * PackageManager::loadRequires ( RexxActivity activity,
RexxString name,
const char *  data,
size_t  length,
ProtectedObject result 
)
static

Loade a requires file from an in-store source. NOTE: This is not cached like the other requires files

Parameters
activityThe current activity.
nameThe fully resolved file name.
resultThe return routine object.
Returns
The return Routine instance.

Definition at line 841 of file PackageManager.cpp.

References checkRequiresCache(), loadedRequires, OREF_NULL, and RexxDirectory::put().

◆ loadRequires() [2/3]

RoutineClass * PackageManager::loadRequires ( RexxActivity activity,
RexxString name,
RexxArray data,
ProtectedObject result 
)
static

Loade a requires file from an array source. NOTE: This is not cached like the other requires files

Parameters
activityThe current activity.
nameThe fully resolved file name.
resultThe return routine object.
Returns
The return Routine instance.

Definition at line 873 of file PackageManager.cpp.

References checkRequiresCache(), loadedRequires, OREF_NULL, and RexxDirectory::put().

◆ loadRequires() [3/3]

RoutineClass * PackageManager::loadRequires ( RexxActivity activity,
RexxString shortName,
RexxString resolvedName,
ProtectedObject result 
)
static

Retrieve a ::REQUIRES file. This will cache the entries so that the same requires entry is returned for every request.

Parameters
activityThe current activity.
shortNameThe short name of the package.
resolvedNameThe fully resolved name of a potential package file. The short name is used for checking in the MacroSpace, the long name is used for file searches.
resultThe return package routine.
Returns
The package routine (also returned in the result protected object).

Definition at line 700 of file PackageManager.cpp.

References SecurityManager::checkRequiresAccess(), RexxActivity::getEffectiveSecurityManager(), getMacroSpaceRequires(), getRequiresFile(), RexxString::getStringData(), OREF_NULL, RexxQueryMacro(), and RXMACRO_SEARCH_BEFORE.

Referenced by InterpreterInstance::loadRequires().

◆ loadRoutine()

RoutineClass * PackageManager::loadRoutine ( RexxString packageName,
RexxString function 
)
static

Quietly load a package function. This goes explicitly to a loaded package to resolve the name rather than relying on the global cache. This will resolve to the same routine object as the global cache, but this prevents us from picking one a different one in case of a name conflict.

Parameters
packageNameThe package name.
functionThe function name.
Returns
A routine object for this function.

Definition at line 379 of file PackageManager.cpp.

References OREF_NULL.

Referenced by RoutineClass::loadExternalRoutine().

◆ queryRegisteredRoutine()

RexxObject * PackageManager::queryRegisteredRoutine ( RexxString name)
static

The query method backing RxFuncQuery(). This checks both our local tables and the global tables to see if something has been registered.

Parameters
nameTarget name.
Returns
True if the external function exists in our local tables or in the global registry.

Definition at line 600 of file PackageManager.cpp.

References getLoadedRoutine(), RexxString::getStringData(), OREF_NULL, RexxQueryFunction(), TheFalseObject, TheTrueObject, and RexxString::upper().

Referenced by BUILTIN().

◆ registerPackage()

bool PackageManager::registerPackage ( RexxString name,
RexxPackageEntry p 
)
static

Register an in-process library package.

Parameters
nameThe name to register under.
pThe package table information.
Returns
true if this was successfully registered, false if a package is already registered under the name.

Definition at line 485 of file PackageManager.cpp.

References RexxDirectory::at(), loadInternalPackage(), OREF_NULL, and packages.

Referenced by InterpreterInstance::processOptions(), and RegisterLibrary().

◆ resolveMethod()

RexxNativeMethod * PackageManager::resolveMethod ( RexxString packageName,
RexxString methodName 
)
static

Create a Native method from a registered package.

Parameters
packageNameThe name of the package the library is loaded from.
methodNameThe name of the procedure to resolve from the package.
Returns
A Native method that represents this package entry. Returns NULL if not found.

Definition at line 241 of file PackageManager.cpp.

References LibraryPackage::resolveMethod().

Referenced by RexxSource::createNativeMethod().

◆ resolveMethodEntry()

PNATIVEMETHOD PackageManager::resolveMethodEntry ( RexxString packageName,
RexxString name 
)
static

Resolve an entry point for a package method entry (used on a restore or reflatten);

Parameters
nameName of the target method.
Returns
The target entry point.

Definition at line 929 of file PackageManager.cpp.

References Error_Execution_library_method, and reportException().

Referenced by RexxNativeMethod::run().

◆ resolveRegisteredRoutineEntry()

PREGISTEREDROUTINE PackageManager::resolveRegisteredRoutineEntry ( RexxString packageName,
RexxString name 
)
static

Resolve an entry point for a package function entry (used on a restore or reflatten);

Parameters
nameName of the target function.
Returns
The target entry point.

Definition at line 971 of file PackageManager.cpp.

References Error_Execution_library_routine, RexxString::getStringData(), OREF_NULL, reportException(), and RexxResolveRoutine().

Referenced by RegisteredRoutine::call().

◆ resolveRoutine() [1/3]

RoutineClass * PackageManager::resolveRoutine ( RexxString function)
static

Resolve a registered function.

Parameters
functionThe function name.
Returns
A function activator for this function, if it can be resolved.

Definition at line 326 of file PackageManager.cpp.

References createRegisteredRoutine(), getLoadedRoutine(), and OREF_NULL.

◆ resolveRoutine() [2/3]

RoutineClass * PackageManager::resolveRoutine ( RexxString function,
RexxString packageName,
RexxString procedure 
)
static

Resolve a package function activator.

Parameters
functionThe function name.
packageThe package/library name.
procedureProcedure name. Only used if directly loaded from a library file.
Returns
A function activator for this function, if it can be resolved.

Definition at line 291 of file PackageManager.cpp.

References RexxDirectory::at(), createRegisteredRoutine(), RexxString::getStringData(), OREF_NULL, registeredRoutines, and RexxRegisterFunctionDll().

Referenced by addRegisteredRoutine(), callNativeRoutine(), and RexxSource::routineDirective().

◆ resolveRoutine() [3/3]

RoutineClass * PackageManager::resolveRoutine ( RexxString packageName,
RexxString function 
)
static

Resolve a package function. This goes explicitly to a loaded package to resolve the name rather than relying on the global cache. This will resolve to the same routine object as the global cache, but this prevents us from picking one a different one in case of a name conflict.

Parameters
packageNameThe package name.
functionThe function name.
Returns
A routine object for this function.

Definition at line 355 of file PackageManager.cpp.

References LibraryPackage::resolveRoutine().

◆ resolveRoutineEntry()

PNATIVEROUTINE PackageManager::resolveRoutineEntry ( RexxString packageName,
RexxString name 
)
static

Resolve an entry point for a package function entry (used on a restore or reflatten);

Parameters
nameName of the target function.
Returns
The target entry point.

Definition at line 950 of file PackageManager.cpp.

References Error_Execution_library_method, and reportException().

Referenced by RexxNativeRoutine::call().

◆ restore() [1/2]

◆ restore() [2/2]

void PackageManager::restore ( RexxArray imageArray)
static

Restore the saved image data.

Parameters
imageArrayThe array we placed in the save image originally.

Definition at line 111 of file PackageManager.cpp.

References RexxArray::get(), IMAGE_PACKAGE_ROUTINES, IMAGE_PACKAGES, IMAGE_REGISTERED_ROUTINES, IMAGE_REQUIRES, imageLoadedRequires, imagePackageRoutines, imagePackages, and imageRegisteredRoutines.

◆ unload()

Member Data Documentation

◆ imageLoadedRequires

RexxDirectory * PackageManager::imageLoadedRequires = OREF_NULL
staticprotected

Definition at line 114 of file PackageManager.hpp.

Referenced by restore(), and unload().

◆ imagePackageRoutines

RexxDirectory * PackageManager::imagePackageRoutines = OREF_NULL
staticprotected

Definition at line 112 of file PackageManager.hpp.

Referenced by restore(), and unload().

◆ imagePackages

RexxDirectory * PackageManager::imagePackages = OREF_NULL
staticprotected

Definition at line 111 of file PackageManager.hpp.

Referenced by restore(), and unload().

◆ imageRegisteredRoutines

RexxDirectory * PackageManager::imageRegisteredRoutines = OREF_NULL
staticprotected

Definition at line 113 of file PackageManager.hpp.

Referenced by restore(), and unload().

◆ loadedRequires

RexxDirectory * PackageManager::loadedRequires = OREF_NULL
staticprotected

◆ packageRoutines

RexxDirectory * PackageManager::packageRoutines = OREF_NULL
staticprotected

◆ packages

RexxDirectory * PackageManager::packages = OREF_NULL
staticprotected

◆ registeredRoutines

RexxDirectory * PackageManager::registeredRoutines = OREF_NULL
staticprotected

◆ rexxPackage

RexxPackageEntry * PackageManager::rexxPackage = &rexx_package_entry
staticprotected

Definition at line 122 of file PackageManager.hpp.

Referenced by initialize(), and restore().


The documentation for this class was generated from the following files: