Fix to allow procedure groups on objective-c types

This commit is contained in:
gingerBill
2023-07-17 12:43:56 +01:00
parent dcf3023d93
commit 921530dd01
6 changed files with 233 additions and 126 deletions
+48
View File
@@ -2935,6 +2935,54 @@ gb_internal DECL_ATTRIBUTE_PROC(foreign_block_decl_attribute) {
return false;
}
gb_internal DECL_ATTRIBUTE_PROC(proc_group_attribute) {
if (name == ATTRIBUTE_USER_TAG_NAME) {
ExactValue ev = check_decl_attribute_value(c, value);
if (ev.kind != ExactValue_String) {
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "objc_name") {
ExactValue ev = check_decl_attribute_value(c, value);
if (ev.kind == ExactValue_String) {
if (string_is_valid_identifier(ev.value_string)) {
ac->objc_name = ev.value_string;
} else {
error(elem, "Invalid identifier for '%.*s', got '%.*s'", LIT(name), LIT(ev.value_string));
}
} else {
error(elem, "Expected a string value for '%.*s'", LIT(name));
}
return true;
} else if (name == "objc_is_class_method") {
ExactValue ev = check_decl_attribute_value(c, value);
if (ev.kind == ExactValue_Bool) {
ac->objc_is_class_method = ev.value_bool;
} else {
error(elem, "Expected a boolean value for '%.*s'", LIT(name));
}
return true;
} else if (name == "objc_type") {
if (value == nullptr) {
error(elem, "Expected a type for '%.*s'", LIT(name));
} else {
Type *objc_type = check_type(c, value);
if (objc_type != nullptr) {
if (!has_type_got_objc_class_attribute(objc_type)) {
gbString t = type_to_string(objc_type);
error(value, "'%.*s' expected a named type with the attribute @(obj_class=<string>), got type %s", LIT(name), t);
gb_string_free(t);
} else {
ac->objc_type = objc_type;
}
}
}
return true;
}
return false;
}
gb_internal DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
if (name == ATTRIBUTE_USER_TAG_NAME) {
ExactValue ev = check_decl_attribute_value(c, value);