From: <sr...@us...> - 2006-11-29 03:55:09
|
Revision: 725 http://svn.sourceforge.net/instantobjects/revision/?rev=725&view=rev Author: srmitch Date: 2006-11-28 19:55:06 -0800 (Tue, 28 Nov 2006) Log Message: ----------- - Update for Object Foundry to support MM9. - Updated and renamed 'OF_readme.txt' to 'ObjectFoundry_readme.txt' and moved it into the main Docs folder. - Introduced an 'ObjectFoundry.inc' file to simplify future MM version support. Modified Paths: -------------- trunk/Source/Design/InstantAttributeEditor.pas trunk/Source/ObjectFoundry/OFClassRegWizard.pas trunk/Source/ObjectFoundry/OFClasses.pas trunk/Source/ObjectFoundry/OFCritic.pas trunk/Source/ObjectFoundry/OFDefs.pas trunk/Source/ObjectFoundry/OFExpert.pas trunk/Source/ObjectFoundry/OFNotify.pas trunk/Source/ObjectFoundry/OFOptions.pas trunk/Source/ObjectFoundry/OFReg.pas trunk/Source/ObjectFoundry/OFUtils.pas Added Paths: ----------- trunk/Docs/ObjectFoundry_readme.txt trunk/Source/ObjectFoundry/ObjectFoundry.inc Removed Paths: ------------- trunk/Source/ObjectFoundry/OF_readme.txt Added: trunk/Docs/ObjectFoundry_readme.txt =================================================================== --- trunk/Docs/ObjectFoundry_readme.txt (rev 0) +++ trunk/Docs/ObjectFoundry_readme.txt 2006-11-29 03:55:06 UTC (rev 725) @@ -0,0 +1,72 @@ +ObjectFoundry (for IO V2.x) Readme +by Carlo Wolter/Steven Mitchell - 21 Mar 2005 +Revised by Steven Mitchell: 29 Nov 2006 + +Introduction +------------ +This file contains instructions and information for the +Object Foundry (OF) integration between IO version 2 and +ModelMaker(c)[http://www.modelmakertools.com]. + +ModelMaker (MM) is an UML designer integrated with Delphi. +It can be used also for InstantObject design, provided +you place the + OFExpt.dll +expert file in the + $(ProgramFiles)\ModelMakerTools\ModelMaker\x.x\Experts +directory. MM detects and loads it during startup and +"ObjectFoundry enabled" is included on the MM startup splash +screen. It is also listed in the "Plug in expert manager" +dialog launched from the Tools/Expert Manager menu option +in MM. + +Currently MM versions 6 to 9 are supported with OF. + +Compiling +--------- +This DLL can be compiled using the project in this directory. + +Please take note that the project needs to know where the +MM Expert files are. Therefore make sure the subdir + $(ProgramFiles)\ModelMakerTools\ModelMaker\x.x\Experts +is in the project options search path + (ie Project/Options/Directories-Conditionals/SearchPath). +This is required because in the MM experts directory there is +a single file that is needed: + MMToolsApi.PAS +Also ensure that the appropriate compiler defines are entered +in the project options Conditional defines (see table below). +(ie Project/Options/Directories-Conditionals/Conditional defines) + + MM Version Define + ---------- ------ + 6.x [none] + 7.x or 8.x MM7+ + 9.x MM9 + +Note: The MMToolsApi.PAS file is protected by copyright of +ModelMakerTools and cannot be put into CVS. Every legitimate +owner of a MM licence, though, should have no problems in +finding it. + +Notes on Usage +-------------- +To operate correctly, this version of OF expects and +generates the IO Metadata identifier tag in the class +metadata info as follows: +"{IOMETADATA " (without quotes but including trailing space). + +Conversion of IO MM projects that did not have the IO +Metadata identifier tag: +Make sure that the model is up to date then save and close +Modelmaker. Backup the MM project file. Backup any previous +'OFExpt.dll' file and copy the new 'OFExpt.dll' file to the +{$Modelmaker}\Experts folder as indicated above. Re-open +Modelmaker. Re-generating the Delphi code from ModelMaker +should update the model code units to include the new class +metadata identifier tag. + +Feedback +-------- +Please report any problems to the IO news support group at +"news.instantobjects.org/instantobjects.org.support". Property changes on: trunk/Docs/ObjectFoundry_readme.txt ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/Source/Design/InstantAttributeEditor.pas =================================================================== --- trunk/Source/Design/InstantAttributeEditor.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/Design/InstantAttributeEditor.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -132,6 +132,7 @@ private FBaseClassStorageName: string; FLimited: Boolean; + FMMUninitializedNewAttribute: Boolean; FModel: TInstantCodeModel; FOnIsClassPersistent: TInstantBooleanEvent; FOnLoadClasses: TInstantStringsEvent; @@ -219,10 +220,14 @@ ObjectClassEdit.Items.Add(FModel.Classes[I].Name); end else if Assigned(ObjectClassEdit.Field) and - (ObjectClassEdit.Field.AsString <> '') then + (ObjectClassEdit.Field.AsString <> '') and + not FMMUninitializedNewAttribute then ObjectClassEdit.Items.Add(ObjectClassEdit.Field.AsString) else if Assigned(FOnLoadClasses) then + begin OnLoadClasses(Self, ObjectClassEdit.Items, NeedOnlyPersistentClasses); + FMMUninitializedNewAttribute := True; + end; if Assigned(ObjectClassEdit.Field) then ObjectClassEdit.ItemIndex := @@ -392,6 +397,8 @@ begin SubjectExposer.AssignFieldValue(ObjectClassEdit.Field, ObjectClassEdit.Text); UpdateControls; + if StorageKindEdit.Items.Count = 0 then + LoadStorageKind; end; procedure TInstantAttributeEditorForm.ObjectClassEditEnter( Modified: trunk/Source/ObjectFoundry/OFClassRegWizard.pas =================================================================== --- trunk/Source/ObjectFoundry/OFClassRegWizard.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFClassRegWizard.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,11 +30,13 @@ unit OFClassRegWizard; +{$I ObjectFoundry.inc} + interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, - StdCtrls, CheckLst, MMToolsAPI, ComCtrls; + StdCtrls, CheckLst, MMToolsAPI, OFDefs, ComCtrls; type TClassRegWizardForm = class(TForm) @@ -206,7 +208,26 @@ Result := False; end; +{$IFDEF MM9} var + UnitManager: IMMModuleManager; + AUnit: IMMModule; + I: Integer; +begin + UnitList.Clear; + UnitManager := MMToolServices.ModuleManager; + if Assigned(UnitManager) then + begin + for I := 0 to Pred(UnitManager.ModuleCount) do + begin + AUnit := UnitManager.Modules[I]; + if UnitHasPersistentClass(AUnit) then + UnitList.Add(AUnit); + end; + end; +end; +{$ELSE} +var UnitManager: IMMUnitManager; AUnit: IMMUnit; I: Integer; @@ -223,6 +244,7 @@ end; end; end; +{$ENDIF} procedure TClassRegWizardForm.OkButtonClick(Sender: TObject); begin @@ -244,7 +266,11 @@ AUnit := Units[I]; with Items.Add do begin + {$IFDEF MM9} + Caption := ExtractFileName(AUnit.RelModuleName); + {$ELSE} Caption := ExtractFileName(AUnit.RelUnitName); + {$ENDIF} Data := Pointer(AUnit); Checked := True; end; Modified: trunk/Source/ObjectFoundry/OFClasses.pas =================================================================== --- trunk/Source/ObjectFoundry/OFClasses.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFClasses.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,13 +30,7 @@ unit OFClasses; -{ 18 Sep 2004 - Steven Mitchell - Modified for use in MM7.25 - - Use V9Visibility property inplace of Visibility - property in MMToolsAPI V10 IMMMember interface. - 30 Sep 2004 - Steven Mitchell - Added tags for part(s) external storage params -} +{$I ObjectFoundry.inc} interface @@ -113,10 +107,17 @@ finally EndOld; end; + {$IFDEF MM9} + if Prop.Classifier.FindMember(OldCountPropName, Index) then + begin + Member := Prop.Classifier.Members[Index]; + Result := MemberAsProperty(Member); + {$ELSE} if Prop.ClassBase.FindMember(OldCountPropName, Index) then begin Member := Prop.ClassBase.Members[Index]; Result := MemberAsProperty(Member); + {$ENDIF} end else Result := nil; end; @@ -130,15 +131,23 @@ Result := FindCountProp; if not Assigned(Result) then begin + {$IFDEF MM9} + Result := Prop.Classifier.AddProperty; + {$ELSE} Result := Prop.ClassBase.AddProperty; + {$ENDIF} Attribute.LinkMember(Result.Id); end; Result.Name := CountPropName; -{$IFDEF MM7+} // SRM begin - 16 Mar 2005 +{$IFDEF MM7+} + {$IFDEF MM9} + Result.Visibility := InstantCodeVisibilityToMMVisibility(Visibility); + {$ELSE} Result.V9Visibility := TV9Visibility(Visibility); + {$ENDIF} {$ELSE} Result.Visibility := TVisibility(Visibility); -{$ENDIF} // SRM end - 16 Mar 2005 +{$ENDIF} Result.SetAccessSpec(rwMethod, rwNone); Getter := MemberAsMethod(Result.ReadMember); if Assigned(Getter) then @@ -208,7 +217,11 @@ begin BeginOld; try + {$IFDEF MM9} + Result := Prop.Classifier.FindMethod(GetMethodName(MT)); + {$ELSE} Result := Prop.ClassBase.FindMethod(GetMethodName(MT)); + {$ENDIF} finally EndOld; end; @@ -235,7 +248,11 @@ begin Result := FindMethod(MT); if not Assigned(Result) then + {$IFDEF MM9} + Result := Prop.Classifier.AddMethod; + {$ELSE} Result := Prop.ClassBase.AddMethod; + {$ENDIF} Attribute.LinkMember(Result.Id); Result.Name := CodeMethod.Name; Result.Parameters := CodeMethod.Proc.Parameters.AsString; @@ -245,11 +262,15 @@ Result.MethodKind := MMEngineDefs.mkFunction; Result.DataName := CodeMethod.Proc.ResultTypeName; end; -{$IFDEF MM7+} // SRM begin - 16 Mar 2005 +{$IFDEF MM7+} + {$IFDEF MM9} + Result.Visibility := InstantCodeVisibilityToMMVisibility(Visibility); + {$ELSE} Result.V9Visibility := TV9Visibility(Visibility); + {$ENDIF} {$ELSE} Result.Visibility := TVisibility(Visibility); -{$ENDIF} // SRM end - 16 Mar 2005 +{$ENDIF} NewBody := CodeMethod.Proc.Body.AsString; if Result.SectionCount = 0 then Result.AddSection(NewBody) @@ -297,11 +318,15 @@ begin Prop.Name := Name; Prop.DataName := PropTypeName; -{$IFDEF MM7+} // SRM begin - 16 Mar 2005 +{$IFDEF MM7+} + {$IFDEF MM9} + Prop.Visibility := InstantCodeVisibilityToMMVisibility(Visibility); + {$ELSE} Prop.V9Visibility := TV9Visibility(Visibility); + {$ENDIF} {$ELSE} Prop.Visibility := TVisibility(Visibility); -{$ENDIF} // SRM end - 16 Mar 2005 +{$ENDIF} TaggedStrings['StorageName'] := StorageName; // External part(s) options TaggedStrings['ExternalStorageName'] := ExternalStorageName; @@ -418,7 +443,11 @@ function TMMCodeAttribute.HasMethod(const Name: string): Boolean; begin + {$IFDEF MM9} + Result := Assigned(Prop.Classifier.FindMethod(Name)); + {$ELSE} Result := Assigned(Prop.ClassBase.FindMethod(Name)); + {$ENDIF} end; function TMMCodeAttribute.IsOld: Boolean; @@ -439,13 +468,23 @@ for MT := Low(MT) to High(MT) do if MT in MethodTypes then begin + {$IFDEF MM9} + Method := Prop.Classifier.FindMethod(GetMethodName(MT)); + {$ELSE} Method := Prop.ClassBase.FindMethod(GetMethodName(MT)); + {$ENDIF} if Assigned(Method) then Attribute.LinkMember(Method.Id); end; + {$IFDEF MM9} + if Prop.Classifier.FindMember(CountPropName, Index) then + begin + Member := Prop.Classifier.Members[Index]; + {$ELSE} if Prop.ClassBase.FindMember(CountPropName, Index) then begin Member := Prop.ClassBase.Members[Index]; + {$ENDIF} CountProp := MemberAsProperty(Member); Attribute.LinkMember(CountProp.Id); end; @@ -456,7 +495,11 @@ FieldTypeName: string; begin Name := Prop.Name; - Visibility := TInstantCodeVisibility(Prop.V9Visibility); // SRM - 18 Sep 2004 + {$IFDEF MM9} + Visibility := MMVisibilityToInstantCodeVisibility(Prop.Visibility); + {$ELSE} + Visibility := TInstantCodeVisibility(Prop.V9Visibility); + {$ENDIF} if Attribute.IsIOAttribute then begin { If the type of attribute field is Integer (which is considered Modified: trunk/Source/ObjectFoundry/OFCritic.pas =================================================================== --- trunk/Source/ObjectFoundry/OFCritic.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFCritic.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,6 +30,8 @@ unit OFCritic; +{$I ObjectFoundry.inc} + interface uses Windows, SysUtils, Classes, MMEngineDefs, MMToolsApi, MMCriticsBase; Modified: trunk/Source/ObjectFoundry/OFDefs.pas =================================================================== --- trunk/Source/ObjectFoundry/OFDefs.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFDefs.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,21 +30,30 @@ unit OFDefs; +{$I ObjectFoundry.inc} + interface - -{$IFDEF MM7+} uses - MMToolsAPI, MMDiagramAPI; + MMToolsAPI + {$IFDEF MM7+} + , MMDiagramAPI + {$ENDIF} + ; type +{$IFDEF MM7+} + {$IFDEF MM9} + IMMUnit = IMMModule; + IMMUnitManager = IMMModuleManager; + IMMV9ClassBase = IMMClassifier; + IMMV9CodeModel = IMMCodeModel; + IMMClassBase = IMMClassifier; + {$ELSE} IMMV9ClassBase = IMMClassBase; IMMV9CodeModel = IMMCodeModel; + {$ENDIF} {$ELSE} -uses - MMToolsAPI; - -type TMMActionData = record Caption: WideString; // ModelMaker provides a defaults name based on to the menu item name ImageIndex: Integer; // Default = -1; Only used for toolbuttons, ignored for menu items @@ -58,7 +67,6 @@ end; {$ENDIF} -type IOFReference = IMMReference; IOFEntityReference = IMMEntityReference; Modified: trunk/Source/ObjectFoundry/OFExpert.pas =================================================================== --- trunk/Source/ObjectFoundry/OFExpert.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFExpert.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,6 +30,8 @@ unit OFExpert; +{$I ObjectFoundry.inc} + interface uses @@ -207,7 +209,11 @@ begin if Assigned(P) and P.Valid then begin + {$IFDEF MM9} + lClass := P.Classifier; + {$ELSE} lClass := P.ClassBase; + {$ENDIF} Attribute := TMMCodeAttribute.Create(P); AttributeValidator := TMMAttributeValidator.Create(Attribute, P); try @@ -615,21 +621,30 @@ if MMInterface = nil then Exit; MMProperty := MMInterface as IMMProperty; + {$IFDEF MM9} + CodeClass := MMProperty.Classifier; + {$ELSE} + CodeClass := MMProperty.ClassBase; + {$ENDIF} - if MMProperty.ClassBase.FindMember(Attribute.Name, I) then - raise Exception.Create('Attribute Name already used'); + // check that the new attribute name is not used in parent class + // except by itself + if CodeClass.FindMember(Attribute.Name, I) and + (CodeClass.Members[I] <> MMProperty) then + raise Exception.Create('Attribute Name already used'); - // check that the same attribute name is not used in an ancestor class - CodeClass := MMProperty.ClassBase; + // check that the new attribute name is not used in any child class + CheckChildClass(CodeClass); + + // check that the new attribute name is not used in an ancestor class + CodeClass := CodeClass.Ancestor; while (CodeClass <> nil) do begin if CodeClass.FindMember(Attribute.Name, I) then raise Exception.CreateFmt('Attribute "%s" exists in ancestor class "%s"', [Attribute.Name, CodeClass.Name]); - CodeClass := CodeClass.Ancestor; + CodeClass := CodeClass.Ancestor; end; - // check that the same attribute name is not used in any child class - CheckChildClass(MMProperty.ClassBase); end; end. Modified: trunk/Source/ObjectFoundry/OFNotify.pas =================================================================== --- trunk/Source/ObjectFoundry/OFNotify.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFNotify.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,6 +30,8 @@ unit OFNotify; +{$I ObjectFoundry.inc} + interface uses SysUtils, Classes, MMEngineDefs, MMToolsApi; Modified: trunk/Source/ObjectFoundry/OFOptions.pas =================================================================== --- trunk/Source/ObjectFoundry/OFOptions.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFOptions.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,6 +30,8 @@ unit OFOptions; +{$I ObjectFoundry.inc} + interface uses Modified: trunk/Source/ObjectFoundry/OFReg.pas =================================================================== --- trunk/Source/ObjectFoundry/OFReg.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFReg.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,6 +30,8 @@ unit OFReg; +{$I ObjectFoundry.inc} + interface uses Modified: trunk/Source/ObjectFoundry/OFUtils.pas =================================================================== --- trunk/Source/ObjectFoundry/OFUtils.pas 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OFUtils.pas 2006-11-29 03:55:06 UTC (rev 725) @@ -30,10 +30,12 @@ unit OFUtils; +{$I ObjectFoundry.inc} + interface uses - MMToolsAPI, MMIOAPI, OFDefs; + MMToolsAPI, MMIOAPI, MMEngineDefs, OFDefs, InstantCode; function ClassAsV9ClassBase(AClass: IMMClassBase): IMMV9ClassBase; function CodeModelAsV9CodeModel(ACodeModel: IMMCodeModel): IMMV9CodeModel; @@ -47,6 +49,12 @@ function MemberAsAttributeProperty(Member: IMMMember): IMMProperty; function SameCode(const Code1, Code2: string): Boolean; +function MMVisibilityToInstantCodeVisibility(const Value: TVisibility): + TInstantCodeVisibility; + +function InstantCodeVisibilityToMMVisibility(const Value: + TInstantCodeVisibility): TVisibility; + implementation uses @@ -135,4 +143,23 @@ Result := SameText(Trim(Code1), Trim(Code2)); end; +function MMVisibilityToInstantCodeVisibility(const Value: TVisibility): + TInstantCodeVisibility; +const + Map: array[TVisibility] of TInstantCodeVisibility = + (viDefault, viPrivate, viPrivate, viProtected, viProtected, + viPublic, viPublished, viPublished); +begin + Result := Map[Value]; +end; + +function InstantCodeVisibilityToMMVisibility(const Value: + TInstantCodeVisibility): TVisibility; +const + Map: array[TInstantCodeVisibility] of TVisibility = + (scDefault, scPrivate, scProtected, scPublic, scPublished); +begin + Result := Map[Value]; +end; + end. Deleted: trunk/Source/ObjectFoundry/OF_readme.txt =================================================================== --- trunk/Source/ObjectFoundry/OF_readme.txt 2006-11-29 03:30:29 UTC (rev 724) +++ trunk/Source/ObjectFoundry/OF_readme.txt 2006-11-29 03:55:06 UTC (rev 725) @@ -1,64 +0,0 @@ -ObjectFoundry (for IO V2) Readme -by Carlo Wolter/Steven Mitchell - 21 Mar 2005 - -Introduction ------------- -This file contains instructions and information for the -Object Foundry (OF) integration between IO version 2 and -ModelMaker(c). - -ModelMaker (MM) is an UML designer integrated with Delphi. -It can be used also for InstantObject design, provided -you place the - OFExpt.dll -expert file in the - $(ProgramFiles)\ModelMakerTools\ModelMaker\x.x\Experts -directory. MM detects and loads it during startup and -"ObjectFoundry enabled" is included on the MM startup splash -screen. It is also listed in the "Plug in expert manager" -dialog launched from the Tools/Expert Manager menu option -in MM. - -Compiling ---------- -This DLL can be compiled using the project in this directory. - -Please take note that the project needs to know where the -MM Expert files are. Therefore make sure the subdir - $(ProgramFiles)\ModelMakerTools\ModelMaker\x.x\Experts -is in the project options search path - (ie Project/Options/Directories-Conditionals/SearchPath). -This is required because in the MM experts directory there is -a single file that is needed: - MMToolsApi.PAS -Also ensure that 'MM7+' is defined in the project options -Conditional defines - (ie Project/Options/Directories-Conditionals/Conditional defines) -when using version 7 or higher of MM. - -Note: The MMToolsApi.PAS file is protected by copyright of -ModelMakerTools and cannot be put into CVS. Every legitimate -owner of a MM licence, though, should have no problems in -finding it. - -Notes on Usage --------------- -To operate correctly, this version of OF expects and -generates the IO Metadata identifier tag in the class -metadata info as follows: -"{IOMETADATA " (without quotes but including trailing space). - -Conversion of IO MM projects that did not have the IO -Metadata identifier tag: -Make sure that the model is up to date then save and close -Modelmaker. Backup the MM project file. Backup any previous -'OFExpt.dll' file and copy the new 'OFExpt.dll' file to the -{$Modelmaker}\Experts folder as indicated above. Re-open -Modelmaker. Re-generating the Delphi code from ModelMaker -should update the model code units to include the new class -metadata identifier tag. - -Feedback --------- -Please report any problems to the IO news groups at -"news.instantobjects.org". Added: trunk/Source/ObjectFoundry/ObjectFoundry.inc =================================================================== --- trunk/Source/ObjectFoundry/ObjectFoundry.inc (rev 0) +++ trunk/Source/ObjectFoundry/ObjectFoundry.inc 2006-11-29 03:55:06 UTC (rev 725) @@ -0,0 +1,3 @@ +{$IFDEF MM9} + {$DEFINE MM7+} +{$ENDIF} Property changes on: trunk/Source/ObjectFoundry/ObjectFoundry.inc ___________________________________________________________________ Name: svn:eol-style + native |