|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sisc.util.Util sisc.interpreter.Context
public abstract class Context
Context is a utility class which facilitates Java to Scheme
calls in SISC.
Typically, this involves obtaining an Interpreter for a given
initialized AppContext
, using the Interpreter for one or more
evaluations, then exiting the context, as follows:
AppContext ctx = ... Interpreter r=Context.enter(ctx); r.eval(someProcedure, new Value[] { ... some arguments ... }); Context.exit();Preferrably, one should use the SchemeCaller supported visitor pattern to allow Context to handle the management of the Interpreter Context, as follows:
Object returnValue=Context.execute(ctx, mySchemeCaller);The provided SchemeCaller instance's execute method is invoked with an Interpreter which is automatically obtained and then returned when the call completes. The return value of the SchemeCaller's execute method is returned from the Context method.
SchemeCaller
,
AppContext
,
Interpreter
Field Summary |
---|
Fields inherited from class sisc.util.Util |
---|
BACKQUOTE, BEGIN, bundles, caseSensitive, EMPTYLIST, EMPTYVEC, EOF, ERRORK, EVAL, EXPSC, EXPTOP, FALSE, FCONT, FIVE, JEXCEPTION, LAMBDA, LOCATION, maxFloatPrecision, MESSAGE, minFloatPrecision, NAME, OTHER, PARENT, permitInterrupts, QUOTE, QUOTESYM, REPORT, SETBANG, SISC, SISC_SPECIFIC, SISCB, SOURCE_COLUMN, SOURCE_FILE, SOURCE_LINE, SYMENV, THIS, TOPLEVEL, TRUE, UNQUOTE, UNQUOTE_SPLICING, VOID, ZV |
Fields inherited from interface sisc.util.Version |
---|
VERSION |
Constructor Summary | |
---|---|
Context()
|
Method Summary | |
---|---|
static AppContext |
currentAppContext()
Returns the AppContext of any current interpreter in an internal call, or the default AppContext if no current interpreter is present. |
static Interpreter |
currentInterpreter()
Fetches the current Interpreter, if this is an internal call (that is, a call from Java to Scheme in the contex of a Scheme->Java call). |
static Interpreter |
currentInterpreter(AppContext ctx)
Fetches the nearest enclosing Interpreter that operates on a given AppContext, if this is an internal call (that is, a call from Java to Scheme in the contex of a Scheme->Java call). |
static Interpreter |
enter()
Returns an Interpreter that shares the AppContext and DynamicEnvironment with the current Interpreter. |
static Interpreter |
enter(AppContext ctx)
Returns an Interpreter bound to the given AppContext with same DynamicEnvironment as the nearest enclosing Interpreter in the same thread that is bound to the same AppContext. |
static Interpreter |
enter(DynamicEnvironment dynenv)
Returns an Interpreter bound to the given DynamicEnvironment. |
static Interpreter |
enter(java.lang.String appName)
Deprecated. use enter(AppContext) instead |
static java.lang.Object |
execute(AppContext ctx,
SchemeCaller caller)
Calls caller with an Interpreter bound to the given AppContext with same DynamicEnvironment as the nearest enclosing Interpreter in the same thread that is bound to the same AppContext. |
static java.lang.Object |
execute(DynamicEnvironment dynenv,
SchemeCaller caller)
Obtains an Interpreter bound to the given DynamicEnvironment and invokes caller.execute(Interpreter) with that Interper. |
static java.lang.Object |
execute(SchemeCaller caller)
Calls caller with an Interpreter that shares the AppContext and DynamicEnvironment with the current Interpreter. |
static java.lang.Object |
execute(java.lang.String appName,
SchemeCaller caller)
Deprecated. use execute(AppContext, SchemeCaller) instead |
static void |
exit()
Exits the current context, releasing the current Interpreter. |
static AppContext |
getDefaultAppContext()
Returns the currently set default AppContext, or creates a new AppContext with default values if non was already set, and attempts to initialize it with the default heap. |
static AppContext |
lookup(java.lang.String appName)
Deprecated. |
static ThreadContext |
lookupThreadContext()
thread context lookup |
static void |
register(java.lang.String appName,
AppContext ctx)
Deprecated. |
static void |
setDefaultAppContext(AppContext ctx)
Sets the default AppContext, which is used sparingly whenever a call originates from uncontrolled Java source that involves the Scheme environment. |
static void |
unregister(java.lang.String appName)
Deprecated. |
Methods inherited from class sisc.util.Util |
---|
annotated, annotatedAppEval, append, argCheck, argsToSymbols, assq, bininport, bininstream, binoutport, binoutstream, box, character, charinport, charinreader, charoutport, charoutwriter, charsetFromString, chr, cont, currentClassLoader, env, error, error, error, error, error, error, error, expr, getDefaultCharacterSet, immutablePair, immutableVector, inport, javaExceptionToString, javaWrap, justify, length, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, list, list, list, list, list, makeURL, mapcar, memq, nlib, num, outport, pair, pairToExpressions, pairToExpVect, pairToValues, proc, read, registerBundle, reverse, reverseInPlace, simpleErrorToString, sourceAnnotations, str, string, sym, symbol, symval, truePair, truth, truth, typeError, typeError, updateName, url, url, url, valArrayToList, valArrayToList, valArrayToVec, vec, warn, warn, warn |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Context()
Method Detail |
---|
public static void register(java.lang.String appName, AppContext ctx)
public static void unregister(java.lang.String appName)
public static AppContext lookup(java.lang.String appName)
public static ThreadContext lookupThreadContext()
public static Interpreter currentInterpreter()
public static Interpreter currentInterpreter(AppContext ctx)
ctx
- the AppContext
public static void setDefaultAppContext(AppContext ctx)
ctx
- the AppContext to make the default.public static AppContext getDefaultAppContext()
public static AppContext currentAppContext()
public static Interpreter enter()
Interpreter
public static Interpreter enter(AppContext ctx)
ctx
- The AppContext
public static Interpreter enter(DynamicEnvironment dynenv)
dynenv
- The DynamicEnvironment
public static Interpreter enter(java.lang.String appName)
enter(AppContext)
instead
public static void exit()
public static java.lang.Object execute(SchemeCaller caller) throws SchemeException
caller
- The SchemeCaller to invoke
SchemeException
public static java.lang.Object execute(AppContext ctx, SchemeCaller caller) throws SchemeException
ctx
- The AppContextcaller
- The SchemeCaller to invoke.
SchemeException
public static java.lang.Object execute(DynamicEnvironment dynenv, SchemeCaller caller) throws SchemeException
dynenv
- The DynamicEnvironment.caller
- The SchemeCaller to invoke.
SchemeException
public static java.lang.Object execute(java.lang.String appName, SchemeCaller caller)
execute(AppContext, SchemeCaller)
instead
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |