mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-26 07:25:00 -07:00
Prevent multiple uses of the same Objective-C class name
This commit is contained in:
@@ -223,9 +223,9 @@ gb_internal void add_objc_proc_type(CheckerContext *c, Ast *call, Type *return_t
|
||||
data.kind = kind;
|
||||
data.proc_type = alloc_type_proc(scope, params, param_types.count, results, results->Tuple.variables.count, false, ProcCC_CDecl);
|
||||
|
||||
mutex_lock(&c->info->objc_types_mutex);
|
||||
mutex_lock(&c->info->objc_objc_msgSend_mutex);
|
||||
map_set(&c->info->objc_msgSend_types, call, data);
|
||||
mutex_unlock(&c->info->objc_types_mutex);
|
||||
mutex_unlock(&c->info->objc_objc_msgSend_mutex);
|
||||
|
||||
try_to_add_package_dependency(c, "runtime", "objc_msgSend");
|
||||
try_to_add_package_dependency(c, "runtime", "objc_msgSend_fpret");
|
||||
|
||||
@@ -524,7 +524,16 @@ gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr,
|
||||
if (decl != nullptr) {
|
||||
AttributeContext ac = {};
|
||||
check_decl_attributes(ctx, decl->attributes, type_decl_attribute, &ac);
|
||||
|
||||
if (e->kind == Entity_TypeName && ac.objc_class != "") {
|
||||
|
||||
mutex_lock(&ctx->info->objc_class_name_mutex);
|
||||
bool class_exists = string_set_update(&ctx->info->obcj_class_name_set, ac.objc_class);
|
||||
mutex_unlock(&ctx->info->objc_class_name_mutex);
|
||||
if (class_exists) {
|
||||
error(e->token, "@(objc_class) '%s' has already been used elsewhere", ac.objc_class);
|
||||
}
|
||||
|
||||
e->TypeName.objc_class_name = ac.objc_class;
|
||||
|
||||
if (ac.objc_is_implementation) {
|
||||
|
||||
@@ -1390,6 +1390,7 @@ gb_internal void init_checker_info(CheckerInfo *i) {
|
||||
|
||||
map_init(&i->objc_msgSend_types);
|
||||
mpsc_init(&i->objc_class_implementations, a);
|
||||
string_set_init(&i->obcj_class_name_set, 0);
|
||||
map_init(&i->objc_method_implementations);
|
||||
|
||||
string_map_init(&i->load_file_cache);
|
||||
|
||||
+3
-1
@@ -487,9 +487,11 @@ struct CheckerInfo {
|
||||
|
||||
MPSCQueue<Ast *> intrinsics_entry_point_usage;
|
||||
|
||||
BlockingMutex objc_types_mutex;
|
||||
BlockingMutex objc_objc_msgSend_mutex;
|
||||
PtrMap<Ast *, ObjcMsgData> objc_msgSend_types;
|
||||
|
||||
BlockingMutex objc_class_name_mutex;
|
||||
StringSet obcj_class_name_set;
|
||||
MPSCQueue<Entity *> objc_class_implementations;
|
||||
|
||||
BlockingMutex objc_method_mutex;
|
||||
|
||||
Reference in New Issue
Block a user