Mercurial > vim
comparison src/structs.h @ 16872:a836d122231a v8.1.1437
patch 8.1.1437: code to handle callbacks is duplicated
commit https://github.com/vim/vim/commit/3a97bb3f0f8bd118ae23f1c97e55d84ff42eef20
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 1 13:28:35 2019 +0200
patch 8.1.1437: code to handle callbacks is duplicated
Problem: Code to handle callbacks is duplicated.
Solution: Add callback_T and functions to deal with it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Jun 2019 13:30:07 +0200 |
parents | 19162ff4eacd |
children | 998603a243d7 |
comparison
equal
deleted
inserted
replaced
16871:e5dab34ded73 | 16872:a836d122231a |
---|---|
1235 typedef struct listvar_S list_T; | 1235 typedef struct listvar_S list_T; |
1236 typedef struct dictvar_S dict_T; | 1236 typedef struct dictvar_S dict_T; |
1237 typedef struct partial_S partial_T; | 1237 typedef struct partial_S partial_T; |
1238 typedef struct blobvar_S blob_T; | 1238 typedef struct blobvar_S blob_T; |
1239 | 1239 |
1240 // Struct that holds both a normal function name and a partial_T, as used for a | |
1241 // callback argument. | |
1242 // When used temporarily "cb_name" is not allocated. The refcounts to either | |
1243 // the function or the partial are incremented and need to be decremented | |
1244 // later with free_callback(). | |
1245 typedef struct { | |
1246 char_u *cb_name; | |
1247 partial_T *cb_partial; | |
1248 int cb_free_name; // cb_name was allocated | |
1249 } callback_T; | |
1250 | |
1240 typedef struct jobvar_S job_T; | 1251 typedef struct jobvar_S job_T; |
1241 typedef struct readq_S readq_T; | 1252 typedef struct readq_S readq_T; |
1242 typedef struct writeq_S writeq_T; | 1253 typedef struct writeq_S writeq_T; |
1243 typedef struct jsonq_S jsonq_T; | 1254 typedef struct jsonq_S jsonq_T; |
1244 typedef struct cbq_S cbq_T; | 1255 typedef struct cbq_S cbq_T; |
1564 #endif | 1575 #endif |
1565 #ifdef MSWIN | 1576 #ifdef MSWIN |
1566 char_u *jv_tty_type; // allocated | 1577 char_u *jv_tty_type; // allocated |
1567 #endif | 1578 #endif |
1568 int jv_exitval; | 1579 int jv_exitval; |
1569 char_u *jv_exit_cb; /* allocated */ | 1580 callback_T jv_exit_cb; |
1570 partial_T *jv_exit_partial; | |
1571 | 1581 |
1572 buf_T *jv_in_buf; /* buffer from "in-name" */ | 1582 buf_T *jv_in_buf; /* buffer from "in-name" */ |
1573 | 1583 |
1574 int jv_refcount; /* reference count */ | 1584 int jv_refcount; /* reference count */ |
1575 int jv_copyID; | 1585 int jv_copyID; |
1604 int jq_no_callback; /* TRUE when no callback was found */ | 1614 int jq_no_callback; /* TRUE when no callback was found */ |
1605 }; | 1615 }; |
1606 | 1616 |
1607 struct cbq_S | 1617 struct cbq_S |
1608 { | 1618 { |
1609 char_u *cq_callback; | 1619 callback_T cq_callback; |
1610 partial_T *cq_partial; | |
1611 int cq_seq_nr; | 1620 int cq_seq_nr; |
1612 cbq_T *cq_next; | 1621 cbq_T *cq_next; |
1613 cbq_T *cq_prev; | 1622 cbq_T *cq_prev; |
1614 }; | 1623 }; |
1615 | 1624 |
1687 * does not block, 1 simulate blocking */ | 1696 * does not block, 1 simulate blocking */ |
1688 int ch_nonblocking; /* write() is non-blocking */ | 1697 int ch_nonblocking; /* write() is non-blocking */ |
1689 writeq_T ch_writeque; /* header for write queue */ | 1698 writeq_T ch_writeque; /* header for write queue */ |
1690 | 1699 |
1691 cbq_T ch_cb_head; /* dummy node for per-request callbacks */ | 1700 cbq_T ch_cb_head; /* dummy node for per-request callbacks */ |
1692 char_u *ch_callback; /* call when a msg is not handled */ | 1701 callback_T ch_callback; /* call when a msg is not handled */ |
1693 partial_T *ch_partial; | |
1694 | 1702 |
1695 bufref_T ch_bufref; /* buffer to read from or write to */ | 1703 bufref_T ch_bufref; /* buffer to read from or write to */ |
1696 int ch_nomodifiable; /* TRUE when buffer can be 'nomodifiable' */ | 1704 int ch_nomodifiable; /* TRUE when buffer can be 'nomodifiable' */ |
1697 int ch_nomod_error; /* TRUE when e_modifiable was given */ | 1705 int ch_nomod_error; /* TRUE when e_modifiable was given */ |
1698 int ch_buf_append; /* write appended lines instead top-bot */ | 1706 int ch_buf_append; /* write appended lines instead top-bot */ |
1729 * closed */ | 1737 * closed */ |
1730 | 1738 |
1731 #ifdef MSWIN | 1739 #ifdef MSWIN |
1732 int ch_named_pipe; /* using named pipe instead of pty */ | 1740 int ch_named_pipe; /* using named pipe instead of pty */ |
1733 #endif | 1741 #endif |
1734 char_u *ch_callback; /* call when any msg is not handled */ | 1742 callback_T ch_callback; /* call when any msg is not handled */ |
1735 partial_T *ch_partial; | 1743 callback_T ch_close_cb; /* call when channel is closed */ |
1736 char_u *ch_close_cb; /* call when channel is closed */ | |
1737 partial_T *ch_close_partial; | |
1738 int ch_drop_never; | 1744 int ch_drop_never; |
1739 int ch_keep_open; /* do not close on read error */ | 1745 int ch_keep_open; /* do not close on read error */ |
1740 int ch_nonblock; | 1746 int ch_nonblock; |
1741 | 1747 |
1742 job_T *ch_job; // Job that uses this channel; this does not | 1748 job_T *ch_job; // Job that uses this channel; this does not |
1831 channel_T *jo_channel; | 1837 channel_T *jo_channel; |
1832 | 1838 |
1833 linenr_T jo_in_top; | 1839 linenr_T jo_in_top; |
1834 linenr_T jo_in_bot; | 1840 linenr_T jo_in_bot; |
1835 | 1841 |
1836 char_u *jo_callback; /* not allocated! */ | 1842 callback_T jo_callback; |
1837 partial_T *jo_partial; /* not referenced! */ | 1843 callback_T jo_out_cb; |
1838 char_u *jo_out_cb; /* not allocated! */ | 1844 callback_T jo_err_cb; |
1839 partial_T *jo_out_partial; /* not referenced! */ | 1845 callback_T jo_close_cb; |
1840 char_u *jo_err_cb; /* not allocated! */ | 1846 callback_T jo_exit_cb; |
1841 partial_T *jo_err_partial; /* not referenced! */ | |
1842 char_u *jo_close_cb; /* not allocated! */ | |
1843 partial_T *jo_close_partial; /* not referenced! */ | |
1844 char_u *jo_exit_cb; /* not allocated! */ | |
1845 partial_T *jo_exit_partial; /* not referenced! */ | |
1846 int jo_drop_never; | 1847 int jo_drop_never; |
1847 int jo_waittime; | 1848 int jo_waittime; |
1848 int jo_timeout; | 1849 int jo_timeout; |
1849 int jo_out_timeout; | 1850 int jo_out_timeout; |
1850 int jo_err_timeout; | 1851 int jo_err_timeout; |
1884 typedef struct listener_S listener_T; | 1885 typedef struct listener_S listener_T; |
1885 struct listener_S | 1886 struct listener_S |
1886 { | 1887 { |
1887 listener_T *lr_next; | 1888 listener_T *lr_next; |
1888 int lr_id; | 1889 int lr_id; |
1889 char_u *lr_callback; | 1890 callback_T lr_callback; |
1890 partial_T *lr_partial; | |
1891 }; | 1891 }; |
1892 #endif | 1892 #endif |
1893 | 1893 |
1894 /* structure used for explicit stack while garbage collecting hash tables */ | 1894 /* structure used for explicit stack while garbage collecting hash tables */ |
1895 typedef struct ht_stack_S | 1895 typedef struct ht_stack_S |
1948 { | 1948 { |
1949 long tr_id; | 1949 long tr_id; |
1950 #ifdef FEAT_TIMERS | 1950 #ifdef FEAT_TIMERS |
1951 timer_T *tr_next; | 1951 timer_T *tr_next; |
1952 timer_T *tr_prev; | 1952 timer_T *tr_prev; |
1953 proftime_T tr_due; /* when the callback is to be invoked */ | 1953 proftime_T tr_due; // when the callback is to be invoked |
1954 char tr_firing; /* when TRUE callback is being called */ | 1954 char tr_firing; // when TRUE callback is being called |
1955 char tr_paused; /* when TRUE callback is not invoked */ | 1955 char tr_paused; // when TRUE callback is not invoked |
1956 int tr_repeat; /* number of times to repeat, -1 forever */ | 1956 int tr_repeat; // number of times to repeat, -1 forever |
1957 long tr_interval; /* msec */ | 1957 long tr_interval; // msec |
1958 char_u *tr_callback; /* allocated */ | 1958 callback_T tr_callback; |
1959 partial_T *tr_partial; | |
1960 int tr_emsg_count; | 1959 int tr_emsg_count; |
1961 #endif | 1960 #endif |
1962 }; | 1961 }; |
1963 | 1962 |
1964 #ifdef FEAT_CRYPT | 1963 #ifdef FEAT_CRYPT |
2507 #endif | 2506 #endif |
2508 | 2507 |
2509 int b_shortname; /* this file has an 8.3 file name */ | 2508 int b_shortname; /* this file has an 8.3 file name */ |
2510 | 2509 |
2511 #ifdef FEAT_JOB_CHANNEL | 2510 #ifdef FEAT_JOB_CHANNEL |
2512 char_u *b_prompt_text; // set by prompt_setprompt() | 2511 char_u *b_prompt_text; // set by prompt_setprompt() |
2513 char_u *b_prompt_callback; // set by prompt_setcallback() | 2512 callback_T b_prompt_callback; // set by prompt_setcallback() |
2514 partial_T *b_prompt_partial; // set by prompt_setcallback() | 2513 callback_T b_prompt_interrupt; // set by prompt_setinterrupt() |
2515 char_u *b_prompt_interrupt; // set by prompt_setinterrupt() | 2514 int b_prompt_insert; // value for restart_edit when entering |
2516 partial_T *b_prompt_int_partial; // set by prompt_setinterrupt() | 2515 // a prompt buffer window. |
2517 int b_prompt_insert; // value for restart_edit when entering | |
2518 // a prompt buffer window. | |
2519 #endif | 2516 #endif |
2520 #ifdef FEAT_MZSCHEME | 2517 #ifdef FEAT_MZSCHEME |
2521 void *b_mzscheme_ref; /* The MzScheme reference to this buffer */ | 2518 void *b_mzscheme_ref; /* The MzScheme reference to this buffer */ |
2522 #endif | 2519 #endif |
2523 | 2520 |