#-----------------------------------------------------------------------------* # # @file gtl_interface.galgas # # @section desc File description # # Interfacing functions to embed GTL. # # @section copyright Copyright # # GTL interpreter, part of Trampoline RTOS # # GTL is copyright (c) CNRS & Ecole Centrale de Nantes # GTL is protected by the French intellectual property law. # # This software is distributed under the GNU Public Licence V2. # Check the LICENSE file in the root directory of Trampoline # # $Date$ # $Rev$ # $Author$ # $URL$ # #-----------------------------------------------------------------------------* #-----------------------------------------------------------------------------* # invokeGTL invoke a template #-----------------------------------------------------------------------------* func invokeGTL ?@gtlString rootTemplateFileName # the template file name ?@gtlContext context # execution context ?@gtlData vars # variables ->@string result # output string { result = "" @library lib = emptyLib() if [option gtl_options.debug value] then message "Starting debugger, type help for command list\n" [".gtlinit" loadCommandFile !?context !?vars !?lib] end # Build a template instruction let @gtlTemplateInstruction rootTemplateInstruction = .new { !.here !"" !emptylstring() # empty prefix !@gtlTerminal.new { # literal gtlString to store the file name !.here !rootTemplateFileName } !false # should always exist !true # global template !.emptyList # no argument !.emptyList # no instruction if not found } # Execute the template [rootTemplateInstruction execute !?context !?vars !?lib !?result ] } #-----------------------------------------------------------------------------* # emptyVarContainer #-----------------------------------------------------------------------------* func emptyVarContainer ->@gtlData result { result = @gtlStruct.new { !.nowhere !emptylstring() !.emptyMap } } #-----------------------------------------------------------------------------* # lstringToGtlString #-----------------------------------------------------------------------------* func lstringToGtlString ?@lstring input ->@gtlString output { output = .new { !input !emptylstring() !input } } #-----------------------------------------------------------------------------* # stringToGtlString #-----------------------------------------------------------------------------* func stringToGtlString ?@string input ->@gtlString output { output = .new { !.nowhere !emptylstring() !input } }