Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2000-05

dealing with objects' properties

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

dvortex

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 ?

(my idea this morning, please let me know if this is completly stupid :o) it's the morning after all :o)

Thanks
Jok

Reply by email

dvortex
to mariano podesta: IMHO the best way is to code a class to manage rtti instead of functions…

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

mariano podesta wrote 173 lines
IMHO the best way is to code a class to manage rtti instead of functions --------------------------------------- mariano podesta > -----Original Message----- > From: dvortex > Sent: Martes 2 de Mayo (5) de 2000 12:02 > To: > 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 with > > "unsubscribe" as the Subject > > archives at http://www.miraclec.com/list_archives/lazarus > > > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.miraclec.com/list_archives/lazarus > _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Michael Van Canneyt
to dvortex: I was waking up this morning after a short night of sleep, and i realized that maybe i…
dvortex wrote 17 lines
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.

Reply by email

mariano podesta
to dvortex: very good point michael ! :o) as i said ... morning idea :o) i will do it as you suggest…

IMHO the best way is to code a class to manage rtti instead of functions

---------------------------------------
mariano podesta

Show quoted text 158 lines
-----Original Message----- From: dvortex Sent: Martes 2 de Mayo (5) de 2000 12:02 To: 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 with > "unsubscribe" as the Subject > archives at http://www.miraclec.com/list_archives/lazarus > _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

dvortex
to Michael Van Canneyt: And it would increase all existing code unnecessary much because it is in the system…

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)

Michael Van Canneyt wrote 113 lines
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 with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

Reply by email