From 03aec70287714fb9d66864e6db0d9e6375c18362 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 14 Feb 2022 17:31:55 +0000 Subject: Change objc_class_name to objc_name with objc_is_class_method --- src/check_decl.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 1d30088d6..45d741532 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -826,15 +826,13 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { } e->Procedure.optimization_mode = cast(ProcedureOptimizationMode)ac.optimization_mode; - if (ac.objc_name.len || ac.objc_class_name.len || ac.objc_type) { - if (ac.objc_class_name.len && ac.objc_name.len) { - error(e->token, "@(objc_class_name) and @(objc_name) may not be allowed at the same time"); + if (ac.objc_name.len || ac.objc_is_class_method || ac.objc_type) { + if (ac.objc_name.len == 0 && ac.objc_is_class_method) { + error(e->token, "@(objc_name) is required with @(objc_is_class_method)"); } else if (ac.objc_type == nullptr) { - if (ac.objc_name.len) { - error(e->token, "@(objc_name) requires that @(objc_type) to be set"); - } else { - error(e->token, "@(objc_class_name) requires that @(objc_type) to be set"); - } + error(e->token, "@(objc_name) requires that @(objc_type) to be set"); + } else if (ac.objc_name.len == 0 && ac.objc_type) { + error(e->token, "@(objc_name) is required with @(objc_type)"); } else { Type *t = ac.objc_type; if (t->kind == Type_Named) { @@ -843,7 +841,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { GB_ASSERT(tn->kind == Entity_TypeName); if (tn->scope != e->scope) { - error(e->token, "@(objc_name) and @(objc_class_name) attributes may only be applied to procedures and types within the same scope"); + error(e->token, "@(objc_name) attribute may only be applied to procedures and types within the same scope"); } else { mutex_lock(&global_type_name_objc_metadata_mutex); defer (mutex_unlock(&global_type_name_objc_metadata_mutex)); @@ -855,7 +853,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { mutex_lock(md->mutex); defer (mutex_unlock(md->mutex)); - if (ac.objc_name.len) { + if (!ac.objc_is_class_method) { bool ok = true; for (TypeNameObjCMetadataEntry const &entry : md->value_entries) { if (entry.name == ac.objc_name) { @@ -870,14 +868,14 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) { } else { bool ok = true; for (TypeNameObjCMetadataEntry const &entry : md->type_entries) { - if (entry.name == ac.objc_class_name) { - error(e->token, "Previous declaration of @(objc_class_name=\"%.*s\")", LIT(ac.objc_class_name)); + if (entry.name == ac.objc_name) { + error(e->token, "Previous declaration of @(objc_name=\"%.*s\")", LIT(ac.objc_name)); ok = false; break; } } if (ok) { - array_add(&md->type_entries, TypeNameObjCMetadataEntry{ac.objc_class_name, e}); + array_add(&md->type_entries, TypeNameObjCMetadataEntry{ac.objc_name, e}); } } } -- cgit v1.2.3