Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Scripting class. More...
#include <ilviews/base/script.h>
Public Member Functions | |
IlvScriptContext (const IlSymbol *languageName, IlvScriptContext *parent) | |
Constructor. | |
IlvScriptContext (IlvScriptLanguage *, IlvScriptContext *parent) | |
Constructor. | |
virtual | ~IlvScriptContext () |
Destructor. | |
IlBoolean | add (IlUInt nScripts, const IlvScript *const *scripts, IlBoolean compileThem=((IlBoolean) 1)) |
Adds a group of scripts. | |
IlBoolean | add (const IlvScript *script, IlBoolean compileIt=((IlBoolean) 1)) |
Adds a new script. | |
virtual IlBoolean | bind (IlvView *v, const char *name) |
Binds a view object. | |
virtual IlBoolean | bind (IlvGraphic *g, const char *name) |
Binds a graphic object. | |
virtual IlBoolean | bind (IlvApplication *a, const char *name) |
Binds an application object. | |
IlUInt | getCardinal () const |
Gets the number of scripts. | |
IlvScriptContext * | getGlobal () const |
Gets the global context. | |
IlUInt | getIndex (const IlvScript *script) const |
Gets the index of a script. | |
IlvScriptLanguage * | getLanguage () const |
Gets the scripting language. | |
const IlSymbol * | getLanguageName () const |
Gets the name of the scripting language. | |
IlvScriptContext * | getParent () const |
Gets the parent context. | |
IlvScript * | getScript (const char *name) const |
Gets a script by name. | |
IlvScript * | getScript (IlUInt rank) const |
Gets a script by index. | |
IlBoolean | insert (IlUInt rank, const IlvScript *script, IlBoolean compileIt=((IlBoolean) 1)) |
Inserts a script. | |
IlBoolean | loadScript (const char *fileName, const char *name=0, IlBoolean compileIt=((IlBoolean) 1)) |
Loads a script file. | |
virtual IlvScript * | read (IlvInputFile &is, const char *pathName=0, IlBoolean compileIt=((IlBoolean) 1)) |
Reads a script. | |
IlBoolean | remove (IlUInt nScripts, const IlvScript *const *scripts) |
Removes a set of scripts. | |
IlBoolean | remove (IlUInt rank) |
Removes a script. | |
virtual IlBoolean | unBind (IlvView *v) |
Unbinds a view object. | |
virtual IlBoolean | unBind (IlvGraphic *g) |
Unbinds a graphic object. | |
virtual IlBoolean | unBind (IlvApplication *a) |
Unbinds an application object. | |
virtual void | write (IlvOutputFile &os) const |
Saves all the scripts. | |
Static Public Member Functions | |
static IlvScriptContext * | GetGlobal (const IlSymbol *languageName=0) |
Gets the global context of a given script language. | |
Protected Member Functions | |
virtual IlBoolean | compile (const IlvScript *script) |
Compiles a script. | |
virtual IlBoolean | compileScripts () |
Compiles all the scripts. |
Scripting class.
Library: display
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 * | , | |
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 IlvScriptContext::~IlvScriptContext | ( | ) | [virtual] |
Destructor.
Releases the memory used by the script context. It includes all the scripts that were stored in this context.
IlBoolean IlvScriptContext::add | ( | IlUInt | nScripts, | |
const IlvScript *const * | scripts, | |||
IlBoolean | compileThem = ((IlBoolean) 1) | |||
) |
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
. 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
. 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. |
virtual IlBoolean IlvScriptContext::bind | ( | IlvGraphic * | g, | |
const char * | name | |||
) | [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. |
virtual IlBoolean IlvScriptContext::bind | ( | IlvApplication * | a, | |
const char * | name | |||
) | [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. |
Compiles a script.
script | The script to be compiled. |
IlTrue
if compilation succeeds or IlFalse
if error are detected in the script. virtual IlBoolean IlvScriptContext::compileScripts | ( | ) | [protected, virtual] |
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.
static IlvScriptContext* IlvScriptContext::GetGlobal | ( | const IlSymbol * | languageName = 0 |
) | [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. |
IlvScriptContext* IlvScriptContext::getGlobal | ( | ) | const |
Gets the global context.
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.
IlvScript* IlvScriptContext::getScript | ( | const char * | name | ) | const |
Gets a script by name.
name | The name of the script you want to retrieve. |
Gets a script by index.
rank | The index of thee script you want to retrieve. |
IlBoolean IlvScriptContext::insert | ( | IlUInt | rank, | |
const IlvScript * | script, | |||
IlBoolean | compileIt = ((IlBoolean) 1) | |||
) |
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 = ((IlBoolean) 1) | |||
) |
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 IlvScript* IlvScriptContext::read | ( | IlvInputFile & | is, | |
const char * | pathName = 0 , |
|||
IlBoolean | compileIt = ((IlBoolean) 1) | |||
) | [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 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. 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
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 IlBoolean IlvScriptContext::unBind | ( | IlvGraphic * | g | ) | [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. |
virtual IlBoolean IlvScriptContext::unBind | ( | IlvApplication * | a | ) | [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 void IlvScriptContext::write | ( | IlvOutputFile & | os | ) | const [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 2012, 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.