Harald Klimach avatar Harald Klimach committed eea8954

Added the option to return the compiled script when loading it from a file

Comments (0)

Files changed (1)


   !> Subroutine to load and execute a script from a file.
-  subroutine open_config_file(L, filename, ErrCode, ErrString)
+  subroutine open_config_file(L, filename, ErrCode, ErrString, buffer)
     type(flu_State) :: L !< Handle to the Lua script
     !> Name of file to load the Lua code from
     !! open_config() will print the error message and stop program execution.
     character(len=*), intent(out), optional :: ErrString
+    !> Optional argument, to return the compiled script after loading it to
+    !! the caller.
+    !!
+    !! It might be handy to reuse the loaded script later on, this argument
+    !! allows you to obtain the script in compiled form, before it is executed.
+    !! The pointer will be allocated and filled with the Lua data.
+    character, pointer, optional :: buffer(:)
     integer :: err
+    integer :: length
     if (.not.flu_isopen(L)) L = fluL_newstate()
       &                  ErrCode)
     if (err == 0) then
+      if (present(buffer)) then
+        call flu_dump(L, buffer, length, err)
+      end if
       call fluL_openlibs(L)
       err = flu_pcall(L, 0, 0, 0)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.