|
@@ -42,6 +42,10 @@ 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;
|
|
@@ -58,12 +62,11 @@ 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); virtual;
|
|
|
|
|
|
+ procedure InvokeJSNoResult(const aName: string; Const Args: Array of const; Invoke: TJOBInvokeSetType = jisCall); 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;
|
|
@@ -93,16 +96,10 @@ 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;
|
|
@@ -157,6 +154,10 @@ 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;
|
|
@@ -505,21 +506,6 @@ 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;
|
|
@@ -533,17 +519,17 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.InvokeJSNoResult(const aName: string;
|
|
procedure TJSObject.InvokeJSNoResult(const aName: string;
|
|
- const Args: array of const);
|
|
|
|
|
|
+ const Args: array of const; Invoke: TJOBInvokeSetType);
|
|
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),nil)
|
|
|
|
|
|
+ aError:=__job_invoke_noresult(ObjectID,PChar(aName),length(aName),InvokeSetToInt[Invoke],nil)
|
|
else begin
|
|
else begin
|
|
InvokeArgs:=CreateInvokeJSArgs(Args);
|
|
InvokeArgs:=CreateInvokeJSArgs(Args);
|
|
try
|
|
try
|
|
- aError:=__job_invoke_noresult(ObjectID,PChar(aName),length(aName),InvokeArgs);
|
|
|
|
|
|
+ aError:=__job_invoke_noresult(ObjectID,PChar(aName),length(aName),InvokeSetToInt[Invoke],InvokeArgs);
|
|
finally
|
|
finally
|
|
if InvokeArgs<>nil then
|
|
if InvokeArgs<>nil then
|
|
FreeMem(InvokeArgs);
|
|
FreeMem(InvokeArgs);
|
|
@@ -672,35 +658,35 @@ end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyBoolean(const aName: string; Value: Boolean);
|
|
procedure TJSObject.WriteJSPropertyBoolean(const aName: string; Value: Boolean);
|
|
begin
|
|
begin
|
|
- SetJSProperty(aName,[Value]);
|
|
|
|
|
|
+ InvokeJSNoResult(aName,[Value],jisSetter);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyDouble(const aName: string; Value: Double);
|
|
procedure TJSObject.WriteJSPropertyDouble(const aName: string; Value: Double);
|
|
begin
|
|
begin
|
|
- SetJSProperty(aName,[Value]);
|
|
|
|
|
|
+ InvokeJSNoResult(aName,[Value],jisSetter);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyUnicodeString(const aName: string;
|
|
procedure TJSObject.WriteJSPropertyUnicodeString(const aName: string;
|
|
const Value: UnicodeString);
|
|
const Value: UnicodeString);
|
|
begin
|
|
begin
|
|
- SetJSProperty(aName,[Value]);
|
|
|
|
|
|
+ InvokeJSNoResult(aName,[Value],jisSetter);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyUtf8String(const aName: string;
|
|
procedure TJSObject.WriteJSPropertyUtf8String(const aName: string;
|
|
const Value: String);
|
|
const Value: String);
|
|
begin
|
|
begin
|
|
- SetJSProperty(aName,[Value]);
|
|
|
|
|
|
+ InvokeJSNoResult(aName,[Value],jisSetter);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyObject(const aName: string; Value: TJSObject
|
|
procedure TJSObject.WriteJSPropertyObject(const aName: string; Value: TJSObject
|
|
);
|
|
);
|
|
begin
|
|
begin
|
|
- SetJSProperty(aName,[Value]);
|
|
|
|
|
|
+ InvokeJSNoResult(aName,[Value],jisSetter);
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TJSObject.WriteJSPropertyLongInt(const aName: string; Value: LongInt);
|
|
procedure TJSObject.WriteJSPropertyLongInt(const aName: string; Value: LongInt);
|
|
begin
|
|
begin
|
|
- SetJSProperty(aName,[Value]);
|
|
|
|
|
|
+ InvokeJSNoResult(aName,[Value],jisSetter);
|
|
end;
|
|
end;
|
|
|
|
|
|
initialization
|
|
initialization
|