#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <windows.h>
#include <time.h>
Include dependency graph for CentumSharedCode.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Namespaces | |
namespace | FunctionCalls |
namespace | StackOperations |
namespace | ThingManipulation |
namespace | bytecodes |
namespace | ThingReferences |
Defines | |
#define | CENTUMSHAREDCODE_API __declspec(dllimport) |
A layer of indirection for including this file safely in all places. | |
#define | CENUTUMSHAREDCODE_H |
A unique define for this include file to prevent multiple inclusion. | |
#define | INST_ALIAS 0x01 |
the member variable is an alias to the CThing indicated | |
#define | INST_CREATE 0x02 |
the member variable is a new instance of the CThing indicated | |
#define | INST_MEMBER 0x03 |
the member variable is a new instance and a contained variable | |
#define | FIND_SCOPE 0x01 |
the search function is currently within a scope | |
#define | FIND_THING 0x02 |
the search function is currently within a rebi | |
#define | FIND_UNDEF 0x03 |
the search function is currently not within any object | |
#define | EXEC_NORMAL 0x00000000 |
this return value means keep looping to execute the next byte code | |
#define | EXEC_RETURN 0x00000001 |
this return value means stop looping and take the values on stack and return | |
#define | EXEC_EXCEPTION 0x00000002 |
this return value means stop executing until you find an exception handler and call it with the return stack | |
#define | EXEC_MULTIPLERETURN 0x000FFFFF |
values above this indicate a multiple return is to be made | |
#define | EXEC_RETURNTO 0x00000003 |
for labeled functions, return to the function with the given label | |
#define | EXEC_RETURNFROM 0x00000004 |
for labeled functions, return from the function with the given label | |
#define | CTHING_READONLY 0x80000000 |
flag for a read-only CThing, neither the definition, local, or any data can be changed | |
#define | CTHING_REGISTEREDFUNCTION 0x00000001 |
this CThing is a wrapper arround a registered external function, and the data holds its address | |
#define | CTHING_DLLFUNCTION 0x00000002 |
this CThing is a wrapper arrounf a dll function call, the data holds the .dll name and function name or function address | |
#define | CTHING_UNDEF 0x00000004 |
this CThing is the predefined "undef" value, and should also be considered read-only | |
#define | DATA_TYPE_RAW 0x80000001 |
stores "raw" (other) type data, variable length | |
#define | DATA_TYPE_SIGNED_LONG 0x80000002 |
stores long type data (4 bytes) | |
#define | DATA_TYPE_FLOAT 0x80000003 |
stores float type data (4 bytes) | |
#define | DATA_TYPE_BOOLEAN 0x80000004 |
represents a true or false value, 4 bytes, 1 is true, 0 is false. | |
#define | DATA_TYPE_STRING 0x80000005 |
string data in the form of one or more chars ending with a 0, varaible length | |
#define | DATA_TYPE_ARRAY 0x80000006 |
the first node of a linked list representing an array of rebis | |
#define | DATA_TYPE_EXTERNAL_FUNCTION 0x80000007 |
for CThings with the CTHING_REGISTEDFUNCTION flag, the address of the function | |
#define | DATA_TYPE_DLL_NAME 0x80000008 |
for CThings with the CTHING_DLLFUNCTION flag, the name of the dll | |
#define | DATA_TYPE_DLL_FUNCTION_NAME 0x80000009 |
for CThings with the CTHING_DLLFUNCTION flag, the name of the function | |
#define | DATA_TYPE_DLL_FUNCTION_VALUE 0x8000000A |
for CThings with the CTHING_DLLFUNCTION flag, the ordinal of the function | |
#define | DATA_TYPE_CONSOLE 0x8000000B |
a structure that keeps track of console handles for print and read operations | |
#define | DATA_TYPE_FILE 0x8000000C |
the handle to an open file | |
#define | DATA_TYPE_SOCKET 0x8000000D |
a socket structre | |
#define | DATA_TYPE_CLIENT_CONNECTION 0x8000000E |
Data that keeps track of a network connection from a server ot a client. | |
#define | DATA_TYPE_SCRIPT 0x8000000F |
Pointer to a CProcessData structure, DEPRECIATED. | |
#define | DATA_TYPE_THREADLIST 0x80000010 |
A list of all running threads. | |
#define | DATA_TYPE_TIME 0x80000011 |
A structure that stores time and date information. | |
#define | DATA_TYPE_FILE_STREAM 0x80000011 |
Stores a pointer that can be used to get symbols from a file being compiled, used for compiler macros. | |
#define | DATA_TYPE_WORD_TYPE 0x80000012 |
The type of a symbol, used for compiler macros. | |
#define | DATA_TYPE_SCOPE 0x80000012 |
A pointer to a CScope object. | |
#define | DATA_TYPE_HWND 0x80000014 |
A handle to a window (HWND). | |
#define | DATA_TYPE_PYTHON 0x80000015 |
Would have been Python data, DEPRECIATED. | |
#define | DATA_TYPE_JAVAVM 0x80000016 |
Stores a structue that contains information needed to make java calls. | |
#define | DATA_TYPE_JAVA_CLASS 0x80000017 |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_OBJECT 0x80000018 |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_LONG 0x80000019 |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_METHODID 0x8000001A |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_MEMBERID 0x8000001B |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_BYTE 0x8000001C |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_CHAR 0x8000001D |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_SHORT 0x8000001E |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_DOUBLE 0x8000001F |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_BOOL 0x80000020 |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_INT 0x80000021 |
Stores a Java data type. | |
#define | DATA_TYPE_JAVA_FLOAT 0x80000022 |
Stores a Java data type. | |
#define | DATA_TYPE_HKEY 0x80000023 |
An HKEY (handle to a registry key). | |
#define | DATA_TYPE_HANDLE 0x80000024 |
Any handle, currently only used for mutexs and events. | |
#define | DATA_TYPE_READANDWRITE 0x80000025 |
A thread protection object. | |
#define | SOBJ_TYPE_BLOCK 1 |
signifies the end of a stack section | |
#define | SOBJ_TYPE_SREF 2 |
singifies a reference with a string table offset as well (to be used locally) | |
#define | SOBJ_TYPE_BREF 3 |
signifies a bare reference (no allusion to string table) | |
#define | SOBJ_NULL ((StackObj*)0) |
NULL. | |
Typedefs | |
typedef ExecutionReturn(* | ExternalCall )(unsigned long, CScope *, CThingStack *, CThingStack *) |
The signature for a registed call or a dll call. | |
Functions | |
CENTUMSHAREDCODE_API ExecutionReturn | ExecuteSingleFunction (CProcessData *dat, CThing *function, CThingStack *params, CThingStack *usings) |
This function executes the passed CThing. | |
CENTUMSHAREDCODE_API void | AddCProcessDataReference (CProcessData *p) |
Increases the reference count of the process. | |
CENTUMSHAREDCODE_API void | ReleaseCProcessData (CProcessData *p) |
Decreases the reference count of the process. | |
CENTUMSHAREDCODE_API void | ConvertSRefToBRef (StackObj *o) |
This function rearranges the internal structure of the StackObj so that it is a bare reference to a red instead of a named (string) reference. | |
CENTUMSHAREDCODE_API ExecutionReturn | CallFunction (CScope *caller, CThing *func, CThingStack *params, CThingStack *usings) |
This function calls a rebi and returns the results of its execution. | |
CENTUMSHAREDCODE_API ExecutionReturn | ExecuteByteCode (CScope *scope) |
This function executes the current byte code command for the scope. | |
CENTUMSHAREDCODE_API void | AddCScopeReference (CScope *scope) |
This function increases the reference count of the scope by one. | |
CENTUMSHAREDCODE_API void | ReleaseCScope (CScope *scope) |
This function decreases the reference count of the scope by one. | |
CENTUMSHAREDCODE_API void | FillWithStack (CThingArray *a, CThingStack *s) |
The FillWithStack function takes a CThingStack and adds its elements to the CThingArray. | |
CENTUMSHAREDCODE_API void | ReleaseAll (CThingArray *a) |
The ReleaseAll function calls ReleaseCThing on all elements of the array and then destroys the array. | |
CENTUMSHAREDCODE_API CThing * | CreateCThing (IMemory *m, CProcessData *p) |
The CreateCThing function returns a new CThing object. | |
CENTUMSHAREDCODE_API CDefinition * | CreateCDefinition (IMemory *m, CProcessData *p) |
The CreateCDefinition function returns a new CDefinition object. | |
CENTUMSHAREDCODE_API CScope * | CreateCScope (IMemory *m, CScope *caller, CProcessData *process) |
The CreateCScope function returns a new CScope object. | |
CENTUMSHAREDCODE_API CLocal * | CreateCLocal (IMemory *m) |
The CreateCLocal function returns a new CLocal object. | |
CENTUMSHAREDCODE_API CThingStack * | CreateCThingStack (IMemory *m) |
The CreateCThingStack function returns a new CThingStack object. | |
CENTUMSHAREDCODE_API void | FinishCScope (CScope *s) |
The FinishCScope function simply calls the ReleaseCScope function on the passed scope. | |
CENTUMSHAREDCODE_API ExecutionReturn | HandleReturnValue (CScope *scope, ExecutionReturn ret) |
This function takes the return value of a function that is to have its results pushed onto the local stack and calls HandleReturnValueAll with the appropriate parameters. | |
CENTUMSHAREDCODE_API ExecutionReturn | HandleUReturnValue (CScope *scope, ExecutionReturn ret) |
This function takes the return value of a function that is to have its results pushed onto the usings stack and calls HandleReturnValueAll with the appropriate parameters. | |
CENTUMSHAREDCODE_API void | ExtractAndReleaseParamsAndUsings (CScope *scope) |
The ExtractAndReleaseParamsAndUsings takes a substack from both the parms and usings stacks passed to a function and finishes them. | |
CENTUMSHAREDCODE_API ExecutionReturn | MakeARegisteredCall (CThing *func, CScope *scope) |
The MakeARegisteredCall function is used when a rebi with the CTHING_REGISTEREDFUNCTION flag is to be called. | |
CENTUMSHAREDCODE_API ExecutionReturn | MakeADLLCall (CThing *func, CScope *scope) |
The MakeADllCall function is used when a rebi with the CTHING_DLLFUNCTION flag is to be called. | |
CENTUMSHAREDCODE_API ExecutionReturn | MakeANormalCall (CThing *func, CScope *scope) |
This function is used to execute a rebi that has no special flags relating to its call. | |
CENTUMSHAREDCODE_API ExecutionReturn | HandleReturnValueAll (CScope *scope, ExecutionReturn ret, CThingStack *dest) |
This function deals with the results of a function return as appropriate, adding them to the correct stack, retuning them further or handling an excpetion. | |
CENTUMSHAREDCODE_API ExecutionReturn | HandleReturnedException (CScope *scope, ExecutionReturn ret) |
The HandleReturnedException function attempts to use an exception handler with the current scope. | |
CENTUMSHAREDCODE_API ExecutionReturn | CleanReturnValue (ExecutionReturn ret) |
This function adjusts the return type of a return value to represent that it has passed though a function. | |
CENTUMSHAREDCODE_API CThing * | StackObjToCThing (StackObj *p) |
This function takes a stack object as a parameter and returns the CThing pointer that it is holding, or NULL if there is none, and releases the StackObj. | |
CENTUMSHAREDCODE_API CThing * | StackObjToCThingSafe (const StackObj *p) |
This function takes a stack object as a parameter and returns the CThing pointer that it is holding, or NULL if there is none. | |
CENTUMSHAREDCODE_API void | FinishCThingStack (CThingStack *s) |
This function takes a CThingStack pointer and releases it. | |
CENTUMSHAREDCODE_API ExecutionReturn | CreateExceptionReturn (CScope *scope, const char *message) |
This function create a new ExecutionReturn with the type EXEC_EXCEPTION, and a single thrown value holding the message. | |
CENTUMSHAREDCODE_API CThing * | FindInScope (CScope *s, unsigned long stringindex, const CStringManager *strings, CThing *newvalue=(CThing *) 0, CThing **parent=(CThing **) 0, long *name=(long *) 0) |
The FindInScope Function finds a rebi with a given name within a scope. | |
CENTUMSHAREDCODE_API CThing * | FindInThing (CThing *t, unsigned long stringindex, const CStringManager *strings, CThing *newvalue=(CThing *) 0, CThing **parent=(CThing **) 0, long *name=(long *) 0) |
The FindInThing Function finds a rebi with a given name within a scope. | |
CENTUMSHAREDCODE_API CThing * | FindInThingSub (CThing *t, unsigned long stringindex, const CStringManager *strings, CThing *newvalue=(CThing *) 0, CThing **parent=(CThing **) 0, long *name=(long *) 0) |
This function looks though a given rebi for a rebi with the given name, possibly replacing it and/or returning data about the object that it is a member of. | |
CENTUMSHAREDCODE_API SFindThing | FindInScopeSub (CScope *s, unsigned long stringindex, const CStringManager *strings, CThing *newvalue=(CThing *) 0, CThing **parent=(CThing **) 0, long *name=(long *) 0) |
This function looks though a given scope for a rebi with the given name, possibly replacing it and/or returning data about the object that it is a member of. | |
CENTUMSHAREDCODE_API SFindThing | UniversalFind (SFindThing current, unsigned long stroffset, const CStringManager *strings, CThing *newvalue=(CThing *) 0, CThing **parent=(CThing **) 0, long *name=(long *) 0) |
The UniversalFind function takes a variable name, and a context to search for it in (can be a scope or a rebi), and returns the result of the search. | |
CENTUMSHAREDCODE_API SFindThing | UniversalArrayFind (SFindThing current, unsigned long stroffset, const CStringManager *strings, CThingArray *dest, CThing **parent=(CThing **) 0, long *name=(long *) 0) |
The UniversaArrayFind function takes a variable name, and a context to search for it in (can be a scope or a rebi), and returns the result of the search, and if more than one return is called for they are stored in an array. | |
CENTUMSHAREDCODE_API CThing * | FindInScopeArray (CScope *s, unsigned long stringindex, const CStringManager *strings, CThingArray *dest, CThing **parent=(CThing **) 0, long *name=(long *) 0) |
The FindInScopArray Function finds a rebi or more than one rebi with a given name within a scope. | |
CENTUMSHAREDCODE_API void | ReturnAllTied (CThing *current, unsigned long cname, CThingArray *ta, LongArray *la) |
This function takes a rebi and the name of a local variable and adds to the passed arrays all the rebi and local variables it is tied to. | |
CENTUMSHAREDCODE_API CThing * | ReturnDestructor (const CThing *t) |
This function searches for a local or static rebi called "Destructor" that belongs to the passed rebi and returns it. | |
CENTUMSHAREDCODE_API CThing * | ReturnConstructor (const CThing *t) |
This function searches for a local or static rebi called "Constructor" that belongs to the passed rebi and returns it. | |
CENTUMSHAREDCODE_API CThing * | BuildFromDef (CDefinition *def, CScope *scope, CThingStack *params, CThingStack *usings, CThing *owner) |
Given a CDefinition object and a scope this function will return a new rebi instance of that definition constructed in the given scope. | |
CENTUMSHAREDCODE_API CThing * | BuildFromString (const char *str, CScope *scope, CThingStack *params, CThingStack *usings, CThing *owner) |
This function creates a new rebi instance based on the definition of the rebi named. | |
CENTUMSHAREDCODE_API void | MakeEqual (CThing *dest, CThing *source) |
This function makes one rebi equal to another, this is not the same as an alias operation. | |
CENTUMSHAREDCODE_API void | CallConstructor (CThing *ret, CScope *scope, CThingStack *params, CThingStack *usings) |
This function calls the "Constructor" function of a rebi. | |
CENTUMSHAREDCODE_API void | CallDestructor (CThing *thing) |
This function calls the "Destructor" function of the given rebi. | |
CENTUMSHAREDCODE_API char * | GetData (const CThing *t, unsigned long type) |
This function returns a pointer to a type of data associated with a rebi instance. | |
CENTUMSHAREDCODE_API void | AddData (CThing *t, unsigned long type, unsigned long length, const char *data) |
This function adds data of a given type and size to a CThing. | |
CENTUMSHAREDCODE_API long | GetLong (const CThing *t, long def=0) |
The GetLong function returns a long based on the data the rebi contains, or the default value if it cannot extract one. | |
CENTUMSHAREDCODE_API float | GetFloat (const CThing *t, float def=0.0) |
The GetFloat function returns a float based on the data the rebi contains, or the default value if it cannot extract one. | |
CENTUMSHAREDCODE_API char * | GetString (const CThing *t, char *def=(char *) 0) |
The GetString function returns a char pointer based on the data the rebi contains, or the default (NULL if not supplied) value if it cannot extract one. | |
CENTUMSHAREDCODE_API bool | HasLong (const CThing *t) |
Returns true if the rebi has either DATA_TYPE_SIGNED_LONG or DATA_TYPE_FLOAT data attached to it. | |
CENTUMSHAREDCODE_API void | RemoveData (CThing *t, unsigned long type) |
This function removes a specific type of data from a CThing. | |
CENTUMSHAREDCODE_API bool | HasDataType (const CThing *t, unsigned long type) |
This function returns true if the rebi instance has data of the given type attached to it and false otherwise. | |
CENTUMSHAREDCODE_API unsigned long | GetDataLength (const CThing *t, unsigned long type) |
This function returns length of a type of data associated with a rebi instance. | |
CENTUMSHAREDCODE_API CThing * | ReplaceAndReturn (CThingArray *refs, unsigned long index, CThing *rep) |
This function replaces the rebi at the provided position in the array if neccessary, and then returns the rebi at that position. | |
CENTUMSHAREDCODE_API CThing * | ReplaceAndReturnGC (CThingArray *refs, unsigned long index, CThing *rep, CThing *from) |
This function replaces the rebi at the provided position in the array if neccessary, and then returns the rebi at that position. | |
CENTUMSHAREDCODE_API void | AddCThingReference (CThing *thing) |
Increases the reference count of a CThing object. | |
CENTUMSHAREDCODE_API void | AddDefReference (CDefinition *def) |
Increases the reference count of a CDefinition object. | |
CENTUMSHAREDCODE_API void | ReleaseCThing (CThing *thing) |
Decrements the reference count of a CThing object and releases its memory if appropriate. | |
CENTUMSHAREDCODE_API void | ReleaseCDefinition (CDefinition *def) |
Decrements the reference count of a CDefinition object and releases its memory if appropriate. | |
CENTUMSHAREDCODE_API void | AddCThingReferenceGC (CThing *thing, CThing *from) |
Increases the reference count of a CThing object and adds a backtrace pointer for garbage collection. | |
CENTUMSHAREDCODE_API void | ReleaseCThingGC (CThing *thing, CThing *from) |
Removes the appropriate back-pointer fromt the CThing parameter and decrements its reference count, releasing it if appropriate. | |
CENTUMSHAREDCODE_API void | GarbageCollect (CThing *thing) |
Traces through the back-pointers stored in a thing and releases it if it is in a closed memory loop. | |
Variables | |
CENTUMSHAREDCODE_API CMemoryTracker | def |
this variable is a global memory manager instance, in case one is not accessable by other means. | |
CENTUMSHAREDCODE_API char | rootpath [512] |
The path to the Centum directory, ends in a slash. |
|
Increases the reference count of the process.
|
|
This function increases the reference count of the scope by one.
|
|
Increases the reference count of a CThing object. Each call to AddCThingReference must be matched to a single call to ReleaseCThing somewhere. AddCThinReference needs to acquire the mutex assocaited with the CThing object.
|
|
Increases the reference count of a CThing object and adds a backtrace pointer for garbage collection. Each call to AddCThingReferenceGC must be matched to a single call to ReleaseCThingGC somewhere. AddCThinReferenceGC needs to acquire the mutex assocaited with the CThing object. This function adds the from pointer to the pointedto member of the thing parameter. The function itself calls AddCThingReference to increase the reference count.
|
|
This function adds data of a given type and size to a CThing. If the CThing is NULL, it has no local, or it is marked as read only or the undef object this function has no effect. A new block of data is allocated equal to the length parameter, the old data is copied into it and the buffer is associated with the rebi. Giving this function a length greate than the data being passed or passing NULL as the data pointer is ans error.
|
|
Increases the reference count of a CDefinition object. Each call to AddDefReference must be matched to a single call to ReleaseCDefinition somewhere. AddDefReference needs to acquire the mutex assocaited with the CDefinition object.
|
|
Given a CDefinition object and a scope this function will return a new rebi instance of that definition constructed in the given scope. This function uses the localinstantiation types under the CDefinition objects to construct the locals for this new object. Locals that are themselves instances are consructed recursively using this function. Passing either the definition or the scope as NULL is an error.
|
|
This function creates a new rebi instance based on the definition of the rebi named. The rebi is searched for in the scope passed to this function. If the rebi cannot be founf the new rebi is created as an instance of the undef rebi. This function works the same as BuildFromDef in all other ways.
|
|
This function calls the "Constructor" function of a rebi. The caller of the constructor function is a new scope which is the rebi that is being constucted so that inside the destructor rebi varaibles may be accessed. Parameters and usings may also be passed to the constructor function.
|
|
This function calls the "Destructor" function of the given rebi. The caller of the destructor function is a new scope which is the rebi that is being destucted so that inside the destructor rebi varaibles may be accessed.
|
|
This function calls a rebi and returns the results of its execution. Passing NULL as the rebi is an error. If either the parameters to this function or the usings are NULL than an empty stack is used in their place (so passing them as NULL is safe). Then an ExecuteByteCode loop is entered until the result of the byte code execution is not EXEC_NORMAL. Finally the last non- EXEC_NORMAL return value is readied for being returned by the use of the CleanReturnValue function, and then it is returned.
|
|
This function adjusts the return type of a return value to represent that it has passed though a function. Multiple return values are adjusted to reflect having returned through another layer, and single returns are turned into normal results to signal that they should be added to the stack and not passed further on.
|
|
This function rearranges the internal structure of the StackObj so that it is a bare reference to a red instead of a named (string) reference. If the StackObj passed to this function is not a string reference no action is taken.
|
|
The CreateCDefinition function returns a new CDefinition object.
|
|
The CreateCLocal function returns a new CLocal object.
|
|
The CreateCScope function returns a new CScope object.
|
|
The CreateCThing function returns a new CThing object. The CThing returned by this function needs to have a CDictionary assigned to it for many parts of the code to function properly.
|
|
The CreateCThingStack function returns a new CThingStack object.
|
|
This function create a new ExecutionReturn with the type EXEC_EXCEPTION, and a single thrown value holding the message. The thown rebi is an intance of the type interpreterexception. The message is attached as string data to that instance.
|
|
This function executes the current byte code command for the scope. If the current code position is greater than the length of the bytecode for the scope than a sub-stack is taken off the interal localstack and returned with a value of EXEC_RETURN. Otherwise the 5 bytes of the bytecode are read, the first byte being the ident.
|
|
This function executes the passed CThing. The CThing is called with the passed parameters and usings (which may be NULL), and is called from the global scope.
|
|
The ExtractAndReleaseParamsAndUsings takes a substack from both the parms and usings stacks passed to a function and finishes them.
|
|
The FillWithStack function takes a CThingStack and adds its elements to the CThingArray. The CThingStack is emptied added to the array from top to bottom. This operation stops as soon as it finds a NULL CThing pointer, which may not necessarily be the entire stack. CThings taken off the stack are not dereferenced, it is your responsibility to clean up after using this function, probably by a call to ReleaseAll.
|
|
The FindInScope Function finds a rebi with a given name within a scope. This function will replace the old value when found if a replacement value is provided. If the [out] parameters are non-NULL this function will also provide the name of the rebi and the rebi that it is a local variable of. Note that these will not be provided if the rebi is found but not as a local variable. If the name of the rebi to search for contains one or more ":" each part of the name is searched through and then the next part is searched through in the result of the that search.
|
|
The FindInScopArray Function finds a rebi or more than one rebi with a given name within a scope. If more than one rebi is to be returned, such as searching for params, they are placed in the dest array (along with a single NULL value to indicate that the results are in the array, as there may be no parameters). If the [out] parameters are non-NULL this function will also provide the name of the rebi and the rebi that it is a local variable of. Note that these will not be provided if the rebi is found but not as a local variable. If the name of the rebi to search for contains one or more ":" each part of the name is searched through and then the next part is searched through in the result of the that search.
|
|
This function looks though a given scope for a rebi with the given name, possibly replacing it and/or returning data about the object that it is a member of. This function searches though the "my" variables of the scope, and if it is not found there through the scope's usings, container, and then the caller. The usings and container (if they exist) are searched with calls to FindInThingSub, and the caller is searched with FindInScopeSub. If a variable with the searched for name exists in the "my" variables it is returned wrapped in a SFindThing structure, and if a repacement value has been passed the previous value will be substituted for it before hand. The name and parent parameters will not be filled by this function, but will be passed on.
|
|
The FindInThing Function finds a rebi with a given name within a scope. This function will replace the old value when found if a replacement value is provided. If the [out] parameters are non-NULL this function will also provide the name of the rebi and the rebi that it is a local variable of. Note that these will not be provided if the rebi is found but not as a local variable. If the name of the rebi to search for contains one or more ":" each part of the name is searched through and then the next part is searched through in the result of the that search.
|
|
This function looks though a given rebi for a rebi with the given name, possibly replacing it and/or returning data about the object that it is a member of. This function searches though the local variable, and if it is not found there through the, container, and then the static variables. The container (if there is one)is searched with a call to FindInThingSub. If a variable with the searched for name exists in the local or static variables it is returned wrapped in a SFindThing structure, and if a repacement value has been passed the previous value will be substituted for it before hand. If it is a local variable the name and parent parameters will be filled in if they exist. Also if the local varaible being re-aliased is tied to any other variables those variables are re-aliased as well.
|
|
The FinishCScope function simply calls the ReleaseCScope function on the passed scope.
|
|
This function takes a CThingStack pointer and releases it. This function releases the CThingStack with a call to IMemoryManager::Free(). It also calls the CThingStack::Destruct() function to clean up any data associated with the stack. Using the pointer after a call to this function is an error.
|
|
Traces through the back-pointers stored in a thing and releases it if it is in a closed memory loop. Calling Garbage collect on a CThing that has a reference count greater than its number of back-pointers is an error. This function operates by searching through each back pointer and then througn the back-pointers of all objects that can be found though back-pointers until either an object that has a reference count greater than its number of back pointers is found or all possible backpointers have been fully searched through. If the second is the case than the object is is a closed memory loop and this function releases it in the same manner that ReleaseCThing does, altough it does not call this function. Releasing this one CThing should release the entire memory loop.
|
|
This function returns a pointer to a type of data associated with a rebi instance. If the CThing passed is NULL, its CLocal is NULL, or it does not have the requested type this function returns NULL.
|
|
This function returns length of a type of data associated with a rebi instance. If the CThing passed is NULL, its CLocal is NULL, or it does not have the requested type this function returns 0.
|
|
The GetFloat function returns a float based on the data the rebi contains, or the default value if it cannot extract one. First the rebi is examined for DATA_TYPE_FLOAT, and if it has that data it is returned. Next this function looks for DATA_TYPE_SIGNED_LONG attached to the rebi, and if it exists it is cast to a float and returned. Finally if the rebi has string data (DATA_TYPE_STRING) that data is converted to a number using atof(). If all these attempts fail the default value attached to this function is returned.
|
|
The GetLong function returns a long based on the data the rebi contains, or the default value if it cannot extract one. First this function looks for DATA_TYPE_SIGNED_LONG attached to the rebi, and returns that data if possible. Next the rebi is examined for DATA_TYPE_FLOAT, and if it has that data it is truncated to a long value and returned. Finally if the rebi has string data (DATA_TYPE_STRING) that data is converted to a number using atoi(). If all these attempts fail the default value attached to this function is returned.
|
|
The GetString function returns a char pointer based on the data the rebi contains, or the default (NULL if not supplied) value if it cannot extract one. First the rebi is examined for DATA_TYPE_STRING, and if it has that data it is returned. Next this function looks for DATA_TYPE_FLOAT attached to the rebi, and if it exists it is turned into a string with sprintf and the format string: "%#.8f" and returned. Finally if the rebi has DATA_TYPE_SIGNED_LONG that data is turned into a string with sprintf and the format string: "%d" and returned. If all these attempts fail the default value attached to this function is returned (remember this may be NULL). WARNING: longs and floats converted into strings this way reside in a single static buffer, and subseqent calls may change this value. You should use the string this function returns as soon as possible and then consider it invalid afterwards.
|
|
The HandleReturnedException function attempts to use an exception handler with the current scope. This function searches though the byte code of the current scope, starting at the current position looking for a bytecode with an ident of 0x03, singifying that it is a handler. This handler is then called with the returned value and the returned value of the handler is subsequently returned. If no handler can be found the value passed to this function is returned unchanged.
|
|
This function takes the return value of a function that is to have its results pushed onto the local stack and calls HandleReturnValueAll with the appropriate parameters. This function provides a layer of indirection that prevents code duplication.
|
|
This function deals with the results of a function return as appropriate, adding them to the correct stack, retuning them further or handling an excpetion. First return values of type EXEC_NORMAL have their values pushed onto the stack passed to the function, and normal return with no stack is returned from the function. Return values of type EXEC_RETURN or multiple returns are passed on with no action taken. Return values of type EXEC_RETURNTO or EXEC_RETURNFROM have their top value of their return stack compared either to the label of the current scope if it is a string reference or if their pointers and the scope's rebi if it is a bare reference. If they pass this test return values of type EXEC_RETURNTO have their return stack added to the appropriate stack as if they were a normal return and returns of type EXEC_RETURNFROM are converted into normal returns. Finally exceptions have HandleReturnedException called on them repeatedly until a handler returns a non-exception which is then returned, or until no more handlers can be found (each passed the result of the previous handler) in that case the resulting exception is returned to be handled in the calling scope.
|
|
This function takes the return value of a function that is to have its results pushed onto the usings stack and calls HandleReturnValueAll with the appropriate parameters. This function provides a layer of indirection that prevents code duplication.
|
|
This function returns true if the rebi instance has data of the given type attached to it and false otherwise. If the CThing passed is NULL, its CLocal is NULL, or it does not have the requested type this function returns false.
|
|
Returns true if the rebi has either DATA_TYPE_SIGNED_LONG or DATA_TYPE_FLOAT data attached to it.
|
|
The MakeADllCall function is used when a rebi with the CTHING_DLLFUNCTION flag is to be called. This function gets the dll name, stored as local data of type DATA_TYPE_DLL_NAME, and then either the name of the function to call, as stored in local data with type: DATA_TYPE_DLL_FUNCTION_NAME or the ordinal as stored in local data of type DATA_TYPE_DLL_FUNCTION_VALUE. Then parameters and usings are extracted from the calling scope ( using CThingStack::GetASubStackUnsafe() ). After being called once as a dll function the rebi is converted into a registed function rebi (flag CTHING_REGISTEREDFUNCTION) for a speed boost. Finally the function itself is called, and then its return stack is reversed and then its return value is processed by the CleanReturnValue function before being returned.
|
|
This function is used to execute a rebi that has no special flags relating to its call. Parameters and usings are extracted from the calling scope ( using CThingStack::GetASubStack() ). Finally the function itself is called, and its return value is processed by the CleanReturnValue function before being returned.
|
|
The MakeARegisteredCall function is used when a rebi with the CTHING_REGISTEREDFUNCTION flag is to be called. This function gets the address of the external function, stored as local data of type DATA_TYPE_EXTERNAL_FUNCTION. Then parameters and usings are extracted from the calling scope ( using CThingStack::GetASubStackUnsafe() ). Finally the function itself is called, and then its return stack is reversed and then its return value is processed by the CleanReturnValue function before being returned.
|
|
This function makes one rebi equal to another, this is not the same as an alias operation. The equals operation alters the structure of the destination rebi to make it equal to the source rebi. Any references to it will remain valid, but will now point to the altered version. This function should not be called on the undef rebi or one marked as read-only, although it will not fail if you do. After the copying operation has been completed the function searches for an "=" function and calls it if possible. You can also consult the Centum language manual for more details on the equality operation.
|
|
The ReleaseAll function calls ReleaseCThing on all elements of the array and then destroys the array. Make sure that when you call this function that you want to call ReleaseCThing on all the elements, and not for example ReleaseCThingGC. Also all of the pointers need either to be valid or NULL or an error will result.
|
|
Decrements the reference count of a CDefinition object and releases its memory if appropriate. Calling ReleaseCDefinition more times than you have called AddDefReference is an error. This function needs to acquire the mutex associated with the definition. If you have aquired it you must release it before calling this function. ReleaseCThing is called on all static members.
|
|
Decreases the reference count of the process. If the reference count is zero the process' destruct function is called and it is freed with its own memory manager.
|
|
This function decreases the reference count of the scope by one. If the reference count of the scope reaches zero than it is destroyed and its memory is released.
|
|
Decrements the reference count of a CThing object and releases its memory if appropriate. Calling ReleaseCThing more times than you have called AddCThingReference is an error. This function needs to acquire the mutex associated with the CThing. If you have aquired it you must release it before calling this function. If the reference count of the CThing is equal to the number of backpointers it has then GarbageCollect is called, which may or may not release it. Otherwise if its reference count is zero the objects locals and data are de-referenced, it is untied from other variables, and its memory is freed.
|
|
Removes the appropriate back-pointer fromt the CThing parameter and decrements its reference count, releasing it if appropriate. Calling ReleaseCThingGC more times than you have called AddCThingReferenceGC is an error. Likewise each call to AddCThingReferenceGC needs to be matched to a call to ReleaseCThingGC with the same from parameter. Internally the reference count it decremented through a call to ReleaseCThing.
|
|
This function removes a specific type of data from a CThing. If the CThing is NULL, it has no local, or it is marked as read only or the undef object this function has no effect. The data of the chosen type is removed from the CThing.
|
|
This function replaces the rebi at the provided position in the array if neccessary, and then returns the rebi at that position. The rebi is replaces if the rep parameter is non-NULL. CThings replaced in this manner have ReleaseCThing called on them.
|
|
This function replaces the rebi at the provided position in the array if neccessary, and then returns the rebi at that position. The rebi is replaces if the rep parameter is non-NULL. CThings replaced in this manner have ReleaseCThingGC called on them. The ReleaseCThingGC uses the from parameter passed to this function.
|
|
This function takes a rebi and the name of a local variable and adds to the passed arrays all the rebi and local variables it is tied to. The arrays passed to this function should already exist and contain the rebi and the name you are passing to this function. The rebi and the name at the same position in the arrays correspond to one tied variable (the rebi it is a local variable in and its name). This function operates recursively.
|
|
This function searches for a local or static rebi called "Constructor" that belongs to the passed rebi and returns it. No Constructor rebi will be returned for a rebi that is not an instance. Calling this function with a NULL parameter will return NULL.
|
|
This function searches for a local or static rebi called "Destructor" that belongs to the passed rebi and returns it. No Destructor rebi will be returned for a rebi that is not an instance. Calling this function with a NULL parameter will return NULL.
|
|
This function takes a stack object as a parameter and returns the CThing pointer that it is holding, or NULL if there is none, and releases the StackObj. The StackObjToCThingSafe function examines the type of the StackObj and returns the appropriate value. The StackObj pointer IS not released by a call to this function, but the reference count of the CThing affected. Calling this function on a StackObj that is still part of the stack is an error.
|
|
This function takes a stack object as a parameter and returns the CThing pointer that it is holding, or NULL if there is none. The StackObjToCThingSafe function examines the type of the StackObj and returns the appropriate value. The StackObj pointer is not released by a call to this function, nor is the reference count of the CThing affected.
|
|
The UniversaArrayFind function takes a variable name, and a context to search for it in (can be a scope or a rebi), and returns the result of the search, and if more than one return is called for they are stored in an array. If the [out] parameters are non-NULL this function will also provide the name of the rebi and the rebi that it is a local variable of. To do searching within a specific scope or rebi FindInThingSub and FindInScopeSub are called internally to accomplish this in typical cases. However this function checks for special cases such as caller or this and returns the appropriate values, internally. The universal find functions are the only place these special cases are checked for.
|
|
The UniversalFind function takes a variable name, and a context to search for it in (can be a scope or a rebi), and returns the result of the search. This function will replace the old value when found if a replacement value is provided. If the [out] parameters are non-NULL this function will also provide the name of the rebi and the rebi that it is a local variable of. To do searching within a specific scope or rebi FindInThingSub and FindInScopeSub are called internally to accomplish this in typical cases. However this function checks for special cases such as caller or this and returns the appropriate values, internally. The universal find functions are the only place these special cases are checked for.
|