| 1 |
# Module Structure |
| 2 |
|
| 3 |
A script module consists of functions that perform the various module |
| 4 |
operations. The final `return` at module scope is what "exports" the functions |
| 5 |
to module consumers. The returned object must be of type `dict[func]`. |
| 6 |
|
| 7 |
```meson |
| 8 |
func func1() |
| 9 |
endfunc |
| 10 |
|
| 11 |
func func2() |
| 12 |
endfunc |
| 13 |
|
| 14 |
return { |
| 15 |
'func1': func1, |
| 16 |
'func2': func2, |
| 17 |
} |
| 18 |
``` |
| 19 |
|
| 20 |
Using some of the new syntax for `dict` mutation we can define modules like this |
| 21 |
too: |
| 22 |
|
| 23 |
```meson |
| 24 |
M = {} |
| 25 |
|
| 26 |
M.func1 = func() |
| 27 |
endfunc |
| 28 |
|
| 29 |
M.func2 = func() |
| 30 |
endfunc |
| 31 |
|
| 32 |
return M |
| 33 |
``` |