Use an explicit flag for class initialization.

Much cleaner than messing with class_Class, which is about to go away.
This commit is contained in:
Bill Currie 2012-11-08 16:46:48 +09:00
parent 7e293a38e8
commit 377f8f9d56
4 changed files with 8 additions and 2 deletions

View file

@ -103,6 +103,8 @@ extern class_t class_Protocol;
extern class_type_t *current_class;
extern int obj_initialized;
struct expr_s;
struct method_s;
struct protocol_s;

View file

@ -94,6 +94,8 @@ class_t class_object = {1, "id"};
class_t class_Class = {1, "Class"};
class_t class_Protocol = {1, "Protocol"};
int obj_initialized = 0;
static struct_def_t sel_struct[] = {
{"sel_id", &type_string},
{"sel_types", &type_string},
@ -289,6 +291,7 @@ class_init (void)
class_init_obj_module ();
init_classes ();
init_objective_structs ();
obj_initialized = 1;
}
symbol_t *
@ -1356,6 +1359,7 @@ clear_classes (void)
Hash_FlushTable (protocol_hash);
if (category_hash)
Hash_FlushTable (category_hash);
obj_initialized = 0;
if (class_hash)
class_Class.super_class = get_class (new_symbol ("Object"), 1);
}

View file

@ -1096,7 +1096,7 @@ check_defs (void)
int flags;
defref_t *this_ref;
if (!class_Class.super_class)
if (!obj_initialized)
class_init ();
flags = QFOD_GLOBAL | QFOD_NOSAVE;
this_ref = make_def (qfo_entity_space, name, &type_id, flags, 0);

View file

@ -348,7 +348,7 @@ keyword_or_id (char *token)
}
keyword = Hash_Find (keyword_tab, token);
if (keyword) {
if (!options.traditional && keyword->objc && !class_Class.super_class)
if (!options.traditional && keyword->objc && !obj_initialized)
class_init ();
if (keyword->value) {
if (keyword->value == STRUCT) {