patch 9.1.0148: Vim9: can't call internal methods with objects
Problem: Vim9: can't call internal methods with objects
Solution: Add support for empty(), len() and string() function
calls for objects (Yegappan Lakshmanan)
closes: #14129
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/structs.h b/src/structs.h
index df2c005..2c6f553 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1531,6 +1531,17 @@
#define OCMFLAG_CONST 0x04 // "const" object/class member
/*
+ * Object methods called by builtin functions (e.g. string(), empty(), etc.)
+ */
+typedef enum {
+ CLASS_BUILTIN_INVALID,
+ CLASS_BUILTIN_STRING,
+ CLASS_BUILTIN_EMPTY,
+ CLASS_BUILTIN_LEN,
+ CLASS_BUILTIN_MAX
+} class_builtin_T;
+
+/*
* Entry for an object or class member variable.
*/
typedef struct {
@@ -1593,6 +1604,9 @@
int class_obj_method_count_child; // count without "extends"
ufunc_T **class_obj_methods; // allocated
+ // index of builtin methods
+ int class_builtin_methods[CLASS_BUILTIN_MAX];
+
garray_T class_type_list; // used for type pointers
type_T class_type; // type used for the class
type_T class_object_type; // same as class_type but VAR_OBJECT