comparison src/userfunc.c @ 17612:e259d11e2900 v8.1.1803

patch 8.1.1803: all builtin functions are global commit https://github.com/vim/vim/commit/ac92e25a33c37ec5becbfffeccda136c73b761ac Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 3 21:58:38 2019 +0200 patch 8.1.1803: all builtin functions are global Problem: All builtin functions are global. Solution: Add the method call operator ->. Implemented for a limited number of functions.
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Aug 2019 22:00:07 +0200
parents ff097edaae89
children 9ffec4eb8d33
comparison
equal deleted inserted replaced
17611:b9a3d542a042 17612:e259d11e2900
1429 1429
1430 if (item == NULL) 1430 if (item == NULL)
1431 { 1431 {
1432 funcexe_T funcexe; 1432 funcexe_T funcexe;
1433 1433
1434 funcexe.argv_func = NULL; 1434 vim_memset(&funcexe, 0, sizeof(funcexe));
1435 funcexe.firstline = curwin->w_cursor.lnum; 1435 funcexe.firstline = curwin->w_cursor.lnum;
1436 funcexe.lastline = curwin->w_cursor.lnum; 1436 funcexe.lastline = curwin->w_cursor.lnum;
1437 funcexe.doesrange = NULL;
1438 funcexe.evaluate = TRUE; 1437 funcexe.evaluate = TRUE;
1439 funcexe.partial = partial; 1438 funcexe.partial = partial;
1440 funcexe.selfdict = selfdict; 1439 funcexe.selfdict = selfdict;
1441 r = call_func(name, -1, rettv, argc, argv, &funcexe); 1440 r = call_func(name, -1, rettv, argc, argv, &funcexe);
1442 } 1441 }
1553 if (!builtin_function(rfname, -1)) 1552 if (!builtin_function(rfname, -1))
1554 { 1553 {
1555 /* 1554 /*
1556 * User defined function. 1555 * User defined function.
1557 */ 1556 */
1558 if (partial != NULL && partial->pt_func != NULL) 1557 if (funcexe->basetv != NULL)
1558 // TODO: support User function: base->Method()
1559 fp = NULL;
1560 else if (partial != NULL && partial->pt_func != NULL)
1559 fp = partial->pt_func; 1561 fp = partial->pt_func;
1560 else 1562 else
1561 fp = find_func(rfname); 1563 fp = find_func(rfname);
1562 1564
1563 /* Trigger FuncUndefined event, may load the function. */ 1565 /* Trigger FuncUndefined event, may load the function. */
1622 restoreRedobuff(&save_redo); 1624 restoreRedobuff(&save_redo);
1623 restore_search_patterns(); 1625 restore_search_patterns();
1624 error = ERROR_NONE; 1626 error = ERROR_NONE;
1625 } 1627 }
1626 } 1628 }
1629 }
1630 else if (funcexe->basetv != NULL)
1631 {
1632 /*
1633 * Find the method name in the table, call its implementation.
1634 */
1635 error = call_internal_method(fname, argcount, argvars, rettv,
1636 funcexe->basetv);
1627 } 1637 }
1628 else 1638 else
1629 { 1639 {
1630 /* 1640 /*
1631 * Find the function name in the table, call its implementation. 1641 * Find the function name in the table, call its implementation.
2713 2723
2714 int 2724 int
2715 translated_function_exists(char_u *name) 2725 translated_function_exists(char_u *name)
2716 { 2726 {
2717 if (builtin_function(name, -1)) 2727 if (builtin_function(name, -1))
2718 return find_internal_func(name) >= 0; 2728 return has_internal_func(name);
2719 return find_func(name) != NULL; 2729 return find_func(name) != NULL;
2720 } 2730 }
2721 2731
2722 /* 2732 /*
2723 * Return TRUE if a function "name" exists. 2733 * Return TRUE if a function "name" exists.
3082 startarg = skipwhite(arg); 3092 startarg = skipwhite(arg);
3083 rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */ 3093 rettv.v_type = VAR_UNKNOWN; /* clear_tv() uses this */
3084 3094
3085 if (*startarg != '(') 3095 if (*startarg != '(')
3086 { 3096 {
3087 semsg(_("E107: Missing parentheses: %s"), eap->arg); 3097 semsg(_(e_missingparen), eap->arg);
3088 goto end; 3098 goto end;
3089 } 3099 }
3090 3100
3091 /* 3101 /*
3092 * When skipping, evaluate the function once, to find the end of the 3102 * When skipping, evaluate the function once, to find the end of the
3118 curwin->w_cursor.col = 0; 3128 curwin->w_cursor.col = 0;
3119 curwin->w_cursor.coladd = 0; 3129 curwin->w_cursor.coladd = 0;
3120 } 3130 }
3121 arg = startarg; 3131 arg = startarg;
3122 3132
3123 funcexe.argv_func = NULL; 3133 vim_memset(&funcexe, 0, sizeof(funcexe));
3124 funcexe.firstline = eap->line1; 3134 funcexe.firstline = eap->line1;
3125 funcexe.lastline = eap->line2; 3135 funcexe.lastline = eap->line2;
3126 funcexe.doesrange = &doesrange; 3136 funcexe.doesrange = &doesrange;
3127 funcexe.evaluate = !eap->skip; 3137 funcexe.evaluate = !eap->skip;
3128 funcexe.partial = partial; 3138 funcexe.partial = partial;