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 attributes
function ferite_variable_destroy() - Destroy a variable
function ferite_duplicate_variable() - Duplicate a variable
function ferite_create_string_variable() - Allocate a FeriteVariable and set it up to be a string from a FeriteString
function ferite_create_string_variable_from_ptr() - Create a FeriteVariable and set it up to be a string from a pointer and length
function ferite_create_number_long_variable() - Create a FeriteVariable and set it up to be a number variable of type long
function ferite_create_number_double_variable() - Create a FeriteVariable and set it up to be a number variable of type double
function ferite_create_object_variable() - Create a FeriteVariable and set it up to be an object variable pointing to 'null'
function ferite_create_uarray_variable() - Create a FeriteVariable and set it up to be an array
function ferite_create_void_variable() - Create a FeriteVariable and set it up to be an void variable
function ferite_variable_id_to_str() - Get the name of a variable type id
function ferite_variable_is_false() - Find out whether a given FeriteVariable is false
function ferite_variable_to_str() - Get a ferite string representation of a variable

Functions

function ferite_variable_destroy Click to go up to the list
Destroy a variable
Declaration:
    void ferite_variable_destroy( FeriteScript *script, FeriteVariable *var )
Parameters:
    Parameter #1: FeriteScript *script - The script the variable belongs to
    Parameter #2: FeriteVariable *var - The variable to destroy

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:
    The new variable

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_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_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_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_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
    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_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 and 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
Returns:
    A FeriteString

Automatically generated at 8:45pm, Wednesday 08 January 2003 by feritedoc.