0: compatibility with latest RO/DA

This commit is contained in:
evgeny-k 2017-11-13 12:00:54 +03:00
parent 90ed5ee62a
commit 415353d8db
2 changed files with 35 additions and 12 deletions

View File

@ -118,7 +118,7 @@ var
begin begin
if Assigned(fDataTable) then begin if Assigned(fDataTable) then begin
for i := 0 to fDataTable.Fields.Count-1 do begin for i := 0 to fDataTable.Fields.Count-1 do begin
fScript.AddRegisteredVariable({$IFDEF UNICODE}WideStringToAnsiString{$ENDIF}(fDataTable.Fields[i].Name), '!NOTIFICATIONVARIANT'); fScript.AddRegisteredVariable(fDataTable.Fields[i].Name, '!NOTIFICATIONVARIANT');
end; { for } end; { for }
end; end;
@ -135,12 +135,12 @@ end;}
function TDAPSScriptingProvider.OnGetNotificationVariant(Sender: TPSScript; const Name: tbtstring): Variant; function TDAPSScriptingProvider.OnGetNotificationVariant(Sender: TPSScript; const Name: tbtstring): Variant;
begin begin
result := fDataTable.Fields.FieldByName({$IFDEF UNICODE}AnsiStringToWideString{$ENDIF}(Name)).Value; result := fDataTable.Fields.FieldByName(Name).Value;
end; end;
procedure TDAPSScriptingProvider.OnSetNotificationVariant(Sender: TPSScript; const Name: tbtstring; V: Variant); procedure TDAPSScriptingProvider.OnSetNotificationVariant(Sender: TPSScript; const Name: tbtstring; V: Variant);
begin begin
fDataTable.Fields.FieldByName({$IFDEF UNICODE}AnsiStringToWideString{$ENDIF}(Name)).Value := V; fDataTable.Fields.FieldByName(Name).Value := V;
end; end;
procedure TDAPSScriptingProvider.PrepareForBusinessProcessor(aBusinessProcessor: TDABusinessProcessor); procedure TDAPSScriptingProvider.PrepareForBusinessProcessor(aBusinessProcessor: TDABusinessProcessor);
@ -202,7 +202,7 @@ begin
end; end;
fDataTablePlugin.DataTable := aDataTable; fDataTablePlugin.DataTable := aDataTable;
lMethod := TScriptMethod(fScript.GetProcMethod({$IFDEF UNICODE}WideStringToAnsiString{$ENDIF}(aMethod))); lMethod := TScriptMethod(fScript.GetProcMethod(aMethod));
if assigned(@lMethod) then if assigned(@lMethod) then
lMethod(); lMethod();
end; end;

View File

@ -275,24 +275,29 @@ type
private private
FVar: TPSVariantIFC; FVar: TPSVariantIFC;
FExec: TPSExec; FExec: TPSExec;
fAttr: TStringList;
protected protected
function GetTypeName: string; function GetTypeName: string;
procedure SetTypeName(const s: string); procedure SetTypeName(const s: string);
procedure Write(Serializer: TROSerializer; const Name: string); procedure Write(Serializer: TROSerializer; const Name: string; ArrayElementId : integer = -1);
procedure Read(Serializer: TROSerializer; const Name: string); procedure Read(Serializer: TROSerializer; const Name: string; ArrayElementId : integer = -1);
function _AddRef: Integer; stdcall; function _AddRef: Integer; stdcall;
function _Release: Integer; stdcall; function _Release: Integer; stdcall;
function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
function CanImplementType(const aName: string):boolean; function CanImplementType(const aName: string):boolean;
procedure SetNull(b: Boolean); procedure SetNull(b: Boolean);
function IsNull: Boolean; function IsNull: Boolean;
function GetAttributes: TStrings;
public public
constructor Create(aVar: TPSVariantIfc; Exec: TPSExec); constructor Create(aVar: TPSVariantIfc; Exec: TPSExec);
destructor Destroy; override;
end; end;
TROArray = class(TROStructure, IROCustomStreamableType, IROCustomStreamableStruct, IROCustomStreamableArray) TROArray = class(TROStructure, IROCustomStreamableType, IROCustomStreamableStruct, IROCustomStreamableArray)
protected protected
function GetCount: Longint; function GetCount: Longint;
procedure SetCount(l: Longint); procedure SetCount(l: Longint);
function GetElementType: string;
end; end;
procedure WriteUserDefined(Exec: TPSExec; const Msg: IROMessage; const Name: string; const n: TPSVariantIfc); procedure WriteUserDefined(Exec: TPSExec; const Msg: IROMessage; const Name: string; const n: TPSVariantIfc);
@ -1142,10 +1147,19 @@ end;
{ TROStructure } { TROStructure }
constructor TROStructure.Create(aVar: TPSVariantIfc; Exec: TPSExec); constructor TROStructure.Create(aVar: TPSVariantIfc; Exec: TPSExec);
var
i: integer;
begin begin
inherited Create; inherited Create;
FVar := aVar; FVar := aVar;
FExec := Exec; FExec := Exec;
fAttr := TStringList.Create;
end;
destructor TROStructure.Destroy;
begin
fAttr.Free;
inherited;
end; end;
function TROStructure.IsNull: Boolean; function TROStructure.IsNull: Boolean;
@ -1162,10 +1176,9 @@ begin
Result := E_NOINTERFACE; Result := E_NOINTERFACE;
end; end;
procedure TROStructure.Read(Serializer: TROSerializer; procedure TROStructure.Read(Serializer: TROSerializer; const Name: string; ArrayElementId : integer = -1);
const Name: string);
begin begin
IntRead(FExec, Serializer, Name, FVar, -1); IntRead(FExec, Serializer, Name, FVar, ArrayElementId);
end; end;
procedure TROStructure.SetNull(b: Boolean); procedure TROStructure.SetNull(b: Boolean);
@ -1173,6 +1186,11 @@ begin
// null not supported // null not supported
end; end;
function TROStructure.GetAttributes: TStrings;
begin
Result:= fAttr;
end;
function TROStructure.GetTypeName: string; function TROStructure.GetTypeName: string;
var var
s: string; s: string;
@ -1184,9 +1202,9 @@ begin
end; end;
procedure TROStructure.Write(Serializer: TROSerializer; procedure TROStructure.Write(Serializer: TROSerializer;
const Name: string); const Name: string; ArrayElementId : integer = -1);
begin begin
IntWrite(FExec, Serializer, Name, FVar, -1); IntWrite(FExec, Serializer, Name, FVar, ArrayElementId);
end; end;
@ -1224,6 +1242,11 @@ begin
Result := PSDynArrayGetLength(Pointer(fVar.Dta^), fvar.aType); Result := PSDynArrayGetLength(Pointer(fVar.Dta^), fvar.aType);
end; end;
function TROArray.GetElementType: string;
begin
Result := '';
end;
procedure TROArray.SetCount(l: Integer); procedure TROArray.SetCount(l: Integer);
begin begin
PSDynArraySetLength(Pointer(fVAr.Dta^), fVar.aType, l); PSDynArraySetLength(Pointer(fVAr.Dta^), fVar.aType, l);