Mercurial > vim
comparison src/vim9class.c @ 33227:3672d3d13524 v9.0.1888
patch 9.0.1888: Vim9: Problem trying to invoke class method
Commit: https://github.com/vim/vim/commit/342f4f626ed56921b1ef145ccaa05ba0a4b8ac01
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Sep 9 11:37:23 2023 +0200
patch 9.0.1888: Vim9: Problem trying to invoke class method
Problem: Vim9: Problem trying to invoke class method
Solution: Lookup the class method insider other classes
closes: #13055
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 09 Sep 2023 11:45:08 +0200 |
parents | 52b121d4feb5 |
children | 108d890d887f |
comparison
equal
deleted
inserted
replaced
33226:b57f476a1c72 | 33227:3672d3d13524 |
---|---|
2089 } | 2089 } |
2090 return -1; | 2090 return -1; |
2091 } | 2091 } |
2092 | 2092 |
2093 /* | 2093 /* |
2094 * If "name[len]" is a class method in cctx->ctx_ufunc->uf_class return the | |
2095 * index in class.class_class_functions[]. | |
2096 * If "cl_ret" is not NULL set it to the class. | |
2097 * Otherwise return -1. | |
2098 */ | |
2099 int | |
2100 class_method_index(char_u *name, size_t len, class_T **cl_ret, cctx_T *cctx) | |
2101 { | |
2102 if (cctx == NULL || cctx->ctx_ufunc == NULL | |
2103 || cctx->ctx_ufunc->uf_class == NULL) | |
2104 return -1; | |
2105 class_T *cl = cctx->ctx_ufunc->uf_class; | |
2106 | |
2107 for (int i = 0; i < cl->class_class_function_count; ++i) | |
2108 { | |
2109 ufunc_T *fp = cl->class_class_functions[i]; | |
2110 if (STRNCMP(name, fp->uf_name, len) == 0 && fp->uf_name[len] == NUL) | |
2111 { | |
2112 if (cl_ret != NULL) | |
2113 *cl_ret = cl; | |
2114 return i; | |
2115 } | |
2116 } | |
2117 return -1; | |
2118 } | |
2119 | |
2120 /* | |
2094 * Return TRUE if current context "cctx_arg" is inside class "cl". | 2121 * Return TRUE if current context "cctx_arg" is inside class "cl". |
2095 * Return FALSE if not. | 2122 * Return FALSE if not. |
2096 */ | 2123 */ |
2097 int | 2124 int |
2098 inside_class(cctx_T *cctx_arg, class_T *cl) | 2125 inside_class(cctx_T *cctx_arg, class_T *cl) |