From: <na...@us...> - 2009-08-14 07:23:07
|
Revision: 823 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=823&view=rev Author: nandod Date: 2009-08-14 07:22:59 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * D2009: Fixed error "implementation expected" when adding the first class to an otherwise empty model unit at design time. Modified Paths: -------------- trunk/Source/Core/InstantCode.pas Modified: trunk/Source/Core/InstantCode.pas =================================================================== --- trunk/Source/Core/InstantCode.pas 2009-08-14 07:18:46 UTC (rev 822) +++ trunk/Source/Core/InstantCode.pas 2009-08-14 07:22:59 UTC (rev 823) @@ -24,7 +24,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Steven Mitchell, + * Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell, * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen * * ***** END LICENSE BLOCK ***** *) @@ -6520,7 +6520,7 @@ function TInstantCodeWriter.GetStreamPos: Int64; begin - Result := inherited GetStreamPos + Origin.Offset; + Result := inherited GetStreamPos + (Origin.Offset * SizeOf(Char)); end; procedure TInstantCodeWriter.Indent; @@ -6536,7 +6536,7 @@ procedure TInstantCodeWriter.SetStreamPos(Value: Int64); begin - inherited SetStreamPos(Value - Origin.Offset); + inherited SetStreamPos(Value - (Origin.Offset * SizeOf(Char))); end; procedure TInstantCodeWriter.Unindent; @@ -8631,6 +8631,7 @@ try Writer := TInstantCodeWriter.Create(Stream); try + Writer.Origin := CursorPos; while IndentLevel > 0 do begin Writer.Indent; |
From: <dav...@us...> - 2009-08-14 08:30:30
|
Revision: 824 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=824&view=rev Author: davidvtaylor Date: 2009-08-14 08:30:21 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Fix for "ModelExplorer can cannot insert InstantRegisterClasses on an "empty" unit" under D2009 - Added logic to explicitly set the StartPos and EndPos of the newly added InitializationSection. Note: The design of the original logic is flawed and fails to properly initialize the position of newly inserted Code Sections. The code worked under previous versions of Delphi, but apparently largely by accident. A related coding error in TInstantCodeModifier.InsertObjectText corrected in Rev 815 appears to have masked this defect. Revision Links: -------------- http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=815&view=rev Modified Paths: -------------- trunk/Source/Core/InstantCode.pas Modified: trunk/Source/Core/InstantCode.pas =================================================================== --- trunk/Source/Core/InstantCode.pas 2009-08-14 07:22:59 UTC (rev 823) +++ trunk/Source/Core/InstantCode.pas 2009-08-14 08:30:21 UTC (rev 824) @@ -25,7 +25,7 @@ * * Contributor(s): * Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell, - * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen + * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen, David Taylor * * ***** END LICENSE BLOCK ***** *) @@ -8880,15 +8880,22 @@ var Section: TInstantCodeInitializationSection; + Origin: TInstantCodePos; Pos: TInstantCodePos; begin Section := Module.InitializationSection; if not Section.IsFiled then begin CursorPos := Module.ImplementationSection.EndPos; + Origin := CursorPos; InsertMode := imAfter; InsertObjectText(Section); + + // Set position of newly added Initialization section + Section.StartPos := Origin; + Section.EndPos := CursorPos; end; + CursorPos := Section.StartPos; SkipLine; if FindText(RegisterProcName) then |
From: <dav...@us...> - 2009-08-14 09:20:40
|
Revision: 825 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=825&view=rev Author: davidvtaylor Date: 2009-08-14 09:20:30 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Revert rev 824 changes in rev 823 corrected the issue Revision Links: -------------- http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=824&view=rev http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=823&view=rev Modified Paths: -------------- trunk/Source/Core/InstantCode.pas Modified: trunk/Source/Core/InstantCode.pas =================================================================== --- trunk/Source/Core/InstantCode.pas 2009-08-14 08:30:21 UTC (rev 824) +++ trunk/Source/Core/InstantCode.pas 2009-08-14 09:20:30 UTC (rev 825) @@ -25,7 +25,7 @@ * * Contributor(s): * Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell, - * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen, David Taylor + * Uberto Barbini, Joao Morais, Riceball Lee, Brian Andersen * * ***** END LICENSE BLOCK ***** *) @@ -8880,22 +8880,15 @@ var Section: TInstantCodeInitializationSection; - Origin: TInstantCodePos; Pos: TInstantCodePos; begin Section := Module.InitializationSection; if not Section.IsFiled then begin CursorPos := Module.ImplementationSection.EndPos; - Origin := CursorPos; InsertMode := imAfter; InsertObjectText(Section); - - // Set position of newly added Initialization section - Section.StartPos := Origin; - Section.EndPos := CursorPos; end; - CursorPos := Section.StartPos; SkipLine; if FindText(RegisterProcName) then |
From: <wp...@us...> - 2009-12-19 16:27:27
|
Revision: 878 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=878&view=rev Author: wp2udk Date: 2009-12-19 16:27:18 +0000 (Sat, 19 Dec 2009) Log Message: ----------- Delphi 2010 Extension: When including Custom Attributes in an IO Model the code parser failed and you got a message saying that Txxx class was not registered when running the application. The fix simply moves the parser beyond the Custom Attributes. This is not a specific implementation for D2010 (no compiler directives are included). It should compile into older versions of D2010 without any problems. If you are using a Delphi version prior to D2010 the IDE will simply throw a Syntax error if you try to use Custom Attributes. A code example: TAddress = class(TInstantObject) {IOMETADATA City: String(30); PostalCode: String(8); Street: String(30); } [MyAttr('x')] <--- D2010 Custom Attribute _City: TInstantString; _PostalCode: TInstantString; _Street: TInstantString; private [MyAttr('x')] <--- D2010 Custom Attribute function GetCity: string; function GetPostalCode: string; function GetStreet: string; procedure SetCity(const Value: string); procedure SetPostalCode(const Value: string); procedure SetStreet(const Value: string); published property City: string read GetCity write SetCity; property PostalCode: string read GetPostalCode write SetPostalCode; property Street: string read GetStreet write SetStreet; end; Modified Paths: -------------- trunk/Source/Core/InstantCode.pas Modified: trunk/Source/Core/InstantCode.pas =================================================================== --- trunk/Source/Core/InstantCode.pas 2009-10-14 05:53:23 UTC (rev 877) +++ trunk/Source/Core/InstantCode.pas 2009-12-19 16:27:18 UTC (rev 878) @@ -495,6 +495,12 @@ TInstantCodeContainerMethodFlag = (mfIndex, mfValue, mfResult); TInstantCodeContainerMethodFlags = set of TInstantCodeContainerMethodFlag; + TInstantCodeRttiAttribute = class(TInstantCodeMember) + protected + class function InternalAtInstance(Reader: TInstantCodeReader; out Name: string): Boolean; override; + procedure InternalRead(Reader: TInstantCodeReader); override; + end; + TInstantCodeAttributeTailor = class(TObject) private FAddMethod: TInstantCodeMethod; @@ -2858,13 +2864,15 @@ Result := TInstantCodeField.AtInstance(Reader) or TInstantCodeMethod.AtInstance(Reader) or - TInstantCodeProperty.AtInstance(Reader); + TInstantCodeProperty.AtInstance(Reader) or + TInstantCodeRttiAttribute.AtInstance(Reader); end; procedure TInstantCodeMembers.InternalRead(Reader: TInstantCodeReader); begin ReadObjects(Reader, - [TInstantCodeField, TInstantCodeMethod, TInstantCodeProperty]); + [TInstantCodeField, TInstantCodeMethod, TInstantCodeProperty, + TInstantCodeRttiAttribute]); end; procedure TInstantCodeMembers.InternalWrite(Writer: TInstantCodeWriter); @@ -3286,6 +3294,32 @@ FTypeLink.Name := Value; end; +{ TInstantCodeRttiAttribute } + +class function TInstantCodeRttiAttribute.InternalAtInstance( + Reader: TInstantCodeReader; out Name: string): Boolean; +begin + Result := Reader.ReadChar = '['; + if Result then + Name := Reader.ReadToken else + Name := ''; +end; + +procedure TInstantCodeRttiAttribute.InternalRead(Reader: TInstantCodeReader); +var + BracketCount: Integer; + C: Char; +begin + inherited; + + BracketCount := 0; + repeat + C := Reader.ReadChar; + if C = '[' then Inc(BracketCount) else + if C = ']' then Dec(BracketCount); + until BracketCount = 0; +end; + { TInstantCodeAttributeTailor } procedure TInstantCodeAttributeTailor.AddCountProp; @@ -9032,4 +9066,3 @@ DestroyTypeProcessors; end. - |
From: <na...@us...> - 2010-10-04 13:23:28
|
Revision: 930 http://instantobjects.svn.sourceforge.net/instantobjects/revision/?rev=930&view=rev Author: nandod Date: 2010-10-04 13:23:21 +0000 (Mon, 04 Oct 2010) Log Message: ----------- + Support for class-level RTTI attributes in model files (meaning they are now ignored by the parser instead of raising Invalid class typecast exceptions). Modified Paths: -------------- trunk/Source/Core/InstantCode.pas Modified: trunk/Source/Core/InstantCode.pas =================================================================== --- trunk/Source/Core/InstantCode.pas 2010-10-01 17:57:28 UTC (rev 929) +++ trunk/Source/Core/InstantCode.pas 2010-10-04 13:23:21 UTC (rev 930) @@ -495,12 +495,18 @@ TInstantCodeContainerMethodFlag = (mfIndex, mfValue, mfResult); TInstantCodeContainerMethodFlags = set of TInstantCodeContainerMethodFlag; - TInstantCodeRttiAttribute = class(TInstantCodeMember) + TInstantCodeMemberRttiAttribute = class(TInstantCodeMember) protected class function InternalAtInstance(Reader: TInstantCodeReader; out Name: string): Boolean; override; procedure InternalRead(Reader: TInstantCodeReader); override; end; + TInstantCodeClassRttiAttribute = class(TInstantCodeType) + protected + class function InternalAtInstance(Reader: TInstantCodeReader; out Name: string): Boolean; override; + procedure InternalRead(Reader: TInstantCodeReader); override; + end; + TInstantCodeAttributeTailor = class(TObject) private FAddMethod: TInstantCodeMethod; @@ -2865,14 +2871,14 @@ TInstantCodeField.AtInstance(Reader) or TInstantCodeMethod.AtInstance(Reader) or TInstantCodeProperty.AtInstance(Reader) or - TInstantCodeRttiAttribute.AtInstance(Reader); + TInstantCodeMemberRttiAttribute.AtInstance(Reader); end; procedure TInstantCodeMembers.InternalRead(Reader: TInstantCodeReader); begin ReadObjects(Reader, [TInstantCodeField, TInstantCodeMethod, TInstantCodeProperty, - TInstantCodeRttiAttribute]); + TInstantCodeMemberRttiAttribute]); end; procedure TInstantCodeMembers.InternalWrite(Writer: TInstantCodeWriter); @@ -3294,10 +3300,8 @@ FTypeLink.Name := Value; end; -{ TInstantCodeRttiAttribute } - -class function TInstantCodeRttiAttribute.InternalAtInstance( - Reader: TInstantCodeReader; out Name: string): Boolean; +function _RttiAttributeAtInstance(Reader: TInstantCodeReader; + out Name: string): Boolean; begin Result := Reader.ReadChar = '['; if Result then @@ -3306,13 +3310,11 @@ Name := ''; end; -procedure TInstantCodeRttiAttribute.InternalRead(Reader: TInstantCodeReader); +procedure _RttiAttributeRead(Reader: TInstantCodeReader); var BracketCount: Integer; C: Char; begin - inherited; - BracketCount := 0; repeat C := Reader.ReadChar; @@ -3323,6 +3325,33 @@ until BracketCount = 0; end; +{ TInstantCodeMemberRttiAttribute } + +class function TInstantCodeMemberRttiAttribute.InternalAtInstance( + Reader: TInstantCodeReader; out Name: string): Boolean; +begin + Result := _RttiAttributeAtInstance(Reader, Name); +end; + +procedure TInstantCodeMemberRttiAttribute.InternalRead(Reader: TInstantCodeReader); +begin + _RttiAttributeRead(Reader); +end; + +{ TInstantCodeClassRttiAttribute } + +class function TInstantCodeClassRttiAttribute.InternalAtInstance( + Reader: TInstantCodeReader; out Name: string): Boolean; +begin + Result := _RttiAttributeAtInstance(Reader, Name); +end; + +procedure TInstantCodeClassRttiAttribute.InternalRead( + Reader: TInstantCodeReader); +begin + _RttiAttributeRead(Reader); +end; + { TInstantCodeAttributeTailor } procedure TInstantCodeAttributeTailor.AddCountProp; @@ -5795,7 +5824,7 @@ ReadObjects(Reader, [TInstantCodeRecord, TInstantCodeClassRef, TInstantCodeClassForward, TInstantCodeClass, TInstantCodeInterface, TInstantCodeDispInterface, TInstantCodeEnum, TInstantCodeSet, - TInstantCodeTypeDef, TInstantCodeProcType, TInstantCodeRttiAttribute, + TInstantCodeTypeDef, TInstantCodeProcType, TInstantCodeClassRttiAttribute, TInstantCodeUnknownType]); end; |