MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
Mezzanine::Scripting::iScript Class Referenceabstract

The interface for a script. More...

#include <script.h>

+ Inheritance diagram for Mezzanine::Scripting::iScript:

Public Member Functions

 iScript ()
 default constructor More...
 
virtual void AddArgument (CountedPtr< iScriptArgument > Arg)=0
 This adds an argument to be passed to the script. More...
 
virtual bool CanReturnMultples ()
 Does this script support multiple return values. More...
 
virtual void ClearArguments ()=0
 Remove all the ARGs!!! http://imgur.com/DJhw7. More...
 
Whole DecrementReferenceCount ()
 Decrease the reference count by one and return the updated count. More...
 
virtual CountedPtr
< iScriptArgument
GetArgument (Whole ArgNumber) const =0
 Retrieve a argument previously passed in. More...
 
virtual Whole GetArgumentCount () const =0
 How many arguments have been attached to this script? More...
 
virtual iScriptMultipleReturnGetAsiScriptMultipleReturn ()
 If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptMultipleReturn if it would be valid. More...
 
virtual iScriptCompilableGetAsScriptCompilable ()
 If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptCompilable if it would be valid. More...
 
virtual iScriptCompilableGetAsScriptCompilable () const
 If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptCompilable if it would be valid. More...
 
virtual iScriptGetMostDerived ()
 Get a pointer to the most Derived type of this class. More...
 
Whole GetReferenceCount ()
 Get the current amount of references. More...
 
virtual iScriptGetReferenceCountTargetAsPointer ()
 Gets the actual pointer to the target. More...
 
virtual String GetSourceCode () const =0
 If present this returns the code of script. More...
 
Whole IncrementReferenceCount ()
 Increase the reference count by one and return the updated count. More...
 
virtual bool IsCompilable () const
 Used to check if this Script supports compilation bytecode. More...
 
virtual bool IsCompiled () const
 Used to check if there is a bytecode version of the script available. More...
 
virtual void RemoveArgument (CountedPtr< iScriptArgument > Arg)=0
 Remove an argument based on a CountedPtr to the script. More...
 
virtual void RemoveArgument (Whole ArgNumber)=0
 Remove a Script argument based on the order it will be passed into the Script at Execution. More...
 
virtual void SetSourceCode (const String &Code)=0
 Sets the string version of the script. More...
 

Protected Attributes

Whole RefCount
 This is the Counter that stores how many references exist.
 

Detailed Description

The interface for a script.

All the methods that all scripts for all languages must implement. These are tiny pieces of data that can be run like miniature programs.

These can be executed by passing them to the appropriate Script Manager.

This uses multiple inheritance to minimize the amount of features a scripting langauge with need to implement. It is expected that a simple scripting language may only need to implement the base iScript interface. Other languages that support more features can have their script classes multiply inherit from the other classes like

Definition at line 70 of file script.h.

Constructor & Destructor Documentation

Mezzanine::Scripting::iScript::iScript ( )
inline

default constructor

Initializes the internal reference counter.

Definition at line 173 of file script.h.

Member Function Documentation

virtual void Mezzanine::Scripting::iScript::AddArgument ( CountedPtr< iScriptArgument Arg)
pure virtual

This adds an argument to be passed to the script.

All arguments added with this are passed in FIFO order to the Script during or just before execution. This should normally run in constant time. Some scripting implementations may change the order arguments are passed if doing it another way mays more sense.

Parameters
ArgThis accepts a CountedPtr to a script argument and The script shares responsibility with caller for deleting the argument.
virtual bool Mezzanine::Scripting::iScript::CanReturnMultples ( )
inlinevirtual

Does this script support multiple return values.

Some scripting language support return tuples of values(Python), return an array of values (javascript), returning tables made of records which are groups of values(sql), and some allow return an arbitrary number of items that could be tables, or values and allow for tables to contain more tables and values(Lua). This allows for checking for an interface to retrieve some of these.

Returns
This default implementation returns false, but if the target language supports this it is expected to overload this and return true instead.

Definition at line 153 of file script.h.

virtual void Mezzanine::Scripting::iScript::ClearArguments ( )
pure virtual

Remove all the ARGs!!! http://imgur.com/DJhw7.

This should run in constant time. It still might be slower than removing and readding just one a few arguments in simple cases

Whole Mezzanine::Scripting::iScript::DecrementReferenceCount ( )
inline

Decrease the reference count by one and return the updated count.

Returns
The updated count;

Definition at line 183 of file script.h.

virtual CountedPtr<iScriptArgument> Mezzanine::Scripting::iScript::GetArgument ( Whole  ArgNumber) const
pure virtual

Retrieve a argument previously passed in.

