Rogue Wave Views Foundation Package API Reference Guide |
Rogue Wave Views Documentation Home |
Scripting class. More...
#include <ilviews/base/script.h>
Public Member Functions | |
IlvScriptContext (IlvScriptLanguage *language, IlvScriptContext *parent) | |
Constructor. More... | |
IlvScriptContext (const IlSymbol *languageName, IlvScriptContext *parent) | |
Constructor. More... | |
virtual | ~IlvScriptContext () |
Destructor. More... | |
IlBoolean | add (const IlvScript *script, IlBoolean compileIt=IlTrue) |
Adds a new script. More... | |
IlBoolean | add (IlUInt nScripts, const IlvScript *const *scripts, IlBoolean compileThem=IlTrue) |
Adds a group of scripts. More... | |
virtual IlBoolean | bind (IlvApplication *a, const char *name) |
Binds an application object. More... | |
virtual IlBoolean | bind (IlvGraphic *g, const char *name) |
Binds a graphic object. More... | |
virtual IlBoolean | bind (IlvView *v, const char *name) |
Binds a view object. More... | |
IlUInt | getCardinal () const |
Gets the number of scripts. More... | |
IlvScriptContext * | getGlobal () const |
Gets the global context. More... | |
IlUInt | getIndex (const IlvScript *script) const |
Gets the index of a script. More... | |
IlvScriptLanguage * | getLanguage () const |
Gets the scripting language. More... | |
const IlSymbol * | getLanguageName () const |
Gets the name of the scripting language. More... | |
IlvScriptContext * | getParent () const |
Gets the parent context. More... | |
IlvScript * | getScript (IlUInt rank) const |
Gets a script by index. More... | |
IlvScript * | getScript (const char *name) const |
Gets a script by name. More... | |
IlBoolean | insert (IlUInt rank, const IlvScript *script, IlBoolean compileIt=IlTrue) |
Inserts a script. More... | |
IlBoolean | loadScript (const char *fileName, const char *name=0, IlBoolean compileIt=IlTrue) |
Loads a script file. More... | |
virtual IlvScript * | read (IlvInputFile &is, const char *pathName=0, IlBoolean compileIt=IlTrue) |
Reads a script. More... | |
IlBoolean | remove (IlUInt rank) |
Removes a script. More... | |
IlBoolean | remove (IlUInt nScripts, const IlvScript *const *scripts) |
Removes a set of scripts. More... | |
virtual IlBoolean | unBind (IlvApplication *a) |
Unbinds an application object. More... | |
virtual IlBoolean | unBind (IlvGraphic *g) |
Unbinds a graphic object. More... | |
virtual IlBoolean | unBind (IlvView *v) |
Unbinds a view object. More... | |
virtual void | write (IlvOutputFile &os) const |
Saves all the scripts. More... | |
Static Public Member Functions | |
static IlvScriptContext * | GetGlobal (const IlSymbol *languageName=0) |
Gets the global context of a given script language. More... | |
Protected Member Functions | |
virtual IlBoolean | compile (const IlvScript *script) |
Compiles a script. More... | |
virtual IlBoolean | compileScripts () |
Compiles all the scripts. More... | |
Scripting class.
Library: xviews or winviews or mviews (mutually exclusive)
This class holds the information relative to a scripting language context. Typically, the IlvScriptContext
class defines the scope of variables and functions.
Script contexts are typically stored in context hierarchies that allow for definition of variables or functions that will be accessible for all child contexts, but not parents.
IlvScript
, IlvScriptFunction
, IlvScriptLanguage
. IlvScriptContext::IlvScriptContext | ( | IlvScriptLanguage * | language, |
IlvScriptContext * | parent | ||
) |
Constructor.
Initializes a new, empty script context.
language | The script language of this script context. |
parent | The parent of this context. |
IlvScriptContext::IlvScriptContext | ( | const IlSymbol * | languageName, |
IlvScriptContext * | parent | ||
) |
Constructor.
You will use this constructor if you want to be able to manipulate scripts and script contexts even though no scripting language has been linked.
languageName | The name of the script language that this script context should use. |
parent | The parent of this context. |
|
virtual |
Destructor.
Releases the memory used by the script context. It includes all the scripts that were stored in this context.
Adds a new script.
Adds a new script to the context and compiles it if compileIt
is set to IlTrue
. The return value is that of the call to compile
or IlTrue
if compileIt
is set to IlFalse
.
script | A pointer to the script object to be added. |
compileIt | A flag that indicates whether or not you want to compile the script when it is added. |
compile
if compileIt is set to IlTrue
, or IlTrue
if compileIt is set to IlFalse
. IlBoolean IlvScriptContext::add | ( | IlUInt | nScripts, |
const IlvScript *const * | scripts, | ||
IlBoolean | compileThem = IlTrue |
||
) |
Adds a group of scripts.
nScripts | The number of scripts to be added (that is, the number of elements in the array scripts). |
scripts | The array of pointers to the scripts to be added. This array must have at least nScripts elements, and is copied internally. The scripts are added but not copied. |
compileThem | A flag that indicates whether or not you want to compile the scripts when they are added. |
compileScript
if compileThem is set to IlTrue
, or IlTrue
if compileThem is set to IlFalse
.
|
virtual |
Binds an application object.
This member function makes it possible for a scripting language to access an application object.
a | The application object. |
name | The name of this object, as known by this script context. |
|
virtual |
Binds a graphic object.
This member function makes it possible for a scripting language to access a graphic object.
g | The graphic object. |
name | The name of this object, as known by this script context. |
Binds a view object.
This member function makes it possible for a scripting language to access a view object.
v | The view object. |
name | The name of this object, as known by this script context. |
Compiles a script.
script | The script to be compiled. |
IlTrue
if compilation succeeds or IlFalse
if error are detected in the script.
|
protectedvirtual |
Compiles all the scripts.
IlTrue
if compilation succeeds or IlFalse
if errors are detected in the script. IlUInt IlvScriptContext::getCardinal | ( | ) | const |
Gets the number of scripts.
IlvScriptContext* IlvScriptContext::getGlobal | ( | ) | const |
Gets the global context.
|
static |
Gets the global context of a given script language.
This member function lets you access the global context of any scripting language. If languageName is 0 (which is the default value) then the global context of the default scripting language is returned.
languageName | The symbol that identifies the scripting language. |
Gets the index of a script.
script | A pointer to the script you want to query the index. |
IlvScriptLanguage* IlvScriptContext::getLanguage | ( | ) | const |
Gets the scripting language.
const IlSymbol* IlvScriptContext::getLanguageName | ( | ) | const |
Gets the name of the scripting language.
IlvScriptContext* IlvScriptContext::getParent | ( | ) | const |
Gets the parent context.
Gets a script by index.
rank | The index of thee script you want to retrieve. |
IlvScript* IlvScriptContext::getScript | ( | const char * | name | ) | const |
Gets a script by name.
name | The name of the script you want to retrieve. |
IlBoolean IlvScriptContext::insert | ( | IlUInt | rank, |
const IlvScript * | script, | ||
IlBoolean | compileIt = IlTrue |
||
) |
Inserts a script.
Inserts a new script at the indicated position in the script list. This member function has the same behavior as the add
method.
rank | The index where the script is inserted. 0 indicates that the script will be inserted first. |
script | The script to be inserted. |
compileIt | A flag that indicates whether or not you want to compile the script when it is added. |
compile
if compileIt is set to IlTrue
, or IlTrue
if compileIt is set to IlFalse
. IlBoolean IlvScriptContext::loadScript | ( | const char * | fileName, |
const char * | name = 0 , |
||
IlBoolean | compileIt = IlTrue |
||
) |
Loads a script file.
If fileName indicates a path where a valid script code is stored, a new script is created and added to the context.
fileName | The path name of the script to be loaded. |
name | The name that will be given to that script, or 0 if you don't want to name that script. This parameter is sent to the constructor of the class IlvScript . |
compileIt | A flag that indicates whether or not you want to compile the script when it is added to the context. |
IlTrue
if the call was successful, or IlFalse
if there has been an error.
|
virtual |
Reads a script.
This method is called when a Rogue Wave Views input stream is read, and when this stream contains scripts to be read. The call is performed on the script context of the holder that reads the stream. For each of the scripts that must be read, this function is called, and the created scripts are added to the context by a call to the add
member function.
is | The input stream from which the script is read. |
pathName | The pathname of that script, or 0 if the script is not loaded from a stream that has a path name. This string is used to display error messages when the script is compiled (that is, when compileIt is set to IlTrue ). |
compileIt | A flag that indicates, when set to IlTrue , that this script should be compiled when loaded. There are situations where you don't want to compile a script at load time. you should then set this parameter to IlFalse . |
Removes a script.
The script is removed from the scripts list, but it is not deleted.
rank | The index of the script to be removed. |
IlTrue
Removes a set of scripts.
The scripts are removed from the scripts list, but they are not deleted.
nScripts | The number of script to be removed (this is also the minimum size of the array scripts). |
scripts | The array of pointers to the scripts to be removed. This array must have at least nScripts elements. |
IlFalse
if the array contains a script that is not found in the script context. In such case, the method does not stop and tries to remove the other scripts.
|
virtual |
Unbinds an application object.
This member function removes the binding of an application object in this script context.
a | The application object to be unbound. |
|
virtual |
Unbinds a graphic object.
This member function removes the binding of a graphic object in this script context.
g | The graphic object to be unbound. |
Unbinds a view object.
This member function removes the binding of a view object in this script context.
v | The view object to be unbound. |
|
virtual |
Saves all the scripts.
After a small header, each one of the IlvScript::write
member functions in all the scripts that belong to this context is called in turn.
os | The output file where scripts will be saved. |
© Copyright 2018, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.