home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 February
/
Chip_2000-02_cd.bin
/
zkuste
/
Delphi
/
navody
/
tt
/
objvm.exe
/
UNITS
/
ClassValue.pas
next >
Wrap
Pascal/Delphi Source File
|
1998-06-26
|
3KB
|
89 lines
unit ClassValue;
interface
uses VisualValue,
ConstValues,LangValue,ObjectValue,Classes,
ValueUtils,ProxyValue;
const nCreate='Create';
type
{TClassValue is value to implement classes in objVM language }
TClassValue=class(TVisualValue)
protected
fValues:TConstValues;
function rdValues(const s:string):ILangValue;override;
public
function HasValue(const s:string):boolean;override;
procedure AddValue(const aName:string;a:ILangValue);override;
procedure RemoveValue(a:ILangValue);override;
function CreateObject(o:TComponent):ILangValue;
published
constructor Create(o:TComponent);override;
destructor Destroy;override;
end;
type TCreateValue=class(ILangValue)
protected
fClass:TClassValue;
public
Constructor CreateFrom(a:TClassValue);
procedure Exec(s:IValStack;MustReturn:boolean);override;
end;
implementation
function TClassValue.rdValues;
begin
Result:=nil;
if S=nCreate then
Result:=TCreateValue.CreateFrom(Self);
end;
function TClassValue.HasValue;
begin
Result:=s=nCreate;
end;
procedure TClassValue.AddValue;
begin
fValues.AddValue(aName,a);
end;
procedure TClassValue.RemoveValue;
begin
fValues.RemoveValue(a);
end;
function TClassValue.CreateObject;
begin
Result:=TDefObjectValue.Create(o);
fValues.AddTo(Result);
Result:=TProxyValue.CreateFrom(Result);
end;
constructor TClassValue.Create;
begin
Inherited Create(o);
fValues:=TConstValues.Create;
end;
destructor TClassValue.Destroy;
begin
fValues.Free;
Inherited Destroy;
end;
Constructor TCreateValue.CreateFrom;
begin
inherited Create(nil);
fClass:=a;
end;
procedure TCreateValue.Exec;
Var o:ILangValue;
cm:ILangValue;
begin
o:=fClass.CreateObject(nil);
cm:=o.Values[nCreate];
if cm=nil then
begin
s.DropFrame;
end
else
begin
cm.Exec(s,false);
end;
if MustReturn then
s.Push(o);
end;
end.