|
@@ -42,10 +42,6 @@ Type
|
|
jigCall, // call function
|
|
jigCall, // call function
|
|
jigGetter // read property
|
|
jigGetter // read property
|
|
);
|
|
);
|
|
- TJOBInvokeSetType = (
|
|
|
|
- jisCall, // call function
|
|
|
|
- jisSetter // write property
|
|
|
|
- );
|
|
|
|
|
|
|
|
TJSObject = class;
|
|
TJSObject = class;
|
|
TJSObjectClass = class of TJSObject;
|
|
TJSObjectClass = class of TJSObject;
|
|
@@ -62,11 +58,12 @@ Type
|
|
procedure InvokeJS_RaiseResultMismatch(const aName: string; Expected, Actual: TJOBResult); virtual;
|
|
procedure InvokeJS_RaiseResultMismatch(const aName: string; Expected, Actual: TJOBResult); virtual;
|
|
procedure InvokeJS_RaiseResultMismatchStr(const aName: string; const Expected, Actual: string); virtual;
|
|
procedure InvokeJS_RaiseResultMismatchStr(const aName: string; const Expected, Actual: string); virtual;
|
|
function CreateInvokeJSArgs(const Args: array of const): PByte; virtual;
|
|
function CreateInvokeJSArgs(const Args: array of const): PByte; virtual;
|
|
|
|
+ procedure SetJSProperty(const aName: string; Const Args: Array of const); virtual;
|
|
public
|
|
public
|
|
constructor CreateFromID(aID: TJOBObjectID); virtual;
|
|
constructor CreateFromID(aID: TJOBObjectID); virtual;
|
|
destructor Destroy; override;
|
|
destructor Destroy; override;
|
|
property ObjectID: TJOBObjectID read FObjectID;
|
|
property ObjectID: TJOBObjectID read FObjectID;
|
|
- procedure InvokeJSNoResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeSetType = jisCall); virtual;
|
|
|
|
|
|
+ procedure InvokeJSNoResult(const aName: string; Const Args: Array of const); virtual;
|
|
function InvokeJSBooleanResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeGetType = jigCall): Boolean; virtual;
|
|
function InvokeJSBooleanResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeGetType = jigCall): Boolean; virtual;
|
|
function InvokeJSDoubleResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeGetType = jigCall): Double; virtual;
|
|
function InvokeJSDoubleResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeGetType = jigCall): Double; virtual;
|
|
function InvokeJSUnicodeStringResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeGetType = jigCall): UnicodeString; virtual;
|
|
function InvokeJSUnicodeStringResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeGetType = jigCall): UnicodeString; virtual;
|
|
@@ -96,10 +93,16 @@ function __job_invoke_noresult(
|
|
ObjID: TJOBObjectID;
|
|
ObjID: TJOBObjectID;
|
|
NameP: PChar;
|
|
NameP: PChar;
|
|
NameLen: longint;
|
|
NameLen: longint;
|
|
- Invoke: longint;
|
|
|
|
ArgP: PByte
|
|
ArgP: PByte
|
|
): TJOBResult; external JOBExportName name JOBFn_InvokeNoResult;
|
|
): TJOBResult; external JOBExportName name JOBFn_InvokeNoResult;
|
|
|
|
|
|
|
|
+function __job_setproperty(
|
|
|
|
+ ObjID: TJOBObjectID;
|
|
|
|
+ NameP: PChar;
|
|
|
|
+ NameLen: longint;
|
|
|
|
+ ArgP: PByte
|
|
|
|
+): TJOBResult; external JOBExportName name JOBFn_SetProperty;
|
|
|
|
+
|
|
function __job_invoke_boolresult(
|
|
function __job_invoke_boolresult(
|
|
ObjID: TJOBObjectID;
|
|
ObjID: TJOBObjectID;
|
|
NameP: PChar;
|
|
NameP: PChar;
|
|
@@ -154,10 +157,6 @@ const
|
|
JOBInvokeCall,
|
|
JOBInvokeCall,
|
|
JOBInvokeGetter
|
|
JOBInvokeGetter
|
|
);
|
|
);
|
|
- InvokeSetToInt: array[TJOBInvokeSetType] of integer = (
|
|
|
|
- JOBInvokeCall,
|
|
|
|
- JOBInvokeSetter
|
|
|
|
- );
|
|
|
|
|
|
|
|
{$IFDEF VerboseJOB}
|
|
{$IFDEF VerboseJOB}
|
|
function GetVarRecName(vt: word): string;
|
|
function GetVarRecName(vt: word): string;
|
|
@@ -506,6 +505,21 @@ begin
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TJSObject.SetJSProperty(const aName: string;
|
|
|
|
+ const Args: array of const);
|
|
|
|
+var
|
|
|
|
+ InvokeArgs: PByte;
|
|
|
|
+begin
|
|
|
|
+ if length(Args)<>1 then
|
|
|
|
+ InvokeJS_Raise(aName,'wrong arg count');
|
|
|
|
+ InvokeArgs:=CreateInvokeJSArgs(Args);
|
|
|
|
+ try
|
|
|
|
+ __job_setproperty(ObjectID,PChar(aName),length(aName),InvokeArgs);
|
|
|
|
+ finally
|
|
|
|
+ FreeMem(InvokeArgs);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
constructor TJSObject.CreateFromID(aID: TJOBObjectID);
|
|
constructor TJSObject.CreateFromID(aID: TJOBObjectID);
|
|
begin
|
|
begin
|
|
FObjectID:=aID;
|
|
FObjectID:=aID;
|
|
@@ -519,17 +533,17 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.InvokeJSNoResult(const aName: string;
|
|
procedure TJSObject.InvokeJSNoResult(const aName: string;
|
|
- const Args: array of const; Invoke: TJOBInvokeSetType);
|
|
|
|
|
|
+ const Args: array of const);
|
|
var
|
|
var
|
|
aError: TJOBResult;
|
|
aError: TJOBResult;
|
|
InvokeArgs: PByte;
|
|
InvokeArgs: PByte;
|
|
begin
|
|
begin
|
|
if length(Args)=0 then
|
|
if length(Args)=0 then
|
|
- aError:=__job_invoke_noresult(ObjectID,PChar(aName),length(aName),InvokeSetToInt[Invoke],nil)
|
|
|
|
|
|
+ aError:=__job_invoke_noresult(ObjectID,PChar(aName),length(aName),nil)
|
|
else begin
|
|
else begin
|
|
InvokeArgs:=CreateInvokeJSArgs(Args);
|
|
InvokeArgs:=CreateInvokeJSArgs(Args);
|
|
try
|
|
try
|
|
- aError:=__job_invoke_noresult(ObjectID,PChar(aName),length(aName),InvokeSetToInt[Invoke],InvokeArgs);
|
|
|
|
|
|
+ aError:=__job_invoke_noresult(ObjectID,PChar(aName),length(aName),InvokeArgs);
|
|
finally
|
|
finally
|
|
if InvokeArgs<>nil then
|
|
if InvokeArgs<>nil then
|
|
FreeMem(InvokeArgs);
|
|
FreeMem(InvokeArgs);
|
|
@@ -658,35 +672,35 @@ end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyBoolean(const aName: string; Value: Boolean);
|
|
procedure TJSObject.WriteJSPropertyBoolean(const aName: string; Value: Boolean);
|
|
begin
|
|
begin
|
|
- InvokeJSNoResult(aName,[Value],jisSetter);
|
|
|
|
|
|
+ SetJSProperty(aName,[Value]);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyDouble(const aName: string; Value: Double);
|
|
procedure TJSObject.WriteJSPropertyDouble(const aName: string; Value: Double);
|
|
begin
|
|
begin
|
|
- InvokeJSNoResult(aName,[Value],jisSetter);
|
|
|
|
|
|
+ SetJSProperty(aName,[Value]);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyUnicodeString(const aName: string;
|
|
procedure TJSObject.WriteJSPropertyUnicodeString(const aName: string;
|
|
const Value: UnicodeString);
|
|
const Value: UnicodeString);
|
|
begin
|
|
begin
|
|
- InvokeJSNoResult(aName,[Value],jisSetter);
|
|
|
|
|
|
+ SetJSProperty(aName,[Value]);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyUtf8String(const aName: string;
|
|
procedure TJSObject.WriteJSPropertyUtf8String(const aName: string;
|
|
const Value: String);
|
|
const Value: String);
|
|
begin
|
|
begin
|
|
- InvokeJSNoResult(aName,[Value],jisSetter);
|
|
|
|
|
|
+ SetJSProperty(aName,[Value]);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyObject(const aName: string; Value: TJSObject
|
|
procedure TJSObject.WriteJSPropertyObject(const aName: string; Value: TJSObject
|
|
);
|
|
);
|
|
begin
|
|
begin
|
|
- InvokeJSNoResult(aName,[Value],jisSetter);
|
|
|
|
|
|
+ SetJSProperty(aName,[Value]);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyLongInt(const aName: string; Value: LongInt);
|
|
procedure TJSObject.WriteJSPropertyLongInt(const aName: string; Value: LongInt);
|
|
begin
|
|
begin
|
|
- InvokeJSNoResult(aName,[Value],jisSetter);
|
|
|
|
|
|
+ SetJSProperty(aName,[Value]);
|
|
end;
|
|
end;
|
|
|
|
|
|
initialization
|
|
initialization
|