docs: add documentation for method overloading patterns and usage examples

This commit is contained in:
2025-12-09 14:09:16 +00:00
parent 4ac83652a1
commit f30f58044c
8 changed files with 196 additions and 3 deletions
+22
View File
@@ -68,6 +68,28 @@ RavaType_t* rava_type_create_array(RavaType_t *element_type, int dimensions) {
return type;
}
RavaType_t* rava_type_copy(RavaType_t *type) {
if (!type) return NULL;
if (_is_pooled_type(type)) {
return type;
}
if (type->kind == RAVA_TYPE_ARRAY) {
return rava_type_create_array(
rava_type_copy(type->data.array.element_type),
type->data.array.dimensions
);
} else if (type->kind == RAVA_TYPE_CLASS) {
return rava_type_create_class(type->data.class_type.class_name);
}
RavaType_t *copy = calloc(1, sizeof(RavaType_t));
copy->kind = type->kind;
copy->name = strdup(type->name);
return copy;
}
void rava_type_destroy(RavaType_t *type) {
if (!type || _is_pooled_type(type)) return;
+1
View File
@@ -42,6 +42,7 @@ struct RavaType_t {
RavaType_t* rava_type_create_primitive(RavaTypeKind_e kind);
RavaType_t* rava_type_create_class(const char *class_name);
RavaType_t* rava_type_create_array(RavaType_t *element_type, int dimensions);
RavaType_t* rava_type_copy(RavaType_t *type);
void rava_type_destroy(RavaType_t *type);
RavaType_t* rava_type_from_name(const char *type_name);