mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-07 12:16:24 +00:00

Before adding the new bindings: 1. Moved wasm-c-api in a subfolder wasmcapi in the package. 2. Adapted the tests to be able to run in this new structure. New: 1. Added the WAMR API in another folder wamrapi in the same level as wasm-c-api. 2. Created an OOP proposal. 3. Added an example using this proposal.
23 lines
597 B
Python
23 lines
597 B
Python
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
from wamr.wamrapi.wamr import Engine, Module, Instance, ExecEnv
|
|
from ctypes import c_uint
|
|
import pathlib
|
|
|
|
def main():
|
|
engine = Engine()
|
|
module = Module.from_file(engine, pathlib.Path(__file__).parent / "sum.wasm")
|
|
module_inst = Instance(module)
|
|
exec_env = ExecEnv(module_inst)
|
|
|
|
func = module_inst.lookup_function("sum")
|
|
|
|
argv = (c_uint * 2)(*[10, 11])
|
|
exec_env.call(func, len(argv), argv)
|
|
print(argv[0])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|