[lazarus] dealing with objects' properties

dvortex dvortex at netcourrier.com
Tue May 2 12:21:58 EDT 2000


I guess that's what the object inspector is all about :o)
just kidding.. 

yes, it will probably end up as a class of its own, sort of like
"PropertyInspector"
so that it can be modified in such a way to make this possible to
implement new "type descriptor"
(like for fonts and what not...).

dv

On Tue, 2 May 2000, mariano podesta wrote:

> IMHO the best way is to code a class to manage rtti instead of functions
> 
> ---------------------------------------
> mariano podesta
> 
> marianop at intercom.com.ar
> marianopodesta at usa.net
> 
> 
> > -----Original Message-----
> > From: dvortex [mailto:dvortex at netcourrier.com]
> > Sent: Martes 2 de Mayo (5) de 2000 12:02
> > To: lazarus at miraclec.com
> > Subject: Re: [lazarus] dealing with objects' properties
> >
> >
> > very good point michael ! :o)
> >
> > as i said ... morning idea :o)
> > i will do it as you suggest at the end of this message..
> > (and if anyone got some different idea, let me know :o)
> >
> >
> >
> > On Tue, 2 May 2000, Michael Van Canneyt wrote:
> >
> > >
> > >
> > > On Tue, 2 May 2000, dvortex wrote:
> > >
> > > >
> > > > I was waking up this morning after a short night of sleep,
> > and i realized
> > > > that maybe i should modify the TObject code and add this:
> > > >
> > > >  Procedure TObject.SetProperty(PropertyName).AsString
> > > >                                             .AsFloat
> > > >                                             .AsInteger
> > > >
> > > > (How can i code something like this by the way ?)
> > > >
> > > > and maybe
> > > >  Function TObject.GetPropertList : TStringList;
> > > >
> > > > ?
> > > >
> > > > What do you think ?
> > > > that would allow to make component coding a lot easier, don't
> > you think ?
> > >
> > >
> > >
> > > And it would increase all existing code unnecessary much
> > because it is in
> > > the system unit, so better not in the system unit.
> > >
> > > Not to mention that you would need the typinfo unit in the
> > system unit, which
> > > would introduce a circular unit dependency. The alternative, to
> > 'include' the
> > > typinfo in the system unit, is definitely out of the question.
> > >
> > > You CAN insert it in the typinfo unit, however:
> > >
> > > Delphi 5 has similar procedures in it's typinfo unit, which we didn't
> > > implement yet. If you implement it there, I will include it in the RTL:
> > >
> > > Here is the list of functions. The Get/Set functions do what you want to
> > > do.
> > >
> > > A sample implementation would be:
> > >
> > > procedure SetStrProp(Instance: TObject;
> > >                      Const PropName: String;
> > >                      Const Value: String);
> > > begin
> > >   SetStrProp(Instance,GetPropInfo(Instance, PropName),Value);
> > > end;
> > >
> > >
> > >
> > > function IsPublishedProp(Instance: TObject; const PropName:
> > string): Boolean; overload;
> > > function IsPublishedProp(AClass: TClass; const PropName:
> > string): Boolean; overload;
> > > function GetPropInfo(Instance: TObject; const PropName: string;
> > AKinds: TTypeKinds = []): PPropInfo; overload;
> > > function GetPropInfo(AClass: TClass; const PropName: string;
> > AKinds: TTypeKinds = []): PPropInfo; overload;
> > >
> > > function PropIsType(Instance: TObject; const PropName: string;
> > TypeKind: TTypeKind): Boolean; overload;
> > > function PropIsType(AClass: TClass; const PropName: string;
> > TypeKind: TTypeKind): Boolean; overload;
> > > function PropType(Instance: TObject; const PropName: string):
> > TTypeKind; overload;
> > > function PropType(AClass: TClass; const PropName: string):
> > TTypeKind; overload;
> > >
> > > function IsStoredProp(Instance: TObject; const PropName:
> > string): Boolean; overload;
> > >
> > > function GetOrdProp(Instance: TObject; const PropName: string):
> > Longint; overload;
> > > procedure SetOrdProp(Instance: TObject; const PropName: string;
> > >   Value: Longint); overload;
> > >
> > > function GetEnumProp(Instance: TObject; const PropName:
> > string): string; overload;
> > > procedure SetEnumProp(Instance: TObject; const PropName: string;
> > >   const Value: string); overload;
> > >
> > > function GetSetProp(Instance: TObject; const PropName: string;
> > >   Brackets: Boolean = False): string; overload;
> > > procedure SetSetProp(Instance: TObject; const PropName: string;
> > >   const Value: string); overload;
> > >
> > > function GetObjectProp(Instance: TObject; const PropName: string;
> > >   MinClass: TClass = nil): TObject; overload;
> > > procedure SetObjectProp(Instance: TObject; const PropName: string;
> > >   Value: TObject); overload;
> > > function GetObjectPropClass(Instance: TObject; const PropName:
> > string): TClass; overload;
> > >
> > > function GetStrProp(Instance: TObject; const PropName: string):
> > string; overload;
> > > procedure SetStrProp(Instance: TObject; const PropName: string;
> > >   const Value: string); overload;
> > >
> > > function GetFloatProp(Instance: TObject; const PropName:
> > string): Extended; overload;
> > > procedure SetFloatProp(Instance: TObject; const PropName: string;
> > >   Value: Extended); overload;
> > >
> > > function GetVariantProp(Instance: TObject; const PropName:
> > string): Variant; overload;
> > > procedure SetVariantProp(Instance: TObject; const PropName: string;
> > >   const Value: Variant); overload;
> > >
> > > function GetMethodProp(Instance: TObject; const PropName:
> > string): TMethod; overload;
> > > procedure SetMethodProp(Instance: TObject; const PropName: string;
> > >   const Value: TMethod); overload;
> > >
> > > function GetInt64Prop(Instance: TObject; const PropName:
> > string): Int64; overload;
> > > procedure SetInt64Prop(Instance: TObject; const PropName: string;
> > >   const Value: Int64); overload;
> > >
> > > function GetPropValue(Instance: TObject; const PropName: string;
> > >   PreferStrings: Boolean = True): Variant;
> > > procedure SetPropValue(Instance: TObject; const PropName: string;
> > >   const Value: Variant);
> > >
> > > Michael.
> > >
> > > _________________________________________________________________
> > >      To unsubscribe: mail lazarus-request at miraclec.com with
> > >                 "unsubscribe" as the Subject
> > >     archives at http://www.miraclec.com/list_archives/lazarus
> > >
> >
> > _________________________________________________________________
> >      To unsubscribe: mail lazarus-request at miraclec.com with
> >                 "unsubscribe" as the Subject
> >     archives at http://www.miraclec.com/list_archives/lazarus
> >
> 
> _________________________________________________________________
>      To unsubscribe: mail lazarus-request at miraclec.com with
>                 "unsubscribe" as the Subject
>     archives at http://www.miraclec.com/list_archives/lazarus
> 






More information about the Lazarus mailing list