0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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>
This commit is contained in:
Yegappan Lakshmanan
2023-09-09 11:37:23 +02:00
committed by Christian Brabandt
parent 23c92d93c1
commit 342f4f626e
5 changed files with 106 additions and 2 deletions

View File

@@ -2090,6 +2090,33 @@ class_member_index(char_u *name, size_t len, class_T **cl_ret, cctx_T *cctx)
return -1;
}
/*
* If "name[len]" is a class method in cctx->ctx_ufunc->uf_class return the
* index in class.class_class_functions[].
* If "cl_ret" is not NULL set it to the class.
* Otherwise return -1.
*/
int
class_method_index(char_u *name, size_t len, class_T **cl_ret, cctx_T *cctx)
{
if (cctx == NULL || cctx->ctx_ufunc == NULL
|| cctx->ctx_ufunc->uf_class == NULL)
return -1;
class_T *cl = cctx->ctx_ufunc->uf_class;
for (int i = 0; i < cl->class_class_function_count; ++i)
{
ufunc_T *fp = cl->class_class_functions[i];
if (STRNCMP(name, fp->uf_name, len) == 0 && fp->uf_name[len] == NUL)
{
if (cl_ret != NULL)
*cl_ret = cl;
return i;
}
}
return -1;
}
/*
* Return TRUE if current context "cctx_arg" is inside class "cl".
* Return FALSE if not.