mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-14 07:49:03 +02:00
Changed the interface to type info function don't raise compiler error.
This commit is contained in:
parent
14601cabf0
commit
0e5c9df70b
@ -22,7 +22,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
{$IFDEF FPC_DOTTEDUNITS}
|
{$IFDEF FPC_DOTTEDUNITS}
|
||||||
System.SysUtils, System.Types, System.RTLConsts, JSApi.JS;
|
System.SysUtils, System.Types, System.RTLConsts, JSApi.JS;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
SysUtils, Types, RTLConsts, JS;
|
SysUtils, Types, RTLConsts, JS;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
@ -436,9 +436,9 @@ function GetEnumProp(Instance: TObject; const PropInfo: TTypeMemberProperty): St
|
|||||||
procedure SetEnumProp(Instance: TObject; const PropName: String; const Value: String);
|
procedure SetEnumProp(Instance: TObject; const PropName: String; const Value: String);
|
||||||
procedure SetEnumProp(Instance: TObject; const PropInfo: TTypeMemberProperty; const Value: String);
|
procedure SetEnumProp(Instance: TObject; const PropInfo: TTypeMemberProperty; const Value: String);
|
||||||
// Auxiliary routines, which may be useful
|
// Auxiliary routines, which may be useful
|
||||||
function GetEnumName(TypeInfo: TTypeInfoEnum; Value: Integer): String;
|
function GetEnumName(TypeInfo: TTypeInfo; Value: Integer): String;
|
||||||
function GetEnumValue(TypeInfo: TTypeInfoEnum; const Name: string): Longint;
|
function GetEnumValue(TypeInfo: TTypeInfo; const Name: string): Longint;
|
||||||
function GetEnumNameCount(TypeInfo: TTypeInfoEnum): Longint;
|
function GetEnumNameCount(TypeInfo: TTypeInfo): Longint;
|
||||||
|
|
||||||
function GetSetProp(Instance: TObject; const PropName: String): String; overload;
|
function GetSetProp(Instance: TObject; const PropName: String): String; overload;
|
||||||
function GetSetProp(Instance: TObject; const PropInfo: TTypeMemberProperty): String; overload;
|
function GetSetProp(Instance: TObject; const PropInfo: TTypeMemberProperty): String; overload;
|
||||||
@ -1200,22 +1200,29 @@ begin
|
|||||||
SetJSValueProp(Instance,PropInfo,n);
|
SetJSValueProp(Instance,PropInfo,n);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetEnumName(TypeInfo: TTypeInfoEnum; Value: Integer): String;
|
function GetEnumName(TypeInfo: TTypeInfo; Value: Integer): String;
|
||||||
begin
|
|
||||||
Result:=TypeInfo.EnumType.IntToName[Value];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function GetEnumValue(TypeInfo: TTypeInfoEnum; const Name: string): Longint;
|
|
||||||
begin
|
|
||||||
Result:=TypeInfo.EnumType.NameToInt[Name];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function GetEnumNameCount(TypeInfo: TTypeInfoEnum): Longint;
|
|
||||||
var
|
var
|
||||||
|
Info: TTypeInfoEnum absolute TypeInfo;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result := Info.EnumType.IntToName[Value];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetEnumValue(TypeInfo: TTypeInfo; const Name: string): Longint;
|
||||||
|
var
|
||||||
|
Info: TTypeInfoEnum absolute TypeInfo;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result := Info.EnumType.NameToInt[Name];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetEnumNameCount(TypeInfo: TTypeInfo): Longint;
|
||||||
|
var
|
||||||
|
Info: TTypeInfoEnum absolute TypeInfo;
|
||||||
o: TJSObject;
|
o: TJSObject;
|
||||||
l, r: LongInt;
|
l, r: LongInt;
|
||||||
begin
|
begin
|
||||||
o:=TJSObject(TypeInfo.EnumType);
|
o:=TJSObject(Info.EnumType);
|
||||||
// as of pas2js 1.0 the RTTI does not contain a min/max value
|
// as of pas2js 1.0 the RTTI does not contain a min/max value
|
||||||
// -> use exponential search
|
// -> use exponential search
|
||||||
// ToDo: adapt this once enums with gaps are supported
|
// ToDo: adapt this once enums with gaps are supported
|
||||||
|
Loading…
Reference in New Issue
Block a user