From: Carlo B. <car...@us...> - 2005-05-02 23:26:44
|
Update of /cvsroot/instantobjects/Source/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14611/Source/Core Modified Files: InstantClasses.pas InstantCode.pas InstantDefines.inc InstantPersistence.pas InstantPresentation.pas InstantRtti.pas InstantUtils.pas Added Files: InstantFpcUtils.pas Log Message: Chanfes for porting to FPC-Lazarus project. Some other little changes to remove uses to forms for non-visual level of IO. Index: InstantCode.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantCode.pas,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** InstantCode.pas 5 Apr 2005 00:35:28 -0000 1.14 --- InstantCode.pas 2 May 2005 23:26:32 -0000 1.15 *************** *** 25,29 **** * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Steven Mitchell, * Joao Morais * --- 25,29 ---- * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Steven Mitchell, , Uberto Barbini * Joao Morais * *************** *** 2845,2850 **** end; ! function CompareMembers(List: TStringList; ! Index1, Index2: Integer): Integer; overload; begin Result := CompareMembers(List.Objects[Index1], List.Objects[Index2]); --- 2845,2850 ---- end; ! function CompareMembersList(List: TStringList; ! Index1, Index2: Integer): Integer; begin Result := CompareMembers(List.Objects[Index1], List.Objects[Index2]); *************** *** 4912,4917 **** end; ! function CompareDivisions(List: TStringList; ! Index1, Index2: Integer): Integer; overload; begin Result := CompareDivisions(List.Objects[Index1], List.Objects[Index2]); --- 4912,4917 ---- end; ! function CompareDivisionsList(List: TStringList; ! Index1, Index2: Integer): Integer; begin Result := CompareDivisions(List.Objects[Index1], List.Objects[Index2]); *************** *** 4922,4926 **** begin Result := FindNearest(FDivisions, Division, Prior, Next, nil, nil, ! CompareDivisions); end; --- 4922,4926 ---- begin Result := FindNearest(FDivisions, Division, Prior, Next, nil, nil, ! CompareDivisionsList); end; *************** *** 4938,4942 **** List := FMembers; Result := FindNearest(List, Instance, Prior, Next, VisibilityFilter, ! @Visibilities, CompareMembers); end; --- 4938,4942 ---- List := FMembers; Result := FindNearest(List, Instance, Prior, Next, VisibilityFilter, ! @Visibilities, CompareMembersList); end; Index: InstantPresentation.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantPresentation.pas,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** InstantPresentation.pas 11 Apr 2005 08:29:55 -0000 1.15 --- InstantPresentation.pas 2 May 2005 23:26:33 -0000 1.16 *************** *** 638,645 **** uses {$IFDEF MSWINDOWS} ! Controls, Mask, Forms, {$ENDIF} {$IFDEF LINUX} ! QControls, QMask, QForms, {$ENDIF} {$IFDEF D6+}Variants, MaskUtils, FmtBcd,{$ENDIF} InstantClasses, --- 638,645 ---- uses {$IFDEF MSWINDOWS} ! //Forms, {$ENDIF} {$IFDEF LINUX} ! QForms, {$ENDIF} {$IFDEF D6+}Variants, MaskUtils, FmtBcd,{$ENDIF} InstantClasses, *************** *** 1640,1647 **** --- 1640,1649 ---- if ATypeInfo = TypeInfo(TDateTime) then Result := DB.ftDateTime + (* else if ATypeInfo = TypeInfo(TDate) then Result := DB.ftDate else if ATypeInfo = TypeInfo(TTime) then Result := DB.ftTime + *) else Result := DB.ftFloat; *************** *** 4123,4127 **** Exposer.DataEvent(deFieldChange, Integer(Field)); except ! Application.HandleException(Self); end; inherited Destroy; --- 4125,4130 ---- Exposer.DataEvent(deFieldChange, Integer(Field)); except ! if Assigned(Classes.ApplicationHandleException) then ! Classes.ApplicationHandleException(Self); end; inherited Destroy; Index: InstantPersistence.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantPersistence.pas,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** InstantPersistence.pas 8 Apr 2005 10:16:08 -0000 1.36 --- InstantPersistence.pas 2 May 2005 23:26:32 -0000 1.37 *************** *** 26,30 **** * Contributor(s): * Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell, ! * Joao Morais, Cesar Coll * * ***** END LICENSE BLOCK ***** *) --- 26,30 ---- * Contributor(s): * Carlo Barazzetta, Andrea Petrelli, Nando Dessena, Steven Mitchell, ! * Joao Morais, Cesar Coll, Uberto Barbini * * ***** END LICENSE BLOCK ***** *) *************** *** 49,52 **** --- 49,55 ---- QGraphics, {$ENDIF} + {$IFDEF FPC} + InstantFpcUtils, + {$ENDIF} Classes, Contnrs, SysUtils, DB, InstantClasses, InstantCommand, InstantConsts; *************** *** 1203,1207 **** --- 1206,1214 ---- function ChangesDisabled: Boolean; procedure CheckId; + {$IFDEF FPC} + class function ClassType: TInstantObjectClass; + {$ELSE} function ClassType: TInstantObjectClass; + {$ENDIF} procedure ClearObjects; function Clone(AConnector: TInstantConnector = nil): TInstantObject; overload; *************** *** 2443,2452 **** uses {$IFDEF MSWINDOWS} ! Windows, Mask, {$ENDIF} {$IFDEF LINUX} Types, {$ENDIF} ! TypInfo, {$IFDEF D6+}MaskUtils, Variants,{$ENDIF} InstantUtils, InstantRtti, InstantDesignHook, InstantCode; --- 2450,2465 ---- uses {$IFDEF MSWINDOWS} ! Windows, {$ENDIF} {$IFDEF LINUX} Types, {$ENDIF} ! TypInfo, ! {$IFDEF D6+} ! MaskUtils, ! Variants, ! {$ELSE} ! Mask, ! {$ENDIF} InstantUtils, InstantRtti, InstantDesignHook, InstantCode; *************** *** 7259,7263 **** --- 7272,7280 ---- end; + {$IFDEF FPC} + class function TInstantObject.ClassType: TInstantObjectClass; + {$ELSE} function TInstantObject.ClassType: TInstantObjectClass; + {$ENDIF} begin Result := TInstantObjectClass(inherited ClassType); *************** *** 8375,8378 **** --- 8392,8396 ---- Destroy; Self := nil; + {$IFNDEF FPC} //UB it raise an error in FPC, surely there'd be better ways to accomplish this asm MOV [EBP - $09], EAX // Avoid calling AfterConstruction *************** *** 8380,8383 **** --- 8398,8402 ---- ADD ESP, $0C end; + {$ENDIF} end; end; *************** *** 11991,11995 **** --- 12010,12018 ---- begin with Attribute do + {$IFDEF FPC} + FieldByName(Metadata.FieldName).AsFloat := Value; + {$ELSE} FieldByName(Metadata.FieldName).AsCurrency := Value; + {$ENDIF} end; *************** *** 14744,14748 **** --- 14767,14773 ---- var Instance: Cardinal; + {$IFNDEF FPC} LibModule: PLibModule; + {$ENDIF} begin if HasModelResource(HInstance)then *************** *** 14751,14754 **** --- 14776,14780 ---- LoadModelFromResource(MainInstance) else begin + {$IFNDEF FPC} LibModule := LibModuleList; while LibModule <> nil do *************** *** 14763,14766 **** --- 14789,14793 ---- LibModule := LibModule.Next; end; + {$ENDIF} end; end; *************** *** 14894,14898 **** {$IFDEF MSWINDOWS} GraphicClassList[gffBmp] := Graphics.TBitmap; ! GraphicClassList[gffEmf] := Graphics.TMetaFile; {$ENDIF} {$IFDEF LINUX} --- 14921,14927 ---- {$IFDEF MSWINDOWS} GraphicClassList[gffBmp] := Graphics.TBitmap; ! {$IFNDEF FPC} ! GraphicClassList[gffEmf] := Graphics.TMetaFile; ! {$ENDIF} {$ENDIF} {$IFDEF LINUX} Index: InstantUtils.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantUtils.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InstantUtils.pas 22 Feb 2005 08:05:04 -0000 1.3 --- InstantUtils.pas 2 May 2005 23:26:33 -0000 1.4 *************** *** 25,29 **** * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli, Nando Dessena * * ***** END LICENSE BLOCK ***** *) --- 25,29 ---- * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli, Nando Dessena, Uberto Barbini * * ***** END LICENSE BLOCK ***** *) *************** *** 96,99 **** --- 96,102 ---- Windows, ActiveX, ComObj, {$ENDIF} + {$IFDEF FPC} + InstantFpcUtils, + {$ENDIF} {$IFDEF D6+}Variants,{$ENDIF} InstantConsts, InstantRtti, SysUtils; *************** *** 177,181 **** S2 := ''; if coPartial in Options then ! S := Copy(S1, 1, Length(S2)) else S := S1; --- 180,184 ---- S2 := ''; if coPartial in Options then ! S := Copy(S1, 1, Length(VarToStr(S2))) else S := S1; Index: InstantRtti.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantRtti.pas,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InstantRtti.pas 23 Aug 2004 09:55:20 -0000 1.4 --- InstantRtti.pas 2 May 2005 23:26:33 -0000 1.5 *************** *** 25,29 **** * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli: porting Kylix * * ***** END LICENSE BLOCK ***** *) --- 25,29 ---- * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli, Uberto Barbini * * ***** END LICENSE BLOCK ***** *) *************** *** 71,74 **** --- 71,75 ---- end; + function GetTypeInfo(PropInfo: PPropInfo) : PTypeInfo; procedure InstantGetEnumNames(TypeInfo: PTypeInfo; Names: TStrings; PrefixLen: Integer = 0); *************** *** 84,88 **** uses {$IFDEF MSWINDOWS} ! Controls, {$ENDIF} {$IFDEF LINUX} --- 85,89 ---- uses {$IFDEF MSWINDOWS} ! // Controls, {$ENDIF} {$IFDEF LINUX} *************** *** 92,95 **** --- 93,105 ---- {$IFDEF D6+}Variants,{$ENDIF}SysUtils; + function GetTypeInfo(PropInfo: PPropInfo) : PTypeInfo; + begin + {$IFDEF FPC} + Result := PropInfo^.PropType; + {$ELSE} + Result := PropInfo^.PropType^; + {$ENDIF} + end; + function AccessProperty(AObject: TObject; PropPath: string; Value: Variant): Variant; *************** *** 109,115 **** else if Assigned(PropInfo) then begin ! if (Value <> Null) and Assigned(PropInfo.SetProc) then begin ! case PropInfo^.PropType^^.Kind of tkClass: SetObjectProp(AObject, PropInfo, TObject(Integer(Value))); --- 119,125 ---- else if Assigned(PropInfo) then begin ! if not VarIsNull(Value) and Assigned(PropInfo.SetProc) then begin ! case GetTypeInfo(PropInfo)^.Kind of tkClass: SetObjectProp(AObject, PropInfo, TObject(Integer(Value))); *************** *** 188,192 **** if Assigned(PInstance) and Assigned(TObject(PInstance^)) then TObject(PInstance^) := GetObjectProp(TObject(PInstance^), PropInfo); ! TypeData := GetTypeData(PropInfo^.PropType^); if Assigned(TypeData) then Result := InstantGetPropInfo(TypeData.ClassType, PropPath, PInstance) --- 198,202 ---- if Assigned(PInstance) and Assigned(TObject(PInstance^)) then TObject(PInstance^) := GetObjectProp(TObject(PInstance^), PropInfo); ! TypeData := GetTypeData(GetTypeInfo(PropInfo)); if Assigned(TypeData) then Result := InstantGetPropInfo(TypeData.ClassType, PropPath, PInstance) *************** *** 303,306 **** --- 313,319 ---- TypeKinds = [tkInteger, tkChar, tkEnumeration, tkFloat, tkString, tkSet, tkClass, tkWChar, tkLString, tkWString, + {$IFDEF FPC} + tkAString, tkBool, + {$ENDIF} tkVariant, tkArray, tkRecord, tkInt64, tkDynArray]; begin *************** *** 401,407 **** end; PropInfo := PropInfos[Index]; ! if PropInfo^.PropType^^.Kind = tkFloat then begin ! if GetTypeData(PropInfo^.PropType^).FloatType = ftCurr then begin CurrencyValue := GetFloatProp(FInstance, PropInfo); --- 414,420 ---- end; PropInfo := PropInfos[Index]; ! if GetTypeInfo(PropInfo)^.Kind = tkFloat then begin ! if GetTypeData(GetTypeInfo(PropInfo)).FloatType = ftCurr then begin CurrencyValue := GetFloatProp(FInstance, PropInfo); *************** *** 410,416 **** begin Value := GetFloatProp(FInstance, PropInfo); ! if (PropInfo.PropType^ = TypeInfo(TDateTime)) ! or (PropInfo.PropType^ = TypeInfo(TDate)) ! or (PropInfo.PropType^ = TypeInfo(TTime)) then Result := VarFromDateTime(Value) else --- 423,430 ---- begin Value := GetFloatProp(FInstance, PropInfo); ! if (GetTypeInfo(PropInfo) = TypeInfo(TDateTime)) ! // or (PropInfo.PropType^ = TypeInfo(TDate)) ! // or (PropInfo.PropType^ = TypeInfo(TTime)) ! then Result := VarFromDateTime(Value) else Index: InstantDefines.inc =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantDefines.inc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InstantDefines.inc 25 Feb 2005 17:01:54 -0000 1.4 --- InstantDefines.inc 2 May 2005 23:26:32 -0000 1.5 *************** *** 24,26 **** {$DEFINE D9} {$DEFINE D9+} ! {$ENDIF} \ No newline at end of file --- 24,42 ---- {$DEFINE D9} {$DEFINE D9+} ! {$ENDIF} ! ! {$IFDEF FPC} ! {$DEFINE D5+} ! {$DEFINE D6+} ! {$DEFINE D7+} ! {$DEFINE SUPPORTS_WIDESTRING} ! {$DEFINE SUPPORTS_INTERFACE} ! {$DEFINE SUPPORTS_INT64} ! {$DEFINE SUPPORTS_DYNAMICARRAYS} ! {$DEFINE SUPPORTS_DEFAULTPARAMS} ! {$DEFINE SUPPORTS_OVERLOAD} ! {$ASMMODE Intel} ! {$MODE DELPHI} ! {$UNDEF UseRegAsm} ! {$ENDIF} ! --- NEW FILE: InstantFpcUtils.pas --- unit InstantFpcUtils; {$mode objfpc}{$H+} interface uses Classes, SysUtils, RtlConsts, Db; procedure OleError(ErrorCode: HResult); procedure OleCheck(Result: HResult); implementation uses typinfo, variants; function OleResult(Res: HResult): Boolean; begin Result := Res and $80000000 = 0; end; { Raise EOleSysError exception from an error code } procedure OleError(ErrorCode: HResult); begin // raise EOleSysError.Create('', ErrorCode, 0); raise Exception.CreateFmt('OleError %d',[ErrorCode]); end; { Raise EOleSysError exception if result code indicates an error } procedure OleCheck(Result: HResult); begin if not OleResult(Result) then OleError(Result); end; end. Index: InstantClasses.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantClasses.pas,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** InstantClasses.pas 21 Mar 2005 16:48:04 -0000 1.6 --- InstantClasses.pas 2 May 2005 23:26:32 -0000 1.7 *************** *** 25,29 **** * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli, Marco Cantù, Nando Dessena * * ***** END LICENSE BLOCK ***** *) --- 25,29 ---- * * Contributor(s): ! * Carlo Barazzetta, Adrea Petrelli, Marco Cantù, Nando Dessena, Uberto Barbini * * ***** END LICENSE BLOCK ***** *) *************** *** 42,46 **** uses ! {$IFDEF VER130}Windows,{$ENDIF} Classes, InstantConsts, SysUtils; --- 42,49 ---- uses ! {$IFDEF MSWINDOWS}Windows,{$ENDIF} ! {$IFDEF FPC} ! InstantFpcUtils, streamex, ! {$ENDIF} Classes, InstantConsts, SysUtils; *************** *** 70,73 **** --- 73,87 ---- end; + {$IFDEF FPC} + TAbstractWriter = class(TDelphiWriter); + {$ELSE} + TAbstractWriter = class(TWriter); + {$ENDIF} + {$IFDEF FPC} + TAbstractReader = class(TDelphiReader); + {$ELSE} + TAbstractReader = class(TReader); + {$ENDIF} + TInstantReader = class; TInstantWriter = class; *************** *** 153,157 **** end; ! TInstantReader = class(TReader) private FStream: TStream; --- 167,171 ---- end; ! TInstantReader = class(TAbstractReader) private FStream: TStream; *************** *** 170,174 **** end; ! TInstantWriter = class(TWriter) private FStream: TStream; --- 184,188 ---- end; ! TInstantWriter = class(TAbstractWriter) private FStream: TStream; *************** *** 240,254 **** FStream: TStream; FTagStack: TStringList; ! FWriter: TWriter; function GetCurrentTag: string; function GetEof: Boolean; function GetPosition: Integer; function GetTagStack: TStringList; ! function GetWriter: TWriter; procedure SetPosition(Value: Integer); procedure WriteString(const S: string); protected property TagStack: TStringList read GetTagStack; ! property Writer: TWriter read GetWriter; public constructor Create(Stream: TStream); --- 254,268 ---- FStream: TStream; FTagStack: TStringList; ! FWriter: TAbstractWriter; function GetCurrentTag: string; function GetEof: Boolean; function GetPosition: Integer; function GetTagStack: TStringList; ! function GetWriter: TAbstractWriter; procedure SetPosition(Value: Integer); procedure WriteString(const S: string); protected property TagStack: TStringList read GetTagStack; ! property Writer: TAbstractWriter read GetWriter; public constructor Create(Stream: TStream); *************** *** 268,276 **** TInstantXMLProcessor = class(TObject) private ! FReader: TReader; FStream: TStream; function GetEof: Boolean; function GetPosition: Integer; ! function GetReader: TReader; function GetToken: TInstantXMLToken; function ReadEscapedChar: Char; --- 282,290 ---- TInstantXMLProcessor = class(TObject) private ! FReader: TAbstractReader; FStream: TStream; function GetEof: Boolean; function GetPosition: Integer; ! function GetReader: TAbstractReader; function GetToken: TInstantXMLToken; function ReadEscapedChar: Char; *************** *** 281,285 **** function ReadChar: Char; procedure SkipBlanks; ! property Reader: TReader read GetReader; public constructor Create(Stream: TStream); --- 295,299 ---- function ReadChar: Char; procedure SkipBlanks; ! property Reader: TAbstractReader read GetReader; public constructor Create(Stream: TStream); *************** *** 1301,1308 **** end; ! function TInstantXMLProducer.GetWriter: TWriter; begin if not Assigned(FWriter) then ! FWriter := TWriter.Create(Stream, InstantBufferSize); Result := FWriter; end; --- 1315,1322 ---- end; ! function TInstantXMLProducer.GetWriter: TAbstractWriter; begin if not Assigned(FWriter) then ! FWriter := TAbstractWriter.Create(Stream, InstantBufferSize); Result := FWriter; end; *************** *** 1407,1414 **** end; ! function TInstantXMLProcessor.GetReader: TReader; begin if not Assigned(FReader) then ! FReader := TReader.Create(Stream, InstantBufferSize); Result := Freader; end; --- 1421,1428 ---- end; ! function TInstantXMLProcessor.GetReader: TAbstractReader; begin if not Assigned(FReader) then ! FReader := TAbstractReader.Create(Stream, InstantBufferSize); Result := Freader; end; *************** *** 1766,1772 **** const StopTag: string); ! procedure ConvertOrdValue(PropType: PPTypeInfo; Value: Integer); begin ! case PropType^^.Kind of tkInteger: Writer.WriteInteger(Value); --- 1780,1786 ---- const StopTag: string); ! (* procedure ConvertOrdValue(PropType: PTypeInfo; Value: Integer); begin ! case PropType^.Kind of tkInteger: Writer.WriteInteger(Value); *************** *** 1774,1781 **** Writer.WriteChar(Chr(Value)); tkEnumeration: ! Writer.WriteIdent(GetEnumName(PropType^, Value)); end; end; ! procedure ConvertProperty(PropInfo: PPropInfo); var --- 1788,1795 ---- Writer.WriteChar(Chr(Value)); tkEnumeration: ! Writer.WriteIdent(GetEnumName(PropType, Value)); end; end; ! *) procedure ConvertProperty(PropInfo: PPropInfo); var *************** *** 1787,1800 **** ValueStr := Processor.ReadData; Writer.WriteStr(PropName); ! case PropInfo^.PropType^^.Kind of tkInteger: Writer.WriteInteger(StrToInt(ValueStr)); tkFloat: begin ! if GetTypeData(PropInfo^.PropType^).FloatType = ftCurr then Writer.WriteCurrency(StrToCurr(ValueStr)) else Writer.WriteFloat(StrToFloat(ValueStr)); end; tkString, tkLString, tkChar: Writer.WriteString(ValueStr); --- 1801,1820 ---- ValueStr := Processor.ReadData; Writer.WriteStr(PropName); ! case GetTypeInfo(PropInfo)^.Kind of //PropInfo^.PropType^^.Kind of tkInteger: Writer.WriteInteger(StrToInt(ValueStr)); tkFloat: begin ! if GetTypeData(GetTypeInfo(PropInfo)(*PropInfo^.PropType^*)).FloatType = ftCurr then Writer.WriteCurrency(StrToCurr(ValueStr)) else Writer.WriteFloat(StrToFloat(ValueStr)); end; + {$IFDEF FPC} + tkAString: + Writer.WriteString(ValueStr); + tkBool: + Writer.WriteIdent(ValueStr); + {$ENDIF} tkString, tkLString, tkChar: Writer.WriteString(ValueStr); |