The terms
module and
module
context are used interchangeably. In SAS Micro Analytic
Service 1.2, a module context represents either of the following:
named C module
a collection of related
C functions
DS2 package
a collection of related
DS2 methods (also referred to in SAS Micro Analytic Service as a DS2
module).
A module context contains
revisions of C or DS2 code. The revisions within a module context
might contain different source code, but all revisions must represent
the same named DS2 package or C module. That is, for DS2 modules the
package name that is given in the source code is not allowed to change
from revision to revision. If it does, an error is returned and the
revision is not created.
In addition to zero
or more revisions, a module context maintains information such as
a description, highest revision number used, number of revisions present,
programming language (C or DS2, for SAS Micro Analytic Service), messages
from the most recent compilation, creation date and time, and last
modified date and time.
Here is a list of available
module contexts:
newModuleContext
long newModuleContext(long userContext,
TkLight.Language language,
java.lang.String displayName,
java.util.EnumSet<TkLight.ModuleOptions> options)
Creates a new module
context within the given user context. A module is a collection of
related steps (a DS2 package or collection of C routines). Add code
to the module context by calling newRevision().
Note: For DS2 packages, the module
displayName is assigned the DS2 package name when the first revision
is created.
Note: DS2 packages containing non-void
methods or methods with DS2 package arguments are treated as internal
and are not returned in queries for the list of methods. It is permissible
to include private methods that do not produce errors, as long as
the code is valid. See
Public and Private Methods and Packages.
Parameters
userContext - The opaque
handle returned from newUserContext().
language - Source language
(C or DS2).
displayName - For DS2,
set it to the DS2 package name. For C, any text identifier is acceptable.
options - If the EnumSet
contains enum INTERNAL, the module context and all revisions are private.
Return
module context - The
module context created (opaque handles), returns zero on error.
Note: The module context handle
that is returned from newModuleContext() actually represents a C language
pointer in SAS Micro Analytic Service core. This handle is opaque
to Java and represented as a value of type long.
This value is used to pass to any method that requires a module context
identifier, and should not be modified.
deleteModuleContext
void deleteModuleContext(long moduleContext)
Deletes the specified
module context and its modules and revisions.
Parameter
moduleContext - The
opaque module context handle
moduleContextExists
boolean moduleContextExists(long moduleContext)
Queries the existence
of a module context.
Parameter
moduleContext - The
opaque module context handle
Return
Boolean - True if context
exists, False otherwise.
getModuleContextDisplayName
java.lang.String
getModuleContextDisplayName(long moduleContext)
Retrieves the display
name of the given module context.
Parameter
moduleContext - The
opaque module context handle.
getModuleContextByName
long getModuleContextByName
(long userContext,java.lang.String name)
Retrieves the module
context opaque handle, when given the display name. This method is
provided as a convenience for clients that choose to identify modules
by name. Callers are responsible for guaranteeing name uniqueness.
Parameters
userContext - The opaque
handle returned from newUserContext().
name - DS2 package
name or C module display name.
Note: For DS2 packages, the module
context name is the name of the DS2 package, which is set when the
first revision is created. If a module context must be retrieved
by name before the first revision is created, then the displayName
argument to newModuleContext() must be set to the correct name (the
name of the DS2 package to be subsequently published) when the module
context is created.
getModuleContextCreationDateTime
java.util.Date
getModuleContextCreationDateTime(long moduleContext)
Gets the module context
creation datetime.
Parameter
moduleContext - The
opaque handle returned from newModuleContext().
Returns
Creation datetime in
SAS form (GMT seconds since 1960).
getModuleContextLastModifiedDateTime
java.util.Date
getModuleContextLastModifiedDateTime(long moduleContext)
Gets the module context’s
last modified datetime.
Parameter
moduleContext - The
opaque handle returned from newModuleContext().
Return
The creation datetime
in SAS form (GMT seconds since 1960).
registerModuleName
int registerModuleName(long moduleContext,
java.lang.String name)
Registers a module
name so that it can participate in calls across code streams. Call
this function to enable other C modules to call functions on the given
module. Calls across code streams can be made by C modules only.
Note: Although DS2 cannot call
across code streams, DS2 package methods can call methods in other
packages. An in-memory DS2 program repository enables DS2 package
references to be resolved at compile time, so that a complete set
of referenced packages is compiled into every code stream. Therefore,
calls across code streams are not necessary with DS2 modules. However,
C modules require external modules to be registered, using this method,
in order to locate the external module at run time.
Parameter
moduleContext - The
opaque handle returned from newModuleContext().
name - The name to
assign the module (must be unique within the user context).
Return
result code - Zero
indicates successful registration nonzero indicates registration failed.