Parameters
ArgNumberThe index of the passed parameter to retrun.
Returns
A reference counted pointer to a ScriptArgument.
virtual Whole Mezzanine::Scripting::iScript::GetArgumentCount ( ) const
pure virtual

How many arguments have been attached to this script?

Returns
A Whole containing the amount of arguments passed in so far.
virtual iScriptMultipleReturn* Mezzanine::Scripting::iScript::GetAsiScriptMultipleReturn ( )
inlinevirtual

If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptMultipleReturn if it would be valid.

Returns
A null pointer if this conversion is invalid or a valid pointer to this as an iScriptMultipleReturn if it is valid.

Reimplemented in Mezzanine::Scripting::iScriptMultipleReturn.

Definition at line 158 of file script.h.

virtual iScriptCompilable* Mezzanine::Scripting::iScript::GetAsScriptCompilable ( )
inlinevirtual

If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptCompilable if it would be valid.

Returns
A null pointer if this conversion is invalid or a valid pointer to this as an iScriptCompilable if it is valid.

Reimplemented in Mezzanine::Scripting::iScriptCompilable.

Definition at line 138 of file script.h.

virtual iScriptCompilable* Mezzanine::Scripting::iScript::GetAsScriptCompilable ( ) const
inlinevirtual

If your only handle to this is a pointer of type iScript this can be called to get a pointer to an iScriptCompilable if it would be valid.

Returns
A null pointer if this conversion is invalid or a valid pointer to this as an iScriptCompilable if it is valid.

Definition at line 142 of file script.h.

virtual iScript* Mezzanine::Scripting::iScript::GetMostDerived ( )
inlinevirtual

Get a pointer to the most Derived type of this class.

Returns
A pointer of the most derived pointing to this.

Reimplemented in Mezzanine::Scripting::iScriptMultipleReturn, and Mezzanine::Scripting::iScriptCompilable.

Definition at line 198 of file script.h.

Whole Mezzanine::Scripting::iScript::GetReferenceCount ( )
inline

Get the current amount of references.

Returns
A Whole with the current reference count

Definition at line 193 of file script.h.

virtual iScript* Mezzanine::Scripting::iScript::GetReferenceCountTargetAsPointer ( )
inlinevirtual

Gets the actual pointer to the target.

Returns
A Pointer of the targeted type to the object being managed.

Definition at line 188 of file script.h.

virtual String Mezzanine::Scripting::iScript::GetSourceCode ( ) const
pure virtual

If present this returns the code of script.

Returns
This will return either an empty String or the code. In cases where bytcode is set it is advised to clear this in implementations.
Whole Mezzanine::Scripting::iScript::IncrementReferenceCount ( )
inline

Increase the reference count by one and return the updated count.

Returns
The updated count;

Definition at line 178 of file script.h.

virtual bool Mezzanine::Scripting::iScript::IsCompilable ( ) const
inlinevirtual

Used to check if this Script supports compilation bytecode.

Returns
This will return false on all scripts not implementing ScriptCompilable and on those that do implement it.

Reimplemented in Mezzanine::Scripting::iScriptCompilable.

Definition at line 133 of file script.h.

virtual bool Mezzanine::Scripting::iScript::IsCompiled ( ) const
inlinevirtual

Used to check if there is a bytecode version of the script available.

Returns
This will return false on all scripts not implementing ScriptCompilable and only false when the bytecode is already compiled.

Reimplemented in Mezzanine::Scripting::iScriptCompilable.

Definition at line 128 of file script.h.

virtual void Mezzanine::Scripting::iScript::RemoveArgument ( CountedPtr< iScriptArgument Arg)
pure virtual

Remove an argument based on a CountedPtr to the script.

This searches through the internal list and removes the first entry it finds matching this. This should be treated as taking linear time, relative to the total count of arguments assigned to this script, to run. This can be used with AddArgument to re-order the way parameters are passed into a script

Parameters
ArgA CountedPtr matching the one to be removed
virtual void Mezzanine::Scripting::iScript::RemoveArgument ( Whole  ArgNumber)
pure virtual

Remove a Script argument based on the order it will be passed into the Script at Execution.

This removes the specified Argument from the internal list. This should be treated as taking linear time, relative to the total count of arguments assigned to this script, to run.

Parameters
ArgNumberThe number of the Argument to be removed. This behaves similar to an array or vector as it starts counting at 0.
virtual void Mezzanine::Scripting::iScript::SetSourceCode ( const String Code)
pure virtual

Sets the string version of the script.

Parameters
CodeA string that defines the source code to be executed or compiled whne running the script.

It is recomended that when this is called that implentors clear any bytecode or any other compiled version of the script. This will prevent issues with mismatched version of source and bytecode.


The documentation for this class was generated from the following file: