To: vim_dev@googlegroups.com Subject: Patch 9.0.1188 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1188 Problem: Return value of type() for class and object unclear. Solution: Add v:t_object and v:t_class. Files: runtime/doc/builtin.txt, runtime/doc/eval.txt, src/evalvars.c, src/vim.h, src/testdir/test_vim9_class.vim *** ../vim-9.0.1187/runtime/doc/builtin.txt 2022-12-20 20:01:09.620090910 +0000 --- runtime/doc/builtin.txt 2023-01-12 21:01:44.772871744 +0000 *************** *** 9099,9104 **** --- 9113,9120 ---- Blob 0z00112233.44556677.8899 List [item, item] Dictionary {key: value, key: value} + Class class SomeName + Object object of SomeName {lnum: 1, col: 3} When a |List| or |Dictionary| has a recursive reference it is replaced by "[...]" or "{...}". Using eval() on the result *************** *** 9931,9936 **** --- 9947,9954 ---- Job: 8 |v:t_job| Channel: 9 |v:t_channel| Blob: 10 |v:t_blob| + Class 12 |v:t_class| + Object 13 |v:t_object| For backward compatibility, this method can be used: > :if type(myvar) == type(0) :if type(myvar) == type("") *** ../vim-9.0.1187/runtime/doc/eval.txt 2022-10-11 21:51:09.958103576 +0100 --- runtime/doc/eval.txt 2023-01-12 20:52:51.940746877 +0000 *************** *** 2498,2503 **** --- 2504,2513 ---- v:t_string Value of |String| type. Read-only. See: |type()| *v:t_blob* *t_blob-variable* v:t_blob Value of |Blob| type. Read-only. See: |type()| + *v:t_class* *t_class-variable* + v:t_class Value of |class| type. Read-only. See: |type()| + *v:t_object* *t_object-variable* + v:t_object Value of |object| type. Read-only. See: |type()| *v:termresponse* *termresponse-variable* v:termresponse The escape sequence returned by the terminal for the |t_RV| *** ../vim-9.0.1187/src/evalvars.c 2023-01-12 20:04:47.352343705 +0000 --- src/evalvars.c 2023-01-12 20:55:57.640806157 +0000 *************** *** 139,144 **** --- 139,146 ---- {VV_NAME("t_job", VAR_NUMBER), NULL, VV_RO}, {VV_NAME("t_channel", VAR_NUMBER), NULL, VV_RO}, {VV_NAME("t_blob", VAR_NUMBER), NULL, VV_RO}, + {VV_NAME("t_class", VAR_NUMBER), NULL, VV_RO}, + {VV_NAME("t_object", VAR_NUMBER), NULL, VV_RO}, {VV_NAME("termrfgresp", VAR_STRING), NULL, VV_RO}, {VV_NAME("termrbgresp", VAR_STRING), NULL, VV_RO}, {VV_NAME("termu7resp", VAR_STRING), NULL, VV_RO}, *************** *** 255,260 **** --- 257,264 ---- set_vim_var_nr(VV_TYPE_JOB, VAR_TYPE_JOB); set_vim_var_nr(VV_TYPE_CHANNEL, VAR_TYPE_CHANNEL); set_vim_var_nr(VV_TYPE_BLOB, VAR_TYPE_BLOB); + set_vim_var_nr(VV_TYPE_CLASS, VAR_TYPE_CLASS); + set_vim_var_nr(VV_TYPE_OBJECT, VAR_TYPE_OBJECT); set_vim_var_nr(VV_ECHOSPACE, sc_col - 1); *** ../vim-9.0.1187/src/vim.h 2023-01-05 19:59:14.003418087 +0000 --- src/vim.h 2023-01-12 20:55:09.504792868 +0000 *************** *** 2083,2105 **** #define VV_TYPE_JOB 85 #define VV_TYPE_CHANNEL 86 #define VV_TYPE_BLOB 87 ! #define VV_TERMRFGRESP 88 ! #define VV_TERMRBGRESP 89 ! #define VV_TERMU7RESP 90 ! #define VV_TERMSTYLERESP 91 ! #define VV_TERMBLINKRESP 92 ! #define VV_EVENT 93 ! #define VV_VERSIONLONG 94 ! #define VV_ECHOSPACE 95 ! #define VV_ARGV 96 ! #define VV_COLLATE 97 ! #define VV_EXITING 98 ! #define VV_COLORNAMES 99 ! #define VV_SIZEOFINT 100 ! #define VV_SIZEOFLONG 101 ! #define VV_SIZEOFPOINTER 102 ! #define VV_MAXCOL 103 ! #define VV_LEN 104 // number of v: vars // used for v_number in VAR_BOOL and VAR_SPECIAL #define VVAL_FALSE 0L // VAR_BOOL --- 2083,2107 ---- #define VV_TYPE_JOB 85 #define VV_TYPE_CHANNEL 86 #define VV_TYPE_BLOB 87 ! #define VV_TYPE_CLASS 88 ! #define VV_TYPE_OBJECT 89 ! #define VV_TERMRFGRESP 90 ! #define VV_TERMRBGRESP 91 ! #define VV_TERMU7RESP 92 ! #define VV_TERMSTYLERESP 93 ! #define VV_TERMBLINKRESP 94 ! #define VV_EVENT 95 ! #define VV_VERSIONLONG 96 ! #define VV_ECHOSPACE 97 ! #define VV_ARGV 98 ! #define VV_COLLATE 99 ! #define VV_EXITING 100 ! #define VV_COLORNAMES 101 ! #define VV_SIZEOFINT 102 ! #define VV_SIZEOFLONG 103 ! #define VV_SIZEOFPOINTER 104 ! #define VV_MAXCOL 105 ! #define VV_LEN 106 // number of v: vars // used for v_number in VAR_BOOL and VAR_SPECIAL #define VVAL_FALSE 0L // VAR_BOOL *** ../vim-9.0.1187/src/testdir/test_vim9_class.vim 2023-01-12 20:04:47.352343705 +0000 --- src/testdir/test_vim9_class.vim 2023-01-12 20:58:26.016839949 +0000 *************** *** 155,160 **** --- 155,165 ---- # call an object method assert_equal('(2, 12)', pos.ToString()) + + assert_equal(v:t_class, type(TextPosition)) + assert_equal(v:t_object, type(pos)) + assert_equal('class', typename(TextPosition)) + assert_equal('object', typename(pos)) END v9.CheckScriptSuccess(lines) enddef *** ../vim-9.0.1187/src/version.c 2023-01-12 20:39:05.868616570 +0000 --- src/version.c 2023-01-12 21:03:53.256886278 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1188, /**/ -- A consultant is a person who takes your money and annoys your employees while tirelessly searching for the best way to extend the consulting contract. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///