mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
make methods showing up only in the implementation work when overiding an
inherited method
This commit is contained in:
parent
24f4bcfebf
commit
1b5bf9d176
3 changed files with 45 additions and 10 deletions
|
@ -65,6 +65,7 @@ struct dstring_s;
|
|||
|
||||
method_t *new_method (struct type_s *ret_type, param_t *selector,
|
||||
param_t *opt_parms);
|
||||
method_t *copy_method (method_t *method);
|
||||
void add_method (methodlist_t *methodlist, method_t *method);
|
||||
struct def_s *method_def (struct class_type_s *class_type, method_t *method);
|
||||
|
||||
|
|
|
@ -390,26 +390,44 @@ class_ivar_expr (class_type_t *class_type, const char *name)
|
|||
method_t *
|
||||
class_find_method (class_type_t *class_type, method_t *method)
|
||||
{
|
||||
methodlist_t *methods;
|
||||
methodlist_t *methods, *start_methods;;
|
||||
method_t *m;
|
||||
dstring_t *sel;
|
||||
class_t *class, *start_class;
|
||||
const char *class_name;
|
||||
const char *category_name = 0;
|
||||
|
||||
if (!class_type->is_class) {
|
||||
methods = class_type->c.category->methods;
|
||||
category_name = class_type->c.category->name;
|
||||
class_name = class_type->c.category->class->name;
|
||||
class = class_type->c.category->class;
|
||||
} else {
|
||||
methods = class_type->c.class->methods;
|
||||
class_name = class_type->c.class->name;
|
||||
class = class_type->c.class;
|
||||
methods = class->methods;
|
||||
}
|
||||
class_name = class->name;
|
||||
start_methods = methods;
|
||||
start_class = class;
|
||||
while (class) {
|
||||
for (m = methods->head; m; m = m->next)
|
||||
if (method_compare (method, m)) {
|
||||
if (m->type != method->type)
|
||||
error (0, "method type mismatch");
|
||||
if (methods != start_methods) {
|
||||
m = copy_method (m);
|
||||
if (m->instance)
|
||||
m->params->type = start_class->type;
|
||||
else
|
||||
m->params->type = &type_Class;
|
||||
add_method (methods, m);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
if (class->methods == methods)
|
||||
class = class->super_class;
|
||||
else
|
||||
methods = class->methods;
|
||||
}
|
||||
for (m = methods->head; m; m = m->next)
|
||||
if (method_compare (method, m)) {
|
||||
if (m->type != method->type)
|
||||
error (0, "method type mismatch");
|
||||
return m;
|
||||
}
|
||||
sel = dstring_newstr ();
|
||||
selector_name (sel, (keywordarg_t *)method->selector);
|
||||
if (options.warnings.interface_check) {
|
||||
|
|
|
@ -115,6 +115,22 @@ new_method (type_t *ret_type, param_t *selector, param_t *opt_parms)
|
|||
return meth;
|
||||
}
|
||||
|
||||
method_t *
|
||||
copy_method (method_t *method)
|
||||
{
|
||||
method_t *meth = calloc (sizeof (method_t), 1);
|
||||
param_t *self = copy_params (method->params);
|
||||
|
||||
meth->next = 0;
|
||||
meth->instance = method->instance;
|
||||
meth->selector = self->next->next;
|
||||
meth->params = self;
|
||||
meth->type = parse_params (method->type->aux_type, meth->params);
|
||||
meth->name = method->name;
|
||||
meth->types = method->types;
|
||||
return meth;
|
||||
}
|
||||
|
||||
void
|
||||
add_method (methodlist_t *methodlist, method_t *method)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue