Browse Source

rtl: MethodName: support callbacks with function reference

mattias 5 years ago
parent
commit
a72e7bf311
1 changed files with 6 additions and 2 deletions
  1. 6 2
      packages/rtl/system.pas

+ 6 - 2
packages/rtl/system.pas

@@ -852,10 +852,14 @@ begin
   if aCode=Nil then
   if aCode=Nil then
     exit;
     exit;
 asm
 asm
+  if (typeof(aCode)!=='function') return "";
   var i = 0;
   var i = 0;
   var TI = this.$rtti;
   var TI = this.$rtti;
-  // Callback ?
-  if ((typeof aCode["fn"] === "string") && (typeof aCode["scope"] === "object")) return aCode["fn"];
+  if (rtl.isObject(aCode.scope)){
+    // callback
+    if (typeof aCode.fn === "string") return aCode.fn;
+    aCode = aCode.fn;
+  }
   // Not a callback, check rtti
   // Not a callback, check rtti
   while ((Result === "") && (TI != null)) {
   while ((Result === "") && (TI != null)) {
     i = 0;
     i = 0;