#include #include #include #include "mlp_priv.h" mlp_object *mlp_new_object(mlp_context *ctx, const mlp_class *class_, int nb_args, const mlp_value **args){ mlp_context_clear_error(ctx) ; mlp_runtime_interface *iface = ctx->runtime->interface ; void *lang_object = (*(iface->new_object))(ctx, class_, nb_args, args) ; if (mlp_context_has_error(ctx)){ return NULL ; } mlp_object *object = (mlp_object *)malloc(sizeof(mlp_object)) ; object->object = lang_object ; return object ; } mlp_value *mlp_call_method(mlp_context *ctx, const mlp_object *object, 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 ; mlp_value *value = (*(iface->call_method))(ctx, object, name, nb_args, args, return_type) ; if (mlp_context_has_error(ctx)){ return NULL ; } value = mlp_convert_value(ctx, value, return_type) ; return value ; } void mlp_detach_object(mlp_context *ctx, const mlp_object *object){ mlp_context_clear_error(ctx) ; mlp_runtime_interface *iface = ctx->runtime->interface ; (*(iface->detach_object))(ctx, object) ; } void mlp_delete_object(mlp_context *ctx, const mlp_object *object){ mlp_context_clear_error(ctx) ; mlp_runtime_interface *iface = ctx->runtime->interface ; (*(iface->delete_object))(ctx, object) ; }