wasm-micro-runtime
wasm-micro-runtime copied to clipboard
Any recommended naming convention to write bindings?
I am writing IDL to link "iwasm" to the COM interface.
Are there any naming conventions recommended when writing bindings? I am looking at the naming style of go binding and python binding to do this work. But I hope to get some advice. :)
For an example of the IDL:
import "unknwn.idl";
[
object,
uuid(261c74a7-272a-45d2-b472-2c8d1f6de631),
helpstring("iwasm COM interface")
]
interface ICOMIWASM : IUnknown
{
HRESULT SetStackSize([in] int Size);
HRESULT SetHeapSize([in] int Size);
HRESULT SetEnv([in] char* EnvString);
HRESULT LoadFromFile([in] char* FileName);
[local] HRESULT CallFunc([in] char* FuncName, [in] void** Arguments, [out,retval] void* Result);
};
[
uuid(f373d9ea-1e49-4831-9753-a092c6a326ee),
helpstring("Implementation of the iwasm COM interface")
]
library COMIWASM
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
interface ICOMIWASM;
}
Thank you.
hi, the C APIs provided by runtime (wasm_export.h) and wasm-c-api (wasm_c_api.h) may be a little complex and not very convenient, for high level language binding, my personal suggestion is to refer to the Go binding APIs, it should be relatively clear and simple. Normally there should be three group APIs: runtime related APIs, wasm/aot module related APIs and wasm/aot module instance related APIs.
interface ICOMIWASM : IUnknown { HRESULT SetStackSize([in] int Size); HRESULT SetHeapSize([in] int Size);
Seems the APIs are for all module instance? Shall we set them for each module instance?
HRESULT SetEnv([in] char* EnvString);
Is it used to set wasi arguments for a module?
HRESULT LoadFromFile([in] char* FileName);
Had better define a module type, and change the return type to handle of the module type? And is there API to load module from a byte array? And if loading module fails, can we get the error info?
[local] HRESULT CallFunc([in] char* FuncName, [in] void** Arguments, [out,retval] void* Result);
Which module instance to call? Do we need to specify the input/output argument count?
There may be multiple return value, had better change to void **Result?
If calling failed, can we get the exception thrown?
And is there runtime initialization and destroy APIs? Thanks.