mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
patch 9.0.1188: return value of type() for class and object unclear
Problem: Return value of type() for class and object unclear. Solution: Add v:t_object and v:t_class.
This commit is contained in:
@ -9947,6 +9947,8 @@ type({expr}) The result is a Number representing the type of {expr}.
|
||||
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("")
|
||||
|
@ -2504,6 +2504,10 @@ v:t_number Value of |Number| type. Read-only. See: |type()|
|
||||
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|
|
||||
|
@ -139,6 +139,8 @@ static struct vimvar
|
||||
{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,6 +257,8 @@ evalvars_init(void)
|
||||
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);
|
||||
|
||||
|
@ -155,6 +155,11 @@ def Test_class_basic()
|
||||
|
||||
# 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<TextPosition>', typename(TextPosition))
|
||||
assert_equal('object<TextPosition>', typename(pos))
|
||||
END
|
||||
v9.CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1188,
|
||||
/**/
|
||||
1187,
|
||||
/**/
|
||||
|
36
src/vim.h
36
src/vim.h
@ -2083,23 +2083,25 @@ typedef int sock_T;
|
||||
#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
|
||||
#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
|
||||
|
Reference in New Issue
Block a user