main.py 597 B

12345678910111213141516171819202122
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. from wamr.wamrapi.wamr import Engine, Module, Instance, ExecEnv
  4. from ctypes import c_uint
  5. import pathlib
  6. def main():
  7. engine = Engine()
  8. module = Module.from_file(engine, pathlib.Path(__file__).parent / "sum.wasm")
  9. module_inst = Instance(module)
  10. exec_env = ExecEnv(module_inst)
  11. func = module_inst.lookup_function("sum")
  12. argv = (c_uint * 2)(*[10, 11])
  13. exec_env.call(func, len(argv), argv)
  14. print(argv[0])
  15. if __name__ == "__main__":
  16. main()