Import source to librtti

Summary:

- Import initial source

Test Plan:
NA
This commit is contained in:
Rongsong Shen 2026-01-29 17:22:53 +08:00
commit c8c1749347
23 changed files with 969 additions and 0 deletions

23
src/str.c Normal file
View file

@ -0,0 +1,23 @@
#include <errno.h>
#include <stdlib.h>
#include "rtti.h"
char* toString(var v, ...)
{
to_string_fn_t method = NULL;
va_list ap;
char* s = NULL;
RTTI_GET_METHOD(method, v, toString, toString);
if (method == NULL) {
errno = -EINVAL;
return NULL;
}
va_start(ap, v);
s = method(v, ap);
va_end(ap);
return s;
}