UNPKG

@abaplint/runtime

Version:
26 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dynamicCallLookup = dynamicCallLookup; function dynamicCallLookup(obj, methodName) { // todo: escape interface and namespace characters in name? const name = typeof methodName === "string" ? methodName : methodName.get().toLowerCase().trimEnd(); let ret = obj[name]; if (ret !== undefined) { ret = ret.bind(obj); } else if (obj.FRIENDS_ACCESS_INSTANCE !== undefined) { // it might be private, note this currently does not respect encapsulation properly // FRIENDS_ACCESS_INSTANCE is already .bind()'ed ret = obj.FRIENDS_ACCESS_INSTANCE[name]; } if (ret === undefined) { // @ts-ignore if (abap.Classes['CX_SY_DYN_CALL_ILLEGAL_METHOD'] === undefined) { throw "CX_SY_DYN_CALL_ILLEGAL_METHOD not found"; } // @ts-ignore throw new abap.Classes['CX_SY_DYN_CALL_ILLEGAL_METHOD'](); } return ret; } //# sourceMappingURL=dynamic_call_lookup.js.map