mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-24 11:39:06 +02:00
rtl: added GetMethodProp
This commit is contained in:
parent
9dd808c9f1
commit
c465228571
@ -59,6 +59,7 @@ type
|
|||||||
PtrUInt = NativeUInt;
|
PtrUInt = NativeUInt;
|
||||||
ValSInt = NativeInt;
|
ValSInt = NativeInt;
|
||||||
ValUInt = NativeUInt;
|
ValUInt = NativeUInt;
|
||||||
|
CodePointer = Pointer;
|
||||||
ValReal = Double;
|
ValReal = Double;
|
||||||
Real = type Double;
|
Real = type Double;
|
||||||
Extended = type Double;
|
Extended = type Double;
|
||||||
@ -95,6 +96,12 @@ type
|
|||||||
end;
|
end;
|
||||||
TGUIDString = type string;
|
TGUIDString = type string;
|
||||||
|
|
||||||
|
PMethod = ^TMethod;
|
||||||
|
TMethod = record
|
||||||
|
Code : CodePointer;
|
||||||
|
Data : Pointer;
|
||||||
|
end;
|
||||||
|
|
||||||
TClass = class of TObject;
|
TClass = class of TObject;
|
||||||
|
|
||||||
{ TObject }
|
{ TObject }
|
||||||
|
@ -440,6 +440,11 @@ function GetSetPropArray(Instance: TObject; const PropInfo: TTypeMemberProperty)
|
|||||||
procedure SetSetPropArray(Instance: TObject; const PropName: String; const Arr: TIntegerDynArray); overload;
|
procedure SetSetPropArray(Instance: TObject; const PropName: String; const Arr: TIntegerDynArray); overload;
|
||||||
procedure SetSetPropArray(Instance: TObject; const PropInfo: TTypeMemberProperty; const Arr: TIntegerDynArray); overload;
|
procedure SetSetPropArray(Instance: TObject; const PropInfo: TTypeMemberProperty; const Arr: TIntegerDynArray); overload;
|
||||||
|
|
||||||
|
function GetBoolProp(Instance: TObject; const PropName: String): boolean;
|
||||||
|
function GetBoolProp(Instance: TObject; const PropInfo: TTypeMemberProperty): boolean;
|
||||||
|
procedure SetBoolProp(Instance: TObject; const PropName: String; Value: boolean);
|
||||||
|
procedure SetBoolProp(Instance: TObject; const PropInfo: TTypeMemberProperty; Value: boolean);
|
||||||
|
|
||||||
function GetStrProp(Instance: TObject; const PropName: String): String;
|
function GetStrProp(Instance: TObject; const PropName: String): String;
|
||||||
function GetStrProp(Instance: TObject; const PropInfo: TTypeMemberProperty): String;
|
function GetStrProp(Instance: TObject; const PropInfo: TTypeMemberProperty): String;
|
||||||
procedure SetStrProp(Instance: TObject; const PropName: String; Value: String);
|
procedure SetStrProp(Instance: TObject; const PropName: String; Value: String);
|
||||||
@ -450,22 +455,22 @@ function GetStringProp(Instance: TObject; const PropInfo: TTypeMemberProperty):
|
|||||||
procedure SetStringProp(Instance: TObject; const PropName: String; Value: String); deprecated; // use GetStrProp
|
procedure SetStringProp(Instance: TObject; const PropName: String; Value: String); deprecated; // use GetStrProp
|
||||||
procedure SetStringProp(Instance: TObject; const PropInfo: TTypeMemberProperty; Value: String); deprecated; // use GetStrProp
|
procedure SetStringProp(Instance: TObject; const PropInfo: TTypeMemberProperty; Value: String); deprecated; // use GetStrProp
|
||||||
|
|
||||||
function GetBoolProp(Instance: TObject; const PropName: String): boolean;
|
function GetFloatProp(Instance: TObject; const PropName: string): Double;
|
||||||
function GetBoolProp(Instance: TObject; const PropInfo: TTypeMemberProperty): boolean;
|
function GetFloatProp(Instance: TObject; PropInfo : TTypeMemberProperty) : Double;
|
||||||
procedure SetBoolProp(Instance: TObject; const PropName: String; Value: boolean);
|
procedure SetFloatProp(Instance: TObject; const PropName: string; Value: Double);
|
||||||
procedure SetBoolProp(Instance: TObject; const PropInfo: TTypeMemberProperty; Value: boolean);
|
procedure SetFloatProp(Instance: TObject; PropInfo : TTypeMemberProperty; Value : Double);
|
||||||
|
|
||||||
function GetObjectProp(Instance: TObject; const PropName: String): TObject;
|
function GetObjectProp(Instance: TObject; const PropName: String): TObject;
|
||||||
function GetObjectProp(Instance: TObject; const PropName: String; MinClass : TClass): TObject;
|
function GetObjectProp(Instance: TObject; const PropName: String; MinClass: TClass): TObject;
|
||||||
function GetObjectProp(Instance: TObject; const PropInfo: TTypeMemberProperty): TObject;
|
function GetObjectProp(Instance: TObject; const PropInfo: TTypeMemberProperty): TObject;
|
||||||
function GetObjectProp(Instance: TObject; const PropInfo: TTypeMemberProperty; MinClass : TClass): TObject;
|
function GetObjectProp(Instance: TObject; const PropInfo: TTypeMemberProperty; MinClass: TClass): TObject;
|
||||||
procedure SetObjectProp(Instance: TObject; const PropName: String; Value: TObject) ;
|
procedure SetObjectProp(Instance: TObject; const PropName: String; Value: TObject) ;
|
||||||
procedure SetObjectProp(Instance: TObject; const PropInfo: TTypeMemberProperty; Value: TObject);
|
procedure SetObjectProp(Instance: TObject; const PropInfo: TTypeMemberProperty; Value: TObject);
|
||||||
|
|
||||||
Function GetFloatProp(Instance: TObject; const PropName: string): Double;
|
function GetMethodProp(Instance: TObject; PropInfo: TTypeMemberProperty): TMethod;
|
||||||
Function GetFloatProp(Instance: TObject; PropInfo : TTypeMemberProperty) : Double;
|
function GetMethodProp(Instance: TObject; const PropName: string): TMethod;
|
||||||
Procedure SetFloatProp(Instance: TObject; const PropName: string; Value: Double);
|
//procedure SetMethodProp(Instance: TObject; PropInfo: TTypeMemberProperty; const Value : TMethod);
|
||||||
Procedure SetFloatProp(Instance: TObject; PropInfo : TTypeMemberProperty; Value : Double);
|
//procedure SetMethodProp(Instance: TObject; const PropName: string; const Value: TMethod);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -1376,27 +1381,42 @@ begin
|
|||||||
SetJSValueProp(Instance,PropInfo,Value);
|
SetJSValueProp(Instance,PropInfo,Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetMethodProp(Instance: TObject; PropInfo: TTypeMemberProperty
|
||||||
|
): TMethod;
|
||||||
|
var
|
||||||
|
v: JSValue;
|
||||||
|
begin
|
||||||
|
Result.Code:=nil;
|
||||||
|
Result.Data:=nil;
|
||||||
|
v:=GetJSValueProp(Instance,PropInfo);
|
||||||
|
if not isFunction(v) then exit;
|
||||||
|
Result.Data:=Pointer(TJSObject(v)['scope']);
|
||||||
|
Result.Code:=CodePointer(TJSObject(v)['fn']);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetMethodProp(Instance: TObject; const PropName: string): TMethod;
|
||||||
|
begin
|
||||||
|
Result:=GetMethodProp(Instance,FindPropInfo(Instance,PropName));
|
||||||
|
end;
|
||||||
|
|
||||||
function GetFloatProp(Instance: TObject; PropInfo: TTypeMemberProperty): Double;
|
function GetFloatProp(Instance: TObject; PropInfo: TTypeMemberProperty): Double;
|
||||||
begin
|
begin
|
||||||
Result:=Double(GetJSValueProp(Instance,PropInfo));
|
Result:=Double(GetJSValueProp(Instance,PropInfo));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetFloatProp(Instance: TObject; const PropName: string): Double;
|
function GetFloatProp(Instance: TObject; const PropName: string): Double;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=GetFloatProp(Instance,FindPropInfo(Instance,PropName));
|
Result:=GetFloatProp(Instance,FindPropInfo(Instance,PropName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetFloatProp(Instance: TObject; const PropName: string; Value: Double
|
procedure SetFloatProp(Instance: TObject; const PropName: string; Value: Double
|
||||||
);
|
);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SetFloatProp(Instance,FindPropInfo(Instance,PropName),Value);
|
SetFloatProp(Instance,FindPropInfo(Instance,PropName),Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SetFloatProp(Instance: TObject; PropInfo: TTypeMemberProperty;
|
procedure SetFloatProp(Instance: TObject; PropInfo: TTypeMemberProperty;
|
||||||
Value: Double);
|
Value: Double);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
SetJSValueProp(Instance,PropInfo,Value);
|
SetJSValueProp(Instance,PropInfo,Value);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user