group Variables

Description

A set of functions to allow for variables to be created and played with. Each of the variable allocation routines take an argument called alloc, this allows for reduced memory consumption regarding the names of variables. For a variable name to be static it must be either externally allocated or a compiled in constant.

e.g. "This is static text";
char *foo = strdup( "This is not (well the result of strdup)" );

To make sure that the variable name is allocated simply pass FE_ALLOC, if you want the name to be set to that of the pointer passed, give the function FE_STATIC.

group contents
Functions
function ferite_create_class_variable(FeriteScript,char,FeriteClass,int) - Create a variable that references an existing class within the ferite script
function ferite_create_namespace_variable(FeriteScript,char,FeriteNamespace,int) - Create a variable that references an existing namespace within the ferite script
function ferite_create_number_double_variable(FeriteScript,char,double,alloc) - Create a FeriteVariable and set it up to be a number variable of type double
function ferite_create_number_long_variable(FeriteScript,char,long,alloc) - Create a FeriteVariable and set it up to be a number variable of type long
function ferite_create_object_variable(FeriteScript,char,alloc) - Create a FeriteVariable and set it up to be an object variable pointing to 'null'
function ferite_create_object_variable_with_data(FeriteScript,char,alloc) - Create a FeriteVariable and set it up to be an object variable pointing to 'o'
function ferite_create_string_variable(FeriteScript,char,FeriteString,int) - Allocate a FeriteVariable and set it up to be a string from a FeriteString
function ferite_create_string_variable_from_ptr(FeriteScript,char,char,int,int,int) - Create a FeriteVariable and set it up to be a string from a pointer and length
function ferite_create_uarray_variable(FeriteScript,char,int,int) - Create a FeriteVariable and set it up to be an array
function ferite_create_void_variable(FeriteScript,char,alloc) - Create a FeriteVariable and set it up to be an void variable
function ferite_duplicate_variable(FeriteScript,FeriteVariable,void) - Duplicate a variable
function ferite_get_variable_ref(FeriteScript,FeriteVariable) - Obtain a reference to an existing variable.
function ferite_number_as_double(FeriteScript,FeriteVariable) - Provide, for a given variable the double representation.
function ferite_number_as_long(FeriteScript,FeriteVariable) - Provide, for a given variable the long representation.
function ferite_set_static_variable_name(FeriteScript,FeriteVariable,char) - Mark the variable name as not allocated and change it to the new name
function ferite_set_variable_name(FeriteScript,FeriteVariable,char) - Mark the variable name as allocated and set it
function ferite_types_are_equal(FeriteScript,int,int) - Check to see, in ferite's eye, whether or not the two types are equal and can be assigned to
function ferite_variable_convert_to_type(FeriteScript,FeriteVariable,int) - Convert a variable to another type
function ferite_variable_destroy(FeriteScript,FeriteVariable) - Destroy a variable
function ferite_variable_id_to_str(FeriteScript,int) - Get the name of a variable type id
function ferite_variable_is_false(FeriteScript,FeriteVariable) - Find out whether a given FeriteVariable is false
function ferite_variable_to_str(FeriteScript,FeriteVariable,int) - Get a ferite string representation of a variable
function ferite_variable_type_to_char(FeriteScript,int) - For a given variable type, provide the first character of the variable's type.

Functions

