diff --git a/include/ucode/types.h b/include/ucode/types.h index c0ccd38e..0fa9500d 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -415,6 +415,17 @@ uc_value_t *ucv_resource_new(uc_resource_type_t *, void *); void *ucv_resource_data(uc_value_t *uv, const char *); void **ucv_resource_dataptr(uc_value_t *, const char *); +static inline uc_value_t * +ucv_resource_create(uc_vm_t *vm, const char *typename, void *value) +{ + uc_resource_type_t *t = NULL; + + if (typename && (t = ucv_resource_type_lookup(vm, typename)) == NULL) + return NULL; + + return uc_resource_new(t, value); +} + uc_value_t *ucv_regexp_new(const char *, bool, bool, bool, char **); uc_value_t *ucv_upvalref_new(size_t);