2023-11-27 18:21:07 +01:00
|
|
|
unit uMyV8Accessor;
|
2017-07-25 22:50:34 +02:00
|
|
|
|
2019-05-19 16:08:15 +02:00
|
|
|
{$MODE Delphi}
|
|
|
|
|
2023-12-23 18:58:40 +01:00
|
|
|
{$I ..\..\..\..\source\cef.inc}
|
2017-07-25 22:50:34 +02:00
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2019-05-19 16:08:15 +02:00
|
|
|
uCEFv8Value, uCEFv8Accessor, uCEFInterfaces, uCEFTypes;
|
2017-07-25 22:50:34 +02:00
|
|
|
|
|
|
|
type
|
2017-11-22 17:43:48 +01:00
|
|
|
TMyV8Accessor = class(TCefV8AccessorOwn)
|
|
|
|
protected
|
|
|
|
FMyVal : ustring;
|
|
|
|
|
2019-11-24 18:19:49 +01:00
|
|
|
function Get(const name: ustring; const object_: ICefv8Value; var retval : ICefv8Value; var exception: ustring): Boolean; override;
|
|
|
|
function Set_(const name: ustring; const object_, value: ICefv8Value; var exception: ustring): Boolean; override;
|
2017-07-25 22:50:34 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2017-11-22 17:43:48 +01:00
|
|
|
function TMyV8Accessor.Get(const name : ustring;
|
2019-11-24 18:19:49 +01:00
|
|
|
const object_ : ICefv8Value;
|
|
|
|
var retval : ICefv8Value;
|
2017-11-22 17:43:48 +01:00
|
|
|
var exception : ustring): Boolean;
|
2017-07-25 22:50:34 +02:00
|
|
|
begin
|
2017-11-22 17:43:48 +01:00
|
|
|
if (name = 'myval') then
|
|
|
|
begin
|
|
|
|
retval := TCefv8ValueRef.NewString(FMyVal);
|
|
|
|
Result := True;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := False;
|
2017-07-25 22:50:34 +02:00
|
|
|
end;
|
|
|
|
|
2019-11-24 18:19:49 +01:00
|
|
|
function TMyV8Accessor.Set_(const name : ustring;
|
|
|
|
const object_ : ICefv8Value;
|
|
|
|
const value : ICefv8Value;
|
|
|
|
var exception : ustring): Boolean;
|
2017-07-25 22:50:34 +02:00
|
|
|
begin
|
2017-11-22 17:43:48 +01:00
|
|
|
if (name = 'myval') then
|
|
|
|
begin
|
|
|
|
if value.IsString then
|
|
|
|
FMyVal := value.GetStringValue
|
|
|
|
else
|
|
|
|
exception := 'Invalid value type';
|
2017-07-25 22:50:34 +02:00
|
|
|
|
2017-11-22 17:43:48 +01:00
|
|
|
Result := True;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := False;
|
2017-07-25 22:50:34 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|