Modules that declare an interface are expected to implement all
methods, prefixing method names with an underscore. However, since
there may be (partially) unimplemented interfaces, the framework
should not make such assumptions about implementations.
This commit modifies the implementation of interfaces so that
methods reference an error stub by default, which warns the caller
that the method is not implemented.
readonly -f interface
readonly -f implements
readonly -f calling_module
+ readonly -f method_not_implemented
return 0
}
return 0
}
+method_not_implemented() {
+ local method
+
+ method="${FUNCNAME[1]}"
+ method="${method#_}"
+
+ echo "ERROR: $method: Not implemented" 1>&2
+ return 127
+}
+
interface() {
local methods=("$@")
# Set the entries in the vtable
for method in "${methods[@]}"; do
- interface["$method"]="_${name}_$method"
+ interface["$method"]=method_not_implemented
done
return 0