Make S_html_create_fresh_methods a little safer Make sure that S_html_create_fresh_methods operates on the method returned by the documented class, not the one of a superclass.
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/719d2298 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/719d2298 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/719d2298 Branch: refs/heads/markdown_v2 Commit: 719d2298f7c74aff080b764370764c4671e8a6d4 Parents: a761adc Author: Nick Wellnhofer <[email protected]> Authored: Wed Dec 3 19:44:14 2014 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Wed Dec 3 19:44:14 2014 +0100 ---------------------------------------------------------------------- compiler/src/CFCCHtml.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/719d2298/compiler/src/CFCCHtml.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCHtml.c b/compiler/src/CFCCHtml.c index 76b8109..c3c701c 100644 --- a/compiler/src/CFCCHtml.c +++ b/compiler/src/CFCCHtml.c @@ -134,7 +134,7 @@ static char* S_html_create_methods(CFCClass *klass); static char* -S_html_create_fresh_methods(CFCClass *klass, CFCClass *invoker); +S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor); static char* S_html_create_func(CFCClass *klass, CFCFunction *func, const char *prefix, @@ -524,7 +524,7 @@ S_html_create_methods(CFCClass *klass) { break; } - char *novel_html = S_html_create_fresh_methods(ancestor, klass); + char *novel_html = S_html_create_fresh_methods(klass, ancestor); if (novel_html[0] != '\0') { if (ancestor == klass) { methods_html = CFCUtil_cat(methods_html, novel_html, NULL); @@ -549,24 +549,24 @@ S_html_create_methods(CFCClass *klass) { return result; } +/** Return HTML for the fresh methods of `ancestor`. + */ static char* -S_html_create_fresh_methods(CFCClass *klass, CFCClass *invoker) { - CFCMethod **fresh_methods = CFCClass_fresh_methods(klass); - const char *class_name = CFCClass_get_class_name(klass); +S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) { + CFCMethod **fresh_methods = CFCClass_fresh_methods(ancestor); + const char *ancestor_name = CFCClass_get_class_name(ancestor); char *result = CFCUtil_strdup(""); for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) { - CFCMethod *method = fresh_methods[meth_num]; - if (!CFCMethod_public(method)) { + CFCMethod *ancestor_method = fresh_methods[meth_num]; + if (!CFCMethod_public(ancestor_method)) { continue; } - const char *macro_sym = CFCMethod_get_macro_sym(method); - CFCMethod *maybe_overridden_method - = CFCClass_method(invoker, macro_sym); - const char *maybe_overridden_class_name - = CFCMethod_get_class_name(maybe_overridden_method); - if (strcmp(maybe_overridden_class_name, class_name) != 0) { + const char *macro_sym = CFCMethod_get_macro_sym(ancestor_method); + CFCMethod *method = CFCClass_method(klass, macro_sym); + const char *class_name = CFCMethod_get_class_name(method); + if (strcmp(class_name, ancestor_name) != 0) { // Overridden by a subclass. continue; } @@ -577,7 +577,7 @@ S_html_create_fresh_methods(CFCClass *klass, CFCClass *invoker) { CFCParcel *parcel = CFCSymbol_get_parcel((CFCSymbol*)method); const char *prefix = CFCParcel_get_PREFIX(parcel); - char *short_sym = CFCMethod_short_method_sym(method, invoker); + char *short_sym = CFCMethod_short_method_sym(method, klass); const char *attrs = NULL; if (CFCMethod_abstract(method)) {
