#include #include #include #include #include #include "mlp_priv.h" mlp_library *mlp_load_library(mlp_context *ctx, const char *name, const void *opts){ mlp_context_clear_error(ctx) ; mlp_runtime_interface *iface = ctx->runtime->interface ; void *lang_library = (*(iface->load_library))(ctx, name, opts) ; if (mlp_context_has_error(ctx)){ return NULL ; } mlp_library *library = (mlp_library *)malloc(sizeof(mlp_library)) ; library->name = strdup(name) ; library->library = lang_library ; return library ; } mlp_value *mlp_call_function(mlp_context *ctx, const mlp_library *library, const char *name, int nb_args, const mlp_value **args, mlp_type return_type){ mlp_context_clear_error(ctx) ; mlp_runtime_interface *iface = ctx->runtime->interface ; void *lib = (library != NULL ? library->library : NULL) ; mlp_value *value = (*(iface->call_function))(ctx, lib, name, nb_args, args, return_type) ; if (mlp_context_has_error(ctx)){ return NULL ; } value = mlp_convert_value(ctx, value, return_type) ; return value ; }