Register a function item: figure out the receiver QN (if any), the * short name, and the return type. */
| 163 | /* Register a function item: figure out the receiver QN (if any), the |
| 164 | * short name, and the return type. */ |
| 165 | static bool register_function(CBMTypeRegistry* reg, CBMArena* arena, |
| 166 | const char* short_name, const char* full_qn, const char* receiver, |
| 167 | yyjson_val* function_obj, const char* crate_qn) { |
| 168 | if (!short_name || !full_qn) return false; |
| 169 | CBMRegisteredFunc rf; |
| 170 | memset(&rf, 0, sizeof(rf)); |
| 171 | rf.qualified_name = full_qn; |
| 172 | rf.short_name = short_name; |
| 173 | rf.receiver_type = receiver; |
| 174 | rf.min_params = -1; |
| 175 | |
| 176 | /* Return type — rustdoc's `function.decl.output` may be omitted |
| 177 | * (implicit unit). */ |
| 178 | const CBMType* ret = cbm_type_builtin(arena, "()"); |
| 179 | if (function_obj && yyjson_is_obj(function_obj)) { |
| 180 | yyjson_val* decl = yyjson_obj_get(function_obj, "decl"); |
| 181 | if (decl && yyjson_is_obj(decl)) { |
| 182 | yyjson_val* out = yyjson_obj_get(decl, "output"); |
| 183 | if (out && !yyjson_is_null(out)) { |
| 184 | ret = parse_rustdoc_type(out, arena, crate_qn); |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | const CBMType** ra = (const CBMType**)cbm_arena_alloc(arena, |
| 189 | 2 * sizeof(const CBMType*)); |
| 190 | ra[0] = ret; |
| 191 | ra[1] = NULL; |
| 192 | rf.signature = cbm_type_func(arena, NULL, NULL, ra); |
| 193 | cbm_registry_add_func(reg, rf); |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | int cbm_rust_rustdoc_ingest(CBMTypeRegistry* reg, CBMArena* arena, |
| 198 | const char* json, int json_len, const char* crate_qn) { |
no test coverage detected