Mercurial > vim
comparison src/vim9class.c @ 31706:824fc05d9571 v9.0.1185
patch 9.0.1185: using class from imported script not tested
Commit: https://github.com/vim/vim/commit/a86655af84f1596f0f3ef22813724fe06f1e4809
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 12 17:06:27 2023 +0000
patch 9.0.1185: using class from imported script not tested
Problem: Using class from imported script not tested.
Solution: Add tests. Implement what is missing.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 12 Jan 2023 18:15:05 +0100 |
parents | 69ee530cac28 |
children | 1949c2613b3e |
comparison
equal
deleted
inserted
replaced
31705:9e44c0a6e54c | 31706:824fc05d9571 |
---|---|
242 semsg(_(e_white_space_required_after_name_str), arg); | 242 semsg(_(e_white_space_required_after_name_str), arg); |
243 return; | 243 return; |
244 } | 244 } |
245 char_u *name_start = arg; | 245 char_u *name_start = arg; |
246 | 246 |
247 // "export class" gets used when creating the class, don't use "is_export" | |
248 // for the items inside the class. | |
249 int class_export = is_export; | |
250 is_export = FALSE; | |
251 | |
247 // TODO: | 252 // TODO: |
248 // generics: <Tkey, Tentry> | 253 // generics: <Tkey, Tentry> |
249 // handle "is_export" if it is set | |
250 | 254 |
251 // Name for "extends BaseClass" | 255 // Name for "extends BaseClass" |
252 char_u *extends = NULL; | 256 char_u *extends = NULL; |
253 | 257 |
254 // Names for "implements SomeInterface" | 258 // Names for "implements SomeInterface" |
556 // Check the "extends" class is valid. | 560 // Check the "extends" class is valid. |
557 if (success && extends != NULL) | 561 if (success && extends != NULL) |
558 { | 562 { |
559 typval_T tv; | 563 typval_T tv; |
560 tv.v_type = VAR_UNKNOWN; | 564 tv.v_type = VAR_UNKNOWN; |
561 if (eval_variable(extends, 0, 0, &tv, NULL, EVAL_VAR_IMPORT) == FAIL) | 565 if (eval_variable_import(extends, &tv) == FAIL) |
562 { | 566 { |
563 semsg(_(e_class_name_not_found_str), extends); | 567 semsg(_(e_class_name_not_found_str), extends); |
564 success = FALSE; | 568 success = FALSE; |
565 } | 569 } |
566 else | 570 else |
592 for (int i = 0; i < ga_impl.ga_len && success; ++i) | 596 for (int i = 0; i < ga_impl.ga_len && success; ++i) |
593 { | 597 { |
594 char_u *impl = ((char_u **)ga_impl.ga_data)[i]; | 598 char_u *impl = ((char_u **)ga_impl.ga_data)[i]; |
595 typval_T tv; | 599 typval_T tv; |
596 tv.v_type = VAR_UNKNOWN; | 600 tv.v_type = VAR_UNKNOWN; |
597 if (eval_variable(impl, 0, 0, &tv, NULL, EVAL_VAR_IMPORT) == FAIL) | 601 if (eval_variable_import(impl, &tv) == FAIL) |
598 { | 602 { |
599 semsg(_(e_interface_name_not_found_str), impl); | 603 semsg(_(e_interface_name_not_found_str), impl); |
600 success = FALSE; | 604 success = FALSE; |
601 break; | 605 break; |
602 } | 606 } |
928 // Add the class to the script-local variables. | 932 // Add the class to the script-local variables. |
929 // TODO: handle other context, e.g. in a function | 933 // TODO: handle other context, e.g. in a function |
930 typval_T tv; | 934 typval_T tv; |
931 tv.v_type = VAR_CLASS; | 935 tv.v_type = VAR_CLASS; |
932 tv.vval.v_class = cl; | 936 tv.vval.v_class = cl; |
937 is_export = class_export; | |
933 set_var_const(cl->class_name, current_sctx.sc_sid, | 938 set_var_const(cl->class_name, current_sctx.sc_sid, |
934 NULL, &tv, FALSE, ASSIGN_DECL, 0); | 939 NULL, &tv, FALSE, ASSIGN_DECL, 0); |
935 return; | 940 return; |
936 } | 941 } |
937 | 942 |