修訂 | bfb6dafab79adb08968c0846638953421549ef67 (tree) |
---|---|
時間 | 2012-04-26 03:31:49 |
作者 | Harald Klimach <harald@klim...> |
Commiter | Harald Klimach |
Some more formatting
@@ -1,4 +1,5 @@ | ||
1 | 1 | !> A module providing access to Lua functions |
2 | +!! | |
2 | 3 | !! Intended usage: |
3 | 4 | !! First open a function with aot_fun_open |
4 | 5 | !! Then put required parameters inot it with |
@@ -21,6 +22,7 @@ | ||
21 | 22 | end type |
22 | 23 | |
23 | 24 | !> Open a Lua function for evaluation. |
25 | + !! | |
24 | 26 | !! After it is opened, arguments might be |
25 | 27 | !! put into the function, and it might be |
26 | 28 | !! executed. This might be repeated for |
@@ -33,6 +35,7 @@ | ||
33 | 35 | end interface aot_fun_open |
34 | 36 | |
35 | 37 | !> Put an argument into the lua function. |
38 | + !! | |
36 | 39 | !! Arguments have to be in order, first put |
37 | 40 | !! the first argument then the second and so on. |
38 | 41 | interface aot_fun_put |
@@ -42,6 +45,7 @@ | ||
42 | 45 | contains |
43 | 46 | |
44 | 47 | !> Return the stack of the top as a function. |
48 | + !! | |
45 | 49 | !! If it actually is not a Lua function, its handle |
46 | 50 | !! will be set to 0. |
47 | 51 | function aot_fun_top(L) result(fun) |
@@ -864,6 +864,7 @@ | ||
864 | 864 | |
865 | 865 | !> Helper function to provide new unit, as long as F2008 newunit argument |
866 | 866 | !! in open statement is not commonly available. |
867 | + !! | |
867 | 868 | !! To be used right in front of the open statement like this: |
868 | 869 | !! myUnit = newunit() |
869 | 870 | !! open(myUnit, ...) |
@@ -18,9 +18,11 @@ | ||
18 | 18 | contains |
19 | 19 | |
20 | 20 | !> Return the position at the top of the stack as a |
21 | - !! table handle for further operations on that table, | |
22 | - !! if it actually exists and is a table. Otherwise | |
23 | - !! 0 will be returned. | |
21 | + !! table handle. | |
22 | + !! | |
23 | + !! If it actually exists and is a table, this handle can be used | |
24 | + !! for further operations on that table. | |
25 | + !! Otherwise a 0 will be returned. | |
24 | 26 | function aot_table_top(L) result(thandle) |
25 | 27 | type(flu_state) :: L |
26 | 28 | integer :: thandle |
@@ -32,8 +34,10 @@ | ||
32 | 34 | end if |
33 | 35 | end function aot_table_top |
34 | 36 | |
35 | - !> Load a globally defined table into the top of the stack | |
36 | - !! and return its position in the stack as a handle for this | |
37 | + | |
38 | + !> Load a globally defined table into the top of the stack. | |
39 | + !! | |
40 | + !! Return its position in the stack as a handle for this | |
37 | 41 | !! table. If it does not exist or the global variable is not |
38 | 42 | !! a table, the handle will be set to 0. |
39 | 43 | subroutine aot_table_global(L, thandle, key) |
@@ -46,6 +50,7 @@ | ||
46 | 50 | thandle = aot_table_top(L) |
47 | 51 | end subroutine aot_table_global |
48 | 52 | |
53 | + | |
49 | 54 | !> This subroutine tries to get a table in a table, and |
50 | 55 | !! return a handle for it. |
51 | 56 | subroutine aot_table_table(L, parent, thandle, key, pos) |
@@ -59,8 +64,10 @@ | ||
59 | 64 | thandle = aot_table_top(L) |
60 | 65 | end subroutine aot_table_table |
61 | 66 | |
62 | - !> Close a table again, by popping all values above and itself | |
63 | - !! from the stack. | |
67 | + | |
68 | + !> Close a table again. | |
69 | + !! | |
70 | + !! This is done by popping all values above and itself from the stack. | |
64 | 71 | subroutine aot_table_close(L, thandle) |
65 | 72 | type(flu_state) :: L |
66 | 73 | integer, intent(in) :: thandle |
@@ -68,6 +75,7 @@ | ||
68 | 75 | if (thandle > 0) call flu_settop(L, thandle-1) |
69 | 76 | end subroutine aot_table_close |
70 | 77 | |
78 | + | |
71 | 79 | !> This subroutine tries to push the value of table thandle on |
72 | 80 | !! the lua stack, or if this fails, the entry at position pos |
73 | 81 | !! of the table. If no corresponding value is found, a nil |
@@ -114,8 +122,11 @@ | ||
114 | 122 | |
115 | 123 | end subroutine aot_table_getval |
116 | 124 | |
125 | + | |
117 | 126 | !> Load the first key-value pair of table thandle on the |
118 | - !! stack. This serves as an entry point, further traversal | |
127 | + !! stack. | |
128 | + !! | |
129 | + !! This serves as an entry point, further traversal | |
119 | 130 | !! can be done by flu_next(L, thandle). |
120 | 131 | !! If there are no entries in the table the function |
121 | 132 | !! returns false, otherwise the result will be true. |
@@ -132,6 +143,7 @@ | ||
132 | 143 | end if |
133 | 144 | end function aot_table_first |
134 | 145 | |
146 | + | |
135 | 147 | !> Count the entries in a lua table. |
136 | 148 | function aot_table_length(L, thandle) result(length) |
137 | 149 | type(flu_state) :: L |