The current mono public embedding API headers are awkward to work with both for runtime developers and for embedding hosts that wish to dynamically load the runtime:
- The API headers are in the same directory as the Mono implementation and the internal Mono headers, making it difficult to understand which headers constitute the public API surface without reading the cmake files. Additionally, other runtimes implementing the mono embedding API cannot easily share the headers.
- The API headers declare mono API functions with
MONO_API return_type function_name (args...), which is reasonable for embedding hosts that link to the runtime at compile time, but are not suitable for hosts that use late binding (dlopen+dlsym) to access the mono symbols. We should reorganize the headers to support late binding. (One idea: define API functions as MONO_API(return_type, function_name, (args...)) and allow users of the headers to re-define the MONO_API macro and include the header multiple times. That would allow C compile-time "code generation" of typedefs and dlsym boilerplate.
- One client of the new headers would be a testsuite of the embedding API. Previously in github.com/mono/mono, the tests (src/mono/mono/tests/libtest.c) had to duplicate the API function signatures just to declare the function pointers storing the dynamically loaded symbols.
Tasks:
The current mono public embedding API headers are awkward to work with both for runtime developers and for embedding hosts that wish to dynamically load the runtime:
MONO_API return_type function_name (args...), which is reasonable for embedding hosts that link to the runtime at compile time, but are not suitable for hosts that use late binding (dlopen+dlsym) to access the mono symbols. We should reorganize the headers to support late binding. (One idea: define API functions asMONO_API(return_type, function_name, (args...))and allow users of the headers to re-define theMONO_APImacro and include the header multiple times. That would allow C compile-time "code generation" of typedefs anddlsymboilerplate.Tasks:
src/native/include/mono-2.0(ie:src/native/include/mono-2.0/mono/metadata/object.hsrc/native/include/mono-2.0//mono/mini/jit.hetc) [build] Move Mono API headers under src/native/public #64569MONO_API_FUNCTION(return_type,name,args_sig)and factor the public headers into "implementation details" headers; move type definitions to separate details headers from function definitions; allow the function definitions headers to be included multiple times and to re-defineMONO_API_FUNCTION (r,n,a)[MonoAPI] Split type and function headers, add MONO_API_FUNCTION macro #65446libtest.cand existing embedding API testing code fromsrc/mono/mono/teststosrc/tests/Interop/MonoAPIand run the tests on desktop mono configurations. Includes switching the tests to use the newMONO_API_FUNCTIONlate binding approach. [tests] Add MonoApi runtime tests #65221