Commits

Kannan Masilamani committed fcdaf24

created interface aot_path_open for aot_path_open_table and aot_path_open_fun

Comments (0)

Files changed (1)

source/aot_path_module.f90

   public :: aot_init_path, aot_fin_path
   public :: aot_path_addNode, aot_path_delNode
   public :: assignment(=)
-  public :: aot_path_open_fun, aot_path_close_fun
+  public :: aot_path_open, aot_path_close
+
+  interface aot_path_open
+    module procedure aot_path_open_fun
+    module procedure aot_path_open_table
+  end interface aot_path_open
+
+  interface aot_path_close
+    module procedure aot_path_close_fun
+    module procedure aot_path_close_table
+  end interface aot_path_close
 
 contains
 
     !! an actual Lua state handle.
     logical, intent(in), optional :: openLua
 
+    integer :: myHandle
+    
+    ! open the table untill it reaches the final head node
+    call aot_path_open_table( me, conf, myHandle, openLua )
+
+    if (me%head%NodeType == 'function') then
+      select case(me%head%ID_kind)
+      case('key')
+        if (associated(me%head, me%GlobalNode)) then
+          call aot_fun_open(L=conf, fun=fun, key=me%head%key)
+        else
+          call aot_fun_open(L=conf, parent=myHandle, fun=fun, key=me%head%key)
+        end if
+      case('position')
+        call aot_fun_open(L=conf, parent=myHandle, fun=fun, pos=me%head%pos)
+      end select
+    end if
+
+  end subroutine aot_path_open_fun
+
+  !> This subroutine opens all the tables on the way to
+  !! the final head node of the given path.
+  !! The handle can be either passed in, to be used for the
+  !! look up of the path, or, when specifying the optional
+  !! openLua argument as true, it will return the handle to
+  !! the newly opened Lua script.
+  subroutine aot_path_open_table(me, conf, thandle, openLua)
+    !> The path object to open as a function
+    type(aot_path_type), intent(inout) :: me
+    !> The flu_state handle, which is either opened according to
+    !! the path, or used to open the path in.
+    type(flu_state) :: conf
+    !> return handle of the last opened table
+    integer, intent(out) :: thandle
+    !> A flag to indicate, wether to open the Lua script, default
+    !! is false, in which case the conf argument has to link to
+    !! an actual Lua state handle.
+    logical, intent(in), optional :: openLua
+
     logical :: new_conf
     type(aot_path_node_type), pointer :: curNode => NULL()
     integer :: myHandle, prevHandle
 
     end do
 
-    if (me%head%NodeType == 'function') then
-      select case(me%head%ID_kind)
-      case('key')
-        if (associated(me%head, me%GlobalNode)) then
-          call aot_fun_open(L=conf, fun=fun, key=me%head%key)
-        else
-          call aot_fun_open(L=conf, parent=myHandle, fun=fun, key=me%head%key)
-        end if
-      case('position')
-        call aot_fun_open(L=conf, parent=myHandle, fun=fun, pos=me%head%pos)
-      end select
-    end if
+    thandle = myHandle
 
-  end subroutine aot_path_open_fun
+  end subroutine aot_path_open_table
 
-
+  !> This routine closes function and all other tables opened
+  !! along the path
   subroutine aot_path_close_fun(me, conf, fun, closeLua)
     !> The path object to open as a function
     type(aot_path_type), intent(inout) :: me
     !! is false.
     logical, intent(in), optional :: closeLua
 
+    ! close function
     call aot_fun_close(L=conf, fun=fun)
+    ! close tables
+    call aot_path_close_table( me, conf, closeLua )
+
+  end subroutine aot_path_close_fun
+
+  !> this routine closes all the table opened in aot_path_open_table
+  subroutine aot_path_close_table(me, conf, closeLua)
+    !> The path object to open as a function
+    type(aot_path_type), intent(inout) :: me
+    !> The flu_state handle, which is either opened according to
+    !! the path, or used to open the path in.
+    type(flu_state) :: conf
+    !> A flag to indicate, wether to close the Lua script, default
+    !! is false.
+    logical, intent(in), optional :: closeLua
+
     if (me%roothandle /= 0) then
       call aot_table_close(L=conf, thandle=me%roothandle)
     end if
       end if
     end if
 
-  end subroutine aot_path_close_fun
+  end subroutine aot_path_close_table
 
 end module aot_path_module
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.