Pārlūkot izejas kodu

* Make GetEnumName safer, check actual type. Allow passing an integer

Michaël Van Canneyt 1 gadu atpakaļ
vecāks
revīzija
cde58d66fc
1 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 6 2
      rtl/objpas/typinfo.pp

+ 6 - 2
rtl/objpas/typinfo.pp

@@ -1479,7 +1479,7 @@ begin
           Result:='';
           Result:='';
       end;
       end;
     end
     end
- else
+ else if TypeInfo^.Kind=tkEnumeration then
    begin
    begin
      PS:=@PT^.NameList;
      PS:=@PT^.NameList;
      dec(Value,PT^.MinValue);
      dec(Value,PT^.MinValue);
@@ -1489,7 +1489,11 @@ begin
          Dec(Value);
          Dec(Value);
        end;
        end;
      Result:=PS^;
      Result:=PS^;
-   end;
+   end
+ else if TypeInfo^.Kind=tkInteger then
+   Result:=IntToStr(Value)
+ else
+   Result:='';  
 end;
 end;