chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
// C stdlib type information for C/C++ LSP type resolver.
|
||||
|
||||
#include "../type_rep.h"
|
||||
#include "../type_registry.h"
|
||||
#include <string.h>
|
||||
|
||||
// Helper macros for concise registration
|
||||
#define REG_FUNC(qn, short, ret_type) do { \
|
||||
memset(&rf, 0, sizeof(rf)); \
|
||||
rf.min_params = -1; \
|
||||
rf.qualified_name = (qn); \
|
||||
rf.short_name = (short); \
|
||||
rf.signature = cbm_type_func(arena, NULL, NULL, (const CBMType*[]){(ret_type), NULL}); \
|
||||
cbm_registry_add_func(reg, rf); \
|
||||
} while(0)
|
||||
|
||||
#define REG_TYPE(qn, short) do { \
|
||||
memset(&rt, 0, sizeof(rt)); \
|
||||
rt.qualified_name = (qn); \
|
||||
rt.short_name = (short); \
|
||||
cbm_registry_add_type(reg, rt); \
|
||||
} while(0)
|
||||
|
||||
void cbm_c_stdlib_register(CBMTypeRegistry* reg, CBMArena* arena) {
|
||||
CBMRegisteredFunc rf;
|
||||
CBMRegisteredType rt;
|
||||
|
||||
const CBMType* t_int = cbm_type_builtin(arena, "int");
|
||||
const CBMType* t_size_t = cbm_type_builtin(arena, "size_t");
|
||||
const CBMType* t_double = cbm_type_builtin(arena, "double");
|
||||
const CBMType* t_void = cbm_type_builtin(arena, "void");
|
||||
const CBMType* t_char_ptr = cbm_type_pointer(arena, cbm_type_builtin(arena, "char"));
|
||||
const CBMType* t_void_ptr = cbm_type_pointer(arena, t_void);
|
||||
|
||||
// FILE type
|
||||
REG_TYPE("FILE", "FILE");
|
||||
const CBMType* t_file_ptr = cbm_type_pointer(arena, cbm_type_named(arena, "FILE"));
|
||||
|
||||
// stdio.h
|
||||
REG_FUNC("fopen", "fopen", t_file_ptr);
|
||||
REG_FUNC("fclose", "fclose", t_int);
|
||||
REG_FUNC("fprintf", "fprintf", t_int);
|
||||
REG_FUNC("fread", "fread", t_size_t);
|
||||
REG_FUNC("fwrite", "fwrite", t_size_t);
|
||||
REG_FUNC("printf", "printf", t_int);
|
||||
REG_FUNC("scanf", "scanf", t_int);
|
||||
REG_FUNC("fgets", "fgets", t_char_ptr);
|
||||
REG_FUNC("fputs", "fputs", t_int);
|
||||
REG_FUNC("fseek", "fseek", t_int);
|
||||
REG_FUNC("ftell", "ftell", cbm_type_builtin(arena, "long"));
|
||||
REG_FUNC("rewind", "rewind", t_void);
|
||||
REG_FUNC("feof", "feof", t_int);
|
||||
REG_FUNC("ferror", "ferror", t_int);
|
||||
REG_FUNC("snprintf", "snprintf", t_int);
|
||||
REG_FUNC("sprintf", "sprintf", t_int);
|
||||
REG_FUNC("sscanf", "sscanf", t_int);
|
||||
REG_FUNC("getchar", "getchar", t_int);
|
||||
REG_FUNC("putchar", "putchar", t_int);
|
||||
REG_FUNC("puts", "puts", t_int);
|
||||
REG_FUNC("perror", "perror", t_void);
|
||||
|
||||
// stdlib.h
|
||||
REG_FUNC("malloc", "malloc", t_void_ptr);
|
||||
REG_FUNC("calloc", "calloc", t_void_ptr);
|
||||
REG_FUNC("realloc", "realloc", t_void_ptr);
|
||||
REG_FUNC("free", "free", t_void);
|
||||
REG_FUNC("atoi", "atoi", t_int);
|
||||
REG_FUNC("atof", "atof", t_double);
|
||||
REG_FUNC("atol", "atol", cbm_type_builtin(arena, "long"));
|
||||
REG_FUNC("strtol", "strtol", cbm_type_builtin(arena, "long"));
|
||||
REG_FUNC("strtod", "strtod", t_double);
|
||||
REG_FUNC("exit", "exit", t_void);
|
||||
REG_FUNC("abort", "abort", t_void);
|
||||
REG_FUNC("abs", "abs", t_int);
|
||||
REG_FUNC("rand", "rand", t_int);
|
||||
REG_FUNC("srand", "srand", t_void);
|
||||
REG_FUNC("qsort", "qsort", t_void);
|
||||
REG_FUNC("bsearch", "bsearch", t_void_ptr);
|
||||
REG_FUNC("getenv", "getenv", t_char_ptr);
|
||||
REG_FUNC("system", "system", t_int);
|
||||
|
||||
// string.h
|
||||
REG_FUNC("strlen", "strlen", t_size_t);
|
||||
REG_FUNC("strcmp", "strcmp", t_int);
|
||||
REG_FUNC("strncmp", "strncmp", t_int);
|
||||
REG_FUNC("strcpy", "strcpy", t_char_ptr);
|
||||
REG_FUNC("strncpy", "strncpy", t_char_ptr);
|
||||
REG_FUNC("strcat", "strcat", t_char_ptr);
|
||||
REG_FUNC("strncat", "strncat", t_char_ptr);
|
||||
REG_FUNC("strchr", "strchr", t_char_ptr);
|
||||
REG_FUNC("strrchr", "strrchr", t_char_ptr);
|
||||
REG_FUNC("strstr", "strstr", t_char_ptr);
|
||||
REG_FUNC("strtok", "strtok", t_char_ptr);
|
||||
REG_FUNC("memcpy", "memcpy", t_void_ptr);
|
||||
REG_FUNC("memmove", "memmove", t_void_ptr);
|
||||
REG_FUNC("memset", "memset", t_void_ptr);
|
||||
REG_FUNC("memcmp", "memcmp", t_int);
|
||||
|
||||
// ctype.h
|
||||
REG_FUNC("isalpha", "isalpha", t_int);
|
||||
REG_FUNC("isdigit", "isdigit", t_int);
|
||||
REG_FUNC("isalnum", "isalnum", t_int);
|
||||
REG_FUNC("isspace", "isspace", t_int);
|
||||
REG_FUNC("isupper", "isupper", t_int);
|
||||
REG_FUNC("islower", "islower", t_int);
|
||||
REG_FUNC("toupper", "toupper", t_int);
|
||||
REG_FUNC("tolower", "tolower", t_int);
|
||||
|
||||
// math.h
|
||||
REG_FUNC("sqrt", "sqrt", t_double);
|
||||
REG_FUNC("pow", "pow", t_double);
|
||||
REG_FUNC("sin", "sin", t_double);
|
||||
REG_FUNC("cos", "cos", t_double);
|
||||
REG_FUNC("tan", "tan", t_double);
|
||||
REG_FUNC("exp", "exp", t_double);
|
||||
REG_FUNC("log", "log", t_double);
|
||||
REG_FUNC("log10", "log10", t_double);
|
||||
REG_FUNC("fabs", "fabs", t_double);
|
||||
REG_FUNC("ceil", "ceil", t_double);
|
||||
REG_FUNC("floor", "floor", t_double);
|
||||
REG_FUNC("round", "round", t_double);
|
||||
|
||||
// assert.h / signal.h / time.h basics
|
||||
REG_FUNC("assert", "assert", t_void);
|
||||
REG_FUNC("signal", "signal", t_void);
|
||||
REG_FUNC("time", "time", cbm_type_builtin(arena, "time_t"));
|
||||
REG_FUNC("clock", "clock", cbm_type_builtin(arena, "clock_t"));
|
||||
REG_FUNC("difftime", "difftime", t_double);
|
||||
}
|
||||
|
||||
#undef REG_FUNC
|
||||
#undef REG_TYPE
|
||||
@@ -0,0 +1,947 @@
|
||||
// C++ stdlib type information for C/C++ LSP type resolver.
|
||||
|
||||
#include "../type_rep.h"
|
||||
#include "../type_registry.h"
|
||||
#include <string.h>
|
||||
|
||||
// Helper: register a method on a type
|
||||
static void reg_method(CBMTypeRegistry* reg, CBMArena* arena,
|
||||
const char* recv_qn, const char* method_name, const CBMType* ret_type) {
|
||||
CBMRegisteredFunc rf;
|
||||
memset(&rf, 0, sizeof(rf));
|
||||
rf.min_params = -1;
|
||||
// Build QN: recv_qn.method_name
|
||||
size_t rlen = strlen(recv_qn);
|
||||
size_t mlen = strlen(method_name);
|
||||
char* qn = (char*)cbm_arena_alloc(arena, rlen + 1 + mlen + 1);
|
||||
if (!qn) return;
|
||||
memcpy(qn, recv_qn, rlen);
|
||||
qn[rlen] = '.';
|
||||
memcpy(qn + rlen + 1, method_name, mlen);
|
||||
qn[rlen + 1 + mlen] = '\0';
|
||||
|
||||
rf.qualified_name = qn;
|
||||
rf.short_name = method_name;
|
||||
rf.receiver_type = recv_qn;
|
||||
rf.signature = cbm_type_func(arena, NULL, NULL,
|
||||
ret_type ? (const CBMType*[]){ret_type, NULL} : NULL);
|
||||
cbm_registry_add_func(reg, rf);
|
||||
}
|
||||
|
||||
// Helper: register a type
|
||||
static void reg_type(CBMTypeRegistry* reg, const char* qn, const char* short_name) {
|
||||
CBMRegisteredType rt;
|
||||
memset(&rt, 0, sizeof(rt));
|
||||
rt.qualified_name = qn;
|
||||
rt.short_name = short_name;
|
||||
cbm_registry_add_type(reg, rt);
|
||||
}
|
||||
|
||||
// Helper: register a type with field names
|
||||
static void reg_type_with_fields(CBMTypeRegistry* reg, CBMArena* arena,
|
||||
const char* qn, const char* short_name,
|
||||
const char** fnames, const CBMType** ftypes) {
|
||||
CBMRegisteredType rt;
|
||||
memset(&rt, 0, sizeof(rt));
|
||||
rt.qualified_name = qn;
|
||||
rt.short_name = short_name;
|
||||
rt.field_names = fnames;
|
||||
rt.field_types = ftypes;
|
||||
cbm_registry_add_type(reg, rt);
|
||||
}
|
||||
|
||||
// Helper: register a free function
|
||||
static void reg_func(CBMTypeRegistry* reg, CBMArena* arena,
|
||||
const char* qn, const char* short_name, const CBMType* ret_type) {
|
||||
CBMRegisteredFunc rf;
|
||||
memset(&rf, 0, sizeof(rf));
|
||||
rf.min_params = -1;
|
||||
rf.qualified_name = qn;
|
||||
rf.short_name = short_name;
|
||||
rf.signature = cbm_type_func(arena, NULL, NULL,
|
||||
ret_type ? (const CBMType*[]){ret_type, NULL} : NULL);
|
||||
cbm_registry_add_func(reg, rf);
|
||||
}
|
||||
|
||||
void cbm_cpp_stdlib_register(CBMTypeRegistry* reg, CBMArena* arena) {
|
||||
const CBMType* t_void = cbm_type_builtin(arena, "void");
|
||||
const CBMType* t_void_ptr = cbm_type_pointer(arena, t_void);
|
||||
const CBMType* t_bool = cbm_type_builtin(arena, "bool");
|
||||
const CBMType* t_int = cbm_type_builtin(arena, "int");
|
||||
const CBMType* t_size_t = cbm_type_builtin(arena, "size_t");
|
||||
const CBMType* t_long = cbm_type_builtin(arena, "long");
|
||||
const CBMType* t_char = cbm_type_builtin(arena, "char");
|
||||
const CBMType* t_char_ptr = cbm_type_pointer(arena, cbm_type_builtin(arena, "const char"));
|
||||
|
||||
// =========================================================================
|
||||
// std.string
|
||||
// =========================================================================
|
||||
const char* string_qn = "std.string";
|
||||
reg_type(reg, string_qn, "string");
|
||||
const CBMType* t_string = cbm_type_named(arena, string_qn);
|
||||
const CBMType* t_string_ref = cbm_type_reference(arena, t_string);
|
||||
|
||||
reg_method(reg, arena, string_qn, "c_str", t_char_ptr);
|
||||
reg_method(reg, arena, string_qn, "data", t_char_ptr);
|
||||
reg_method(reg, arena, string_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, string_qn, "length", t_size_t);
|
||||
reg_method(reg, arena, string_qn, "capacity", t_size_t);
|
||||
reg_method(reg, arena, string_qn, "max_size", t_size_t);
|
||||
reg_method(reg, arena, string_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, string_qn, "clear", t_void);
|
||||
reg_method(reg, arena, string_qn, "substr", t_string);
|
||||
reg_method(reg, arena, string_qn, "find", t_size_t);
|
||||
reg_method(reg, arena, string_qn, "rfind", t_size_t);
|
||||
reg_method(reg, arena, string_qn, "compare", t_int);
|
||||
reg_method(reg, arena, string_qn, "append", t_string_ref);
|
||||
reg_method(reg, arena, string_qn, "insert", t_string_ref);
|
||||
reg_method(reg, arena, string_qn, "erase", t_string_ref);
|
||||
reg_method(reg, arena, string_qn, "replace", t_string_ref);
|
||||
reg_method(reg, arena, string_qn, "push_back", t_void);
|
||||
reg_method(reg, arena, string_qn, "pop_back", t_void);
|
||||
reg_method(reg, arena, string_qn, "front", cbm_type_reference(arena, t_char));
|
||||
reg_method(reg, arena, string_qn, "back", cbm_type_reference(arena, t_char));
|
||||
reg_method(reg, arena, string_qn, "at", cbm_type_reference(arena, t_char));
|
||||
reg_method(reg, arena, string_qn, "operator[]", cbm_type_reference(arena, t_char));
|
||||
reg_method(reg, arena, string_qn, "begin", cbm_type_named(arena, "std.string.iterator"));
|
||||
reg_method(reg, arena, string_qn, "end", cbm_type_named(arena, "std.string.iterator"));
|
||||
reg_method(reg, arena, string_qn, "resize", t_void);
|
||||
reg_method(reg, arena, string_qn, "reserve", t_void);
|
||||
reg_method(reg, arena, string_qn, "starts_with", t_bool);
|
||||
reg_method(reg, arena, string_qn, "ends_with", t_bool);
|
||||
reg_method(reg, arena, string_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, string_qn, "operator+", t_string);
|
||||
reg_method(reg, arena, string_qn, "operator+=", t_string_ref);
|
||||
// Also register as std.basic_string alias
|
||||
{
|
||||
CBMRegisteredType rt;
|
||||
memset(&rt, 0, sizeof(rt));
|
||||
rt.qualified_name = "std.basic_string";
|
||||
rt.short_name = "basic_string";
|
||||
rt.alias_of = string_qn;
|
||||
cbm_registry_add_type(reg, rt);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// std.string_view
|
||||
// =========================================================================
|
||||
const char* sv_qn = "std.string_view";
|
||||
reg_type(reg, sv_qn, "string_view");
|
||||
reg_method(reg, arena, sv_qn, "data", t_char_ptr);
|
||||
reg_method(reg, arena, sv_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, sv_qn, "length", t_size_t);
|
||||
reg_method(reg, arena, sv_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, sv_qn, "substr", cbm_type_named(arena, sv_qn));
|
||||
reg_method(reg, arena, sv_qn, "find", t_size_t);
|
||||
reg_method(reg, arena, sv_qn, "starts_with", t_bool);
|
||||
reg_method(reg, arena, sv_qn, "ends_with", t_bool);
|
||||
reg_method(reg, arena, sv_qn, "operator[]", t_char);
|
||||
|
||||
// =========================================================================
|
||||
// std.vector<T> — T is first template arg
|
||||
// =========================================================================
|
||||
const char* vec_qn = "std.vector";
|
||||
reg_type(reg, vec_qn, "vector");
|
||||
const CBMType* t_T = cbm_type_type_param(arena, "T");
|
||||
const CBMType* t_T_ref = cbm_type_reference(arena, t_T);
|
||||
const CBMType* t_T_ptr = cbm_type_pointer(arena, t_T);
|
||||
|
||||
reg_method(reg, arena, vec_qn, "push_back", t_void);
|
||||
reg_method(reg, arena, vec_qn, "emplace_back", t_void);
|
||||
reg_method(reg, arena, vec_qn, "pop_back", t_void);
|
||||
reg_method(reg, arena, vec_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, vec_qn, "capacity", t_size_t);
|
||||
reg_method(reg, arena, vec_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, vec_qn, "clear", t_void);
|
||||
reg_method(reg, arena, vec_qn, "resize", t_void);
|
||||
reg_method(reg, arena, vec_qn, "reserve", t_void);
|
||||
reg_method(reg, arena, vec_qn, "shrink_to_fit", t_void);
|
||||
reg_method(reg, arena, vec_qn, "front", t_T_ref);
|
||||
reg_method(reg, arena, vec_qn, "back", t_T_ref);
|
||||
reg_method(reg, arena, vec_qn, "at", t_T_ref);
|
||||
reg_method(reg, arena, vec_qn, "data", t_T_ptr);
|
||||
reg_method(reg, arena, vec_qn, "operator[]", t_T_ref);
|
||||
reg_method(reg, arena, vec_qn, "begin", cbm_type_named(arena, "std.vector.iterator"));
|
||||
reg_method(reg, arena, vec_qn, "end", cbm_type_named(arena, "std.vector.iterator"));
|
||||
reg_method(reg, arena, vec_qn, "erase", cbm_type_named(arena, "std.vector.iterator"));
|
||||
reg_method(reg, arena, vec_qn, "insert", cbm_type_named(arena, "std.vector.iterator"));
|
||||
|
||||
// =========================================================================
|
||||
// std.map<K,V>
|
||||
// =========================================================================
|
||||
const char* map_qn = "std.map";
|
||||
reg_type(reg, map_qn, "map");
|
||||
const CBMType* t_V = cbm_type_type_param(arena, "V");
|
||||
const CBMType* t_V_ref = cbm_type_reference(arena, t_V);
|
||||
|
||||
reg_method(reg, arena, map_qn, "operator[]", t_V_ref);
|
||||
reg_method(reg, arena, map_qn, "at", t_V_ref);
|
||||
reg_method(reg, arena, map_qn, "find", cbm_type_named(arena, "std.map.iterator"));
|
||||
reg_method(reg, arena, map_qn, "insert", cbm_type_named(arena, "std.pair"));
|
||||
reg_method(reg, arena, map_qn, "emplace", cbm_type_named(arena, "std.pair"));
|
||||
reg_method(reg, arena, map_qn, "erase", t_size_t);
|
||||
reg_method(reg, arena, map_qn, "count", t_size_t);
|
||||
reg_method(reg, arena, map_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, map_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, map_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, map_qn, "clear", t_void);
|
||||
reg_method(reg, arena, map_qn, "begin", cbm_type_named(arena, "std.map.iterator"));
|
||||
reg_method(reg, arena, map_qn, "end", cbm_type_named(arena, "std.map.iterator"));
|
||||
|
||||
// std.unordered_map<K,V> — same interface
|
||||
const char* umap_qn = "std.unordered_map";
|
||||
reg_type(reg, umap_qn, "unordered_map");
|
||||
reg_method(reg, arena, umap_qn, "operator[]", t_V_ref);
|
||||
reg_method(reg, arena, umap_qn, "at", t_V_ref);
|
||||
reg_method(reg, arena, umap_qn, "find", cbm_type_named(arena, "std.unordered_map.iterator"));
|
||||
reg_method(reg, arena, umap_qn, "insert", cbm_type_named(arena, "std.pair"));
|
||||
reg_method(reg, arena, umap_qn, "emplace", cbm_type_named(arena, "std.pair"));
|
||||
reg_method(reg, arena, umap_qn, "erase", t_size_t);
|
||||
reg_method(reg, arena, umap_qn, "count", t_size_t);
|
||||
reg_method(reg, arena, umap_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, umap_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, umap_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, umap_qn, "clear", t_void);
|
||||
reg_method(reg, arena, umap_qn, "begin", cbm_type_named(arena, "std.unordered_map.iterator"));
|
||||
reg_method(reg, arena, umap_qn, "end", cbm_type_named(arena, "std.unordered_map.iterator"));
|
||||
|
||||
// =========================================================================
|
||||
// std.set<T> / std.unordered_set<T>
|
||||
// =========================================================================
|
||||
const char* set_qn = "std.set";
|
||||
reg_type(reg, set_qn, "set");
|
||||
reg_method(reg, arena, set_qn, "insert", cbm_type_named(arena, "std.pair"));
|
||||
reg_method(reg, arena, set_qn, "find", cbm_type_named(arena, "std.set.iterator"));
|
||||
reg_method(reg, arena, set_qn, "erase", t_size_t);
|
||||
reg_method(reg, arena, set_qn, "count", t_size_t);
|
||||
reg_method(reg, arena, set_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, set_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, set_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, set_qn, "clear", t_void);
|
||||
reg_method(reg, arena, set_qn, "begin", cbm_type_named(arena, "std.set.iterator"));
|
||||
reg_method(reg, arena, set_qn, "end", cbm_type_named(arena, "std.set.iterator"));
|
||||
|
||||
const char* uset_qn = "std.unordered_set";
|
||||
reg_type(reg, uset_qn, "unordered_set");
|
||||
reg_method(reg, arena, uset_qn, "insert", cbm_type_named(arena, "std.pair"));
|
||||
reg_method(reg, arena, uset_qn, "find", cbm_type_named(arena, "std.unordered_set.iterator"));
|
||||
reg_method(reg, arena, uset_qn, "erase", t_size_t);
|
||||
reg_method(reg, arena, uset_qn, "count", t_size_t);
|
||||
reg_method(reg, arena, uset_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, uset_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, uset_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, uset_qn, "clear", t_void);
|
||||
|
||||
// =========================================================================
|
||||
// Smart pointers: std.unique_ptr<T>, std.shared_ptr<T>, std.weak_ptr<T>
|
||||
// =========================================================================
|
||||
const char* uptr_qn = "std.unique_ptr";
|
||||
reg_type(reg, uptr_qn, "unique_ptr");
|
||||
reg_method(reg, arena, uptr_qn, "get", t_T_ptr);
|
||||
reg_method(reg, arena, uptr_qn, "reset", t_void);
|
||||
reg_method(reg, arena, uptr_qn, "release", t_T_ptr);
|
||||
reg_method(reg, arena, uptr_qn, "operator->", t_T_ptr);
|
||||
reg_method(reg, arena, uptr_qn, "operator*", t_T_ref);
|
||||
reg_method(reg, arena, uptr_qn, "operator bool", t_bool);
|
||||
reg_method(reg, arena, uptr_qn, "swap", t_void);
|
||||
|
||||
const char* sptr_qn = "std.shared_ptr";
|
||||
reg_type(reg, sptr_qn, "shared_ptr");
|
||||
reg_method(reg, arena, sptr_qn, "get", t_T_ptr);
|
||||
reg_method(reg, arena, sptr_qn, "reset", t_void);
|
||||
reg_method(reg, arena, sptr_qn, "use_count", t_long);
|
||||
reg_method(reg, arena, sptr_qn, "unique", t_bool);
|
||||
reg_method(reg, arena, sptr_qn, "operator->", t_T_ptr);
|
||||
reg_method(reg, arena, sptr_qn, "operator*", t_T_ref);
|
||||
reg_method(reg, arena, sptr_qn, "operator bool", t_bool);
|
||||
reg_method(reg, arena, sptr_qn, "swap", t_void);
|
||||
|
||||
const char* wptr_qn = "std.weak_ptr";
|
||||
reg_type(reg, wptr_qn, "weak_ptr");
|
||||
reg_method(reg, arena, wptr_qn, "lock", cbm_type_named(arena, sptr_qn));
|
||||
reg_method(reg, arena, wptr_qn, "use_count", t_long);
|
||||
reg_method(reg, arena, wptr_qn, "expired", t_bool);
|
||||
reg_method(reg, arena, wptr_qn, "reset", t_void);
|
||||
|
||||
// std.make_unique / std.make_shared — free functions
|
||||
// Return type depends on template arg, registered as returning unique_ptr/shared_ptr
|
||||
reg_func(reg, arena, "std.make_unique", "make_unique",
|
||||
cbm_type_named(arena, uptr_qn));
|
||||
reg_func(reg, arena, "std.make_shared", "make_shared",
|
||||
cbm_type_named(arena, sptr_qn));
|
||||
|
||||
// =========================================================================
|
||||
// std.optional<T>
|
||||
// =========================================================================
|
||||
const char* opt_qn = "std.optional";
|
||||
reg_type(reg, opt_qn, "optional");
|
||||
reg_method(reg, arena, opt_qn, "value", t_T_ref);
|
||||
reg_method(reg, arena, opt_qn, "has_value", t_bool);
|
||||
reg_method(reg, arena, opt_qn, "value_or", t_T);
|
||||
reg_method(reg, arena, opt_qn, "operator*", t_T_ref);
|
||||
reg_method(reg, arena, opt_qn, "operator->", t_T_ptr);
|
||||
reg_method(reg, arena, opt_qn, "operator bool", t_bool);
|
||||
reg_method(reg, arena, opt_qn, "reset", t_void);
|
||||
reg_method(reg, arena, opt_qn, "emplace", t_T_ref);
|
||||
|
||||
// =========================================================================
|
||||
// std.pair<T1, T2>
|
||||
// =========================================================================
|
||||
const char* pair_qn = "std.pair";
|
||||
{
|
||||
static const char* pair_field_names[] = {"first", "second", NULL};
|
||||
const CBMType** pair_field_types = (const CBMType**)cbm_arena_alloc(arena,
|
||||
3 * sizeof(const CBMType*));
|
||||
pair_field_types[0] = cbm_type_type_param(arena, "T1");
|
||||
pair_field_types[1] = cbm_type_type_param(arena, "T2");
|
||||
pair_field_types[2] = NULL;
|
||||
reg_type_with_fields(reg, arena, pair_qn, "pair", pair_field_names, pair_field_types);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// std.tuple<...>
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.tuple", "tuple");
|
||||
reg_func(reg, arena, "std.get", "get", cbm_type_unknown());
|
||||
|
||||
// =========================================================================
|
||||
// std.array<T, N>
|
||||
// =========================================================================
|
||||
const char* arr_qn = "std.array";
|
||||
reg_type(reg, arr_qn, "array");
|
||||
reg_method(reg, arena, arr_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, arr_qn, "data", t_T_ptr);
|
||||
reg_method(reg, arena, arr_qn, "at", t_T_ref);
|
||||
reg_method(reg, arena, arr_qn, "front", t_T_ref);
|
||||
reg_method(reg, arena, arr_qn, "back", t_T_ref);
|
||||
reg_method(reg, arena, arr_qn, "operator[]", t_T_ref);
|
||||
reg_method(reg, arena, arr_qn, "begin", t_T_ptr);
|
||||
reg_method(reg, arena, arr_qn, "end", t_T_ptr);
|
||||
reg_method(reg, arena, arr_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, arr_qn, "fill", t_void);
|
||||
|
||||
// =========================================================================
|
||||
// std.function<F>
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.function", "function");
|
||||
reg_method(reg, arena, "std.function", "operator()", cbm_type_unknown());
|
||||
reg_method(reg, arena, "std.function", "operator bool", t_bool);
|
||||
reg_method(reg, arena, "std.function", "target", t_void_ptr);
|
||||
|
||||
// =========================================================================
|
||||
// I/O streams
|
||||
// =========================================================================
|
||||
const char* os_qn = "std.ostream";
|
||||
reg_type(reg, os_qn, "ostream");
|
||||
const CBMType* t_ostream_ref = cbm_type_reference(arena, cbm_type_named(arena, os_qn));
|
||||
reg_method(reg, arena, os_qn, "operator<<", t_ostream_ref);
|
||||
reg_method(reg, arena, os_qn, "write", t_ostream_ref);
|
||||
reg_method(reg, arena, os_qn, "flush", t_ostream_ref);
|
||||
reg_method(reg, arena, os_qn, "put", t_ostream_ref);
|
||||
reg_method(reg, arena, os_qn, "good", t_bool);
|
||||
reg_method(reg, arena, os_qn, "fail", t_bool);
|
||||
reg_method(reg, arena, os_qn, "bad", t_bool);
|
||||
reg_method(reg, arena, os_qn, "eof", t_bool);
|
||||
|
||||
const char* is_qn = "std.istream";
|
||||
reg_type(reg, is_qn, "istream");
|
||||
const CBMType* t_istream_ref = cbm_type_reference(arena, cbm_type_named(arena, is_qn));
|
||||
reg_method(reg, arena, is_qn, "operator>>", t_istream_ref);
|
||||
reg_method(reg, arena, is_qn, "read", t_istream_ref);
|
||||
reg_method(reg, arena, is_qn, "getline", t_istream_ref);
|
||||
reg_method(reg, arena, is_qn, "get", t_int);
|
||||
reg_method(reg, arena, is_qn, "peek", t_int);
|
||||
reg_method(reg, arena, is_qn, "good", t_bool);
|
||||
reg_method(reg, arena, is_qn, "fail", t_bool);
|
||||
|
||||
// Global stream objects
|
||||
reg_func(reg, arena, "std.cout", "cout", cbm_type_named(arena, os_qn));
|
||||
reg_func(reg, arena, "std.cin", "cin", cbm_type_named(arena, is_qn));
|
||||
reg_func(reg, arena, "std.cerr", "cerr", cbm_type_named(arena, os_qn));
|
||||
reg_func(reg, arena, "std.clog", "clog", cbm_type_named(arena, os_qn));
|
||||
|
||||
// std.endl, std.flush — manipulators (treat as returning ostream ref)
|
||||
reg_func(reg, arena, "std.endl", "endl", t_ostream_ref);
|
||||
reg_func(reg, arena, "std.flush", "flush", t_ostream_ref);
|
||||
|
||||
// =========================================================================
|
||||
// std.filesystem.path
|
||||
// =========================================================================
|
||||
const char* fspath_qn = "std.filesystem.path";
|
||||
reg_type(reg, fspath_qn, "path");
|
||||
const CBMType* t_path = cbm_type_named(arena, fspath_qn);
|
||||
reg_method(reg, arena, fspath_qn, "string", t_string);
|
||||
reg_method(reg, arena, fspath_qn, "c_str", t_char_ptr);
|
||||
reg_method(reg, arena, fspath_qn, "extension", t_path);
|
||||
reg_method(reg, arena, fspath_qn, "filename", t_path);
|
||||
reg_method(reg, arena, fspath_qn, "parent_path", t_path);
|
||||
reg_method(reg, arena, fspath_qn, "stem", t_path);
|
||||
reg_method(reg, arena, fspath_qn, "root_path", t_path);
|
||||
reg_method(reg, arena, fspath_qn, "is_absolute", t_bool);
|
||||
reg_method(reg, arena, fspath_qn, "is_relative", t_bool);
|
||||
reg_method(reg, arena, fspath_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, fspath_qn, "exists", t_bool);
|
||||
reg_method(reg, arena, fspath_qn, "operator/", t_path);
|
||||
reg_method(reg, arena, fspath_qn, "operator/=", cbm_type_reference(arena, t_path));
|
||||
|
||||
// =========================================================================
|
||||
// std.thread
|
||||
// =========================================================================
|
||||
const char* thread_qn = "std.thread";
|
||||
reg_type(reg, thread_qn, "thread");
|
||||
reg_method(reg, arena, thread_qn, "join", t_void);
|
||||
reg_method(reg, arena, thread_qn, "detach", t_void);
|
||||
reg_method(reg, arena, thread_qn, "joinable", t_bool);
|
||||
reg_method(reg, arena, thread_qn, "get_id", cbm_type_named(arena, "std.thread.id"));
|
||||
|
||||
// =========================================================================
|
||||
// std.mutex / std.lock_guard / std.unique_lock
|
||||
// =========================================================================
|
||||
const char* mutex_qn = "std.mutex";
|
||||
reg_type(reg, mutex_qn, "mutex");
|
||||
reg_method(reg, arena, mutex_qn, "lock", t_void);
|
||||
reg_method(reg, arena, mutex_qn, "unlock", t_void);
|
||||
reg_method(reg, arena, mutex_qn, "try_lock", t_bool);
|
||||
|
||||
reg_type(reg, "std.lock_guard", "lock_guard");
|
||||
reg_type(reg, "std.unique_lock", "unique_lock");
|
||||
reg_method(reg, arena, "std.unique_lock", "lock", t_void);
|
||||
reg_method(reg, arena, "std.unique_lock", "unlock", t_void);
|
||||
reg_method(reg, arena, "std.unique_lock", "try_lock", t_bool);
|
||||
reg_method(reg, arena, "std.unique_lock", "owns_lock", t_bool);
|
||||
|
||||
// =========================================================================
|
||||
// std.chrono basics
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.chrono.seconds", "seconds");
|
||||
reg_type(reg, "std.chrono.milliseconds", "milliseconds");
|
||||
reg_type(reg, "std.chrono.microseconds", "microseconds");
|
||||
reg_type(reg, "std.chrono.nanoseconds", "nanoseconds");
|
||||
reg_type(reg, "std.chrono.system_clock", "system_clock");
|
||||
reg_type(reg, "std.chrono.steady_clock", "steady_clock");
|
||||
reg_func(reg, arena, "std.chrono.system_clock.now", "now",
|
||||
cbm_type_named(arena, "std.chrono.time_point"));
|
||||
reg_func(reg, arena, "std.chrono.steady_clock.now", "now",
|
||||
cbm_type_named(arena, "std.chrono.time_point"));
|
||||
|
||||
// =========================================================================
|
||||
// std.algorithm free functions
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.sort", "sort", t_void);
|
||||
reg_func(reg, arena, "std.find", "find", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.find_if", "find_if", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.for_each", "for_each", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.transform", "transform", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.copy", "copy", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.move", "move", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.swap", "swap", t_void);
|
||||
reg_func(reg, arena, "std.min", "min", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.max", "max", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.accumulate", "accumulate", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.count", "count", t_size_t);
|
||||
reg_func(reg, arena, "std.count_if", "count_if", t_size_t);
|
||||
reg_func(reg, arena, "std.remove", "remove", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.remove_if", "remove_if", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.reverse", "reverse", t_void);
|
||||
reg_func(reg, arena, "std.unique", "unique", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.lower_bound", "lower_bound", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.upper_bound", "upper_bound", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.binary_search", "binary_search", t_bool);
|
||||
|
||||
// std.to_string
|
||||
reg_func(reg, arena, "std.to_string", "to_string", t_string);
|
||||
reg_func(reg, arena, "std.stoi", "stoi", t_int);
|
||||
reg_func(reg, arena, "std.stol", "stol", t_long);
|
||||
reg_func(reg, arena, "std.stof", "stof", cbm_type_builtin(arena, "float"));
|
||||
reg_func(reg, arena, "std.stod", "stod", cbm_type_builtin(arena, "double"));
|
||||
|
||||
// =========================================================================
|
||||
// =========================================================================
|
||||
// std.variant<T...>
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.variant", "variant");
|
||||
reg_method(reg, arena, "std.variant", "index", t_size_t);
|
||||
reg_method(reg, arena, "std.variant", "valueless_by_exception", t_bool);
|
||||
reg_func(reg, arena, "std.holds_alternative", "holds_alternative", t_bool);
|
||||
reg_func(reg, arena, "std.get_if", "get_if", t_T_ptr);
|
||||
|
||||
// =========================================================================
|
||||
// std.any
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.any", "any");
|
||||
reg_method(reg, arena, "std.any", "has_value", t_bool);
|
||||
reg_method(reg, arena, "std.any", "type", cbm_type_unknown()); // type_info
|
||||
reg_method(reg, arena, "std.any", "reset", t_void);
|
||||
reg_func(reg, arena, "std.any_cast", "any_cast", t_T);
|
||||
reg_func(reg, arena, "std.make_any", "make_any", cbm_type_named(arena, "std.any"));
|
||||
|
||||
// =========================================================================
|
||||
// std.regex / std.smatch
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.regex", "regex");
|
||||
reg_type(reg, "std.smatch", "smatch");
|
||||
reg_method(reg, arena, "std.smatch", "size", t_size_t);
|
||||
reg_method(reg, arena, "std.smatch", "empty", t_bool);
|
||||
reg_method(reg, arena, "std.smatch", "str", t_string);
|
||||
reg_method(reg, arena, "std.smatch", "prefix", cbm_type_unknown());
|
||||
reg_method(reg, arena, "std.smatch", "suffix", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.regex_search", "regex_search", t_bool);
|
||||
reg_func(reg, arena, "std.regex_match", "regex_match", t_bool);
|
||||
reg_func(reg, arena, "std.regex_replace", "regex_replace", t_string);
|
||||
|
||||
// =========================================================================
|
||||
// std.pair<K,V>
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.pair", "pair");
|
||||
reg_func(reg, arena, "std.make_pair", "make_pair",
|
||||
cbm_type_named(arena, "std.pair"));
|
||||
|
||||
// =========================================================================
|
||||
// <numeric> algorithms
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.accumulate", "accumulate", t_T);
|
||||
reg_func(reg, arena, "std.inner_product", "inner_product", t_T);
|
||||
reg_func(reg, arena, "std.iota", "iota", t_void);
|
||||
reg_func(reg, arena, "std.partial_sum", "partial_sum", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.adjacent_difference", "adjacent_difference", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.reduce", "reduce", t_T);
|
||||
reg_func(reg, arena, "std.transform_reduce", "transform_reduce", t_T);
|
||||
|
||||
// =========================================================================
|
||||
// <iterator> functions
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.advance", "advance", t_void);
|
||||
reg_func(reg, arena, "std.distance", "distance", cbm_type_builtin(arena, "ptrdiff_t"));
|
||||
reg_func(reg, arena, "std.next", "next", cbm_type_unknown()); // iterator
|
||||
reg_func(reg, arena, "std.prev", "prev", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.begin", "begin", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.end", "end", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.rbegin", "rbegin", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.rend", "rend", cbm_type_unknown());
|
||||
|
||||
// =========================================================================
|
||||
// <algorithm> — additional entries with better return types
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.for_each", "for_each", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.all_of", "all_of", t_bool);
|
||||
reg_func(reg, arena, "std.any_of", "any_of", t_bool);
|
||||
reg_func(reg, arena, "std.none_of", "none_of", t_bool);
|
||||
reg_func(reg, arena, "std.min", "min", t_T_ref);
|
||||
reg_func(reg, arena, "std.max", "max", t_T_ref);
|
||||
reg_func(reg, arena, "std.min_element", "min_element", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.max_element", "max_element", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.minmax", "minmax",
|
||||
cbm_type_named(arena, "std.pair"));
|
||||
reg_func(reg, arena, "std.clamp", "clamp", t_T_ref);
|
||||
reg_func(reg, arena, "std.swap", "swap", t_void);
|
||||
reg_func(reg, arena, "std.fill", "fill", t_void);
|
||||
reg_func(reg, arena, "std.replace", "replace", t_void);
|
||||
reg_func(reg, arena, "std.replace_if", "replace_if", t_void);
|
||||
reg_func(reg, arena, "std.equal", "equal", t_bool);
|
||||
reg_func(reg, arena, "std.mismatch", "mismatch",
|
||||
cbm_type_named(arena, "std.pair"));
|
||||
reg_func(reg, arena, "std.lexicographical_compare", "lexicographical_compare", t_bool);
|
||||
reg_func(reg, arena, "std.partition", "partition", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.stable_partition", "stable_partition", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.nth_element", "nth_element", t_void);
|
||||
reg_func(reg, arena, "std.partial_sort", "partial_sort", t_void);
|
||||
reg_func(reg, arena, "std.stable_sort", "stable_sort", t_void);
|
||||
reg_func(reg, arena, "std.is_sorted", "is_sorted", t_bool);
|
||||
reg_func(reg, arena, "std.merge", "merge", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.includes", "includes", t_bool);
|
||||
reg_func(reg, arena, "std.set_union", "set_union", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.set_intersection", "set_intersection", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.set_difference", "set_difference", cbm_type_unknown());
|
||||
reg_func(reg, arena, "std.generate", "generate", t_void);
|
||||
reg_func(reg, arena, "std.generate_n", "generate_n", cbm_type_unknown());
|
||||
|
||||
// =========================================================================
|
||||
// <memory> — additional
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.addressof", "addressof", t_T_ptr);
|
||||
reg_func(reg, arena, "std.allocate_shared", "allocate_shared",
|
||||
cbm_type_named(arena, sptr_qn));
|
||||
|
||||
// =========================================================================
|
||||
// <utility>
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.move", "move", t_T);
|
||||
reg_func(reg, arena, "std.forward", "forward", t_T);
|
||||
reg_func(reg, arena, "std.exchange", "exchange", t_T);
|
||||
reg_func(reg, arena, "std.declval", "declval", t_T);
|
||||
reg_func(reg, arena, "std.as_const", "as_const", t_T_ref);
|
||||
|
||||
// =========================================================================
|
||||
// <type_traits> — common query functions
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.is_same_v", "is_same_v", t_bool);
|
||||
reg_func(reg, arena, "std.is_base_of_v", "is_base_of_v", t_bool);
|
||||
|
||||
// =========================================================================
|
||||
// std.deque<T>
|
||||
// =========================================================================
|
||||
const char* deq_qn = "std.deque";
|
||||
reg_type(reg, deq_qn, "deque");
|
||||
reg_method(reg, arena, deq_qn, "push_back", t_void);
|
||||
reg_method(reg, arena, deq_qn, "push_front", t_void);
|
||||
reg_method(reg, arena, deq_qn, "pop_back", t_void);
|
||||
reg_method(reg, arena, deq_qn, "pop_front", t_void);
|
||||
reg_method(reg, arena, deq_qn, "front", t_T_ref);
|
||||
reg_method(reg, arena, deq_qn, "back", t_T_ref);
|
||||
reg_method(reg, arena, deq_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, deq_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, deq_qn, "clear", t_void);
|
||||
reg_method(reg, arena, deq_qn, "at", t_T_ref);
|
||||
|
||||
// =========================================================================
|
||||
// std.list<T>
|
||||
// =========================================================================
|
||||
const char* list_qn = "std.list";
|
||||
reg_type(reg, list_qn, "list");
|
||||
reg_method(reg, arena, list_qn, "push_back", t_void);
|
||||
reg_method(reg, arena, list_qn, "push_front", t_void);
|
||||
reg_method(reg, arena, list_qn, "pop_back", t_void);
|
||||
reg_method(reg, arena, list_qn, "pop_front", t_void);
|
||||
reg_method(reg, arena, list_qn, "front", t_T_ref);
|
||||
reg_method(reg, arena, list_qn, "back", t_T_ref);
|
||||
reg_method(reg, arena, list_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, list_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, list_qn, "clear", t_void);
|
||||
reg_method(reg, arena, list_qn, "sort", t_void);
|
||||
reg_method(reg, arena, list_qn, "reverse", t_void);
|
||||
reg_method(reg, arena, list_qn, "merge", t_void);
|
||||
reg_method(reg, arena, list_qn, "unique", t_void);
|
||||
|
||||
// =========================================================================
|
||||
// std.stack<T> / std.queue<T> / std.priority_queue<T>
|
||||
// =========================================================================
|
||||
const char* stack_qn = "std.stack";
|
||||
reg_type(reg, stack_qn, "stack");
|
||||
reg_method(reg, arena, stack_qn, "push", t_void);
|
||||
reg_method(reg, arena, stack_qn, "pop", t_void);
|
||||
reg_method(reg, arena, stack_qn, "top", t_T_ref);
|
||||
reg_method(reg, arena, stack_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, stack_qn, "empty", t_bool);
|
||||
|
||||
const char* queue_qn = "std.queue";
|
||||
reg_type(reg, queue_qn, "queue");
|
||||
reg_method(reg, arena, queue_qn, "push", t_void);
|
||||
reg_method(reg, arena, queue_qn, "pop", t_void);
|
||||
reg_method(reg, arena, queue_qn, "front", t_T_ref);
|
||||
reg_method(reg, arena, queue_qn, "back", t_T_ref);
|
||||
reg_method(reg, arena, queue_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, queue_qn, "empty", t_bool);
|
||||
|
||||
const char* pq_qn = "std.priority_queue";
|
||||
reg_type(reg, pq_qn, "priority_queue");
|
||||
reg_method(reg, arena, pq_qn, "push", t_void);
|
||||
reg_method(reg, arena, pq_qn, "pop", t_void);
|
||||
reg_method(reg, arena, pq_qn, "top", t_T_ref);
|
||||
reg_method(reg, arena, pq_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, pq_qn, "empty", t_bool);
|
||||
|
||||
// =========================================================================
|
||||
// std.bitset<N>
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.bitset", "bitset");
|
||||
reg_method(reg, arena, "std.bitset", "set", cbm_type_named(arena, "std.bitset"));
|
||||
reg_method(reg, arena, "std.bitset", "reset", cbm_type_named(arena, "std.bitset"));
|
||||
reg_method(reg, arena, "std.bitset", "flip", cbm_type_named(arena, "std.bitset"));
|
||||
reg_method(reg, arena, "std.bitset", "test", t_bool);
|
||||
reg_method(reg, arena, "std.bitset", "count", t_size_t);
|
||||
reg_method(reg, arena, "std.bitset", "size", t_size_t);
|
||||
reg_method(reg, arena, "std.bitset", "any", t_bool);
|
||||
reg_method(reg, arena, "std.bitset", "none", t_bool);
|
||||
reg_method(reg, arena, "std.bitset", "all", t_bool);
|
||||
reg_method(reg, arena, "std.bitset", "to_string", t_string);
|
||||
reg_method(reg, arena, "std.bitset", "to_ulong", cbm_type_builtin(arena, "unsigned long"));
|
||||
|
||||
// =========================================================================
|
||||
// std.stringstream / std.ostringstream / std.istringstream
|
||||
// =========================================================================
|
||||
const char* ss_qn = "std.stringstream";
|
||||
reg_type(reg, ss_qn, "stringstream");
|
||||
reg_method(reg, arena, ss_qn, "str", t_string);
|
||||
reg_method(reg, arena, ss_qn, "clear", t_void);
|
||||
|
||||
const char* oss_qn = "std.ostringstream";
|
||||
reg_type(reg, oss_qn, "ostringstream");
|
||||
reg_method(reg, arena, oss_qn, "str", t_string);
|
||||
reg_method(reg, arena, oss_qn, "clear", t_void);
|
||||
|
||||
const char* iss_qn = "std.istringstream";
|
||||
reg_type(reg, iss_qn, "istringstream");
|
||||
reg_method(reg, arena, iss_qn, "str", t_string);
|
||||
reg_method(reg, arena, iss_qn, "clear", t_void);
|
||||
|
||||
// =========================================================================
|
||||
// std.filesystem — additional
|
||||
// =========================================================================
|
||||
reg_func(reg, arena, "std.filesystem.exists", "exists", t_bool);
|
||||
reg_func(reg, arena, "std.filesystem.is_directory", "is_directory", t_bool);
|
||||
reg_func(reg, arena, "std.filesystem.is_regular_file", "is_regular_file", t_bool);
|
||||
reg_func(reg, arena, "std.filesystem.file_size", "file_size", cbm_type_builtin(arena, "uintmax_t"));
|
||||
reg_func(reg, arena, "std.filesystem.create_directory", "create_directory", t_bool);
|
||||
reg_func(reg, arena, "std.filesystem.create_directories", "create_directories", t_bool);
|
||||
reg_func(reg, arena, "std.filesystem.remove", "remove", t_bool);
|
||||
reg_func(reg, arena, "std.filesystem.remove_all", "remove_all", cbm_type_builtin(arena, "uintmax_t"));
|
||||
reg_func(reg, arena, "std.filesystem.copy", "copy", t_void);
|
||||
reg_func(reg, arena, "std.filesystem.rename", "rename", t_void);
|
||||
reg_func(reg, arena, "std.filesystem.current_path", "current_path",
|
||||
cbm_type_named(arena, fspath_qn));
|
||||
reg_func(reg, arena, "std.filesystem.absolute", "absolute",
|
||||
cbm_type_named(arena, fspath_qn));
|
||||
reg_func(reg, arena, "std.filesystem.canonical", "canonical",
|
||||
cbm_type_named(arena, fspath_qn));
|
||||
reg_func(reg, arena, "std.filesystem.relative", "relative",
|
||||
cbm_type_named(arena, fspath_qn));
|
||||
reg_func(reg, arena, "std.filesystem.temp_directory_path", "temp_directory_path",
|
||||
cbm_type_named(arena, fspath_qn));
|
||||
|
||||
const char* direntry_qn = "std.filesystem.directory_entry";
|
||||
reg_type(reg, direntry_qn, "directory_entry");
|
||||
reg_method(reg, arena, direntry_qn, "path", cbm_type_named(arena, fspath_qn));
|
||||
reg_method(reg, arena, direntry_qn, "exists", t_bool);
|
||||
reg_method(reg, arena, direntry_qn, "is_directory", t_bool);
|
||||
reg_method(reg, arena, direntry_qn, "is_regular_file", t_bool);
|
||||
reg_method(reg, arena, direntry_qn, "file_size", cbm_type_builtin(arena, "uintmax_t"));
|
||||
|
||||
// =========================================================================
|
||||
// std.chrono — additional
|
||||
// =========================================================================
|
||||
reg_type(reg, "std.chrono.time_point", "time_point");
|
||||
reg_method(reg, arena, "std.chrono.time_point", "time_since_epoch", cbm_type_unknown());
|
||||
reg_method(reg, arena, "std.chrono.system_clock", "now",
|
||||
cbm_type_named(arena, "std.chrono.time_point"));
|
||||
reg_method(reg, arena, "std.chrono.steady_clock", "now",
|
||||
cbm_type_named(arena, "std.chrono.time_point"));
|
||||
reg_func(reg, arena, "std.chrono.duration_cast", "duration_cast", cbm_type_unknown());
|
||||
|
||||
// =========================================================================
|
||||
// Boost smart pointers (common in older codebases)
|
||||
// =========================================================================
|
||||
const char* bsptr_qn = "boost.shared_ptr";
|
||||
reg_type(reg, bsptr_qn, "shared_ptr");
|
||||
reg_method(reg, arena, bsptr_qn, "get", t_T_ptr);
|
||||
reg_method(reg, arena, bsptr_qn, "reset", t_void);
|
||||
reg_method(reg, arena, bsptr_qn, "use_count", t_long);
|
||||
reg_method(reg, arena, bsptr_qn, "operator->", t_T_ptr);
|
||||
reg_method(reg, arena, bsptr_qn, "operator*", t_T_ref);
|
||||
|
||||
const char* bscoped_qn = "boost.scoped_ptr";
|
||||
reg_type(reg, bscoped_qn, "scoped_ptr");
|
||||
reg_method(reg, arena, bscoped_qn, "get", t_T_ptr);
|
||||
reg_method(reg, arena, bscoped_qn, "reset", t_void);
|
||||
reg_method(reg, arena, bscoped_qn, "operator->", t_T_ptr);
|
||||
reg_method(reg, arena, bscoped_qn, "operator*", t_T_ref);
|
||||
|
||||
// =========================================================================
|
||||
// Boost optional / filesystem
|
||||
// =========================================================================
|
||||
const char* bopt_qn = "boost.optional";
|
||||
reg_type(reg, bopt_qn, "optional");
|
||||
reg_method(reg, arena, bopt_qn, "value", t_T_ref);
|
||||
reg_method(reg, arena, bopt_qn, "get", t_T_ref);
|
||||
reg_method(reg, arena, bopt_qn, "value_or", t_T);
|
||||
reg_method(reg, arena, bopt_qn, "is_initialized", t_bool);
|
||||
reg_method(reg, arena, bopt_qn, "operator*", t_T_ref);
|
||||
reg_method(reg, arena, bopt_qn, "operator->", t_T_ptr);
|
||||
|
||||
const char* bfspath_qn = "boost.filesystem.path";
|
||||
reg_type(reg, bfspath_qn, "path");
|
||||
reg_method(reg, arena, bfspath_qn, "string", t_string);
|
||||
reg_method(reg, arena, bfspath_qn, "parent_path", cbm_type_named(arena, bfspath_qn));
|
||||
reg_method(reg, arena, bfspath_qn, "filename", cbm_type_named(arena, bfspath_qn));
|
||||
reg_method(reg, arena, bfspath_qn, "extension", cbm_type_named(arena, bfspath_qn));
|
||||
reg_method(reg, arena, bfspath_qn, "stem", cbm_type_named(arena, bfspath_qn));
|
||||
reg_method(reg, arena, bfspath_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, bfspath_qn, "exists", t_bool);
|
||||
|
||||
// =========================================================================
|
||||
// Protobuf (google.protobuf.Message)
|
||||
// =========================================================================
|
||||
const char* pb_msg_qn = "google.protobuf.Message";
|
||||
reg_type(reg, pb_msg_qn, "Message");
|
||||
reg_method(reg, arena, pb_msg_qn, "SerializeToString", t_bool);
|
||||
reg_method(reg, arena, pb_msg_qn, "SerializeAsString", t_string);
|
||||
reg_method(reg, arena, pb_msg_qn, "ParseFromString", t_bool);
|
||||
reg_method(reg, arena, pb_msg_qn, "ParseFromArray", t_bool);
|
||||
reg_method(reg, arena, pb_msg_qn, "DebugString", t_string);
|
||||
reg_method(reg, arena, pb_msg_qn, "ShortDebugString", t_string);
|
||||
reg_method(reg, arena, pb_msg_qn, "ByteSizeLong", t_size_t);
|
||||
reg_method(reg, arena, pb_msg_qn, "IsInitialized", t_bool);
|
||||
reg_method(reg, arena, pb_msg_qn, "Clear", t_void);
|
||||
reg_method(reg, arena, pb_msg_qn, "CopyFrom", t_void);
|
||||
reg_method(reg, arena, pb_msg_qn, "MergeFrom", t_void);
|
||||
reg_method(reg, arena, pb_msg_qn, "GetTypeName", t_string);
|
||||
// MessageLite is base of Message
|
||||
reg_type(reg, "google.protobuf.MessageLite", "MessageLite");
|
||||
|
||||
// =========================================================================
|
||||
// Abseil (absl.)
|
||||
// =========================================================================
|
||||
const char* absv_qn = "absl.string_view";
|
||||
reg_type(reg, absv_qn, "string_view");
|
||||
reg_method(reg, arena, absv_qn, "data", cbm_type_pointer(arena, cbm_type_builtin(arena, "char")));
|
||||
reg_method(reg, arena, absv_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, absv_qn, "length", t_size_t);
|
||||
reg_method(reg, arena, absv_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, absv_qn, "substr", cbm_type_named(arena, absv_qn));
|
||||
|
||||
const char* abstat_qn = "absl.Status";
|
||||
reg_type(reg, abstat_qn, "Status");
|
||||
reg_method(reg, arena, abstat_qn, "ok", t_bool);
|
||||
reg_method(reg, arena, abstat_qn, "code", cbm_type_unknown());
|
||||
reg_method(reg, arena, abstat_qn, "message", cbm_type_named(arena, absv_qn));
|
||||
reg_method(reg, arena, abstat_qn, "ToString", t_string);
|
||||
reg_func(reg, arena, "absl.OkStatus", "OkStatus", cbm_type_named(arena, abstat_qn));
|
||||
|
||||
const char* absor_qn = "absl.StatusOr";
|
||||
reg_type(reg, absor_qn, "StatusOr");
|
||||
reg_method(reg, arena, absor_qn, "ok", t_bool);
|
||||
reg_method(reg, arena, absor_qn, "status", cbm_type_named(arena, abstat_qn));
|
||||
reg_method(reg, arena, absor_qn, "value", t_T_ref);
|
||||
reg_method(reg, arena, absor_qn, "operator*", t_T_ref);
|
||||
reg_method(reg, arena, absor_qn, "operator->", t_T_ptr);
|
||||
|
||||
const char* abfhm_qn = "absl.flat_hash_map";
|
||||
reg_type(reg, abfhm_qn, "flat_hash_map");
|
||||
reg_method(reg, arena, abfhm_qn, "find", cbm_type_unknown());
|
||||
reg_method(reg, arena, abfhm_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, abfhm_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, abfhm_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, abfhm_qn, "clear", t_void);
|
||||
reg_method(reg, arena, abfhm_qn, "insert", cbm_type_unknown());
|
||||
reg_method(reg, arena, abfhm_qn, "erase", t_size_t);
|
||||
reg_method(reg, arena, abfhm_qn, "count", t_size_t);
|
||||
|
||||
const char* abfhs_qn = "absl.flat_hash_set";
|
||||
reg_type(reg, abfhs_qn, "flat_hash_set");
|
||||
reg_method(reg, arena, abfhs_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, abfhs_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, abfhs_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, abfhs_qn, "clear", t_void);
|
||||
reg_method(reg, arena, abfhs_qn, "insert", cbm_type_unknown());
|
||||
reg_method(reg, arena, abfhs_qn, "erase", t_size_t);
|
||||
reg_method(reg, arena, abfhs_qn, "count", t_size_t);
|
||||
|
||||
const char* abspan_qn = "absl.Span";
|
||||
reg_type(reg, abspan_qn, "Span");
|
||||
reg_method(reg, arena, abspan_qn, "data", t_T_ptr);
|
||||
reg_method(reg, arena, abspan_qn, "size", t_size_t);
|
||||
reg_method(reg, arena, abspan_qn, "empty", t_bool);
|
||||
reg_method(reg, arena, abspan_qn, "front", t_T_ref);
|
||||
reg_method(reg, arena, abspan_qn, "back", t_T_ref);
|
||||
reg_method(reg, arena, abspan_qn, "at", t_T_ref);
|
||||
reg_method(reg, arena, abspan_qn, "subspan", cbm_type_named(arena, abspan_qn));
|
||||
|
||||
// absl string functions
|
||||
reg_func(reg, arena, "absl.StrCat", "StrCat", t_string);
|
||||
reg_func(reg, arena, "absl.StrAppend", "StrAppend", t_void);
|
||||
reg_func(reg, arena, "absl.StrJoin", "StrJoin", t_string);
|
||||
reg_func(reg, arena, "absl.StrSplit", "StrSplit",
|
||||
cbm_type_named(arena, "std.vector"));
|
||||
reg_func(reg, arena, "absl.StrFormat", "StrFormat", t_string);
|
||||
reg_func(reg, arena, "absl.Substitute", "Substitute", t_string);
|
||||
|
||||
// =========================================================================
|
||||
// gRPC
|
||||
// =========================================================================
|
||||
const char* grpc_status_qn = "grpc.Status";
|
||||
reg_type(reg, grpc_status_qn, "Status");
|
||||
reg_method(reg, arena, grpc_status_qn, "ok", t_bool);
|
||||
reg_method(reg, arena, grpc_status_qn, "error_code", cbm_type_unknown());
|
||||
reg_method(reg, arena, grpc_status_qn, "error_message", t_string);
|
||||
reg_func(reg, arena, "grpc.Status.OK", "OK", cbm_type_named(arena, grpc_status_qn));
|
||||
|
||||
const char* grpc_sb_qn = "grpc.ServerBuilder";
|
||||
reg_type(reg, grpc_sb_qn, "ServerBuilder");
|
||||
reg_method(reg, arena, grpc_sb_qn, "AddListeningPort", cbm_type_named(arena, grpc_sb_qn));
|
||||
reg_method(reg, arena, grpc_sb_qn, "RegisterService", cbm_type_named(arena, grpc_sb_qn));
|
||||
reg_method(reg, arena, grpc_sb_qn, "BuildAndStart", cbm_type_unknown());
|
||||
|
||||
const char* grpc_chan_qn = "grpc.Channel";
|
||||
reg_type(reg, grpc_chan_qn, "Channel");
|
||||
reg_func(reg, arena, "grpc.CreateChannel", "CreateChannel",
|
||||
cbm_type_named(arena, grpc_chan_qn));
|
||||
|
||||
const char* grpc_ctx_qn = "grpc.ClientContext";
|
||||
reg_type(reg, grpc_ctx_qn, "ClientContext");
|
||||
reg_method(reg, arena, grpc_ctx_qn, "set_deadline", t_void);
|
||||
reg_method(reg, arena, grpc_ctx_qn, "AddMetadata", t_void);
|
||||
|
||||
// =========================================================================
|
||||
// spdlog
|
||||
// =========================================================================
|
||||
const char* spdlog_qn = "spdlog.logger";
|
||||
reg_type(reg, spdlog_qn, "logger");
|
||||
reg_method(reg, arena, spdlog_qn, "info", t_void);
|
||||
reg_method(reg, arena, spdlog_qn, "warn", t_void);
|
||||
reg_method(reg, arena, spdlog_qn, "error", t_void);
|
||||
reg_method(reg, arena, spdlog_qn, "debug", t_void);
|
||||
reg_method(reg, arena, spdlog_qn, "trace", t_void);
|
||||
reg_method(reg, arena, spdlog_qn, "critical", t_void);
|
||||
reg_method(reg, arena, spdlog_qn, "set_level", t_void);
|
||||
reg_method(reg, arena, spdlog_qn, "flush", t_void);
|
||||
reg_func(reg, arena, "spdlog.info", "info", t_void);
|
||||
reg_func(reg, arena, "spdlog.warn", "warn", t_void);
|
||||
reg_func(reg, arena, "spdlog.error", "error", t_void);
|
||||
reg_func(reg, arena, "spdlog.debug", "debug", t_void);
|
||||
reg_func(reg, arena, "spdlog.trace", "trace", t_void);
|
||||
reg_func(reg, arena, "spdlog.critical", "critical", t_void);
|
||||
reg_func(reg, arena, "spdlog.set_level", "set_level", t_void);
|
||||
reg_func(reg, arena, "spdlog.get", "get",
|
||||
cbm_type_named(arena, spdlog_qn));
|
||||
|
||||
// =========================================================================
|
||||
// Qt basics
|
||||
// =========================================================================
|
||||
const char* qobj_qn = "QObject";
|
||||
reg_type(reg, qobj_qn, "QObject");
|
||||
reg_method(reg, arena, qobj_qn, "parent", cbm_type_pointer(arena, cbm_type_named(arena, qobj_qn)));
|
||||
reg_method(reg, arena, qobj_qn, "children", cbm_type_unknown());
|
||||
reg_method(reg, arena, qobj_qn, "objectName", cbm_type_named(arena, "QString"));
|
||||
reg_method(reg, arena, qobj_qn, "setObjectName", t_void);
|
||||
reg_method(reg, arena, qobj_qn, "deleteLater", t_void);
|
||||
|
||||
const char* qstr_qn = "QString";
|
||||
reg_type(reg, qstr_qn, "QString");
|
||||
reg_method(reg, arena, qstr_qn, "toStdString", t_string);
|
||||
reg_method(reg, arena, qstr_qn, "toUtf8", cbm_type_unknown());
|
||||
reg_method(reg, arena, qstr_qn, "toLatin1", cbm_type_unknown());
|
||||
reg_method(reg, arena, qstr_qn, "size", t_int);
|
||||
reg_method(reg, arena, qstr_qn, "length", t_int);
|
||||
reg_method(reg, arena, qstr_qn, "isEmpty", t_bool);
|
||||
reg_method(reg, arena, qstr_qn, "contains", t_bool);
|
||||
reg_method(reg, arena, qstr_qn, "startsWith", t_bool);
|
||||
reg_method(reg, arena, qstr_qn, "endsWith", t_bool);
|
||||
reg_method(reg, arena, qstr_qn, "trimmed", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "simplified", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "toLower", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "toUpper", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "arg", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "split", cbm_type_unknown());
|
||||
reg_method(reg, arena, qstr_qn, "replace", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "mid", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "left", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "right", cbm_type_named(arena, qstr_qn));
|
||||
reg_method(reg, arena, qstr_qn, "toInt", t_int);
|
||||
reg_method(reg, arena, qstr_qn, "toDouble", cbm_type_builtin(arena, "double"));
|
||||
reg_func(reg, arena, "QString.number", "number", cbm_type_named(arena, qstr_qn));
|
||||
reg_func(reg, arena, "QString.fromStdString", "fromStdString", cbm_type_named(arena, qstr_qn));
|
||||
reg_func(reg, arena, "QString.fromUtf8", "fromUtf8", cbm_type_named(arena, qstr_qn));
|
||||
|
||||
const char* qwidget_qn = "QWidget";
|
||||
reg_type(reg, qwidget_qn, "QWidget");
|
||||
reg_method(reg, arena, qwidget_qn, "show", t_void);
|
||||
reg_method(reg, arena, qwidget_qn, "hide", t_void);
|
||||
reg_method(reg, arena, qwidget_qn, "close", t_bool);
|
||||
reg_method(reg, arena, qwidget_qn, "setVisible", t_void);
|
||||
reg_method(reg, arena, qwidget_qn, "isVisible", t_bool);
|
||||
reg_method(reg, arena, qwidget_qn, "resize", t_void);
|
||||
reg_method(reg, arena, qwidget_qn, "setWindowTitle", t_void);
|
||||
reg_method(reg, arena, qwidget_qn, "update", t_void);
|
||||
reg_method(reg, arena, qwidget_qn, "repaint", t_void);
|
||||
reg_method(reg, arena, qwidget_qn, "setLayout", t_void);
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,517 @@
|
||||
/*
|
||||
* kotlin_stdlib_data.c — Curated Kotlin stdlib registration for the LSP.
|
||||
*
|
||||
* Hand-distilled subset of the Kotlin standard library: the types and
|
||||
* functions that account for the vast majority of real-world usages.
|
||||
* The reverse-engineered LSP relies on this to resolve calls into
|
||||
* `kotlin.*`, `kotlin.collections.*`, `kotlin.text.*`, `kotlin.io.*`,
|
||||
* `kotlin.ranges.*`, `kotlin.sequences.*`, and a few `java.lang.*` /
|
||||
* `java.util.*` types reachable from default imports under the JVM
|
||||
* target.
|
||||
*
|
||||
* Source of truth: the Kotlin language specification + kotlin-stdlib API
|
||||
* docs (1.9.x). We do NOT vendor or fetch any new source — all type
|
||||
* shapes here were transcribed by hand from the public spec to match
|
||||
* the resolver's expectations.
|
||||
*
|
||||
* This file is included from lsp_all.c.
|
||||
*/
|
||||
|
||||
#include "../type_rep.h"
|
||||
#include "../type_registry.h"
|
||||
#include "../kotlin_lsp.h"
|
||||
#include <string.h>
|
||||
|
||||
/* Convenience macros to compress the repetitive registration calls. */
|
||||
|
||||
#define KT_TYPE_SIMPLE(qn_, short_) \
|
||||
do { \
|
||||
CBMRegisteredType rt = {0}; \
|
||||
rt.qualified_name = (qn_); \
|
||||
rt.short_name = (short_); \
|
||||
cbm_registry_add_type(reg, rt); \
|
||||
} while (0)
|
||||
|
||||
#define KT_TYPE_WITH_METHODS(qn_, short_, methods_) \
|
||||
do { \
|
||||
CBMRegisteredType rt = {0}; \
|
||||
rt.qualified_name = (qn_); \
|
||||
rt.short_name = (short_); \
|
||||
rt.method_names = (methods_); \
|
||||
cbm_registry_add_type(reg, rt); \
|
||||
} while (0)
|
||||
|
||||
#define KT_FUNC0(qn_, short_, ret_qn_) \
|
||||
do { \
|
||||
CBMRegisteredFunc rf = {0}; \
|
||||
rf.qualified_name = (qn_); \
|
||||
rf.short_name = (short_); \
|
||||
rf.min_params = 0; \
|
||||
cbm_registry_add_func(reg, rf); \
|
||||
(void)(ret_qn_); \
|
||||
} while (0)
|
||||
|
||||
#define KT_METHOD(class_qn_, method_qn_, short_) \
|
||||
do { \
|
||||
CBMRegisteredFunc rf = {0}; \
|
||||
rf.qualified_name = (method_qn_); \
|
||||
rf.receiver_type = (class_qn_); \
|
||||
rf.short_name = (short_); \
|
||||
rf.min_params = 0; \
|
||||
cbm_registry_add_func(reg, rf); \
|
||||
} while (0)
|
||||
|
||||
/* Default-imported package list, exposed to the LSP context for
|
||||
* wildcard-style resolution of bare names (e.g. `println` resolves into
|
||||
* `kotlin.io`). Order matters: more-specific shadows less-specific. */
|
||||
static const char *const KT_DEFAULT_IMPORTS[] = {
|
||||
"kotlin",
|
||||
"kotlin.annotation",
|
||||
"kotlin.collections",
|
||||
"kotlin.comparisons",
|
||||
"kotlin.io",
|
||||
"kotlin.ranges",
|
||||
"kotlin.sequences",
|
||||
"kotlin.text",
|
||||
/* JVM target adds: */
|
||||
"java.lang",
|
||||
"kotlin.jvm",
|
||||
};
|
||||
|
||||
const char *const *cbm_kotlin_default_import_packages(int *count_out) {
|
||||
if (count_out) {
|
||||
*count_out = (int)(sizeof(KT_DEFAULT_IMPORTS) / sizeof(KT_DEFAULT_IMPORTS[0]));
|
||||
}
|
||||
return KT_DEFAULT_IMPORTS;
|
||||
}
|
||||
|
||||
/* Method-name tables (NULL-terminated). Used for is_member checks
|
||||
* — the resolver walks these to decide whether `obj.foo()` should
|
||||
* be attributed as a method call on a known type. */
|
||||
|
||||
static const char *KT_ANY_METHODS[] = {
|
||||
"equals", "hashCode", "toString", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_STRING_METHODS[] = {
|
||||
"length", "isEmpty", "isNotEmpty", "isBlank", "isNotBlank", "compareTo", "contains",
|
||||
"startsWith", "endsWith", "indexOf", "lastIndexOf", "substring", "replace", "split",
|
||||
"trim", "trimStart", "trimEnd", "trimIndent", "trimMargin", "toUpperCase", "toLowerCase",
|
||||
"uppercase", "lowercase", "uppercaseChar", "lowercaseChar", "capitalize", "decapitalize",
|
||||
"reversed", "lines", "padStart", "padEnd", "repeat", "removePrefix", "removeSuffix",
|
||||
"removeSurrounding", "toByteArray", "toCharArray", "toInt", "toIntOrNull", "toLong",
|
||||
"toLongOrNull", "toDouble", "toDoubleOrNull", "toFloat", "toFloatOrNull", "toBoolean",
|
||||
"format", "intern", "matches", "replaceFirst", "filter", "filterNot", "filterIndexed",
|
||||
"map", "flatMap", "fold", "reduce", "forEach", "any", "all", "none", "count", "first",
|
||||
"firstOrNull", "last", "lastOrNull", "single", "singleOrNull", "take", "takeLast",
|
||||
"takeWhile", "drop", "dropLast", "dropWhile", "windowed", "chunked", "zip", "associate",
|
||||
"associateBy", "associateWith", "groupBy", "partition", "joinToString", "iterator",
|
||||
"subSequence", "get", "set", "plus", "minus", "times", "div", "rem", "compareTo",
|
||||
"hashCode", "toString", "equals", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_LIST_METHODS[] = {
|
||||
"size", "isEmpty", "contains", "containsAll", "iterator", "listIterator", "subList",
|
||||
"indexOf", "lastIndexOf", "get", "first", "firstOrNull", "last", "lastOrNull", "single",
|
||||
"singleOrNull", "elementAt", "elementAtOrNull", "elementAtOrElse", "find", "findLast",
|
||||
"filter", "filterNot", "filterNotNull", "filterIndexed", "filterIsInstance", "map",
|
||||
"mapNotNull", "mapIndexed", "mapIndexedNotNull", "flatMap", "flatten", "fold", "foldRight",
|
||||
"foldIndexed", "reduce", "reduceRight", "reduceIndexed", "scan", "runningFold",
|
||||
"runningReduce", "forEach", "forEachIndexed", "any", "all", "none", "count", "sum",
|
||||
"sumBy", "sumOf", "max", "maxOrNull", "maxBy", "maxByOrNull", "maxOf", "maxOfOrNull",
|
||||
"min", "minOrNull", "minBy", "minByOrNull", "minOf", "minOfOrNull", "average", "sorted",
|
||||
"sortedBy", "sortedDescending", "sortedByDescending", "sortedWith", "reversed",
|
||||
"shuffled", "distinct", "distinctBy", "intersect", "union", "subtract", "groupBy",
|
||||
"groupingBy", "associate", "associateBy", "associateWith", "partition", "windowed",
|
||||
"chunked", "zip", "zipWithNext", "joinToString", "joinTo", "take", "takeLast",
|
||||
"takeWhile", "takeLastWhile", "drop", "dropLast", "dropWhile", "dropLastWhile",
|
||||
"asSequence", "asIterable", "toList", "toMutableList", "toSet", "toMutableSet",
|
||||
"toHashSet", "toSortedSet", "toTypedArray", "toCollection", "plus", "minus",
|
||||
"ifEmpty", "stream", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_MUTABLE_LIST_METHODS[] = {
|
||||
"add", "addAll", "remove", "removeAt", "removeAll", "removeFirst", "removeLast",
|
||||
"removeIf", "retainAll", "clear", "set", "fill", "sort", "sortBy", "sortByDescending",
|
||||
"sortWith", "reverse", "shuffle", "swap", "trimToSize",
|
||||
/* Plus all read-only methods (inherited): */
|
||||
"size", "isEmpty", "contains", "containsAll", "iterator", "listIterator", "subList",
|
||||
"indexOf", "lastIndexOf", "get", "first", "firstOrNull", "last", "lastOrNull", "single",
|
||||
"singleOrNull", "find", "findLast", "elementAt", "elementAtOrNull", "elementAtOrElse",
|
||||
"filter", "filterNot", "filterNotNull", "filterIndexed", "filterIsInstance", "map",
|
||||
"mapNotNull", "mapIndexed", "flatMap", "flatten", "fold", "foldRight", "reduce",
|
||||
"reduceRight", "forEach", "forEachIndexed", "any", "all", "none", "count", "sum",
|
||||
"sumBy", "sumOf", "max", "maxOrNull", "maxBy", "min", "minOrNull", "minBy", "average",
|
||||
"sorted", "sortedBy", "sortedDescending", "sortedByDescending", "sortedWith",
|
||||
"reversed", "shuffled", "distinct", "distinctBy", "groupBy", "groupingBy", "associate",
|
||||
"associateBy", "associateWith", "partition", "windowed", "chunked", "zip", "zipWithNext",
|
||||
"joinToString", "joinTo", "take", "takeLast", "takeWhile", "drop", "dropLast",
|
||||
"dropWhile", "asSequence", "asIterable", "toList", "toMutableList", "toSet",
|
||||
"toMutableSet", "toHashSet", "toTypedArray", "toCollection", "ifEmpty", "stream", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_MAP_METHODS[] = {
|
||||
"size", "isEmpty", "containsKey", "containsValue", "get", "getOrDefault", "getOrElse",
|
||||
"getOrNull", "getValue", "keys", "values", "entries", "iterator", "forEach", "filter",
|
||||
"filterKeys", "filterValues", "filterNot", "filterTo", "map", "mapKeys", "mapValues",
|
||||
"mapNotNull", "any", "all", "none", "count", "max", "min", "maxBy", "minBy", "toList",
|
||||
"toMap", "toMutableMap", "toSortedMap", "asSequence", "asIterable", "plus", "minus",
|
||||
"ifEmpty", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_MUTABLE_MAP_METHODS[] = {
|
||||
"put", "putAll", "putIfAbsent", "remove", "clear", "computeIfAbsent", "computeIfPresent",
|
||||
"compute", "merge", "replace", "replaceAll", "getOrPut",
|
||||
/* Plus read-only methods: */
|
||||
"size", "isEmpty", "containsKey", "containsValue", "get", "keys", "values", "entries",
|
||||
"iterator", "forEach", "filter", "map", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_SET_METHODS[] = {
|
||||
"size", "isEmpty", "contains", "containsAll", "iterator", "intersect", "union",
|
||||
"subtract", "filter", "map", "fold", "reduce", "forEach", "any", "all", "none",
|
||||
"count", "first", "last", "elementAt", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_ITERATOR_METHODS[] = {
|
||||
"hasNext", "next", "remove", "nextIndex", "previousIndex", "previous", "hasPrevious",
|
||||
"set", "add", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_SEQUENCE_METHODS[] = {
|
||||
"iterator", "filter", "filterNot", "filterNotNull", "filterIndexed", "filterIsInstance",
|
||||
"map", "mapNotNull", "mapIndexed", "flatMap", "flatten", "fold", "foldIndexed", "reduce",
|
||||
"reduceIndexed", "forEach", "forEachIndexed", "any", "all", "none", "count", "sum",
|
||||
"sumBy", "sumOf", "max", "maxOrNull", "min", "minOrNull", "first", "firstOrNull",
|
||||
"last", "lastOrNull", "single", "singleOrNull", "find", "findLast", "elementAt",
|
||||
"elementAtOrNull", "take", "takeWhile", "drop", "dropWhile", "windowed", "chunked",
|
||||
"zip", "zipWithNext", "distinct", "distinctBy", "sorted", "sortedBy", "sortedDescending",
|
||||
"sortedWith", "associate", "associateBy", "associateWith", "groupBy", "partition",
|
||||
"joinToString", "toList", "toSet", "toMap", "toCollection", "asIterable", "constrainOnce",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *KT_INT_RANGE_METHODS[] = {
|
||||
"first", "last", "step", "isEmpty", "iterator", "contains", "reversed", "forEach",
|
||||
"map", "filter", "sum", "count", "any", "all", "none", "elementAt", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_PAIR_METHODS[] = {
|
||||
"first", "second", "toString", "toList", "component1", "component2", "copy",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *KT_TRIPLE_METHODS[] = {
|
||||
"first", "second", "third", "toString", "toList", "component1", "component2",
|
||||
"component3", "copy", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_THROWABLE_METHODS[] = {
|
||||
"message", "cause", "stackTrace", "stackTraceToString", "printStackTrace",
|
||||
"addSuppressed", "getSuppressed", "fillInStackTrace", "initCause", "toString", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_EXCEPTION_METHODS[] = {
|
||||
"message", "cause", "stackTrace", "stackTraceToString", "printStackTrace", "toString",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *KT_NUMBER_METHODS[] = {
|
||||
"toByte", "toShort", "toInt", "toLong", "toFloat", "toDouble", "toChar", "toString",
|
||||
"compareTo", "equals", "hashCode",
|
||||
/* Operator conventions */
|
||||
"plus", "minus", "times", "div", "rem", "mod", "inc", "dec", "unaryMinus", "unaryPlus",
|
||||
"and", "or", "xor", "inv", "shl", "shr", "ushr",
|
||||
"rangeTo", "rangeUntil", "downTo", "until", "coerceAtLeast", "coerceAtMost", "coerceIn",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *KT_BOOLEAN_METHODS[] = {
|
||||
"and", "or", "xor", "not", "compareTo", "toString", "equals", "hashCode", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_CHAR_METHODS[] = {
|
||||
"isDigit", "isLetter", "isLetterOrDigit", "isWhitespace", "isUpperCase", "isLowerCase",
|
||||
"uppercase", "lowercase", "uppercaseChar", "lowercaseChar", "digitToInt", "code",
|
||||
"compareTo", "toString", "equals", "hashCode", "plus", "minus", "rangeTo",
|
||||
"isHighSurrogate", "isLowSurrogate", "isSurrogate", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_ARRAY_METHODS[] = {
|
||||
"size", "get", "set", "iterator", "isEmpty", "isNotEmpty", "contains", "indexOf",
|
||||
"lastIndexOf", "first", "last", "filter", "map", "fold", "reduce", "forEach", "any",
|
||||
"all", "none", "count", "sum", "max", "min", "joinToString", "asList", "asSequence",
|
||||
"toList", "toMutableList", "toSet", "copyOf", "copyOfRange", "fill", "sort", "sorted",
|
||||
"reversed", "reverse", "binarySearch", "plus", "component1", "component2", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_REGEX_METHODS[] = {
|
||||
"matchEntire", "matches", "containsMatchIn", "find", "findAll", "replace",
|
||||
"replaceFirst", "split", "splitToSequence", "toPattern", "pattern", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_MATCH_RESULT_METHODS[] = {
|
||||
"value", "range", "groups", "groupValues", "destructured", "next", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_FILE_METHODS[] = {
|
||||
"path", "name", "parent", "exists", "isFile", "isDirectory", "isAbsolute", "length",
|
||||
"lastModified", "canRead", "canWrite", "delete", "deleteRecursively", "createNewFile",
|
||||
"mkdir", "mkdirs", "renameTo", "list", "listFiles", "walk", "walkTopDown",
|
||||
"walkBottomUp", "readText", "readLines", "readBytes", "writeText", "writeBytes",
|
||||
"appendText", "appendBytes", "useLines", "forEachLine", "bufferedReader",
|
||||
"bufferedWriter", "inputStream", "outputStream", "reader", "writer", "printWriter",
|
||||
"absolutePath", "absoluteFile", "canonicalPath", "canonicalFile", "extension",
|
||||
"nameWithoutExtension", "toPath", "toURI", "resolve", "resolveSibling", "relativeTo",
|
||||
"copyTo", "copyRecursively", "endsWith", "startsWith", "normalize", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_SCOPE_METHODS[] = {
|
||||
"let", "run", "with", "apply", "also", "takeIf", "takeUnless", "use", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_LAZY_METHODS[] = {
|
||||
"value", "isInitialized", "getValue", NULL,
|
||||
};
|
||||
|
||||
static const char *KT_RESULT_METHODS[] = {
|
||||
"getOrNull", "exceptionOrNull", "isSuccess", "isFailure", "getOrThrow", "getOrDefault",
|
||||
"getOrElse", "fold", "map", "mapCatching", "recover", "recoverCatching", "onSuccess",
|
||||
"onFailure", NULL,
|
||||
};
|
||||
|
||||
/* ── Top-level builtin function registration. ──────────────────────
|
||||
* We register the names that show up in the wild as bare calls and
|
||||
* route them to their kotlin.* / kotlin.io.* QNs. The resolver checks
|
||||
* in-package and class-method lookups before falling through to these.
|
||||
*/
|
||||
|
||||
void cbm_kotlin_stdlib_register(CBMTypeRegistry *reg, CBMArena *arena) {
|
||||
(void)arena;
|
||||
|
||||
/* Core types — kotlin.* */
|
||||
KT_TYPE_WITH_METHODS("kotlin.Any", "Any", KT_ANY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Number", "Number", KT_NUMBER_METHODS);
|
||||
KT_TYPE_SIMPLE("kotlin.Unit", "Unit");
|
||||
KT_TYPE_SIMPLE("kotlin.Nothing", "Nothing");
|
||||
KT_TYPE_WITH_METHODS("kotlin.Boolean", "Boolean", KT_BOOLEAN_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Byte", "Byte", KT_NUMBER_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Short", "Short", KT_NUMBER_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Int", "Int", KT_NUMBER_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Long", "Long", KT_NUMBER_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Float", "Float", KT_NUMBER_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Double", "Double", KT_NUMBER_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Char", "Char", KT_CHAR_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.String", "String", KT_STRING_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.CharSequence", "CharSequence", KT_STRING_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Throwable", "Throwable", KT_THROWABLE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Pair", "Pair", KT_PAIR_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Triple", "Triple", KT_TRIPLE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Result", "Result", KT_RESULT_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.Lazy", "Lazy", KT_LAZY_METHODS);
|
||||
KT_TYPE_SIMPLE("kotlin.Enum", "Enum");
|
||||
KT_TYPE_SIMPLE("kotlin.Function", "Function");
|
||||
KT_TYPE_SIMPLE("kotlin.KotlinVersion", "KotlinVersion");
|
||||
|
||||
/* Common exceptions */
|
||||
KT_TYPE_WITH_METHODS("kotlin.Exception", "Exception", KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.RuntimeException", "RuntimeException", KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.IllegalArgumentException", "IllegalArgumentException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.IllegalStateException", "IllegalStateException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.IndexOutOfBoundsException", "IndexOutOfBoundsException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.NoSuchElementException", "NoSuchElementException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.NumberFormatException", "NumberFormatException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.NullPointerException", "NullPointerException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ClassCastException", "ClassCastException", KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.UnsupportedOperationException", "UnsupportedOperationException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ArithmeticException", "ArithmeticException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
|
||||
/* Collections */
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.Iterable", "Iterable", KT_LIST_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.Collection", "Collection", KT_LIST_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.MutableCollection", "MutableCollection",
|
||||
KT_MUTABLE_LIST_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.List", "List", KT_LIST_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.MutableList", "MutableList", KT_MUTABLE_LIST_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.Set", "Set", KT_SET_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.MutableSet", "MutableSet", KT_SET_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.HashSet", "HashSet", KT_SET_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.LinkedHashSet", "LinkedHashSet", KT_SET_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.Map", "Map", KT_MAP_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.MutableMap", "MutableMap", KT_MUTABLE_MAP_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.HashMap", "HashMap", KT_MUTABLE_MAP_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.LinkedHashMap", "LinkedHashMap",
|
||||
KT_MUTABLE_MAP_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.ArrayList", "ArrayList", KT_MUTABLE_LIST_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.Iterator", "Iterator", KT_ITERATOR_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.MutableIterator", "MutableIterator",
|
||||
KT_ITERATOR_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.collections.ListIterator", "ListIterator", KT_ITERATOR_METHODS);
|
||||
|
||||
/* Sequences */
|
||||
KT_TYPE_WITH_METHODS("kotlin.sequences.Sequence", "Sequence", KT_SEQUENCE_METHODS);
|
||||
|
||||
/* Arrays */
|
||||
KT_TYPE_WITH_METHODS("kotlin.Array", "Array", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.IntArray", "IntArray", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.LongArray", "LongArray", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.DoubleArray", "DoubleArray", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.FloatArray", "FloatArray", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ByteArray", "ByteArray", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ShortArray", "ShortArray", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.BooleanArray", "BooleanArray", KT_ARRAY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.CharArray", "CharArray", KT_ARRAY_METHODS);
|
||||
|
||||
/* Ranges */
|
||||
KT_TYPE_WITH_METHODS("kotlin.ranges.IntRange", "IntRange", KT_INT_RANGE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ranges.LongRange", "LongRange", KT_INT_RANGE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ranges.CharRange", "CharRange", KT_INT_RANGE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ranges.IntProgression", "IntProgression", KT_INT_RANGE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ranges.LongProgression", "LongProgression", KT_INT_RANGE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ranges.ClosedRange", "ClosedRange", KT_INT_RANGE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.ranges.ClosedFloatingPointRange", "ClosedFloatingPointRange",
|
||||
KT_INT_RANGE_METHODS);
|
||||
|
||||
/* Text */
|
||||
KT_TYPE_WITH_METHODS("kotlin.text.Regex", "Regex", KT_REGEX_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.text.MatchResult", "MatchResult", KT_MATCH_RESULT_METHODS);
|
||||
KT_TYPE_WITH_METHODS("kotlin.text.StringBuilder", "StringBuilder", KT_STRING_METHODS);
|
||||
|
||||
/* IO (java.io.File is reachable through kotlin.io extension functions) */
|
||||
KT_TYPE_WITH_METHODS("java.io.File", "File", KT_FILE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.io.PrintStream", "PrintStream", KT_FILE_METHODS);
|
||||
|
||||
/* java.lang basics that come in via default JVM imports */
|
||||
KT_TYPE_WITH_METHODS("java.lang.String", "String", KT_STRING_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.lang.Object", "Object", KT_ANY_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.lang.Throwable", "Throwable", KT_THROWABLE_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.lang.Exception", "Exception", KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.lang.RuntimeException", "RuntimeException", KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.lang.IllegalArgumentException", "IllegalArgumentException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.lang.IllegalStateException", "IllegalStateException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_WITH_METHODS("java.lang.NumberFormatException", "NumberFormatException",
|
||||
KT_EXCEPTION_METHODS);
|
||||
KT_TYPE_SIMPLE("java.lang.System", "System");
|
||||
KT_TYPE_SIMPLE("java.lang.Math", "Math");
|
||||
KT_TYPE_SIMPLE("java.lang.Integer", "Integer");
|
||||
KT_TYPE_SIMPLE("java.lang.Long", "Long");
|
||||
KT_TYPE_SIMPLE("java.lang.Double", "Double");
|
||||
KT_TYPE_SIMPLE("java.lang.Float", "Float");
|
||||
KT_TYPE_SIMPLE("java.lang.Boolean", "Boolean");
|
||||
|
||||
/* ── Top-level functions ── */
|
||||
/* kotlin.io */
|
||||
KT_FUNC0("kotlin.io.println", "println", "kotlin.Unit");
|
||||
KT_FUNC0("kotlin.io.print", "print", "kotlin.Unit");
|
||||
KT_FUNC0("kotlin.io.readLine", "readLine", "kotlin.String");
|
||||
KT_FUNC0("kotlin.io.readln", "readln", "kotlin.String");
|
||||
KT_FUNC0("kotlin.io.readlnOrNull", "readlnOrNull", "kotlin.String");
|
||||
|
||||
/* kotlin (root) */
|
||||
KT_FUNC0("kotlin.error", "error", "kotlin.Nothing");
|
||||
KT_FUNC0("kotlin.check", "check", "kotlin.Unit");
|
||||
KT_FUNC0("kotlin.checkNotNull", "checkNotNull", "kotlin.Any");
|
||||
KT_FUNC0("kotlin.require", "require", "kotlin.Unit");
|
||||
KT_FUNC0("kotlin.requireNotNull", "requireNotNull", "kotlin.Any");
|
||||
KT_FUNC0("kotlin.assert", "assert", "kotlin.Unit");
|
||||
KT_FUNC0("kotlin.TODO", "TODO", "kotlin.Nothing");
|
||||
KT_FUNC0("kotlin.runCatching", "runCatching", "kotlin.Result");
|
||||
KT_FUNC0("kotlin.run", "run", "kotlin.Any");
|
||||
KT_FUNC0("kotlin.with", "with", "kotlin.Any");
|
||||
KT_FUNC0("kotlin.repeat", "repeat", "kotlin.Unit");
|
||||
KT_FUNC0("kotlin.synchronized", "synchronized", "kotlin.Any");
|
||||
KT_FUNC0("kotlin.lazy", "lazy", "kotlin.Lazy");
|
||||
KT_FUNC0("kotlin.lazyOf", "lazyOf", "kotlin.Lazy");
|
||||
KT_FUNC0("kotlin.to", "to", "kotlin.Pair");
|
||||
|
||||
/* kotlin.collections — top-level builders */
|
||||
KT_FUNC0("kotlin.collections.listOf", "listOf", "kotlin.collections.List");
|
||||
KT_FUNC0("kotlin.collections.mutableListOf", "mutableListOf",
|
||||
"kotlin.collections.MutableList");
|
||||
KT_FUNC0("kotlin.collections.arrayListOf", "arrayListOf", "kotlin.collections.ArrayList");
|
||||
KT_FUNC0("kotlin.collections.emptyList", "emptyList", "kotlin.collections.List");
|
||||
KT_FUNC0("kotlin.collections.listOfNotNull", "listOfNotNull", "kotlin.collections.List");
|
||||
KT_FUNC0("kotlin.collections.setOf", "setOf", "kotlin.collections.Set");
|
||||
KT_FUNC0("kotlin.collections.mutableSetOf", "mutableSetOf", "kotlin.collections.MutableSet");
|
||||
KT_FUNC0("kotlin.collections.hashSetOf", "hashSetOf", "kotlin.collections.HashSet");
|
||||
KT_FUNC0("kotlin.collections.linkedSetOf", "linkedSetOf",
|
||||
"kotlin.collections.LinkedHashSet");
|
||||
KT_FUNC0("kotlin.collections.emptySet", "emptySet", "kotlin.collections.Set");
|
||||
KT_FUNC0("kotlin.collections.sortedSetOf", "sortedSetOf", "kotlin.collections.Set");
|
||||
KT_FUNC0("kotlin.collections.mapOf", "mapOf", "kotlin.collections.Map");
|
||||
KT_FUNC0("kotlin.collections.mutableMapOf", "mutableMapOf", "kotlin.collections.MutableMap");
|
||||
KT_FUNC0("kotlin.collections.hashMapOf", "hashMapOf", "kotlin.collections.HashMap");
|
||||
KT_FUNC0("kotlin.collections.linkedMapOf", "linkedMapOf",
|
||||
"kotlin.collections.LinkedHashMap");
|
||||
KT_FUNC0("kotlin.collections.emptyMap", "emptyMap", "kotlin.collections.Map");
|
||||
KT_FUNC0("kotlin.collections.sortedMapOf", "sortedMapOf", "kotlin.collections.Map");
|
||||
KT_FUNC0("kotlin.arrayOf", "arrayOf", "kotlin.Array");
|
||||
KT_FUNC0("kotlin.arrayOfNulls", "arrayOfNulls", "kotlin.Array");
|
||||
KT_FUNC0("kotlin.emptyArray", "emptyArray", "kotlin.Array");
|
||||
KT_FUNC0("kotlin.intArrayOf", "intArrayOf", "kotlin.IntArray");
|
||||
KT_FUNC0("kotlin.longArrayOf", "longArrayOf", "kotlin.LongArray");
|
||||
KT_FUNC0("kotlin.floatArrayOf", "floatArrayOf", "kotlin.FloatArray");
|
||||
KT_FUNC0("kotlin.doubleArrayOf", "doubleArrayOf", "kotlin.DoubleArray");
|
||||
KT_FUNC0("kotlin.byteArrayOf", "byteArrayOf", "kotlin.ByteArray");
|
||||
KT_FUNC0("kotlin.shortArrayOf", "shortArrayOf", "kotlin.ShortArray");
|
||||
KT_FUNC0("kotlin.booleanArrayOf", "booleanArrayOf", "kotlin.BooleanArray");
|
||||
KT_FUNC0("kotlin.charArrayOf", "charArrayOf", "kotlin.CharArray");
|
||||
|
||||
/* kotlin.sequences */
|
||||
KT_FUNC0("kotlin.sequences.sequenceOf", "sequenceOf", "kotlin.sequences.Sequence");
|
||||
KT_FUNC0("kotlin.sequences.emptySequence", "emptySequence", "kotlin.sequences.Sequence");
|
||||
KT_FUNC0("kotlin.sequences.generateSequence", "generateSequence",
|
||||
"kotlin.sequences.Sequence");
|
||||
KT_FUNC0("kotlin.sequences.sequence", "sequence", "kotlin.sequences.Sequence");
|
||||
|
||||
/* kotlin.ranges */
|
||||
KT_FUNC0("kotlin.ranges.until", "until", "kotlin.ranges.IntRange");
|
||||
KT_FUNC0("kotlin.ranges.downTo", "downTo", "kotlin.ranges.IntProgression");
|
||||
KT_FUNC0("kotlin.ranges.coerceAtLeast", "coerceAtLeast", "kotlin.Int");
|
||||
KT_FUNC0("kotlin.ranges.coerceAtMost", "coerceAtMost", "kotlin.Int");
|
||||
KT_FUNC0("kotlin.ranges.coerceIn", "coerceIn", "kotlin.Int");
|
||||
|
||||
/* kotlin.comparisons */
|
||||
KT_FUNC0("kotlin.comparisons.compareValues", "compareValues", "kotlin.Int");
|
||||
KT_FUNC0("kotlin.comparisons.compareBy", "compareBy", "java.util.Comparator");
|
||||
KT_FUNC0("kotlin.comparisons.compareByDescending", "compareByDescending",
|
||||
"java.util.Comparator");
|
||||
KT_FUNC0("kotlin.comparisons.minOf", "minOf", "kotlin.Comparable");
|
||||
KT_FUNC0("kotlin.comparisons.maxOf", "maxOf", "kotlin.Comparable");
|
||||
KT_FUNC0("kotlin.comparisons.naturalOrder", "naturalOrder", "java.util.Comparator");
|
||||
KT_FUNC0("kotlin.comparisons.reverseOrder", "reverseOrder", "java.util.Comparator");
|
||||
|
||||
/* kotlin.text — useful builders on String companion */
|
||||
KT_FUNC0("kotlin.text.buildString", "buildString", "kotlin.String");
|
||||
KT_FUNC0("kotlin.text.toRegex", "toRegex", "kotlin.text.Regex");
|
||||
|
||||
/* kotlin scope-functions are registered as extension functions
|
||||
* (receiver_type = "kotlin.Any") so that resolver finds them on every
|
||||
* receiver. Their full QN is kotlin.<name>. */
|
||||
{
|
||||
const char *names[] = {"let", "run", "apply", "also", "takeIf", "takeUnless", "use", NULL};
|
||||
const char *qns[] = {"kotlin.let", "kotlin.run", "kotlin.apply", "kotlin.also",
|
||||
"kotlin.takeIf", "kotlin.takeUnless",
|
||||
"kotlin.io.use", /* `use` lives in kotlin.io for Closeable */
|
||||
NULL};
|
||||
for (int i = 0; names[i]; i++) {
|
||||
CBMRegisteredFunc rf = {0};
|
||||
rf.qualified_name = qns[i];
|
||||
rf.short_name = names[i];
|
||||
rf.receiver_type = "kotlin.Any";
|
||||
rf.min_params = 1; /* the lambda */
|
||||
cbm_registry_add_func(reg, rf);
|
||||
}
|
||||
}
|
||||
(void)KT_SCOPE_METHODS; /* reserved for future tightening */
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* perl_stdlib_data.c — hand-written Perl stdlib + CPAN type data.
|
||||
*
|
||||
* Strategy mirrors php_stdlib_data.c (docs/PLAN_PHP_LSP_INTEGRATION.md §6):
|
||||
* 1. perlfunc core built-ins (print, bless, ref, ...) registered as global,
|
||||
* package-less functions reachable from any namespace.
|
||||
* 2. Curated, corpus-driven CPAN OOP modules (Scalar::Util, List::Util,
|
||||
* Carp, POSIX, Storable, Data::Dumper) registered as module-qualified
|
||||
* functions.
|
||||
*
|
||||
* Module-qualified functions use dotted QNs (Foo.Bar.func) to match
|
||||
* perl_pkg_to_dot (Foo::Bar -> Foo.Bar) so an Exporter import map
|
||||
* (plan 22-03) can resolve `use Scalar::Util qw(blessed)` to these symbols.
|
||||
*
|
||||
* Return types are left UNKNOWN (cbm_type_unknown) for v1: real signature
|
||||
* inference is out of scope here — this seed only provides a baseline symbol
|
||||
* table for the resolver. Moose meta stubs (has/extends/with) are deferred
|
||||
* (Open Question #4).
|
||||
*/
|
||||
|
||||
#include "../type_rep.h"
|
||||
#include "../type_registry.h"
|
||||
#include "../../arena.h"
|
||||
#include "../perl_lsp.h"
|
||||
#include <string.h>
|
||||
|
||||
#define MIXED cbm_type_unknown()
|
||||
|
||||
/* Register a global (package-less) built-in function returning `ret_type_`.
|
||||
* Reachable from any package — short_name == qualified_name (bare name). */
|
||||
#define REG_BUILTIN(name_, ret_type_) \
|
||||
do { \
|
||||
memset(&rf, 0, sizeof(rf)); \
|
||||
rf.min_params = -1; \
|
||||
rf.qualified_name = (name_); \
|
||||
rf.short_name = (name_); \
|
||||
{ \
|
||||
const CBMType **rets = (const CBMType **)cbm_arena_alloc(arena, 2 * sizeof(*rets)); \
|
||||
rets[0] = (ret_type_); \
|
||||
rets[1] = NULL; \
|
||||
rf.signature = cbm_type_func(arena, NULL, NULL, rets); \
|
||||
} \
|
||||
cbm_registry_add_func(reg, rf); \
|
||||
} while (0)
|
||||
|
||||
/* Register a module-qualified function (an exported sub, not a method).
|
||||
* `module_dot_` is the dotted package QN (e.g. "Scalar.Util"); `name_` is the
|
||||
* bare sub name. QN becomes "Scalar.Util.blessed"; short_name stays bare so an
|
||||
* Exporter import map can resolve `use Scalar::Util qw(blessed)`. */
|
||||
#define REG_FUNC(module_dot_, name_, ret_type_) \
|
||||
do { \
|
||||
memset(&rf, 0, sizeof(rf)); \
|
||||
rf.min_params = -1; \
|
||||
rf.qualified_name = cbm_arena_sprintf(arena, "%s.%s", (module_dot_), (name_)); \
|
||||
rf.short_name = (name_); \
|
||||
{ \
|
||||
const CBMType **rets = (const CBMType **)cbm_arena_alloc(arena, 2 * sizeof(*rets)); \
|
||||
rets[0] = (ret_type_); \
|
||||
rets[1] = NULL; \
|
||||
rf.signature = cbm_type_func(arena, NULL, NULL, rets); \
|
||||
} \
|
||||
cbm_registry_add_func(reg, rf); \
|
||||
} while (0)
|
||||
|
||||
void cbm_perl_stdlib_register(CBMTypeRegistry *reg, CBMArena *arena) {
|
||||
CBMRegisteredFunc rf;
|
||||
|
||||
/* ── perlfunc core built-ins (global, package-less) ─────────────
|
||||
* Source: RESEARCH.md L365 (perldoc perlfunc core list). Reachable from
|
||||
* any package; return types unknown for v1. */
|
||||
REG_BUILTIN("print", MIXED);
|
||||
REG_BUILTIN("printf", MIXED);
|
||||
REG_BUILTIN("sprintf", cbm_type_builtin(arena, "string"));
|
||||
REG_BUILTIN("open", MIXED);
|
||||
REG_BUILTIN("close", MIXED);
|
||||
REG_BUILTIN("push", cbm_type_builtin(arena, "int"));
|
||||
REG_BUILTIN("pop", MIXED);
|
||||
REG_BUILTIN("shift", MIXED);
|
||||
REG_BUILTIN("unshift", cbm_type_builtin(arena, "int"));
|
||||
REG_BUILTIN("map", MIXED);
|
||||
REG_BUILTIN("grep", MIXED);
|
||||
REG_BUILTIN("sort", MIXED);
|
||||
REG_BUILTIN("join", cbm_type_builtin(arena, "string"));
|
||||
REG_BUILTIN("split", MIXED);
|
||||
REG_BUILTIN("length", cbm_type_builtin(arena, "int"));
|
||||
REG_BUILTIN("substr", cbm_type_builtin(arena, "string"));
|
||||
REG_BUILTIN("chomp", MIXED);
|
||||
REG_BUILTIN("chop", MIXED);
|
||||
REG_BUILTIN("die", MIXED);
|
||||
REG_BUILTIN("warn", MIXED);
|
||||
REG_BUILTIN("ref", cbm_type_builtin(arena, "string"));
|
||||
REG_BUILTIN("bless", MIXED);
|
||||
REG_BUILTIN("defined", cbm_type_builtin(arena, "bool"));
|
||||
REG_BUILTIN("exists", cbm_type_builtin(arena, "bool"));
|
||||
REG_BUILTIN("delete", MIXED);
|
||||
REG_BUILTIN("scalar", MIXED);
|
||||
REG_BUILTIN("keys", MIXED);
|
||||
REG_BUILTIN("values", MIXED);
|
||||
REG_BUILTIN("each", MIXED);
|
||||
|
||||
/* ── Scalar::Util ───────────────────────────────────────────────
|
||||
* Source: RESEARCH.md L366. Exported subs; module QN "Scalar.Util". */
|
||||
REG_FUNC("Scalar.Util", "blessed", MIXED);
|
||||
REG_FUNC("Scalar.Util", "reftype", cbm_type_builtin(arena, "string"));
|
||||
REG_FUNC("Scalar.Util", "weaken", MIXED);
|
||||
|
||||
/* ── List::Util ─────────────────────────────────────────────────
|
||||
* Source: RESEARCH.md L366. Module QN "List.Util". */
|
||||
REG_FUNC("List.Util", "sum", MIXED);
|
||||
REG_FUNC("List.Util", "max", MIXED);
|
||||
REG_FUNC("List.Util", "min", MIXED);
|
||||
REG_FUNC("List.Util", "first", MIXED);
|
||||
REG_FUNC("List.Util", "reduce", MIXED);
|
||||
|
||||
/* ── Carp ───────────────────────────────────────────────────────
|
||||
* Source: RESEARCH.md L367. Module QN "Carp". */
|
||||
REG_FUNC("Carp", "croak", MIXED);
|
||||
REG_FUNC("Carp", "carp", MIXED);
|
||||
REG_FUNC("Carp", "confess", MIXED);
|
||||
REG_FUNC("Carp", "cluck", MIXED);
|
||||
|
||||
/* ── POSIX (commonly-imported entry points) ─────────────────────
|
||||
* Source: RESEARCH.md L367. Module QN "POSIX". */
|
||||
REG_FUNC("POSIX", "floor", MIXED);
|
||||
REG_FUNC("POSIX", "ceil", MIXED);
|
||||
REG_FUNC("POSIX", "strftime", cbm_type_builtin(arena, "string"));
|
||||
REG_FUNC("POSIX", "INT_MAX", cbm_type_builtin(arena, "int"));
|
||||
|
||||
/* ── Storable ───────────────────────────────────────────────────
|
||||
* Source: RESEARCH.md L367. Module QN "Storable". */
|
||||
REG_FUNC("Storable", "dclone", MIXED);
|
||||
REG_FUNC("Storable", "freeze", cbm_type_builtin(arena, "string"));
|
||||
REG_FUNC("Storable", "thaw", MIXED);
|
||||
REG_FUNC("Storable", "nstore", MIXED);
|
||||
REG_FUNC("Storable", "retrieve", MIXED);
|
||||
|
||||
/* ── Data::Dumper ───────────────────────────────────────────────
|
||||
* Source: RESEARCH.md L367. Module QN "Data.Dumper". */
|
||||
REG_FUNC("Data.Dumper", "Dumper", cbm_type_builtin(arena, "string"));
|
||||
}
|
||||
@@ -0,0 +1,687 @@
|
||||
/*
|
||||
* php_stdlib_data.c — corpus-seeded PHP stdlib + framework type data.
|
||||
*
|
||||
* Strategy from docs/PLAN_PHP_LSP_INTEGRATION.md §6:
|
||||
* 1. Genuinely-stdlib base — SPL containers/iterators, PSR interfaces,
|
||||
* DateTime, Throwable hierarchy.
|
||||
* 2. Top-N corpus-driven types from laravel/framework benchmark
|
||||
* (Model in=836, Builder, Container, Collection, etc.).
|
||||
*
|
||||
* Each entry is a one-liner. Sources commented inline.
|
||||
*
|
||||
* Class QNs use dotted form (Foo.Bar.Baz) to match how the unified
|
||||
* extractor + php_resolve_class_name produce names.
|
||||
*/
|
||||
|
||||
#include "../type_rep.h"
|
||||
#include "../type_registry.h"
|
||||
#include "../../arena.h"
|
||||
#include "../php_lsp.h"
|
||||
#include <string.h>
|
||||
|
||||
#define REG_TYPE(qn_, short_, is_iface_, parents_) do { \
|
||||
memset(&rt, 0, sizeof(rt)); \
|
||||
rt.qualified_name = (qn_); \
|
||||
rt.short_name = (short_); \
|
||||
rt.is_interface = (is_iface_); \
|
||||
rt.embedded_types = (parents_); \
|
||||
cbm_registry_add_type(reg, rt); \
|
||||
} while (0)
|
||||
|
||||
#define REG_METHOD(class_qn_, method_name_, ret_type_) do { \
|
||||
memset(&rf, 0, sizeof(rf)); \
|
||||
rf.min_params = -1; \
|
||||
rf.qualified_name = cbm_arena_sprintf(arena, "%s.%s", (class_qn_), (method_name_)); \
|
||||
rf.short_name = (method_name_); \
|
||||
rf.receiver_type = (class_qn_); \
|
||||
{ \
|
||||
const CBMType **rets = (const CBMType **)cbm_arena_alloc(arena, 2 * sizeof(*rets)); \
|
||||
rets[0] = (ret_type_); rets[1] = NULL; \
|
||||
rf.signature = cbm_type_func(arena, NULL, NULL, rets); \
|
||||
} \
|
||||
cbm_registry_add_func(reg, rf); \
|
||||
} while (0)
|
||||
|
||||
#define MIXED cbm_type_unknown()
|
||||
|
||||
void cbm_php_stdlib_register(CBMTypeRegistry *reg, CBMArena *arena) {
|
||||
CBMRegisteredType rt;
|
||||
CBMRegisteredFunc rf;
|
||||
|
||||
/* ── Throwable hierarchy ────────────────────────────────────── */
|
||||
static const char *throwable_parents[] = {NULL};
|
||||
static const char *exception_parents[] = {"Throwable", NULL};
|
||||
static const char *error_parents[] = {"Throwable", NULL};
|
||||
static const char *runtime_exception_parents[] = {"Exception", NULL};
|
||||
static const char *logic_exception_parents[] = {"Exception", NULL};
|
||||
static const char *invalid_argument_parents[] = {"LogicException", NULL};
|
||||
static const char *type_error_parents[] = {"Error", NULL};
|
||||
static const char *value_error_parents[] = {"Error", NULL};
|
||||
|
||||
REG_TYPE("Throwable", "Throwable", true, throwable_parents);
|
||||
REG_TYPE("Exception", "Exception", false, exception_parents);
|
||||
REG_TYPE("Error", "Error", false, error_parents);
|
||||
REG_TYPE("RuntimeException", "RuntimeException", false, runtime_exception_parents);
|
||||
REG_TYPE("LogicException", "LogicException", false, logic_exception_parents);
|
||||
REG_TYPE("InvalidArgumentException", "InvalidArgumentException", false,
|
||||
invalid_argument_parents);
|
||||
REG_TYPE("TypeError", "TypeError", false, type_error_parents);
|
||||
REG_TYPE("ValueError", "ValueError", false, value_error_parents);
|
||||
|
||||
REG_METHOD("Throwable", "getMessage", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Throwable", "getCode", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD("Throwable", "getFile", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Throwable", "getLine", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD("Throwable", "getTrace", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("Throwable", "getTraceAsString", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Throwable", "getPrevious", cbm_type_named(arena, "Throwable"));
|
||||
|
||||
/* ── DateTime family ────────────────────────────────────────── */
|
||||
static const char *datetime_iface_parents[] = {NULL};
|
||||
static const char *datetime_parents[] = {"DateTimeInterface", NULL};
|
||||
static const char *datetime_immutable_parents[] = {"DateTimeInterface", NULL};
|
||||
|
||||
REG_TYPE("DateTimeInterface", "DateTimeInterface", true, datetime_iface_parents);
|
||||
REG_TYPE("DateTime", "DateTime", false, datetime_parents);
|
||||
REG_TYPE("DateTimeImmutable", "DateTimeImmutable", false, datetime_immutable_parents);
|
||||
REG_TYPE("DateInterval", "DateInterval", false, throwable_parents);
|
||||
REG_TYPE("DateTimeZone", "DateTimeZone", false, throwable_parents);
|
||||
|
||||
REG_METHOD("DateTimeInterface", "format", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("DateTimeInterface", "getTimestamp", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD("DateTimeInterface", "getOffset", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD("DateTime", "modify", cbm_type_named(arena, "DateTime"));
|
||||
REG_METHOD("DateTime", "add", cbm_type_named(arena, "DateTime"));
|
||||
REG_METHOD("DateTime", "sub", cbm_type_named(arena, "DateTime"));
|
||||
REG_METHOD("DateTime", "setDate", cbm_type_named(arena, "DateTime"));
|
||||
REG_METHOD("DateTime", "setTime", cbm_type_named(arena, "DateTime"));
|
||||
REG_METHOD("DateTimeImmutable", "modify", cbm_type_named(arena, "DateTimeImmutable"));
|
||||
REG_METHOD("DateTimeImmutable", "add", cbm_type_named(arena, "DateTimeImmutable"));
|
||||
REG_METHOD("DateTimeImmutable", "sub", cbm_type_named(arena, "DateTimeImmutable"));
|
||||
|
||||
/* ── SPL containers / iterators ─────────────────────────────── */
|
||||
static const char *traversable_parents[] = {NULL};
|
||||
static const char *iterator_parents[] = {"Traversable", NULL};
|
||||
static const char *iterator_aggregate_parents[] = {"Traversable", NULL};
|
||||
static const char *generator_parents[] = {"Iterator", NULL};
|
||||
static const char *array_iterator_parents[] = {"Iterator", "Countable", "ArrayAccess",
|
||||
"Serializable", NULL};
|
||||
static const char *array_object_parents[] = {"IteratorAggregate", "Countable",
|
||||
"ArrayAccess", "Serializable", NULL};
|
||||
static const char *spl_doubly_linked_list_parents[] = {"Iterator", "Countable",
|
||||
"ArrayAccess", "Serializable", NULL};
|
||||
static const char *spl_stack_parents[] = {"SplDoublyLinkedList", NULL};
|
||||
static const char *spl_queue_parents[] = {"SplDoublyLinkedList", NULL};
|
||||
static const char *spl_object_storage_parents[] = {"Countable", "Iterator", "Serializable",
|
||||
"ArrayAccess", NULL};
|
||||
static const char *countable_parents[] = {NULL};
|
||||
static const char *array_access_parents[] = {NULL};
|
||||
static const char *stringable_parents[] = {NULL};
|
||||
|
||||
REG_TYPE("Traversable", "Traversable", true, traversable_parents);
|
||||
REG_TYPE("Iterator", "Iterator", true, iterator_parents);
|
||||
REG_TYPE("IteratorAggregate", "IteratorAggregate", true, iterator_aggregate_parents);
|
||||
REG_TYPE("Generator", "Generator", false, generator_parents);
|
||||
REG_TYPE("ArrayIterator", "ArrayIterator", false, array_iterator_parents);
|
||||
REG_TYPE("ArrayObject", "ArrayObject", false, array_object_parents);
|
||||
REG_TYPE("SplDoublyLinkedList", "SplDoublyLinkedList", false, spl_doubly_linked_list_parents);
|
||||
REG_TYPE("SplStack", "SplStack", false, spl_stack_parents);
|
||||
REG_TYPE("SplQueue", "SplQueue", false, spl_queue_parents);
|
||||
REG_TYPE("SplObjectStorage", "SplObjectStorage", false, spl_object_storage_parents);
|
||||
REG_TYPE("Countable", "Countable", true, countable_parents);
|
||||
REG_TYPE("ArrayAccess", "ArrayAccess", true, array_access_parents);
|
||||
REG_TYPE("Stringable", "Stringable", true, stringable_parents);
|
||||
REG_TYPE("Serializable", "Serializable", true, traversable_parents);
|
||||
|
||||
REG_METHOD("Iterator", "current", MIXED);
|
||||
REG_METHOD("Iterator", "key", MIXED);
|
||||
REG_METHOD("Iterator", "next", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Iterator", "rewind", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Iterator", "valid", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("Countable", "count", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD("ArrayAccess", "offsetExists", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("ArrayAccess", "offsetGet", MIXED);
|
||||
REG_METHOD("ArrayAccess", "offsetSet", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("ArrayAccess", "offsetUnset", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Stringable", "__toString", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("ArrayObject", "getIterator", cbm_type_named(arena, "ArrayIterator"));
|
||||
|
||||
/* ── PSR interfaces (de facto stdlib) ───────────────────────── */
|
||||
static const char *psr_logger_parents[] = {NULL};
|
||||
static const char *psr_container_parents[] = {NULL};
|
||||
static const char *psr_request_parents[] = {NULL};
|
||||
static const char *psr_response_parents[] = {NULL};
|
||||
|
||||
REG_TYPE("Psr.Log.LoggerInterface", "LoggerInterface", true, psr_logger_parents);
|
||||
REG_TYPE("Psr.Container.ContainerInterface", "ContainerInterface", true,
|
||||
psr_container_parents);
|
||||
REG_TYPE("Psr.Container.NotFoundExceptionInterface", "NotFoundExceptionInterface", true,
|
||||
psr_container_parents);
|
||||
REG_TYPE("Psr.Http.Message.RequestInterface", "RequestInterface", true, psr_request_parents);
|
||||
REG_TYPE("Psr.Http.Message.ResponseInterface", "ResponseInterface", true,
|
||||
psr_response_parents);
|
||||
REG_TYPE("Psr.Http.Message.ServerRequestInterface", "ServerRequestInterface", true,
|
||||
psr_request_parents);
|
||||
REG_TYPE("Psr.Http.Message.UriInterface", "UriInterface", true, psr_request_parents);
|
||||
|
||||
REG_METHOD("Psr.Log.LoggerInterface", "info", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Psr.Log.LoggerInterface", "warning", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Psr.Log.LoggerInterface", "error", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Psr.Log.LoggerInterface", "debug", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Psr.Log.LoggerInterface", "critical", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Psr.Log.LoggerInterface", "log", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Psr.Container.ContainerInterface", "get", MIXED);
|
||||
REG_METHOD("Psr.Container.ContainerInterface", "has", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("Psr.Http.Message.RequestInterface", "getMethod", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Psr.Http.Message.RequestInterface", "getUri",
|
||||
cbm_type_named(arena, "Psr.Http.Message.UriInterface"));
|
||||
REG_METHOD("Psr.Http.Message.ResponseInterface", "getStatusCode",
|
||||
cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD("Psr.Http.Message.ResponseInterface", "getBody", MIXED);
|
||||
|
||||
/* ── Closure / fibers ──────────────────────────────────────── */
|
||||
REG_TYPE("Closure", "Closure", false, throwable_parents);
|
||||
REG_METHOD("Closure", "bindTo", cbm_type_named(arena, "Closure"));
|
||||
REG_METHOD("Closure", "call", MIXED);
|
||||
REG_METHOD("Closure", "__invoke", MIXED);
|
||||
|
||||
/* ── Laravel framework — top-N corpus-seeded ────────────────── */
|
||||
/* These are NOT stdlib; they are seeded because laravel/framework is the
|
||||
* canonical PHP benchmark corpus and dominates real-world receiver-type
|
||||
* resolution. Comments cite the inbound-edge count from the Q3 row of
|
||||
* docs/BENCHMARK.md and from the Q3 search_graph response. */
|
||||
|
||||
static const char *facade_parents[] = {NULL};
|
||||
REG_TYPE("Illuminate.Support.Facades.Facade", "Facade", false, facade_parents);
|
||||
REG_METHOD("Illuminate.Support.Facades.Facade", "__callStatic", MIXED);
|
||||
REG_METHOD("Illuminate.Support.Facades.Facade", "getFacadeRoot", MIXED);
|
||||
|
||||
/* Each named facade extends Facade so __callStatic detection lights up. */
|
||||
static const char *facade_child_parents[] = {"Illuminate.Support.Facades.Facade", NULL};
|
||||
REG_TYPE("Illuminate.Support.Facades.DB", "DB", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Cache", "Cache", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Auth", "Auth", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Log", "Log", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Route", "Route", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Schema", "Schema", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Storage", "Storage", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Mail", "Mail", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Queue", "Queue", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Event", "Event", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Config", "Config", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.Session", "Session", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.URL", "URL", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.View", "View", false, facade_child_parents);
|
||||
REG_TYPE("Illuminate.Support.Facades.App", "App", false, facade_child_parents);
|
||||
|
||||
/* ── Eloquent + Query Builder ───────────────────────────────── *
|
||||
*
|
||||
* The query builder is the single highest-leverage chain in any Laravel
|
||||
* codebase: `Model::query()->where(...)->orderBy(...)->first()`. We
|
||||
* register a fluent builder where every "where/order/group/select/take/
|
||||
* skip/limit/distinct/join" method returns `Builder` so chains keep
|
||||
* resolving. Terminal methods (get/first/find/value/exists) return
|
||||
* Collection or the model. */
|
||||
|
||||
REG_TYPE("Illuminate.Database.Eloquent.Builder", "Builder", false, throwable_parents);
|
||||
REG_TYPE("Illuminate.Database.Query.Builder", "Builder", false, throwable_parents);
|
||||
REG_TYPE("Illuminate.Database.Eloquent.Model", "Model", false, throwable_parents);
|
||||
REG_TYPE("Illuminate.Database.Eloquent.Collection", "Collection", false,
|
||||
traversable_parents);
|
||||
REG_TYPE("Illuminate.Support.Collection", "Collection", false, traversable_parents);
|
||||
|
||||
/* Eloquent Builder chain methods. */
|
||||
{
|
||||
const char *eb = "Illuminate.Database.Eloquent.Builder";
|
||||
const CBMType *self = cbm_type_named(arena, "Illuminate.Database.Eloquent.Builder");
|
||||
const CBMType *coll = cbm_type_named(arena, "Illuminate.Database.Eloquent.Collection");
|
||||
const CBMType *model = cbm_type_named(arena, "Illuminate.Database.Eloquent.Model");
|
||||
REG_METHOD(eb, "where", self);
|
||||
REG_METHOD(eb, "orWhere", self);
|
||||
REG_METHOD(eb, "whereIn", self);
|
||||
REG_METHOD(eb, "whereNull", self);
|
||||
REG_METHOD(eb, "whereNotNull", self);
|
||||
REG_METHOD(eb, "whereHas", self);
|
||||
REG_METHOD(eb, "with", self);
|
||||
REG_METHOD(eb, "without", self);
|
||||
REG_METHOD(eb, "select", self);
|
||||
REG_METHOD(eb, "distinct", self);
|
||||
REG_METHOD(eb, "orderBy", self);
|
||||
REG_METHOD(eb, "orderByDesc", self);
|
||||
REG_METHOD(eb, "groupBy", self);
|
||||
REG_METHOD(eb, "having", self);
|
||||
REG_METHOD(eb, "join", self);
|
||||
REG_METHOD(eb, "leftJoin", self);
|
||||
REG_METHOD(eb, "rightJoin", self);
|
||||
REG_METHOD(eb, "limit", self);
|
||||
REG_METHOD(eb, "take", self);
|
||||
REG_METHOD(eb, "skip", self);
|
||||
REG_METHOD(eb, "offset", self);
|
||||
REG_METHOD(eb, "tap", self);
|
||||
REG_METHOD(eb, "when", self);
|
||||
REG_METHOD(eb, "unless", self);
|
||||
REG_METHOD(eb, "scopeQuery", self);
|
||||
REG_METHOD(eb, "get", coll);
|
||||
REG_METHOD(eb, "all", coll);
|
||||
REG_METHOD(eb, "pluck", coll);
|
||||
REG_METHOD(eb, "first", model);
|
||||
REG_METHOD(eb, "firstOrFail", model);
|
||||
REG_METHOD(eb, "find", model);
|
||||
REG_METHOD(eb, "findOrFail", model);
|
||||
REG_METHOD(eb, "create", model);
|
||||
REG_METHOD(eb, "firstOrCreate", model);
|
||||
REG_METHOD(eb, "updateOrCreate", model);
|
||||
REG_METHOD(eb, "exists", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD(eb, "count", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD(eb, "sum", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD(eb, "value", MIXED);
|
||||
REG_METHOD(eb, "toSql", cbm_type_builtin(arena, "string"));
|
||||
}
|
||||
|
||||
/* Eloquent Model: convenience static-call entry points. */
|
||||
{
|
||||
const char *em = "Illuminate.Database.Eloquent.Model";
|
||||
const CBMType *eb = cbm_type_named(arena, "Illuminate.Database.Eloquent.Builder");
|
||||
const CBMType *self = cbm_type_named(arena, "Illuminate.Database.Eloquent.Model");
|
||||
const CBMType *coll = cbm_type_named(arena, "Illuminate.Database.Eloquent.Collection");
|
||||
REG_METHOD(em, "query", eb);
|
||||
REG_METHOD(em, "newQuery", eb);
|
||||
REG_METHOD(em, "where", eb);
|
||||
REG_METHOD(em, "with", eb);
|
||||
REG_METHOD(em, "all", coll);
|
||||
REG_METHOD(em, "find", self);
|
||||
REG_METHOD(em, "findOrFail", self);
|
||||
REG_METHOD(em, "create", self);
|
||||
REG_METHOD(em, "save", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD(em, "update", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD(em, "delete", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD(em, "fresh", self);
|
||||
REG_METHOD(em, "refresh", self);
|
||||
REG_METHOD(em, "load", self);
|
||||
REG_METHOD(em, "loadMissing", self);
|
||||
REG_METHOD(em, "toArray", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD(em, "toJson", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD(em, "getKey", MIXED);
|
||||
REG_METHOD(em, "getAttribute", MIXED);
|
||||
}
|
||||
|
||||
/* Illuminate\Support\Collection — chain returns self. */
|
||||
{
|
||||
const char *coll_qn = "Illuminate.Support.Collection";
|
||||
const CBMType *self = cbm_type_named(arena, "Illuminate.Support.Collection");
|
||||
REG_METHOD(coll_qn, "map", self);
|
||||
REG_METHOD(coll_qn, "filter", self);
|
||||
REG_METHOD(coll_qn, "reject", self);
|
||||
REG_METHOD(coll_qn, "where", self);
|
||||
REG_METHOD(coll_qn, "values", self);
|
||||
REG_METHOD(coll_qn, "keys", self);
|
||||
REG_METHOD(coll_qn, "sort", self);
|
||||
REG_METHOD(coll_qn, "sortBy", self);
|
||||
REG_METHOD(coll_qn, "sortByDesc", self);
|
||||
REG_METHOD(coll_qn, "groupBy", self);
|
||||
REG_METHOD(coll_qn, "keyBy", self);
|
||||
REG_METHOD(coll_qn, "merge", self);
|
||||
REG_METHOD(coll_qn, "concat", self);
|
||||
REG_METHOD(coll_qn, "unique", self);
|
||||
REG_METHOD(coll_qn, "take", self);
|
||||
REG_METHOD(coll_qn, "skip", self);
|
||||
REG_METHOD(coll_qn, "chunk", self);
|
||||
REG_METHOD(coll_qn, "flatten", self);
|
||||
REG_METHOD(coll_qn, "flatMap", self);
|
||||
REG_METHOD(coll_qn, "pluck", self);
|
||||
REG_METHOD(coll_qn, "tap", self);
|
||||
REG_METHOD(coll_qn, "each", self);
|
||||
REG_METHOD(coll_qn, "reverse", self);
|
||||
REG_METHOD(coll_qn, "first", MIXED);
|
||||
REG_METHOD(coll_qn, "last", MIXED);
|
||||
REG_METHOD(coll_qn, "count", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD(coll_qn, "isEmpty", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD(coll_qn, "isNotEmpty", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD(coll_qn, "contains", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD(coll_qn, "toArray", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD(coll_qn, "toJson", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD(coll_qn, "implode", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD(coll_qn, "sum", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD(coll_qn, "avg", cbm_type_builtin(arena, "float"));
|
||||
REG_METHOD(coll_qn, "max", MIXED);
|
||||
REG_METHOD(coll_qn, "min", MIXED);
|
||||
}
|
||||
|
||||
/* ── Symfony HttpFoundation (used by Laravel + Symfony) ─────── */
|
||||
static const char *symfony_request_parents[] = {NULL};
|
||||
REG_TYPE("Symfony.Component.HttpFoundation.Request", "Request", false,
|
||||
symfony_request_parents);
|
||||
REG_TYPE("Symfony.Component.HttpFoundation.Response", "Response", false,
|
||||
symfony_request_parents);
|
||||
REG_TYPE("Symfony.Component.HttpFoundation.HeaderBag", "HeaderBag", false,
|
||||
symfony_request_parents);
|
||||
REG_TYPE("Symfony.Component.HttpFoundation.ParameterBag", "ParameterBag", false,
|
||||
symfony_request_parents);
|
||||
REG_METHOD("Symfony.Component.HttpFoundation.Request", "getMethod",
|
||||
cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Symfony.Component.HttpFoundation.Request", "getPathInfo",
|
||||
cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Symfony.Component.HttpFoundation.Request", "getUri",
|
||||
cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Symfony.Component.HttpFoundation.Response", "getStatusCode",
|
||||
cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD("Symfony.Component.HttpFoundation.Response", "getContent",
|
||||
cbm_type_builtin(arena, "string"));
|
||||
|
||||
/* ── Carbon (Laravel's date/time wrapper) ───────────────────── */
|
||||
static const char *carbon_parents[] = {"DateTimeImmutable", NULL};
|
||||
REG_TYPE("Carbon.Carbon", "Carbon", false, carbon_parents);
|
||||
REG_TYPE("Carbon.CarbonImmutable", "CarbonImmutable", false, carbon_parents);
|
||||
{
|
||||
const char *c = "Carbon.Carbon";
|
||||
const CBMType *self = cbm_type_named(arena, "Carbon.Carbon");
|
||||
REG_METHOD(c, "addDay", self);
|
||||
REG_METHOD(c, "addDays", self);
|
||||
REG_METHOD(c, "subDay", self);
|
||||
REG_METHOD(c, "addMonth", self);
|
||||
REG_METHOD(c, "addYear", self);
|
||||
REG_METHOD(c, "startOfDay", self);
|
||||
REG_METHOD(c, "endOfDay", self);
|
||||
REG_METHOD(c, "format", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD(c, "toDateString", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD(c, "toDateTimeString", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD(c, "diffInDays", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD(c, "diffInHours", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD(c, "diffInMinutes", cbm_type_builtin(arena, "int"));
|
||||
REG_METHOD(c, "now", self);
|
||||
REG_METHOD(c, "today", self);
|
||||
REG_METHOD(c, "yesterday", self);
|
||||
REG_METHOD(c, "tomorrow", self);
|
||||
REG_METHOD(c, "parse", self);
|
||||
}
|
||||
|
||||
/* ── PSR-7 / PSR-15 extras (used by Symfony stack) ──────────── */
|
||||
REG_METHOD("Psr.Http.Message.RequestInterface", "withMethod",
|
||||
cbm_type_named(arena, "Psr.Http.Message.RequestInterface"));
|
||||
REG_METHOD("Psr.Http.Message.RequestInterface", "withUri",
|
||||
cbm_type_named(arena, "Psr.Http.Message.RequestInterface"));
|
||||
REG_METHOD("Psr.Http.Message.ResponseInterface", "withStatus",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
REG_METHOD("Psr.Http.Message.ResponseInterface", "withHeader",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
|
||||
/* ── Symfony Console ─────────────────────────────────────── */
|
||||
static const char *symfony_console_io_parents[] = {NULL};
|
||||
REG_TYPE("Symfony.Component.Console.Input.InputInterface", "InputInterface", true,
|
||||
symfony_console_io_parents);
|
||||
REG_TYPE("Symfony.Component.Console.Output.OutputInterface", "OutputInterface", true,
|
||||
symfony_console_io_parents);
|
||||
REG_TYPE("Symfony.Component.Console.Style.StyleInterface", "StyleInterface", true,
|
||||
symfony_console_io_parents);
|
||||
REG_TYPE("Symfony.Component.Console.Style.SymfonyStyle", "SymfonyStyle", false,
|
||||
symfony_console_io_parents);
|
||||
REG_METHOD("Symfony.Component.Console.Input.InputInterface", "getArgument", MIXED);
|
||||
REG_METHOD("Symfony.Component.Console.Input.InputInterface", "getOption", MIXED);
|
||||
REG_METHOD("Symfony.Component.Console.Input.InputInterface", "hasOption",
|
||||
cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("Symfony.Component.Console.Output.OutputInterface", "writeln",
|
||||
cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Symfony.Component.Console.Output.OutputInterface", "write",
|
||||
cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Symfony.Component.Console.Style.SymfonyStyle", "success",
|
||||
cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Symfony.Component.Console.Style.SymfonyStyle", "error",
|
||||
cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Symfony.Component.Console.Style.SymfonyStyle", "info",
|
||||
cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Symfony.Component.Console.Style.SymfonyStyle", "warning",
|
||||
cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Symfony.Component.Console.Style.SymfonyStyle", "ask",
|
||||
cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Symfony.Component.Console.Style.SymfonyStyle", "confirm",
|
||||
cbm_type_builtin(arena, "bool"));
|
||||
|
||||
/* ── Doctrine ORM ───────────────────────────────────────── */
|
||||
static const char *doctrine_parents[] = {NULL};
|
||||
REG_TYPE("Doctrine.ORM.EntityManagerInterface", "EntityManagerInterface", true,
|
||||
doctrine_parents);
|
||||
REG_TYPE("Doctrine.ORM.EntityManager", "EntityManager", false, doctrine_parents);
|
||||
REG_TYPE("Doctrine.ORM.QueryBuilder", "QueryBuilder", false, doctrine_parents);
|
||||
REG_TYPE("Doctrine.ORM.Query", "Query", false, doctrine_parents);
|
||||
REG_TYPE("Doctrine.ORM.EntityRepository", "EntityRepository", false, doctrine_parents);
|
||||
REG_METHOD("Doctrine.ORM.EntityManagerInterface", "find", MIXED);
|
||||
REG_METHOD("Doctrine.ORM.EntityManagerInterface", "persist", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Doctrine.ORM.EntityManagerInterface", "remove", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Doctrine.ORM.EntityManagerInterface", "flush", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Doctrine.ORM.EntityManagerInterface", "createQuery",
|
||||
cbm_type_named(arena, "Doctrine.ORM.Query"));
|
||||
REG_METHOD("Doctrine.ORM.EntityManagerInterface", "createQueryBuilder",
|
||||
cbm_type_named(arena, "Doctrine.ORM.QueryBuilder"));
|
||||
REG_METHOD("Doctrine.ORM.EntityManagerInterface", "getRepository",
|
||||
cbm_type_named(arena, "Doctrine.ORM.EntityRepository"));
|
||||
{
|
||||
const char *qb = "Doctrine.ORM.QueryBuilder";
|
||||
const CBMType *self = cbm_type_named(arena, "Doctrine.ORM.QueryBuilder");
|
||||
REG_METHOD(qb, "select", self);
|
||||
REG_METHOD(qb, "from", self);
|
||||
REG_METHOD(qb, "where", self);
|
||||
REG_METHOD(qb, "andWhere", self);
|
||||
REG_METHOD(qb, "orWhere", self);
|
||||
REG_METHOD(qb, "join", self);
|
||||
REG_METHOD(qb, "leftJoin", self);
|
||||
REG_METHOD(qb, "innerJoin", self);
|
||||
REG_METHOD(qb, "orderBy", self);
|
||||
REG_METHOD(qb, "groupBy", self);
|
||||
REG_METHOD(qb, "setParameter", self);
|
||||
REG_METHOD(qb, "setMaxResults", self);
|
||||
REG_METHOD(qb, "setFirstResult", self);
|
||||
REG_METHOD(qb, "getQuery", cbm_type_named(arena, "Doctrine.ORM.Query"));
|
||||
}
|
||||
REG_METHOD("Doctrine.ORM.Query", "getResult", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("Doctrine.ORM.Query", "getOneOrNullResult", MIXED);
|
||||
REG_METHOD("Doctrine.ORM.Query", "execute", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("Doctrine.ORM.EntityRepository", "find", MIXED);
|
||||
REG_METHOD("Doctrine.ORM.EntityRepository", "findAll", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("Doctrine.ORM.EntityRepository", "findBy", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("Doctrine.ORM.EntityRepository", "findOneBy", MIXED);
|
||||
|
||||
/* ── Guzzle HTTP ─────────────────────────────────────────── */
|
||||
static const char *guzzle_parents[] = {NULL};
|
||||
REG_TYPE("GuzzleHttp.Client", "Client", false, guzzle_parents);
|
||||
REG_TYPE("GuzzleHttp.ClientInterface", "ClientInterface", true, guzzle_parents);
|
||||
REG_METHOD("GuzzleHttp.ClientInterface", "request",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
REG_METHOD("GuzzleHttp.ClientInterface", "send",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
REG_METHOD("GuzzleHttp.ClientInterface", "sendAsync", MIXED);
|
||||
REG_METHOD("GuzzleHttp.Client", "request",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
REG_METHOD("GuzzleHttp.Client", "get",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
REG_METHOD("GuzzleHttp.Client", "post",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
REG_METHOD("GuzzleHttp.Client", "put",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
REG_METHOD("GuzzleHttp.Client", "delete",
|
||||
cbm_type_named(arena, "Psr.Http.Message.ResponseInterface"));
|
||||
|
||||
/* ── Twig ─────────────────────────────────────────────── */
|
||||
static const char *twig_parents[] = {NULL};
|
||||
REG_TYPE("Twig.Environment", "Environment", false, twig_parents);
|
||||
REG_TYPE("Twig.TemplateWrapper", "TemplateWrapper", false, twig_parents);
|
||||
REG_METHOD("Twig.Environment", "render", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Twig.Environment", "load",
|
||||
cbm_type_named(arena, "Twig.TemplateWrapper"));
|
||||
REG_METHOD("Twig.Environment", "createTemplate",
|
||||
cbm_type_named(arena, "Twig.TemplateWrapper"));
|
||||
REG_METHOD("Twig.TemplateWrapper", "render", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Twig.TemplateWrapper", "renderBlock", cbm_type_builtin(arena, "string"));
|
||||
|
||||
/* ── Eloquent Model magic-static methods (forwarded to Builder) ─ *
|
||||
*
|
||||
* Eloquent: every Model subclass has access to all Builder methods
|
||||
* via ::__callStatic. We register the full Builder method set as
|
||||
* static methods on Model so chains like User::where()->first()
|
||||
* resolve immediately. */
|
||||
{
|
||||
const char *em = "Illuminate.Database.Eloquent.Model";
|
||||
const CBMType *eb = cbm_type_named(arena, "Illuminate.Database.Eloquent.Builder");
|
||||
const CBMType *coll = cbm_type_named(arena, "Illuminate.Database.Eloquent.Collection");
|
||||
const CBMType *self = cbm_type_named(arena, "Illuminate.Database.Eloquent.Model");
|
||||
REG_METHOD(em, "whereIn", eb);
|
||||
REG_METHOD(em, "whereNotNull", eb);
|
||||
REG_METHOD(em, "whereHas", eb);
|
||||
REG_METHOD(em, "orderBy", eb);
|
||||
REG_METHOD(em, "limit", eb);
|
||||
REG_METHOD(em, "take", eb);
|
||||
REG_METHOD(em, "select", eb);
|
||||
REG_METHOD(em, "get", coll);
|
||||
REG_METHOD(em, "first", self);
|
||||
REG_METHOD(em, "firstOrFail", self);
|
||||
REG_METHOD(em, "firstOrCreate", self);
|
||||
}
|
||||
|
||||
/* (Generator already registered in the SPL section above.) */
|
||||
|
||||
/* ── Symfony Cache ─────────────────────────────────────── */
|
||||
static const char *cache_parents[] = {NULL};
|
||||
REG_TYPE("Symfony.Contracts.Cache.CacheInterface", "CacheInterface", true, cache_parents);
|
||||
REG_TYPE("Symfony.Contracts.Cache.ItemInterface", "ItemInterface", true, cache_parents);
|
||||
REG_TYPE("Psr.Cache.CacheItemPoolInterface", "CacheItemPoolInterface", true, cache_parents);
|
||||
REG_TYPE("Psr.Cache.CacheItemInterface", "CacheItemInterface", true, cache_parents);
|
||||
REG_METHOD("Symfony.Contracts.Cache.CacheInterface", "get", MIXED);
|
||||
REG_METHOD("Symfony.Contracts.Cache.CacheInterface", "delete", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("Symfony.Contracts.Cache.ItemInterface", "set",
|
||||
cbm_type_named(arena, "Symfony.Contracts.Cache.ItemInterface"));
|
||||
REG_METHOD("Symfony.Contracts.Cache.ItemInterface", "expiresAfter",
|
||||
cbm_type_named(arena, "Symfony.Contracts.Cache.ItemInterface"));
|
||||
REG_METHOD("Symfony.Contracts.Cache.ItemInterface", "get", MIXED);
|
||||
REG_METHOD("Psr.Cache.CacheItemPoolInterface", "getItem",
|
||||
cbm_type_named(arena, "Psr.Cache.CacheItemInterface"));
|
||||
REG_METHOD("Psr.Cache.CacheItemPoolInterface", "save",
|
||||
cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("Psr.Cache.CacheItemInterface", "get", MIXED);
|
||||
REG_METHOD("Psr.Cache.CacheItemInterface", "set",
|
||||
cbm_type_named(arena, "Psr.Cache.CacheItemInterface"));
|
||||
|
||||
/* ── Symfony EventDispatcher ────────────────────────────── */
|
||||
static const char *event_parents[] = {NULL};
|
||||
REG_TYPE("Symfony.Contracts.EventDispatcher.EventDispatcherInterface",
|
||||
"EventDispatcherInterface", true, event_parents);
|
||||
REG_TYPE("Symfony.Contracts.EventDispatcher.Event", "Event", false, event_parents);
|
||||
REG_METHOD("Symfony.Contracts.EventDispatcher.EventDispatcherInterface", "dispatch", MIXED);
|
||||
|
||||
/* ── Symfony Mailer ─────────────────────────────────────── */
|
||||
static const char *mailer_parents[] = {NULL};
|
||||
REG_TYPE("Symfony.Component.Mailer.MailerInterface", "MailerInterface", true, mailer_parents);
|
||||
REG_TYPE("Symfony.Component.Mime.Email", "Email", false, mailer_parents);
|
||||
REG_METHOD("Symfony.Component.Mailer.MailerInterface", "send",
|
||||
cbm_type_builtin(arena, "void"));
|
||||
{
|
||||
const char *e = "Symfony.Component.Mime.Email";
|
||||
const CBMType *self = cbm_type_named(arena, "Symfony.Component.Mime.Email");
|
||||
REG_METHOD(e, "from", self);
|
||||
REG_METHOD(e, "to", self);
|
||||
REG_METHOD(e, "cc", self);
|
||||
REG_METHOD(e, "bcc", self);
|
||||
REG_METHOD(e, "subject", self);
|
||||
REG_METHOD(e, "text", self);
|
||||
REG_METHOD(e, "html", self);
|
||||
REG_METHOD(e, "attachFromPath", self);
|
||||
}
|
||||
|
||||
/* ── Symfony Validator ─────────────────────────────────── */
|
||||
static const char *validator_parents[] = {NULL};
|
||||
REG_TYPE("Symfony.Component.Validator.Validator.ValidatorInterface", "ValidatorInterface",
|
||||
true, validator_parents);
|
||||
REG_TYPE("Symfony.Component.Validator.ConstraintViolationListInterface",
|
||||
"ConstraintViolationListInterface", true, validator_parents);
|
||||
REG_METHOD("Symfony.Component.Validator.Validator.ValidatorInterface", "validate",
|
||||
cbm_type_named(arena,
|
||||
"Symfony.Component.Validator.ConstraintViolationListInterface"));
|
||||
REG_METHOD("Symfony.Component.Validator.ConstraintViolationListInterface", "count",
|
||||
cbm_type_builtin(arena, "int"));
|
||||
|
||||
/* ── Laravel HTTP Request / Response ──────────────────── */
|
||||
static const char *laravel_request_parents[] = {"Symfony.Component.HttpFoundation.Request",
|
||||
NULL};
|
||||
REG_TYPE("Illuminate.Http.Request", "Request", false, laravel_request_parents);
|
||||
REG_TYPE("Illuminate.Http.Response", "Response", false, laravel_request_parents);
|
||||
REG_TYPE("Illuminate.Http.JsonResponse", "JsonResponse", false, laravel_request_parents);
|
||||
REG_METHOD("Illuminate.Http.Request", "input", MIXED);
|
||||
REG_METHOD("Illuminate.Http.Request", "query", MIXED);
|
||||
REG_METHOD("Illuminate.Http.Request", "all", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("Illuminate.Http.Request", "user", MIXED);
|
||||
REG_METHOD("Illuminate.Http.Request", "validate", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("Illuminate.Http.Response", "header",
|
||||
cbm_type_named(arena, "Illuminate.Http.Response"));
|
||||
REG_METHOD("Illuminate.Http.Response", "withHeaders",
|
||||
cbm_type_named(arena, "Illuminate.Http.Response"));
|
||||
REG_METHOD("Illuminate.Http.JsonResponse", "header",
|
||||
cbm_type_named(arena, "Illuminate.Http.JsonResponse"));
|
||||
|
||||
/* ── Laravel Auth ─────────────────────────────────────── */
|
||||
static const char *auth_parents[] = {NULL};
|
||||
REG_TYPE("Illuminate.Contracts.Auth.Authenticatable", "Authenticatable", true,
|
||||
auth_parents);
|
||||
REG_TYPE("Illuminate.Contracts.Auth.Guard", "Guard", true, auth_parents);
|
||||
REG_METHOD("Illuminate.Contracts.Auth.Authenticatable", "getAuthIdentifier", MIXED);
|
||||
REG_METHOD("Illuminate.Contracts.Auth.Authenticatable", "getAuthPassword",
|
||||
cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Illuminate.Contracts.Auth.Guard", "user",
|
||||
cbm_type_named(arena, "Illuminate.Contracts.Auth.Authenticatable"));
|
||||
REG_METHOD("Illuminate.Contracts.Auth.Guard", "check", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("Illuminate.Contracts.Auth.Guard", "id", MIXED);
|
||||
|
||||
/* ── Laravel Session / View ──────────────────────────── */
|
||||
static const char *session_parents[] = {NULL};
|
||||
REG_TYPE("Illuminate.Contracts.Session.Session", "Session", true, session_parents);
|
||||
REG_METHOD("Illuminate.Contracts.Session.Session", "get", MIXED);
|
||||
REG_METHOD("Illuminate.Contracts.Session.Session", "put", cbm_type_builtin(arena, "void"));
|
||||
REG_METHOD("Illuminate.Contracts.Session.Session", "has", cbm_type_builtin(arena, "bool"));
|
||||
REG_METHOD("Illuminate.Contracts.Session.Session", "flash", cbm_type_builtin(arena, "void"));
|
||||
|
||||
REG_TYPE("Illuminate.View.View", "View", false, session_parents);
|
||||
REG_METHOD("Illuminate.View.View", "render", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("Illuminate.View.View", "with",
|
||||
cbm_type_named(arena, "Illuminate.View.View"));
|
||||
|
||||
/* ── ReactPHP / Promise ───────────────────────────────── */
|
||||
static const char *promise_parents[] = {NULL};
|
||||
REG_TYPE("React.Promise.PromiseInterface", "PromiseInterface", true, promise_parents);
|
||||
REG_TYPE("GuzzleHttp.Promise.PromiseInterface", "PromiseInterface", true, promise_parents);
|
||||
REG_METHOD("React.Promise.PromiseInterface", "then",
|
||||
cbm_type_named(arena, "React.Promise.PromiseInterface"));
|
||||
REG_METHOD("React.Promise.PromiseInterface", "catch",
|
||||
cbm_type_named(arena, "React.Promise.PromiseInterface"));
|
||||
REG_METHOD("React.Promise.PromiseInterface", "finally",
|
||||
cbm_type_named(arena, "React.Promise.PromiseInterface"));
|
||||
REG_METHOD("GuzzleHttp.Promise.PromiseInterface", "then",
|
||||
cbm_type_named(arena, "GuzzleHttp.Promise.PromiseInterface"));
|
||||
|
||||
/* ── Monolog (popular logger) ───────────────────────── */
|
||||
static const char *monolog_parents[] = {"Psr.Log.LoggerInterface", NULL};
|
||||
REG_TYPE("Monolog.Logger", "Logger", false, monolog_parents);
|
||||
/* Logger inherits info/warning/error/etc. methods from PSR LoggerInterface. */
|
||||
REG_METHOD("Monolog.Logger", "pushHandler",
|
||||
cbm_type_named(arena, "Monolog.Logger"));
|
||||
REG_METHOD("Monolog.Logger", "pushProcessor",
|
||||
cbm_type_named(arena, "Monolog.Logger"));
|
||||
|
||||
/* ── Reflection API ──────────────────────────────────── */
|
||||
static const char *reflection_parents[] = {NULL};
|
||||
REG_TYPE("ReflectionClass", "ReflectionClass", false, reflection_parents);
|
||||
REG_TYPE("ReflectionMethod", "ReflectionMethod", false, reflection_parents);
|
||||
REG_TYPE("ReflectionProperty", "ReflectionProperty", false, reflection_parents);
|
||||
REG_TYPE("ReflectionFunction", "ReflectionFunction", false, reflection_parents);
|
||||
REG_METHOD("ReflectionClass", "getName", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("ReflectionClass", "getMethods", cbm_type_builtin(arena, "array"));
|
||||
REG_METHOD("ReflectionClass", "getMethod",
|
||||
cbm_type_named(arena, "ReflectionMethod"));
|
||||
REG_METHOD("ReflectionClass", "newInstance", MIXED);
|
||||
REG_METHOD("ReflectionClass", "newInstanceArgs", MIXED);
|
||||
REG_METHOD("ReflectionMethod", "invoke", MIXED);
|
||||
REG_METHOD("ReflectionMethod", "invokeArgs", MIXED);
|
||||
REG_METHOD("ReflectionMethod", "getName", cbm_type_builtin(arena, "string"));
|
||||
REG_METHOD("ReflectionProperty", "getValue", MIXED);
|
||||
REG_METHOD("ReflectionProperty", "setValue", cbm_type_builtin(arena, "void"));
|
||||
}
|
||||
|
||||
#undef REG_TYPE
|
||||
#undef REG_METHOD
|
||||
#undef MIXED
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,426 @@
|
||||
/* rust_crates_seed.c — Common-crate API seeds for the Rust LSP.
|
||||
*
|
||||
* Per RUST_LSP_FOLLOWUP.md A3: we don't run Cargo or download deps.
|
||||
* What we CAN do is hand-curate a small registered-method seed for the
|
||||
* most-used external crates (serde, tokio, anyhow, clap, regex, log,
|
||||
* futures, thiserror, reqwest, hyper, async-trait, parking_lot,
|
||||
* chrono, uuid, lazy_static, once_cell, rayon, …) so a project that
|
||||
* just `use`s these crates resolves the obvious calls instead of
|
||||
* leaving them all `unresolved`.
|
||||
*
|
||||
* Each entry is "best-effort" — we register the type with its trait
|
||||
* QNs in embedded_types and synthesize the high-frequency methods
|
||||
* with vaguely-correct return shapes. Anything we get wrong stays
|
||||
* `unresolved` rather than a wrong edge (per the doc's no-false-edge
|
||||
* policy: we only register what we're confident about).
|
||||
*
|
||||
* Designed to be appended to the existing stdlib register: takes the
|
||||
* same (reg, arena) pair. */
|
||||
|
||||
#include "../type_rep.h"
|
||||
#include "../type_registry.h"
|
||||
#include "../rust_lsp.h"
|
||||
#include <string.h>
|
||||
|
||||
/* Shorthand. Mirrors the macros in rust_stdlib_data.c. */
|
||||
#ifndef RUST_CRATES_SEED_INCLUDED
|
||||
#define RUST_CRATES_SEED_INCLUDED 1
|
||||
|
||||
#define CADD_TYPE(qn, sn, iface) do { \
|
||||
CBMRegisteredType _rt; \
|
||||
memset(&_rt, 0, sizeof(_rt)); \
|
||||
_rt.qualified_name = (qn); \
|
||||
_rt.short_name = (sn); \
|
||||
_rt.is_interface = (iface); \
|
||||
cbm_registry_add_type(reg, _rt); \
|
||||
} while (0)
|
||||
|
||||
#define CADD_FUNC(rcv, sn, qn, ret_type) do { \
|
||||
CBMRegisteredFunc _rf; \
|
||||
memset(&_rf, 0, sizeof(_rf)); \
|
||||
_rf.qualified_name = (qn); \
|
||||
_rf.short_name = (sn); \
|
||||
_rf.receiver_type = (rcv); \
|
||||
_rf.min_params = -1; \
|
||||
const CBMType** _rta = (const CBMType**)cbm_arena_alloc(arena, \
|
||||
2 * sizeof(const CBMType*)); \
|
||||
_rta[0] = (ret_type); \
|
||||
_rta[1] = NULL; \
|
||||
_rf.signature = cbm_type_func(arena, NULL, NULL, _rta); \
|
||||
cbm_registry_add_func(reg, _rf); \
|
||||
} while (0)
|
||||
|
||||
void cbm_rust_crates_register(CBMTypeRegistry* reg, CBMArena* arena) {
|
||||
const CBMType* t_unit = cbm_type_builtin(arena, "()");
|
||||
const CBMType* t_bool = cbm_type_builtin(arena, "bool");
|
||||
const CBMType* t_usize = cbm_type_builtin(arena, "usize");
|
||||
const CBMType* t_str_ref = cbm_type_reference(arena,
|
||||
cbm_type_builtin(arena, "str"));
|
||||
const CBMType* t_string = cbm_type_named(arena, "alloc.string.String");
|
||||
|
||||
/* ── serde — Serialize / Deserialize / json ─────────────── */
|
||||
CADD_TYPE("serde.Serialize", "Serialize", true);
|
||||
CADD_TYPE("serde.Deserialize", "Deserialize", true);
|
||||
CADD_TYPE("serde.Serializer", "Serializer", true);
|
||||
CADD_TYPE("serde.Deserializer", "Deserializer", true);
|
||||
CADD_TYPE("serde.de.Error", "Error", true);
|
||||
CADD_TYPE("serde.ser.Error", "Error", true);
|
||||
CADD_TYPE("serde_json.Value", "Value", false);
|
||||
CADD_TYPE("serde_json.Map", "Map", false);
|
||||
CADD_TYPE("serde_json.Number", "Number", false);
|
||||
CADD_TYPE("serde_json.Error", "Error", false);
|
||||
|
||||
CADD_FUNC("serde.Serialize", "serialize", "serde.Serialize.serialize", cbm_type_unknown());
|
||||
CADD_FUNC("serde.Deserialize", "deserialize", "serde.Deserialize.deserialize", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "is_null", "serde_json.Value.is_null", t_bool);
|
||||
CADD_FUNC("serde_json.Value", "is_bool", "serde_json.Value.is_bool", t_bool);
|
||||
CADD_FUNC("serde_json.Value", "is_number", "serde_json.Value.is_number", t_bool);
|
||||
CADD_FUNC("serde_json.Value", "is_string", "serde_json.Value.is_string", t_bool);
|
||||
CADD_FUNC("serde_json.Value", "is_array", "serde_json.Value.is_array", t_bool);
|
||||
CADD_FUNC("serde_json.Value", "is_object", "serde_json.Value.is_object", t_bool);
|
||||
CADD_FUNC("serde_json.Value", "as_bool", "serde_json.Value.as_bool", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "as_i64", "serde_json.Value.as_i64", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "as_f64", "serde_json.Value.as_f64", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "as_str", "serde_json.Value.as_str", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "as_array", "serde_json.Value.as_array", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "as_object", "serde_json.Value.as_object", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "get", "serde_json.Value.get", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "pointer", "serde_json.Value.pointer", cbm_type_unknown());
|
||||
CADD_FUNC("serde_json.Value", "to_string", "serde_json.Value.to_string", t_string);
|
||||
/* Free functions in serde_json. */
|
||||
CADD_FUNC(NULL, "from_str", "serde_json.from_str", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "to_string", "serde_json.to_string", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "from_value","serde_json.from_value",cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "to_value", "serde_json.to_value", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "json", "serde_json.json", cbm_type_named(arena, "serde_json.Value"));
|
||||
|
||||
/* ── anyhow — Error / Result / ensure!/bail!/anyhow! ───── */
|
||||
CADD_TYPE("anyhow.Error", "Error", false);
|
||||
CADD_TYPE("anyhow.Result", "Result", false);
|
||||
CADD_TYPE("anyhow.Chain", "Chain", false);
|
||||
CADD_FUNC("anyhow.Error", "new", "anyhow.Error.new", cbm_type_named(arena, "anyhow.Error"));
|
||||
CADD_FUNC("anyhow.Error", "from", "anyhow.Error.from", cbm_type_named(arena, "anyhow.Error"));
|
||||
CADD_FUNC("anyhow.Error", "msg", "anyhow.Error.msg", cbm_type_named(arena, "anyhow.Error"));
|
||||
CADD_FUNC("anyhow.Error", "context", "anyhow.Error.context", cbm_type_named(arena, "anyhow.Error"));
|
||||
CADD_FUNC("anyhow.Error", "downcast", "anyhow.Error.downcast", cbm_type_unknown());
|
||||
CADD_FUNC("anyhow.Error", "downcast_ref","anyhow.Error.downcast_ref", cbm_type_unknown());
|
||||
CADD_FUNC("anyhow.Error", "is", "anyhow.Error.is", t_bool);
|
||||
CADD_FUNC("anyhow.Error", "chain", "anyhow.Error.chain", cbm_type_unknown());
|
||||
CADD_FUNC("anyhow.Error", "root_cause","anyhow.Error.root_cause", cbm_type_unknown());
|
||||
CADD_FUNC("anyhow.Error", "source", "anyhow.Error.source", cbm_type_unknown());
|
||||
/* Free functions. */
|
||||
CADD_FUNC(NULL, "anyhow", "anyhow.anyhow", cbm_type_named(arena, "anyhow.Error"));
|
||||
CADD_FUNC(NULL, "bail", "anyhow.bail", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "ensure", "anyhow.ensure", cbm_type_unknown());
|
||||
|
||||
/* ── thiserror — derive-only crate, but the Error trait. ─── */
|
||||
/* (Error trait is already covered under core.error.Error.) */
|
||||
|
||||
/* ── tokio — runtime + I/O + sync primitives. ───────────── */
|
||||
CADD_TYPE("tokio.runtime.Runtime", "Runtime", false);
|
||||
CADD_TYPE("tokio.runtime.Handle", "Handle", false);
|
||||
CADD_TYPE("tokio.runtime.Builder", "Builder", false);
|
||||
CADD_TYPE("tokio.task.JoinHandle", "JoinHandle",false);
|
||||
CADD_TYPE("tokio.sync.Mutex", "Mutex", false);
|
||||
CADD_TYPE("tokio.sync.RwLock", "RwLock", false);
|
||||
CADD_TYPE("tokio.sync.Semaphore", "Semaphore", false);
|
||||
CADD_TYPE("tokio.sync.Notify", "Notify", false);
|
||||
CADD_TYPE("tokio.sync.oneshot.Sender","Sender", false);
|
||||
CADD_TYPE("tokio.sync.oneshot.Receiver","Receiver", false);
|
||||
CADD_TYPE("tokio.sync.mpsc.Sender", "Sender", false);
|
||||
CADD_TYPE("tokio.sync.mpsc.Receiver", "Receiver", false);
|
||||
CADD_TYPE("tokio.sync.mpsc.UnboundedSender","UnboundedSender", false);
|
||||
CADD_TYPE("tokio.sync.mpsc.UnboundedReceiver","UnboundedReceiver", false);
|
||||
CADD_TYPE("tokio.net.TcpListener", "TcpListener", false);
|
||||
CADD_TYPE("tokio.net.TcpStream", "TcpStream", false);
|
||||
CADD_TYPE("tokio.io.BufReader", "BufReader", false);
|
||||
CADD_TYPE("tokio.io.BufWriter", "BufWriter", false);
|
||||
CADD_TYPE("tokio.time.Sleep", "Sleep", false);
|
||||
CADD_TYPE("tokio.time.Interval", "Interval", false);
|
||||
CADD_TYPE("tokio.fs.File", "File", false);
|
||||
CADD_TYPE("tokio.process.Command", "Command", false);
|
||||
CADD_TYPE("tokio.process.Child", "Child", false);
|
||||
|
||||
CADD_FUNC("tokio.runtime.Runtime", "new", "tokio.runtime.Runtime.new", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Runtime", "block_on", "tokio.runtime.Runtime.block_on", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Runtime", "spawn", "tokio.runtime.Runtime.spawn", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Runtime", "handle", "tokio.runtime.Runtime.handle", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Runtime", "shutdown_timeout","tokio.runtime.Runtime.shutdown_timeout", t_unit);
|
||||
CADD_FUNC("tokio.runtime.Builder", "new_multi_thread","tokio.runtime.Builder.new_multi_thread", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Builder", "new_current_thread","tokio.runtime.Builder.new_current_thread", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Builder", "worker_threads","tokio.runtime.Builder.worker_threads", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Builder", "enable_all","tokio.runtime.Builder.enable_all", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Builder", "build", "tokio.runtime.Builder.build", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Handle", "current", "tokio.runtime.Handle.current", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Handle", "spawn", "tokio.runtime.Handle.spawn", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.runtime.Handle", "block_on", "tokio.runtime.Handle.block_on", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.task.JoinHandle", "await", "tokio.task.JoinHandle.await", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.task.JoinHandle", "abort", "tokio.task.JoinHandle.abort", t_unit);
|
||||
CADD_FUNC("tokio.task.JoinHandle", "is_finished","tokio.task.JoinHandle.is_finished", t_bool);
|
||||
CADD_FUNC("tokio.sync.Mutex", "new", "tokio.sync.Mutex.new", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.Mutex", "lock", "tokio.sync.Mutex.lock", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.Mutex", "try_lock", "tokio.sync.Mutex.try_lock", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.RwLock", "new", "tokio.sync.RwLock.new", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.RwLock", "read", "tokio.sync.RwLock.read", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.RwLock", "write", "tokio.sync.RwLock.write", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.Semaphore", "new", "tokio.sync.Semaphore.new", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.Semaphore", "acquire", "tokio.sync.Semaphore.acquire", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.Semaphore", "add_permits","tokio.sync.Semaphore.add_permits", t_unit);
|
||||
CADD_FUNC("tokio.sync.Notify", "new", "tokio.sync.Notify.new", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.Notify", "notified", "tokio.sync.Notify.notified", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.Notify", "notify_one","tokio.sync.Notify.notify_one", t_unit);
|
||||
CADD_FUNC("tokio.sync.Notify", "notify_waiters","tokio.sync.Notify.notify_waiters", t_unit);
|
||||
CADD_FUNC("tokio.sync.mpsc.Sender", "send", "tokio.sync.mpsc.Sender.send", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.mpsc.Sender", "try_send","tokio.sync.mpsc.Sender.try_send",cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.mpsc.Receiver","recv", "tokio.sync.mpsc.Receiver.recv", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.mpsc.Receiver","try_recv","tokio.sync.mpsc.Receiver.try_recv",cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.oneshot.Sender","send", "tokio.sync.oneshot.Sender.send", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.sync.oneshot.Receiver","await","tokio.sync.oneshot.Receiver.await", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.net.TcpListener", "bind", "tokio.net.TcpListener.bind", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.net.TcpListener", "accept", "tokio.net.TcpListener.accept", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.net.TcpListener", "local_addr","tokio.net.TcpListener.local_addr",cbm_type_unknown());
|
||||
CADD_FUNC("tokio.net.TcpStream", "connect", "tokio.net.TcpStream.connect", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.net.TcpStream", "peer_addr","tokio.net.TcpStream.peer_addr", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.time.Sleep", "await", "tokio.time.Sleep.await", t_unit);
|
||||
CADD_FUNC("tokio.time.Interval", "tick", "tokio.time.Interval.tick", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.fs.File", "open", "tokio.fs.File.open", cbm_type_unknown());
|
||||
CADD_FUNC("tokio.fs.File", "create", "tokio.fs.File.create", cbm_type_unknown());
|
||||
/* Free functions. */
|
||||
CADD_FUNC(NULL, "spawn", "tokio.spawn", cbm_type_named(arena, "tokio.task.JoinHandle"));
|
||||
CADD_FUNC(NULL, "spawn_blocking","tokio.task.spawn_blocking", cbm_type_named(arena, "tokio.task.JoinHandle"));
|
||||
CADD_FUNC(NULL, "yield_now","tokio.task.yield_now", t_unit);
|
||||
CADD_FUNC(NULL, "sleep", "tokio.time.sleep", cbm_type_named(arena, "tokio.time.Sleep"));
|
||||
CADD_FUNC(NULL, "sleep_until","tokio.time.sleep_until", cbm_type_named(arena, "tokio.time.Sleep"));
|
||||
CADD_FUNC(NULL, "interval", "tokio.time.interval", cbm_type_named(arena, "tokio.time.Interval"));
|
||||
CADD_FUNC(NULL, "timeout", "tokio.time.timeout", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "read_to_string","tokio.fs.read_to_string", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "write", "tokio.fs.write", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "read", "tokio.fs.read", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "channel", "tokio.sync.mpsc.channel", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "unbounded_channel","tokio.sync.mpsc.unbounded_channel", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "join", "tokio.join", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "try_join", "tokio.try_join", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "select", "tokio.select", cbm_type_unknown());
|
||||
|
||||
/* ── clap — argument parsing. ─────────────────────────── */
|
||||
CADD_TYPE("clap.Parser", "Parser", true);
|
||||
CADD_TYPE("clap.Args", "Args", true);
|
||||
CADD_TYPE("clap.Subcommand", "Subcommand", true);
|
||||
CADD_TYPE("clap.ValueEnum", "ValueEnum", true);
|
||||
CADD_TYPE("clap.Command", "Command", false);
|
||||
CADD_TYPE("clap.Arg", "Arg", false);
|
||||
CADD_TYPE("clap.ArgMatches", "ArgMatches", false);
|
||||
|
||||
CADD_FUNC("clap.Parser", "parse", "clap.Parser.parse", cbm_type_unknown());
|
||||
CADD_FUNC("clap.Parser", "try_parse", "clap.Parser.try_parse", cbm_type_unknown());
|
||||
CADD_FUNC("clap.Parser", "parse_from", "clap.Parser.parse_from", cbm_type_unknown());
|
||||
CADD_FUNC("clap.Parser", "try_parse_from","clap.Parser.try_parse_from",cbm_type_unknown());
|
||||
CADD_FUNC("clap.Parser", "command", "clap.Parser.command", cbm_type_named(arena, "clap.Command"));
|
||||
CADD_FUNC("clap.Command","new", "clap.Command.new", cbm_type_named(arena, "clap.Command"));
|
||||
CADD_FUNC("clap.Command","arg", "clap.Command.arg", cbm_type_named(arena, "clap.Command"));
|
||||
CADD_FUNC("clap.Command","subcommand", "clap.Command.subcommand", cbm_type_named(arena, "clap.Command"));
|
||||
CADD_FUNC("clap.Command","about", "clap.Command.about", cbm_type_named(arena, "clap.Command"));
|
||||
CADD_FUNC("clap.Command","version", "clap.Command.version", cbm_type_named(arena, "clap.Command"));
|
||||
CADD_FUNC("clap.Command","author", "clap.Command.author", cbm_type_named(arena, "clap.Command"));
|
||||
CADD_FUNC("clap.Command","get_matches", "clap.Command.get_matches", cbm_type_named(arena, "clap.ArgMatches"));
|
||||
CADD_FUNC("clap.Command","get_matches_from","clap.Command.get_matches_from", cbm_type_named(arena, "clap.ArgMatches"));
|
||||
CADD_FUNC("clap.Arg", "new", "clap.Arg.new", cbm_type_named(arena, "clap.Arg"));
|
||||
CADD_FUNC("clap.Arg", "short", "clap.Arg.short", cbm_type_named(arena, "clap.Arg"));
|
||||
CADD_FUNC("clap.Arg", "long", "clap.Arg.long", cbm_type_named(arena, "clap.Arg"));
|
||||
CADD_FUNC("clap.Arg", "value_name", "clap.Arg.value_name", cbm_type_named(arena, "clap.Arg"));
|
||||
CADD_FUNC("clap.Arg", "required", "clap.Arg.required", cbm_type_named(arena, "clap.Arg"));
|
||||
CADD_FUNC("clap.Arg", "default_value", "clap.Arg.default_value", cbm_type_named(arena, "clap.Arg"));
|
||||
CADD_FUNC("clap.Arg", "help", "clap.Arg.help", cbm_type_named(arena, "clap.Arg"));
|
||||
CADD_FUNC("clap.ArgMatches","get_one", "clap.ArgMatches.get_one", cbm_type_unknown());
|
||||
CADD_FUNC("clap.ArgMatches","get_many", "clap.ArgMatches.get_many", cbm_type_unknown());
|
||||
CADD_FUNC("clap.ArgMatches","get_flag", "clap.ArgMatches.get_flag", t_bool);
|
||||
CADD_FUNC("clap.ArgMatches","contains_id","clap.ArgMatches.contains_id",t_bool);
|
||||
CADD_FUNC("clap.ArgMatches","subcommand", "clap.ArgMatches.subcommand",cbm_type_unknown());
|
||||
|
||||
/* ── regex — pattern matching. ────────────────────────── */
|
||||
CADD_TYPE("regex.Regex", "Regex", false);
|
||||
CADD_TYPE("regex.Captures", "Captures", false);
|
||||
CADD_TYPE("regex.Match", "Match", false);
|
||||
CADD_TYPE("regex.RegexBuilder","RegexBuilder", false);
|
||||
|
||||
CADD_FUNC("regex.Regex", "new", "regex.Regex.new", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Regex", "is_match", "regex.Regex.is_match", t_bool);
|
||||
CADD_FUNC("regex.Regex", "find", "regex.Regex.find", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Regex", "find_iter", "regex.Regex.find_iter", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Regex", "captures", "regex.Regex.captures", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Regex", "captures_iter","regex.Regex.captures_iter", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Regex", "replace", "regex.Regex.replace", t_string);
|
||||
CADD_FUNC("regex.Regex", "replace_all", "regex.Regex.replace_all", t_string);
|
||||
CADD_FUNC("regex.Regex", "split", "regex.Regex.split", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Regex", "as_str", "regex.Regex.as_str", t_str_ref);
|
||||
CADD_FUNC("regex.Captures","get", "regex.Captures.get", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Captures","name", "regex.Captures.name", cbm_type_unknown());
|
||||
CADD_FUNC("regex.Captures","len", "regex.Captures.len", t_usize);
|
||||
CADD_FUNC("regex.Match", "as_str", "regex.Match.as_str", t_str_ref);
|
||||
CADD_FUNC("regex.Match", "start", "regex.Match.start", t_usize);
|
||||
CADD_FUNC("regex.Match", "end", "regex.Match.end", t_usize);
|
||||
CADD_FUNC("regex.Match", "range", "regex.Match.range", cbm_type_unknown());
|
||||
|
||||
/* ── log — logging macros + Logger trait. ─────────────── */
|
||||
CADD_TYPE("log.Logger", "Logger", true);
|
||||
CADD_TYPE("log.Level", "Level", false);
|
||||
CADD_TYPE("log.LevelFilter", "LevelFilter", false);
|
||||
CADD_TYPE("log.Metadata", "Metadata", false);
|
||||
CADD_TYPE("log.Record", "Record", false);
|
||||
/* The macros log!/info!/warn!/error!/debug!/trace! are matched by
|
||||
* name in rust_lsp.c's macro handler — register them as void
|
||||
* synthetic functions so the resolver can attribute them. */
|
||||
CADD_FUNC(NULL, "info", "log.info", t_unit);
|
||||
CADD_FUNC(NULL, "warn", "log.warn", t_unit);
|
||||
CADD_FUNC(NULL, "error", "log.error", t_unit);
|
||||
CADD_FUNC(NULL, "debug", "log.debug", t_unit);
|
||||
CADD_FUNC(NULL, "trace", "log.trace", t_unit);
|
||||
CADD_FUNC(NULL, "log", "log.log", t_unit);
|
||||
CADD_FUNC(NULL, "set_logger","log.set_logger", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "set_max_level","log.set_max_level", t_unit);
|
||||
|
||||
/* ── futures — Future combinators + stream / sink. ────── */
|
||||
CADD_TYPE("futures.Future", "Future", true);
|
||||
CADD_TYPE("futures.Stream", "Stream", true);
|
||||
CADD_TYPE("futures.Sink", "Sink", true);
|
||||
CADD_TYPE("futures.StreamExt","StreamExt",true);
|
||||
CADD_TYPE("futures.FutureExt","FutureExt",true);
|
||||
CADD_TYPE("futures.SinkExt", "SinkExt", true);
|
||||
CADD_TYPE("futures.executor.LocalPool","LocalPool", false);
|
||||
|
||||
CADD_FUNC("futures.StreamExt", "next", "futures.StreamExt.next", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "map", "futures.StreamExt.map", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "filter", "futures.StreamExt.filter", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "filter_map", "futures.StreamExt.filter_map", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "for_each", "futures.StreamExt.for_each", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "collect", "futures.StreamExt.collect", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "fold", "futures.StreamExt.fold", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "take", "futures.StreamExt.take", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "skip", "futures.StreamExt.skip", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "chunks", "futures.StreamExt.chunks", cbm_type_unknown());
|
||||
CADD_FUNC("futures.StreamExt", "buffered", "futures.StreamExt.buffered", cbm_type_unknown());
|
||||
CADD_FUNC("futures.SinkExt", "send", "futures.SinkExt.send", cbm_type_unknown());
|
||||
CADD_FUNC("futures.SinkExt", "send_all", "futures.SinkExt.send_all", cbm_type_unknown());
|
||||
CADD_FUNC("futures.SinkExt", "flush", "futures.SinkExt.flush", cbm_type_unknown());
|
||||
CADD_FUNC("futures.SinkExt", "close", "futures.SinkExt.close", cbm_type_unknown());
|
||||
CADD_FUNC("futures.FutureExt", "boxed", "futures.FutureExt.boxed", cbm_type_unknown());
|
||||
CADD_FUNC("futures.FutureExt", "fuse", "futures.FutureExt.fuse", cbm_type_unknown());
|
||||
CADD_FUNC("futures.FutureExt", "shared", "futures.FutureExt.shared", cbm_type_unknown());
|
||||
|
||||
CADD_FUNC(NULL, "join_all", "futures.future.join_all", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "try_join_all", "futures.future.try_join_all", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "select", "futures.future.select", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "ready", "futures.future.ready", cbm_type_unknown());
|
||||
|
||||
/* ── parking_lot — drop-in std::sync alternatives. ────── */
|
||||
CADD_TYPE("parking_lot.Mutex", "Mutex", false);
|
||||
CADD_TYPE("parking_lot.RwLock", "RwLock", false);
|
||||
CADD_TYPE("parking_lot.MutexGuard", "MutexGuard", false);
|
||||
CADD_TYPE("parking_lot.RwLockReadGuard","RwLockReadGuard", false);
|
||||
CADD_TYPE("parking_lot.RwLockWriteGuard","RwLockWriteGuard", false);
|
||||
CADD_TYPE("parking_lot.Condvar", "Condvar", false);
|
||||
CADD_TYPE("parking_lot.Once", "Once", false);
|
||||
|
||||
CADD_FUNC("parking_lot.Mutex", "new", "parking_lot.Mutex.new", cbm_type_unknown());
|
||||
CADD_FUNC("parking_lot.Mutex", "lock", "parking_lot.Mutex.lock", cbm_type_unknown());
|
||||
CADD_FUNC("parking_lot.Mutex", "try_lock", "parking_lot.Mutex.try_lock", cbm_type_unknown());
|
||||
CADD_FUNC("parking_lot.RwLock", "new", "parking_lot.RwLock.new", cbm_type_unknown());
|
||||
CADD_FUNC("parking_lot.RwLock", "read", "parking_lot.RwLock.read", cbm_type_unknown());
|
||||
CADD_FUNC("parking_lot.RwLock", "write", "parking_lot.RwLock.write", cbm_type_unknown());
|
||||
|
||||
/* ── lazy_static / once_cell — singleton init. ────────── */
|
||||
CADD_TYPE("once_cell.sync.Lazy", "Lazy", false);
|
||||
CADD_TYPE("once_cell.sync.OnceCell","OnceCell", false);
|
||||
CADD_TYPE("once_cell.unsync.Lazy","Lazy", false);
|
||||
CADD_FUNC("once_cell.sync.Lazy","new","once_cell.sync.Lazy.new",cbm_type_unknown());
|
||||
CADD_FUNC("once_cell.sync.OnceCell","new","once_cell.sync.OnceCell.new",cbm_type_unknown());
|
||||
CADD_FUNC("once_cell.sync.OnceCell","get","once_cell.sync.OnceCell.get",cbm_type_unknown());
|
||||
CADD_FUNC("once_cell.sync.OnceCell","set","once_cell.sync.OnceCell.set",cbm_type_unknown());
|
||||
CADD_FUNC("once_cell.sync.OnceCell","get_or_init","once_cell.sync.OnceCell.get_or_init", cbm_type_unknown());
|
||||
|
||||
/* ── chrono — date/time. ────────────────────────────── */
|
||||
CADD_TYPE("chrono.DateTime", "DateTime", false);
|
||||
CADD_TYPE("chrono.NaiveDate", "NaiveDate", false);
|
||||
CADD_TYPE("chrono.NaiveTime", "NaiveTime", false);
|
||||
CADD_TYPE("chrono.NaiveDateTime","NaiveDateTime",false);
|
||||
CADD_TYPE("chrono.Duration", "Duration", false);
|
||||
CADD_TYPE("chrono.Utc", "Utc", false);
|
||||
CADD_TYPE("chrono.Local", "Local", false);
|
||||
|
||||
CADD_FUNC("chrono.DateTime", "now", "chrono.DateTime.now", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.DateTime", "format", "chrono.DateTime.format", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.DateTime", "timestamp", "chrono.DateTime.timestamp", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.DateTime", "to_rfc3339","chrono.DateTime.to_rfc3339",t_string);
|
||||
CADD_FUNC("chrono.Utc", "now", "chrono.Utc.now", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.Local", "now", "chrono.Local.now", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.Duration", "seconds", "chrono.Duration.seconds", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.Duration", "minutes", "chrono.Duration.minutes", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.Duration", "hours", "chrono.Duration.hours", cbm_type_unknown());
|
||||
CADD_FUNC("chrono.Duration", "days", "chrono.Duration.days", cbm_type_unknown());
|
||||
|
||||
/* ── uuid — IDs. ────────────────────────────────────── */
|
||||
CADD_TYPE("uuid.Uuid", "Uuid", false);
|
||||
CADD_FUNC("uuid.Uuid", "new_v4", "uuid.Uuid.new_v4", cbm_type_unknown());
|
||||
CADD_FUNC("uuid.Uuid", "nil", "uuid.Uuid.nil", cbm_type_unknown());
|
||||
CADD_FUNC("uuid.Uuid", "parse_str", "uuid.Uuid.parse_str", cbm_type_unknown());
|
||||
CADD_FUNC("uuid.Uuid", "to_string", "uuid.Uuid.to_string", t_string);
|
||||
CADD_FUNC("uuid.Uuid", "to_hyphenated","uuid.Uuid.to_hyphenated", cbm_type_unknown());
|
||||
CADD_FUNC("uuid.Uuid", "as_bytes", "uuid.Uuid.as_bytes", cbm_type_unknown());
|
||||
|
||||
/* ── reqwest — HTTP client. ──────────────────────────── */
|
||||
CADD_TYPE("reqwest.Client", "Client", false);
|
||||
CADD_TYPE("reqwest.RequestBuilder","RequestBuilder", false);
|
||||
CADD_TYPE("reqwest.Response", "Response", false);
|
||||
CADD_TYPE("reqwest.Error", "Error", false);
|
||||
CADD_TYPE("reqwest.Url", "Url", false);
|
||||
CADD_TYPE("reqwest.header.HeaderMap","HeaderMap", false);
|
||||
|
||||
CADD_FUNC("reqwest.Client", "new", "reqwest.Client.new", cbm_type_named(arena, "reqwest.Client"));
|
||||
CADD_FUNC("reqwest.Client", "builder", "reqwest.Client.builder", cbm_type_unknown());
|
||||
CADD_FUNC("reqwest.Client", "get", "reqwest.Client.get", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.Client", "post", "reqwest.Client.post", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.Client", "put", "reqwest.Client.put", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.Client", "delete", "reqwest.Client.delete", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.Client", "request", "reqwest.Client.request", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.RequestBuilder","header","reqwest.RequestBuilder.header", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.RequestBuilder","headers","reqwest.RequestBuilder.headers", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.RequestBuilder","body", "reqwest.RequestBuilder.body", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.RequestBuilder","json", "reqwest.RequestBuilder.json", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.RequestBuilder","form", "reqwest.RequestBuilder.form", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.RequestBuilder","query","reqwest.RequestBuilder.query", cbm_type_named(arena, "reqwest.RequestBuilder"));
|
||||
CADD_FUNC("reqwest.RequestBuilder","send", "reqwest.RequestBuilder.send", cbm_type_named(arena, "reqwest.Response"));
|
||||
CADD_FUNC("reqwest.Response","status", "reqwest.Response.status", cbm_type_unknown());
|
||||
CADD_FUNC("reqwest.Response","headers", "reqwest.Response.headers", cbm_type_unknown());
|
||||
CADD_FUNC("reqwest.Response","text", "reqwest.Response.text", cbm_type_unknown());
|
||||
CADD_FUNC("reqwest.Response","json", "reqwest.Response.json", cbm_type_unknown());
|
||||
CADD_FUNC("reqwest.Response","bytes", "reqwest.Response.bytes", cbm_type_unknown());
|
||||
CADD_FUNC("reqwest.Url", "parse", "reqwest.Url.parse", cbm_type_unknown());
|
||||
|
||||
/* ── rayon — parallel iteration. ────────────────────── */
|
||||
CADD_TYPE("rayon.iter.ParallelIterator","ParallelIterator", true);
|
||||
CADD_TYPE("rayon.iter.IntoParallelIterator","IntoParallelIterator", true);
|
||||
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","map", "rayon.iter.ParallelIterator.map", cbm_type_unknown());
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","filter", "rayon.iter.ParallelIterator.filter", cbm_type_unknown());
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","for_each", "rayon.iter.ParallelIterator.for_each", t_unit);
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","collect", "rayon.iter.ParallelIterator.collect", cbm_type_unknown());
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","reduce", "rayon.iter.ParallelIterator.reduce", cbm_type_unknown());
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","sum", "rayon.iter.ParallelIterator.sum", cbm_type_unknown());
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","count", "rayon.iter.ParallelIterator.count", t_usize);
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","any", "rayon.iter.ParallelIterator.any", t_bool);
|
||||
CADD_FUNC("rayon.iter.ParallelIterator","all", "rayon.iter.ParallelIterator.all", t_bool);
|
||||
CADD_FUNC("rayon.iter.IntoParallelIterator","into_par_iter","rayon.iter.IntoParallelIterator.into_par_iter", cbm_type_unknown());
|
||||
|
||||
CADD_FUNC(NULL, "scope", "rayon.scope", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "par_iter", "rayon.par_iter", cbm_type_unknown());
|
||||
CADD_FUNC(NULL, "spawn", "rayon.spawn", t_unit);
|
||||
CADD_FUNC(NULL, "join", "rayon.join", cbm_type_unknown());
|
||||
|
||||
/* ── async-trait / async_trait — typically derive-only. ──
|
||||
* Calls to trait methods are resolved through the normal trait
|
||||
* dispatch since async_trait emits real Rust impl blocks. No
|
||||
* extra registration needed. */
|
||||
(void)t_str_ref;
|
||||
}
|
||||
|
||||
#endif /* RUST_CRATES_SEED_INCLUDED */
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user