patch 9.0.1041: cannot define a method in a class
Problem: Cannot define a method in a class.
Solution: Implement defining an object method. Make calling an object
method work.
diff --git a/src/structs.h b/src/structs.h
index 09b0743..1395a20 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1478,15 +1478,16 @@
int class_obj_method_count;
ufunc_T **class_obj_methods; // allocated
- ufunc_T *class_new_func; // new() function that was created
garray_T class_type_list; // used for type pointers
type_T class_type;
+ type_T class_object_type; // same as class_type but VAR_OBJECT
};
// Used for v_object of typval of VAR_OBJECT.
// The member variables follow in an array of typval_T.
-struct object_S {
+struct object_S
+{
class_T *obj_class; // class this object is created for;
// pointer adds to class_refcount
int obj_refcount;
@@ -2123,6 +2124,7 @@
int fe_evaluate; // actually evaluate expressions
partial_T *fe_partial; // for extra arguments
dict_T *fe_selfdict; // Dictionary for "self"
+ object_T *fe_object; // object, e.g. for "this.Func()"
typval_T *fe_basetv; // base for base->method()
type_T *fe_check_type; // type from funcref or NULL
int fe_found_var; // if the function is not found then give an