patch 9.1.0020: Vim9: cannot compile all methods in a class
Problem: Vim9: cannot compile all methods in a class
Solution: Support compiling all the methods in a class using :defcompile
(Yegappan Lakshmanan)
closes: #13844
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/tags b/runtime/doc/tags
index bab6b3b..b3691bb 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -6428,6 +6428,7 @@
cino-} indent.txt /*cino-}*
cinoptions-values indent.txt /*cinoptions-values*
class vim9class.txt /*class*
+class-compile vim9class.txt /*class-compile*
class-method vim9class.txt /*class-method*
clear-undo undo.txt /*clear-undo*
clearmatches() builtin.txt /*clearmatches()*
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 9847ff7..746488e 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -130,8 +130,6 @@
Issue #11822: any.Func() can be a dict or an object call, need to handle
this at runtime. Also see #12198 for an example.
Possibly issue #11981 can be fixed at the same time (has two examples).
- - Make ":defcompile ClassName" compile all functions and methods in the
- class.
- Forward declaration of a class? E.g. for Clone() function.
Email lifepillar 2023 Mar 26
- object empty(), len() - can class define a method to be used for them?
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index b12b1cc..b246fcb 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1,4 +1,4 @@
-*vim9.txt* For Vim version 9.1. Last change: 2023 Dec 24
+*vim9.txt* For Vim version 9.1. Last change: 2024 Jan 12
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1260,10 +1260,12 @@
level. They cannot be created in a function, also not in a legacy function.
*:defc* *:defcompile*
-:defc[ompile] Compile functions defined in the current script that
- were not compiled yet.
- This will report any errors found during compilation.
- This excludes functions defined inside a class.
+:defc[ompile] Compile functions and classes (|class-compile|)
+ defined in the current script that were not compiled
+ yet. This will report any errors found during
+ compilation.
+
+:defc[ompile] MyClass Compile all methods in a class |class-compile|.
:defc[ompile] {func}
:defc[ompile] debug {func}
diff --git a/runtime/doc/vim9class.txt b/runtime/doc/vim9class.txt
index 6e94e84..ba821c1 100644
--- a/runtime/doc/vim9class.txt
+++ b/runtime/doc/vim9class.txt
@@ -1,4 +1,4 @@
-*vim9class.txt* For Vim version 9.1. Last change: 2024 Jan 06
+*vim9class.txt* For Vim version 9.1. Last change: 2024 Jan 12
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -830,7 +830,14 @@
"new()" then the default constructor is added, even though there are other
constructor methods.
+Compiling methods in a Class ~
+ *class-compile*
+The |:defcompile| command can be used to compile all the class and object
+methods defined in a class: >
+ defcompile MyClass # Compile class "MyClass"
+ defcompile # Compile the classes in the current script
+<
==============================================================================
7. Type definition *typealias* *Vim9-type* *:type*