Browse Source

+ add TRttiOrdinalType and TRttiInt64Type (what's left of the "ordinal like" ones is TRttiEnumerationType, TRttiSetType and a non-Delphi compatible TRttiBooleanType (due to FPC supporting multiple Boolean types))

git-svn-id: trunk@42719 -
svenbarth 6 years ago
parent
commit
7d9b249def
1 changed files with 87 additions and 1 deletions
  1. 87 1
      packages/rtl-objpas/src/inc/rtti.pp

+ 87 - 1
packages/rtl-objpas/src/inc/rtti.pp

@@ -255,6 +255,31 @@ type
     property FloatType: TFloatType read GetFloatType;
     property FloatType: TFloatType read GetFloatType;
   end;
   end;
 
 
+  TRttiOrdinalType = class(TRttiType)
+  private
+    function GetMaxValue: LongInt; inline;
+    function GetMinValue: LongInt; inline;
+    function GetOrdType: TOrdType; inline;
+  protected
+    function GetTypeSize: Integer; override;
+  public
+    property OrdType: TOrdType read GetOrdType;
+    property MinValue: LongInt read GetMinValue;
+    property MaxValue: LongInt read GetMaxValue;
+  end;
+
+  TRttiInt64Type = class(TRttiType)
+  private
+    function GetMaxValue: Int64; inline;
+    function GetMinValue: Int64; inline;
+    function GetUnsigned: Boolean; inline;
+  protected
+    function GetTypeSize: integer; override;
+  public
+    property MinValue: Int64 read GetMinValue;
+    property MaxValue: Int64 read GetMaxValue;
+    property Unsigned: Boolean read GetUnsigned;
+  end;
 
 
   TRttiStringKind = (skShortString, skAnsiString, skWideString, skUnicodeString);
   TRttiStringKind = (skShortString, skAnsiString, skWideString, skUnicodeString);
 
 
@@ -1051,7 +1076,6 @@ begin
   for cc := Low(TCallConv) to High(TCallConv) do
   for cc := Low(TCallConv) to High(TCallConv) do
     FuncCallMgr[cc] := NoFunctionCallManager;
     FuncCallMgr[cc] := NoFunctionCallManager;
 end;
 end;
-
 { TRttiPool }
 { TRttiPool }
 
 
 function TRttiPool.GetTypes: specialize TArray<TRttiType>;
 function TRttiPool.GetTypes: specialize TArray<TRttiType>;
@@ -1094,6 +1118,11 @@ begin
           tkClass   : Result := TRttiInstanceType.Create(ATypeInfo);
           tkClass   : Result := TRttiInstanceType.Create(ATypeInfo);
           tkInterface: Result := TRttiRefCountedInterfaceType.Create(ATypeInfo);
           tkInterface: Result := TRttiRefCountedInterfaceType.Create(ATypeInfo);
           tkInterfaceRaw: Result := TRttiRawInterfaceType.Create(ATypeInfo);
           tkInterfaceRaw: Result := TRttiRawInterfaceType.Create(ATypeInfo);
+          tkInt64,
+          tkQWord: Result := TRttiInt64Type.Create(ATypeInfo);
+          tkInteger,
+          tkChar,
+          tkWChar: Result := TRttiOrdinalType.Create(ATypeInfo);
           tkSString,
           tkSString,
           tkLString,
           tkLString,
           tkAString,
           tkAString,
@@ -2643,6 +2672,63 @@ begin
     Result := FParams;
     Result := FParams;
 end;
 end;
 
 
+{ TRttiInt64Type }
+
+function TRttiInt64Type.GetMaxValue: Int64;
+begin
+  Result := FTypeData^.MaxInt64Value;
+end;
+
+function TRttiInt64Type.GetMinValue: Int64;
+begin
+  Result := FTypeData^.MinInt64Value;
+end;
+
+function TRttiInt64Type.GetUnsigned: Boolean;
+begin
+  Result := FTypeData^.OrdType = otUQWord;
+end;
+
+function TRttiInt64Type.GetTypeSize: integer;
+begin
+  Result := SizeOf(QWord);
+end;
+
+{ TRttiOrdinalType }
+
+function TRttiOrdinalType.GetMaxValue: LongInt;
+begin
+  Result := FTypeData^.MaxValue;
+end;
+
+function TRttiOrdinalType.GetMinValue: LongInt;
+begin
+  Result := FTypeData^.MinValue;
+end;
+
+function TRttiOrdinalType.GetOrdType: TOrdType;
+begin
+  Result := FTypeData^.OrdType;
+end;
+
+function TRttiOrdinalType.GetTypeSize: Integer;
+begin
+  case OrdType of
+    otSByte,
+    otUByte:
+      Result := SizeOf(Byte);
+    otSWord,
+    otUWord:
+      Result := SizeOf(Word);
+    otSLong,
+    otULong:
+      Result := SizeOf(LongWord);
+    otSQWord,
+    otUQWord:
+      Result := SizeOf(QWord);
+  end;
+end;
+
 { TRttiFloatType }
 { TRttiFloatType }
 
 
 function TRttiFloatType.GetFloatType: TFloatType;
 function TRttiFloatType.GetFloatType: TFloatType;