ddl.LoaderRegistry



class LibraryVersionException: object.Exception;
Exception class used exclusively by the Linker.

LibraryVersionException are generated when the linker can load a library but it does not match the requested version as embedded in that module's metadata (std.version).

char[] getLibraryName();
The name of the library that was the cause of the exception

char[] getRequiredStdVersion();
The required version for the library

char[] getLibStdVersion();
The value of std.version in the libary

this(char[] libraryName, char[] requiredStdVersion, char[] libStdVersion);
Constructor.

char[] libraryName the name of the library involved.
char[] requiredStdVersion the required version of the library
char[] libStdVersion the version that the library actually has (if it has one at all).


class LoaderRegistry;
The LoaderRegistry fufills the role of controlling access to the loaders to be used for a set of library load operations. While this is most directly used by the Linker class, the registry can be used independently of a given linker. In fact, several implementations of the DynamicLibrary class use the registry to support nested libraries. This is accomplished by the registry passing a reference to itself forward through every call to load() on a given loader.

It also helps to establish a coherent set of support for a given chain of library loads. Should a developer not want OMF or COFF support in their application, they can simply compose a registry that does not utilize either of those loaders. This also helps prevent program bloat by not taking on classes that support types that are not needed.

The DefaultRegistry provides a boilerplate implementation of the LoaderRegistry, that pulls in every standard loader that DDL provides. Efficency minded developers should look to rolling their own LoaderRegistry intstead.

void register(DynamicLibraryLoader loader);
Registers a loader within the registry. The loader will then be used in subsequent calls to load (and its variants) to investigate if it can load a given file (via canLoadLibrary) and to actually load a library (via load).

The loader is associated in the registry via its type (loader.getLibraryType()). Should another loader of the same exact type be passed to this method, the latter loader will be associated instead.

DynamicLibraryLoader loader the loader to register.


DynamicLibraryLoader getLoader(char[] type);
Returns:
a loader for the type given, or none if there is no loader for the associated type.

char[] type the type of loader to find.


DynamicLibrary load(FileBuffer buffer, char[] attrStdVersion = "");
Returns:
a dynamic library for the requested file, or null if there is no loader for the given library.

If the attrStdVersion parameter is supplied this is matched against the "std.version" attribute in the supplied library. If the attribute doesn't exist, and or the attrStdVersion attribute is omitted or set to "", then the library is loaded anyway. Otherwise, should attrStdVersion not match the "std.version" attribute, the method throws an exception.

FileBuffer buffer buffer for the binary file
char[] attrStdVersion (optional) the version of the library to match


DynamicLibrary load(char[] filename, char[] attrStdVersion = "");
Returns:
a dynamic library for the requested filename, or null if there is no loader for the given library.

If the attrStdVersion parameter is supplied this is matched against the "std.version" attribute in the supplied library. If the attribute doesn't exist, and or the attrStdVersion attribute is omitted or set to "", then the library is loaded anyway. Otherwise, should attrStdVersion not match the "std.version" attribute, the method throws an exception.

file the filename of the library to load.
char[] attrStdVersion (optional) the version of the library to match


bool canLoad(FileBuffer file);
Returns:
true if the file can be loaded, false if it cannot.

FileBuffer file the file to test. The file is expected to already be loaded.


bool canLoad(char[] filename);
Returns:
true if the file can be loaded, false if it cannot.

char[] filename name of the file to test.


char[][] getSupportedTypes();
Returns:
an array of type names for all the supported loaders in this registry.

bool isSupported(char[] type);
Returns:
true if the typename is supported, false if it is not.

char[] type the name of the type to test. See DynamicLibraryLoader.getLibraryType() for more infomation.