function ferite_create_class_variable Click to go up to the list
Create a variable that references an existing class within the ferite script
Declaration:
    FeriteVariable *ferite_create_class_variable( FeriteScript *script, char *name, FeriteClass *klass, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: char *name - The name of the variable
    Parameter #3: FeriteClass *klass - A pointer to the class to reference
    Parameter #4: int alloc - Whether or not to allocate the variable name
Returns:
    A variable that references the supplied class

function ferite_create_namespace_variable Click to go up to the list
Create a variable that references an existing namespace within the ferite script
Declaration:
    FeriteVariable *ferite_create_namespace_variable( FeriteScript *script, char *name, FeriteNamespace *ns, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: char *name - The name of the variable
    Parameter #3: FeriteNamespace *ns - A pointer to the namespace to reference
    Parameter #4: int alloc - Whether or not to allocate the variable name
Returns:
    A variable that references the supplied namespace

function ferite_create_number_double_variable Click to go up to the list
Create a FeriteVariable and set it up to be a number variable of type double
Declaration:
    FeriteVariable *ferite_create_number_double_variable( FeriteScript *script, char *name, double data, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: double data - The initial value
    Parameter #4: alloc Whether - or not to set the variable's name as static or allocated
Returns:
    Returns a newly created number variable

function ferite_create_number_long_variable Click to go up to the list
Create a FeriteVariable and set it up to be a number variable of type long
Declaration:
    FeriteVariable *ferite_create_number_long_variable( FeriteScript *script, char *name, long data, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: long data - The initial value
    Parameter #4: alloc Whether - or not to set the variable's name as static or allocated
Returns:
    Returns a newly created number variable

function ferite_create_object_variable Click to go up to the list
Create a FeriteVariable and set it up to be an object variable pointing to 'null'
Declaration:
    FeriteVariable *ferite_create_object_variable( FeriteScript *script, char *name, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: alloc Whether - or not to set the variable's name as static or allocated
Returns:
    Returns a newly created object variable

function ferite_create_object_variable_with_data Click to go up to the list
Create a FeriteVariable and set it up to be an object variable pointing to 'o'
Declaration:
    FeriteVariable *ferite_create_object_variable_with_data( FeriteScript *script, char *name, FeriteObject *o, int alloc )
Description:
This function can be made to mimic ferite_create_object_variable by passing NULL in for 'o'
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: alloc Whether - or not to set the variable's name as static or allocated
Returns:
    Returns a newly created object variable referencing the varuabke that has been passed in.

function ferite_create_string_variable Click to go up to the list
Allocate a FeriteVariable and set it up to be a string from a FeriteString
Declaration:
    FeriteVariable *ferite_create_string_variable( FeriteScript *script, char *name, FeriteString *data, int alloc )
Description:
As ferite's string variable is based upon FeriteString it can happily handle binary data
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: FeriteString *data - The data to set the default value of the variable to
    Parameter #4: int alloc - Whether or not to set the variable's name as static or allocated
Returns:
    Returns a newly created string variable

function ferite_create_string_variable_from_ptr Click to go up to the list
Create a FeriteVariable and set it up to be a string from a pointer and length
Declaration:
    FeriteVariable *ferite_create_string_variable( FeriteScript *script, char *name, char *data, int length, int encoding, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: char *data - The data to set the default value of the variable to
    Parameter #4: int length - The amount of data that exists - required to be greater than 0 for binary data. For a null terminated string, 0 will cause ferite to work out the length of the data.
    Parameter #5: int encoding - The method that was used to encode the string, if you are unsure use FE_CHARSET_DEFAULT
    Parameter #6: int alloc - Whether or not to set the variable's name as static or allocated
Returns:
    Returns a newly created string variable

function ferite_create_uarray_variable Click to go up to the list
Create a FeriteVariable and set it up to be an array
Declaration:
    FeriteVariable *ferite_create_uarray_variable( FeriteScript *script, char *name, int size, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: int size - The intial size of the array [This is currently ignored and is taken as a 'hint']
    Parameter #4: int alloc - Whether or not to set the variable's name as static or allocated
Returns:
    Returns a newly created array variable

function ferite_create_void_variable Click to go up to the list
Create a FeriteVariable and set it up to be an void variable
Declaration:
    FeriteVariable *ferite_create_void_variable( FeriteScript *script, char *name, int alloc )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: char *name - The name of the variable
    Parameter #3: alloc Whether - or not to set the variable's name as static or allocated
Returns:
    Returns a newly created void variable

function ferite_duplicate_variable Click to go up to the list
Duplicate a variable
Declaration:
    FeriteVariable *ferite_duplicate_variable( FeriteScript *script, FeriteVariable *var, void *extra )
Parameters:
    Parameter #1: FeriteScript *script - The script the variable belongs to
    Parameter #2: FeriteVariable *var - The variable to duplicate
    Parameter #3: void *extra - Ignore this, just pass NULL to the function
Returns:
    A duplicate of the variable

function ferite_get_variable_ref Click to go up to the list
Obtain a reference to an existing variable.
Declaration:
    FeriteVariable *ferite_get_variable_ref( FeriteScript *script, FeriteVariable *variable )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: FeriteVariable *variable - The variable to obtain a reference count to
Returns:
    The same variable pointed to by 'variable'

function ferite_number_as_double Click to go up to the list
Provide, for a given variable the double representation.
Warning!
It is important to check script->error_state for ERROR_THROWN. This happens when the variable is not a number type.
Declaration:
    double ferite_number_as_double( FeriteScript *script, FeriteVariable *var )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: FeriteVariable *var - The variable to convert
Returns:
    The value of the variable

function ferite_number_as_long Click to go up to the list
Provide, for a given variable the long representation.
Warning!
It is important to check script->error_state for ERROR_THROWN. This happens when the variable is not a number type.
Declaration:
    long ferite_number_as_long( FeriteScript *script, FeriteVariable *var )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: FeriteVariable *var - The variable to convert
Returns:
    The value of the variable

function ferite_set_static_variable_name Click to go up to the list
Mark the variable name as not allocated and change it to the new name
Declaration:
    void ferite_set_static_variable_name( FeriteScript *script, FeriteVariable *var, char *newname )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: FeriteVariable *var - The variable to apply the name to
    Parameter #3: char *newname - The new name to use

function ferite_set_variable_name Click to go up to the list
Mark the variable name as allocated and set it
Declaration:
    void ferite_set_variable_name( FeriteScript *script, FeriteVariable *var, char *newname )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: FeriteVariable *var - The variable to apply the name to
    Parameter #3: char *newname - The new name to use

function ferite_types_are_equal Click to go up to the list
Check to see, in ferite's eye, whether or not the two types are equal and can be assigned to
Declaration:
    int ferite_types_are_equal( FeriteScript *script, int typea, int typeb )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: int typea - The first type
    Parameter #3: int typeb - The second type
Returns:
    FE_TRUE if they are considered the same, FE_FALSE otherwise

function ferite_variable_convert_to_type Click to go up to the list
Convert a variable to another type
Declaration:
    void ferite_variable_convert_to_type( FeriteScript *script, FeriteVariable *var, int type )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteVariable *var - The variable to convert
    Parameter #3: int type - The type to convert the variable to

function ferite_variable_destroy Click to go up to the list
Destroy a variable
Declaration:
    void ferite_variable_destroy( FeriteScript *script, FeriteVariable *var )
Description:
If a variable has got multiple references, the reference will be decremented. Once the reference count reaches 0 (zero) the memory the variable uses will either be handed back to the variable cache or the memory pool.
Parameters:
    Parameter #1: FeriteScript *script - The script the variable belongs to
    Parameter #2: FeriteVariable *var - The variable to destroy

function ferite_variable_id_to_str Click to go up to the list
Get the name of a variable type id
Declaration:
    char *ferite_variable_id_to_str( FeriteScript *script, int variable )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: int variable - The type of the variable
Returns:
    A string, e.g. void, string or number

function ferite_variable_is_false Click to go up to the list
Find out whether a given FeriteVariable is false
Declaration:
    int ferite_variable_is_false( FeriteScript *script, FeriteVariable *var )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteVariable *var - The variable to check
Returns:
    FE_TRUE if the variable is false, FE_FALSE otherwise

function ferite_variable_to_str Click to go up to the list
Get a ferite string representation of a variable
Declaration:
    FeriteString *ferite_variable_to_str( FeriteScript *script, FeriteVariable *var, int quote )
Description:
This function works as would be aspected as for all variables but with special behavior for objects. If there is a .toString() method in the object it will be called with it's results used as the return value for this function, if the method does not exist then the return will be a string including the real address of the object along with a statement regarding the toString method.
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteVariable *var - The variable to convert
    Parameter #3: int quote - Whether or not to quote the string format. This only applies to string variables.
Returns:
    A FeriteString

function ferite_variable_type_to_char Click to go up to the list
For a given variable type, provide the first character of the variable's type.
Declaration:
    char ferite_variable_type_to_char( FeriteScript *script, int type )
Parameters:
    Parameter #1: FeriteScript *script - The script context
    Parameter #2: int type - The variable type
Returns:
    A character describing the type.

Automatically generated at 12:07PM, Wednesday 25 May 2005 by feritedoc.