mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-09-10 23:09:07 +02:00
rtl: cache IObjectInstance as string
This commit is contained in:
parent
2ed1cff471
commit
6244b933ac
@ -306,6 +306,20 @@ function StrictInequal(const A: JSValue; const B): boolean; assembler;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TJSObj - simple access to JS Object }
|
||||||
|
|
||||||
|
TJSObj = class external name 'Object'
|
||||||
|
private
|
||||||
|
function GetProperties(Name: String): JSValue; external name '[]';
|
||||||
|
procedure SetProperties(Name: String; const AValue: JSValue); external name '[]';
|
||||||
|
public
|
||||||
|
//constructor new;
|
||||||
|
//function hasOwnProperty(prop: String): boolean;
|
||||||
|
property Properties[Name: String]: JSValue read GetProperties write SetProperties; default;
|
||||||
|
end;
|
||||||
|
|
||||||
// function parseInt(s: String; Radix: NativeInt): NativeInt; external name 'parseInt'; // may result NaN
|
// function parseInt(s: String; Radix: NativeInt): NativeInt; external name 'parseInt'; // may result NaN
|
||||||
function isNaN(i: JSValue): boolean; external name 'isNaN'; // may result NaN
|
function isNaN(i: JSValue): boolean; external name 'isNaN'; // may result NaN
|
||||||
|
|
||||||
@ -399,13 +413,10 @@ asm
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function Pos(const Search, InString: String; StartAt : Integer): Integer; assembler; overload;
|
function Pos(const Search, InString: String; StartAt : Integer): Integer; assembler; overload;
|
||||||
|
|
||||||
asm
|
asm
|
||||||
return InString.indexOf(Search,StartAt-1)+1;
|
return InString.indexOf(Search,StartAt-1)+1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure Insert(const Insertion: String; var Target: String; Index: Integer);
|
procedure Insert(const Insertion: String; var Target: String; Index: Integer);
|
||||||
var
|
var
|
||||||
t: String;
|
t: String;
|
||||||
@ -582,7 +593,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function upcase(c : char) : char; assembler;
|
function upcase(c : char) : char; assembler;
|
||||||
|
|
||||||
asm
|
asm
|
||||||
return c.toUpperCase();
|
return c.toUpperCase();
|
||||||
end;
|
end;
|
||||||
@ -731,6 +741,7 @@ begin
|
|||||||
asm
|
asm
|
||||||
var i = iid.$intf;
|
var i = iid.$intf;
|
||||||
if (i){
|
if (i){
|
||||||
|
// iid is the private TGuid of an interface
|
||||||
i = rtl.getIntfG(this,i.$guid,2);
|
i = rtl.getIntfG(this,i.$guid,2);
|
||||||
if (i){
|
if (i){
|
||||||
obj.set(i);
|
obj.set(i);
|
||||||
@ -748,7 +759,9 @@ end;
|
|||||||
|
|
||||||
function TObject.GetInterfaceByStr(const iidstr: String; out obj): boolean;
|
function TObject.GetInterfaceByStr(const iidstr: String; out obj): boolean;
|
||||||
begin
|
begin
|
||||||
if (iidstr = IObjectInstance) then
|
if not TJSObj(IObjectInstance)['$str'] then
|
||||||
|
TJSObj(IObjectInstance)['$str']:=GUIDToString(IObjectInstance);
|
||||||
|
if iidstr = TJSObj(IObjectInstance)['$str'] then
|
||||||
begin
|
begin
|
||||||
obj:=Self;
|
obj:=Self;
|
||||||
exit(true);
|
exit(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user