wasm_application.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2019 Taobao (China) Inc. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _WASM_APPLICATION_H
  17. #define _WASM_APPLICATION_H
  18. //#include "wasm_runtime.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. struct WASMModuleInstance;
  23. /**
  24. * Find the unique main function from a WASM module instance
  25. * and execute that function.
  26. *
  27. * @param module_inst the WASM module instance
  28. * @param argc the number of arguments
  29. * @param argv the arguments array
  30. *
  31. * @return true if the main function is called, false otherwise and exception will be thrown,
  32. * the caller can call wasm_runtime_get_exception to get exception info.
  33. */
  34. bool
  35. wasm_application_execute_main(struct WASMModuleInstance *module_inst,
  36. int argc, char *argv[]);
  37. /**
  38. * Find the specified function in argv[0] from a WASM module instance
  39. * and execute that function.
  40. *
  41. * @param module_inst the WASM module instance
  42. * @param name the name of the function to execute
  43. * @param argc the number of arguments
  44. * @param argv the arguments array
  45. *
  46. * @return true if the specified function is called, false otherwise and exception will be thrown,
  47. * the caller can call wasm_runtime_get_exception to get exception info.
  48. */
  49. bool
  50. wasm_application_execute_func(struct WASMModuleInstance *module_inst,
  51. char *name, int argc, char *argv[]);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* end of _WASM_APPLICATION_H */