File tree Expand file tree Collapse file tree 2 files changed +37
-24
lines changed Expand file tree Collapse file tree 2 files changed +37
-24
lines changed Original file line number Diff line number Diff line change @@ -760,10 +760,6 @@ function mixin_private.apply_mixin_foundation(object)
760
760
return mixin_private .create_fluid_proxy (prop )
761
761
end
762
762
763
- if not prop and k == " fallback_call" then
764
- return mixin_public .fallback_call
765
- end
766
-
767
763
return prop
768
764
end
769
765
@@ -1053,24 +1049,4 @@ function mixin_public.eachentry(region, layer)
1053
1049
end
1054
1050
end
1055
1051
1056
- --[[
1057
- % fallback_call
1058
-
1059
- Checks the existence of a class method before calling it. If the method exists, it returns
1060
- as expected. If the method does not exist, it returns the fallback_value. This function allows
1061
- a script to call a method that does not exist in earlier versions of Lua (specifically, in JW Lua.)
1062
-
1063
- @ instance (userdata) The class instance on which to call the method.
1064
- @ method_name (string) The name of the method to return.
1065
- @ fallback_value (any) The value that will be returned if the method does not exist. If this value is `nil`, the function returns `self`.
1066
- @ additional_parameters (...) The additional parameters of the method.
1067
- ]]
1068
- function mixin_public .fallback_call (instance , method_name , fallback_value , ...)
1069
- if not instance [method_name ] then
1070
- return fallback_value or instance
1071
- end
1072
-
1073
- return instance [method_name ](instance , ... )
1074
- end
1075
-
1076
1052
return mixin
Original file line number Diff line number Diff line change
1
+ -- Author: Robert Patterson
2
+ -- Date: January 20, 2024
3
+ --[[
4
+ $module __FCMBase
5
+
6
+ ## Summary of Modifications
7
+ - Add method _FallbackCall to gracefully allow skipping missing methods in earlier Lua versions
8
+ ]] --
9
+ local mixin = require (" library.mixin" )
10
+ local mixin_helper = require (" library.mixin_helper" )
11
+
12
+ local class = {Methods = {}}
13
+ local methods = class .Methods
14
+
15
+
16
+ --[[
17
+ % _FallbackCall
18
+
19
+ Checks the existence of a class method before calling it. If the method exists, it returns
20
+ as expected. If the method does not exist, it returns the fallback_value. This function allows
21
+ a script to call a method that does not exist in earlier versions of Lua (specifically, in JW Lua)
22
+ and get a default return value in that case.
23
+
24
+ @ self (userdata) The class instance on which to call the method.
25
+ @ method_name (string) The name of the method to return.
26
+ @ fallback_value (any) The value that will be returned if the method does not exist. If this value is `nil`, the function returns `self`.
27
+ @ additional_parameters (...) The additional parameters of the method.
28
+ ]]
29
+ function methods :_FallbackCall (method_name , fallback_value , ...)
30
+ if not self [method_name ] then
31
+ return fallback_value or self
32
+ end
33
+
34
+ return self [method_name ](self , ... )
35
+ end
36
+
37
+ return class
You can’t perform that action at this time.
0 commit comments