patch 9.0.1074: class members are not supported yet
Problem: Class members are not supported yet.
Solution: Add initial support for class members.
diff --git a/src/structs.h b/src/structs.h
index 2f9a782..f4bd386 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1387,6 +1387,7 @@
typedef double float_T;
+typedef struct typval_S typval_T;
typedef struct listvar_S list_T;
typedef struct dictvar_S dict_T;
typedef struct partial_S partial_T;
@@ -1466,14 +1467,14 @@
} omacc_T;
/*
- * Entry for an object member variable.
+ * Entry for an object or class member variable.
*/
typedef struct {
- char_u *om_name; // allocated
- omacc_T om_access;
- type_T *om_type;
- char_u *om_init; // allocated
-} objmember_T;
+ char_u *ocm_name; // allocated
+ omacc_T ocm_access;
+ type_T *ocm_type;
+ char_u *ocm_init; // allocated
+} ocmember_T;
// "class_T": used for v_class of typval of VAR_CLASS
struct class_S
@@ -1481,14 +1482,25 @@
char_u *class_name; // allocated
int class_refcount;
- int class_obj_member_count;
- objmember_T *class_obj_members; // allocated
+ // class members: "static varname"
+ int class_class_member_count;
+ ocmember_T *class_class_members; // allocated
+ typval_T *class_members_tv; // allocated array of class member vals
+ // class methods: "static def SomeMethod()"
+ int class_class_method_count;
+ ufunc_T **class_class_methods; // allocated
+
+ // object members: "this.varname"
+ int class_obj_member_count;
+ ocmember_T *class_obj_members; // allocated
+
+ // object methods: "def SomeMethod()"
int class_obj_method_count;
ufunc_T **class_obj_methods; // allocated
garray_T class_type_list; // used for type pointers
- type_T class_type;
+ type_T class_type; // type used for the class
type_T class_object_type; // same as class_type but VAR_OBJECT
};
@@ -1513,7 +1525,7 @@
/*
* Structure to hold an internal variable without a name.
*/
-typedef struct
+struct typval_S
{
vartype_T v_type;
char v_lock; // see below: VAR_LOCKED, VAR_FIXED
@@ -1534,7 +1546,7 @@
class_T *v_class; // class value (can be NULL)
object_T *v_object; // object value (can be NULL)
} vval;
-} typval_T;
+};
// Values for "dv_scope".
#define VAR_SCOPE 1 // a:, v:, s:, etc. scope dictionaries