TEAL compiler can produce compiled templates not only for DbUML application, but for any other application needed in text generation. To be able to use TEAL templates, application has to implement Data Processor interface, load template library and call desired template function. TEAL compiler comes with a demo project "FileSysReport" to generate a text representation of a file system structure. The project includes an application source code and an example templates. A compiled application and templates are also available.
6.1 Generator interface
Generator DLL created as result of TEAL template file compilation contains following exported functions
void Init(int). After loading of DLL into memory the host process has to call this function to initialize the generation
process. The parameter is reserved for future versions.
void Finit(). Before DLL unloading, the host application has to call this function to release all resources allocated by
DLL code.
void RegProcessorCall(int, void*). The function is used to register call-back functionality of Data Processor implemented
by host application. For details look "Data Processor interface and implementation" below.
void* AllocDllMem(int). This function can be used to allocate a memory block using internal DLL mechanism. Usually this
function is never used by host application - all internal memory alocations are done inside of DLL code.
void FreeDllMem(void*). All textual results generated by DLL reside in a memory allocated by DLL code. After result is
used by the host application, the memory has to be released to avoid memory leak. Use this function to release memory allocated
by generation functions implemented in DLL.
char* GetResource(char*). The function returns a text associated with parameter using TEAL "resource" command. The result
has to be released using FreeDllMem function.
char* __<exported template function name>(<parameters>). For each exported TEAL function compiler generates a DLL function
prefixed with double underscore. The full comma-delimited list of such functions is available via GetResource("export") call -
each function name in the result are followed by colon-separated list of parameter types enclosed in parenthesis. For example
__main(p),__main2(p:p),__genprm(p:s)
where "p" means "pointer to an object" and "s" means "string". Results of exported template functions have to be released by
FreeDllMem calls.
[TBD]
6.2 Data Processor interface and implementation
TCountFunc = function(obj: TObject): integer; cdecl;
TGetFunc = function (obj: TObject; index: integer): TObject; cdecl;
RIterator = record
count: TCountFunc;
get: TGetFunc;
end;
PIterator = ^RIterator;
procedure GetIterator(obj: TObject; const code: pchar; var pitr: PIterator); cdecl;
function GetProperties(obj: TObject; const name: pchar; container: TObject): pchar; cdecl; // obsolete ?
procedure SetEnv(const name, value: pchar); cdecl;
function GetEnv(const name: pchar): pchar; cdecl; // not used
function GetObjAttrs(obj: TObject; container: TObject): cardinal; cdecl; // obsolete
procedure SetObjAttrs(obj: TObject; container: TObject; value: cardinal); cdecl; // obsolete
function RunFun(const name: pchar; params: Ppointer; count: integer): pchar; cdecl;
[TBD]