Files
metabuilder/typthon/Python/config_common.h
johndoe6345789 0e707caa56 feat: Add Typthon
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:10:58 +00:00

37 lines
754 B
C

static inline int
_config_dict_get(TyObject *dict, const char *name, TyObject **p_item)
{
TyObject *item;
if (TyDict_GetItemStringRef(dict, name, &item) < 0) {
return -1;
}
if (item == NULL) {
// We do not set an exception.
return -1;
}
*p_item = item;
return 0;
}
static TyObject*
config_dict_get(TyObject *dict, const char *name)
{
TyObject *item;
if (_config_dict_get(dict, name, &item) < 0) {
if (!TyErr_Occurred()) {
TyErr_Format(TyExc_ValueError, "missing config key: %s", name);
}
return NULL;
}
return item;
}
static void
config_dict_invalid_type(const char *name)
{
TyErr_Format(TyExc_TypeError, "invalid config type: %s", name);
}