rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions
IlvScriptContext Class Reference

Scripting class. More...

#include <ilviews/base/script.h>

Public Member Functions

 IlvScriptContext (IlvScriptLanguage *, 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...
 
IlvScriptContextgetGlobal () const
 Gets the global context. More...
 
IlUInt getIndex (const IlvScript *script) const
 Gets the index of a script. More...
 
IlvScriptLanguagegetLanguage () const
 Gets the scripting language. More...
 
const IlSymbolgetLanguageName () const
 Gets the name of the scripting language. More...
 
IlvScriptContextgetParent () const
 Gets the parent context. More...
 
IlvScriptgetScript (IlUInt rank) const
 Gets a script by index. More...
 
IlvScriptgetScript (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 IlvScriptread (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 IlvScriptContextGetGlobal (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...
 

Detailed Description

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.

See Also
IlvScript, IlvScriptFunction, IlvScriptLanguage.

Constructor & Destructor Documentation

IlvScriptContext::IlvScriptContext ( IlvScriptLanguage ,
IlvScriptContext parent 
)

Constructor.

Initializes a new, empty script context.

Parameters
languageThe script language of this script context.
parentThe 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.

Parameters
languageNameThe name of the script language that this script context should use.
parentThe 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.

Member Function Documentation

IlBoolean IlvScriptContext::add ( const IlvScript script,
IlBoolean  compileIt = IlTrue 
)

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.

Parameters
scriptA pointer to the script object to be added.
compileItA flag that indicates whether or not you want to compile the script when it is added.
Returns
The returned value of the call to 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.

Parameters
nScriptsThe number of scripts to be added (that is, the number of elements in the array scripts).
scriptsThe 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.
compileThemA flag that indicates whether or not you want to compile the scripts when they are added.
Returns
The returned value of the call to compileScript if compileThem is set to IlTrue, or IlTrue if compileThem is set to IlFalse.
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.

Parameters
aThe application object.
nameThe 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.

Parameters
gThe graphic object.
nameThe name of this object, as known by this script context.
virtual IlBoolean IlvScriptContext::bind ( IlvView v,
const char *  name 
)
virtual

Binds a view object.

This member function makes it possible for a scripting language to access a view object.

Parameters
vThe view object.
nameThe name of this object, as known by this script context.
virtual IlBoolean IlvScriptContext::compile ( const IlvScript script)
protectedvirtual

Compiles a script.

Parameters
scriptThe script to be compiled.
Returns
IlTrue if compilation succeeds or IlFalse if error are detected in the script.
virtual IlBoolean IlvScriptContext::compileScripts ( )
protectedvirtual

Compiles all the scripts.

Returns
IlTrue if compilation succeeds or IlFalse if errors are detected in the script.
IlUInt IlvScriptContext::getCardinal ( ) const

Gets the number of scripts.

Returns
The number of scripts that are stored in this script context.
IlvScriptContext* IlvScriptContext::getGlobal ( ) const

Gets the global context.

Returns
The global context of the scripting language to which the context belongs.
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.

Parameters
languageNameThe symbol that identifies the scripting language.
Returns
The global context of the scripting language whose name is stored in languageName symbol.
IlUInt IlvScriptContext::getIndex ( const IlvScript script) const

Gets the index of a script.

Parameters
scriptA pointer to the script you want to query the index.
Returns
The index of the script script in this context.
IlvScriptLanguage* IlvScriptContext::getLanguage ( ) const

Gets the scripting language.

Returns
A pointer to the scripting language to which the context belongs.
const IlSymbol* IlvScriptContext::getLanguageName ( ) const

Gets the name of the scripting language.

Returns
The symbol that references the name of the scripting language to which the context belongs.
IlvScriptContext* IlvScriptContext::getParent ( ) const

Gets the parent context.

Returns
The parent context of this context, or 0 if there is none.
IlvScript* IlvScriptContext::getScript ( IlUInt  rank) const

Gets a script by index.

Parameters
rankThe index of thee script you want to retrieve.
Returns
The script stored at the index rank, or 0 if rank is invalid.
IlvScript* IlvScriptContext::getScript ( const char *  name) const

Gets a script by name.

Parameters
nameThe name of the script you want to retrieve.
Returns
The script that has a name equal to name, or 0 if no such script is stored in this context.
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.

Parameters
rankThe index where the script is inserted. 0 indicates that the script will be inserted first.
scriptThe script to be inserted.
compileItA flag that indicates whether or not you want to compile the script when it is added.
Returns
The returned value of the call to 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.

Parameters
fileNameThe path name of the script to be loaded.
nameThe 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.
compileItA flag that indicates whether or not you want to compile the script when it is added to the context.
Returns
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 = IlTrue 
)
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.

Parameters
isThe input stream from which the script is read.
pathNameThe 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).
compileItA 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.
Returns
A pointer to the new loaded script object, or 0 if an error occurred
IlBoolean IlvScriptContext::remove ( IlUInt  rank)

Removes a script.

The script is removed from the scripts list, but it is not deleted.

Parameters
rankThe index of the script to be removed.
Returns
IlTrue
IlBoolean IlvScriptContext::remove ( IlUInt  nScripts,
const IlvScript *const *  scripts 
)

Removes a set of scripts.

The scripts are removed from the scripts list, but they are not deleted.

Parameters
nScriptsThe number of script to be removed (this is also the minimum size of the array scripts).
scriptsThe array of pointers to the scripts to be removed. This array must have at least nScripts elements.
Returns
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 IlBoolean IlvScriptContext::unBind ( IlvApplication *  a)
virtual

Unbinds an application object.

This member function removes the binding of an application object in this script context.

Parameters
aThe application 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.

Parameters
gThe graphic object to be unbound.
virtual IlBoolean IlvScriptContext::unBind ( IlvView v)
virtual

Unbinds a view object.

This member function removes the binding of a view object in this script context.

Parameters
vThe view 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.

Parameters
osThe 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.