| 1 |
# SPDX-License-Identifier: Apache-2.0 |
| 2 |
# Copyright 2015 The Meson development team |
| 3 |
|
| 4 |
from __future__ import annotations |
| 5 |
import typing as T |
| 6 |
|
| 7 |
from . import NewExtensionModule, ModuleInfo |
| 8 |
from ..interpreterbase import noKwargs, noPosargs |
| 9 |
|
| 10 |
if T.TYPE_CHECKING: |
| 11 |
from . import ModuleState |
| 12 |
from ..interpreter.interpreter import Interpreter |
| 13 |
from ..interpreterbase.baseobjects import TYPE_kwargs, TYPE_var |
| 14 |
|
| 15 |
|
| 16 |
class TestModule(NewExtensionModule): |
| 17 |
|
| 18 |
INFO = ModuleInfo('modtest') |
| 19 |
|
| 20 |
def __init__(self, interpreter: Interpreter) -> None: |
| 21 |
super().__init__() |
| 22 |
self.methods.update({ |
| 23 |
'print_hello': self.print_hello, |
| 24 |
}) |
| 25 |
|
| 26 |
@noKwargs |
| 27 |
@noPosargs |
| 28 |
def print_hello(self, state: ModuleState, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> None: |
| 29 |
print('Hello from a Meson module') |
| 30 |
|
| 31 |
|
| 32 |
def initialize(interp: Interpreter) -> TestModule: |
| 33 |
return TestModule(interp) |