rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IlvScriptContext Class Reference

Scripting class. More...

#include <ilviews/base/script.h>

List of all members.

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

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:
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.

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


Member Function Documentation

IlBoolean IlvScriptContext::add ( IlUInt  nScripts,
const IlvScript *const *  scripts,
IlBoolean  compileThem = ((IlBoolean) 1) 
)

Adds a group of scripts.

Parameters:
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.
Returns:
The returned value of the call to compileScript if compileThem is set to IlTrue, or IlTrue if compileThem is set to IlFalse.
IlBoolean IlvScriptContext::add ( const IlvScript script,
IlBoolean  compileIt = ((IlBoolean) 1) 
)

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:
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.
Returns:
The returned value of the call to compile if compileIt is set to IlTrue, or IlTrue if compileIt is set to IlFalse.
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:
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.

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

Parameters:
a The application object.
name The name of this object, as known by this script context.
virtual IlBoolean IlvScriptContext::compile ( const IlvScript script  )  [protected, virtual]

Compiles a script.

Parameters:
script The script to be compiled.
Returns:
IlTrue if compilation succeeds or IlFalse if error are detected in the script.
virtual IlBoolean IlvScriptContext::compileScripts (  )  [protected, virtual]

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.
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:
languageName The symbol that identifies the scripting language.
Returns:
The global context of the scripting language whose name is stored in languageName symbol.
IlvScriptContext* IlvScriptContext::getGlobal (  )  const

Gets the global context.

Returns:
The global context of the scripting language to which the context belongs.
IlUInt IlvScriptContext::getIndex ( const IlvScript script  )  const

Gets the index of a script.

Parameters:
script A 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 ( const char *  name  )  const

Gets a script by name.

Parameters:
name The 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.
IlvScript* IlvScriptContext::getScript ( IlUInt  rank  )  const

Gets a script by index.

Parameters:
rank The index of thee script you want to retrieve.
Returns:
The script stored at the index rank, or 0 if rank is invalid.
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.

Parameters:
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.
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 = ((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.

Parameters:
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.
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 = ((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.

Parameters:
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.
Returns:
A pointer to the new loaded script object, or 0 if an error occurred
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:
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.
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.
IlBoolean IlvScriptContext::remove ( IlUInt  rank  ) 

Removes a script.

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

Parameters:
rank The index of the script to be removed.
Returns:
IlTrue
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:
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.

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

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

Parameters:
os The output file where scripts will be saved.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

© 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.