Browse Source

* Patch from Dariusz Mazur to fix compilation with Delphi

git-svn-id: trunk@13602 -
michael 16 years ago
parent
commit
612d58c80f
3 changed files with 40 additions and 16 deletions
  1. 15 9
      packages/fcl-xml/src/dom.pp
  2. 21 5
      packages/fcl-xml/src/xmlutils.pp
  3. 4 2
      packages/fcl-xml/src/xmlwrite.pp

+ 15 - 9
packages/fcl-xml/src/dom.pp

@@ -43,6 +43,10 @@ uses
 // -------------------------------------------------------
 // -------------------------------------------------------
 //   DOMException
 //   DOMException
 // -------------------------------------------------------
 // -------------------------------------------------------
+{$ifndef fpc}
+type
+  tFpList = tList;
+{$endif}
 
 
 const
 const
 
 
@@ -101,6 +105,8 @@ type
   TDOMAttrDef = class;
   TDOMAttrDef = class;
   PNodePool = ^TNodePool;
   PNodePool = ^TNodePool;
   TNodePool = class;
   TNodePool = class;
+  TTabNodePool = array[0..0] of TNodePool;
+  PTabNodePool = ^TTabNodePool;
 
 
 
 
 // -------------------------------------------------------
 // -------------------------------------------------------
@@ -430,7 +436,7 @@ type
     FEmptyNode: TDOMElement;
     FEmptyNode: TDOMElement;
     FNodeLists: THashTable;
     FNodeLists: THashTable;
     FMaxPoolSize: Integer;
     FMaxPoolSize: Integer;
-    FPools: PNodePool;
+    FPools: PTabNodePool;
     FDocumentURI: DOMString;
     FDocumentURI: DOMString;
     function GetDocumentElement: TDOMElement;
     function GetDocumentElement: TDOMElement;
     function GetDocType: TDOMDocumentType;
     function GetDocType: TDOMDocumentType;
@@ -3167,24 +3173,24 @@ var
   sz: Integer;
   sz: Integer;
 begin
 begin
   ext := FCurrExtent;
   ext := FCurrExtent;
-  ptr := Pointer(FCurrBlock) + FElementSize;
+  ptrInt(ptr) := ptrInt(FCurrBlock) + FElementSize;
   sz := FCurrExtentSize;
   sz := FCurrExtentSize;
   while Assigned(ext) do
   while Assigned(ext) do
   begin
   begin
     // call destructors for everyone still there
     // call destructors for everyone still there
-    ptr_end := Pointer(ext) + sizeof(TExtent) + (sz - 1) * FElementSize;
-    while ptr <= ptr_end do
+    ptrInt(ptr_end) := ptrInt(ext) + sizeof(TExtent) + (sz - 1) * FElementSize;
+    while ptrInt(ptr) <= ptrInt(ptr_end) do
     begin
     begin
       if TDOMNode(ptr).FPool = Self then
       if TDOMNode(ptr).FPool = Self then
         TObject(ptr).Destroy;
         TObject(ptr).Destroy;
-      Inc(ptr, FElementSize);
+      Inc(ptrInt(ptr), FElementSize);
     end;
     end;
     // dispose the extent and pass to the next one
     // dispose the extent and pass to the next one
     next := ext^.Next;
     next := ext^.Next;
     FreeMem(ext);
     FreeMem(ext);
     ext := next;
     ext := next;
     sz := sz div 2;
     sz := sz div 2;
-    ptr := Pointer(ext) + sizeof(TExtent);
+    ptrInt(ptr) := ptrInt(ext) + sizeof(TExtent);
   end;
   end;
   inherited Destroy;
   inherited Destroy;
 end;
 end;
@@ -3194,13 +3200,13 @@ var
   ext: PExtent;
   ext: PExtent;
 begin
 begin
   Assert((FCurrExtent = nil) or
   Assert((FCurrExtent = nil) or
-    (Pointer(FCurrBlock) = Pointer(FCurrExtent) + sizeof(TExtent)));
+    (ptrInt(FCurrBlock) = ptrInt(FCurrExtent) + sizeof(TExtent)));
   Assert(AElemCount > 0);
   Assert(AElemCount > 0);
 
 
   GetMem(ext, sizeof(TExtent) + AElemCount * FElementSize);
   GetMem(ext, sizeof(TExtent) + AElemCount * FElementSize);
   ext^.Next := FCurrExtent;
   ext^.Next := FCurrExtent;
   // point to the beginning of the last block of extent
   // point to the beginning of the last block of extent
-  FCurrBlock := TDOMNode(Pointer(ext) + sizeof(TExtent) + (AElemCount - 1) * FElementSize);
+  FCurrBlock := TDOMNode(ptrInt(ext) + sizeof(TExtent) + (AElemCount - 1) * FElementSize);
   FCurrExtent := ext;
   FCurrExtent := ext;
   FCurrExtentSize := AElemCount;
   FCurrExtentSize := AElemCount;
 end;
 end;
@@ -3214,7 +3220,7 @@ begin
   end
   end
   else
   else
   begin
   begin
-    if Pointer(FCurrBlock) = Pointer(FCurrExtent) + sizeof(TExtent) then
+    if ptrInt(FCurrBlock) = ptrInt(FCurrExtent) + sizeof(TExtent) then
       AddExtent(FCurrExtentSize * 2);
       AddExtent(FCurrExtentSize * 2);
     Result := FCurrBlock;
     Result := FCurrBlock;
     Dec(PChar(FCurrBlock), FElementSize);
     Dec(PChar(FCurrBlock), FElementSize);

+ 21 - 5
packages/fcl-xml/src/xmlutils.pp

@@ -14,14 +14,20 @@
  **********************************************************************}
  **********************************************************************}
 unit xmlutils;
 unit xmlutils;
 
 
-{$mode objfpc}
-{$H+}
+{$ifdef fpc}
+{$MODE objfpc}{$H+}
+{$endif}
 
 
 interface
 interface
 
 
 uses
 uses
   SysUtils;
   SysUtils;
 
 
+ {$IFNDEF FPC}
+
+type   ptrint=integer;
+{$ENDIF} 
+
 function IsXmlName(const Value: WideString; Xml11: Boolean = False): Boolean; overload;
 function IsXmlName(const Value: WideString; Xml11: Boolean = False): Boolean; overload;
 function IsXmlName(Value: PWideChar; Len: Integer; Xml11: Boolean = False): Boolean; overload;
 function IsXmlName(Value: PWideChar; Len: Integer; Xml11: Boolean = False): Boolean; overload;
 function IsXmlNames(const Value: WideString; Xml11: Boolean = False): Boolean;
 function IsXmlNames(const Value: WideString; Xml11: Boolean = False): Boolean;
@@ -38,6 +44,7 @@ function WStrLIComp(S1, S2: PWideChar; Len: Integer): Integer;
 { a simple hash table with WideString keys }
 { a simple hash table with WideString keys }
 
 
 type
 type
+  PTabPHashItem = ^TTabPHashItem;
   PPHashItem = ^PHashItem;
   PPHashItem = ^PHashItem;
   PHashItem = ^THashItem;
   PHashItem = ^THashItem;
   THashItem = record
   THashItem = record
@@ -46,6 +53,7 @@ type
     Next: PHashItem;
     Next: PHashItem;
     Data: TObject;
     Data: TObject;
   end;
   end;
+  TTabPHashItem = array[0..0] of pHashItem;
 
 
   THashForEach = function(Entry: PHashItem; arg: Pointer): Boolean;
   THashForEach = function(Entry: PHashItem; arg: Pointer): Boolean;
 
 
@@ -53,7 +61,7 @@ type
   private
   private
     FCount: LongWord;
     FCount: LongWord;
     FBucketCount: LongWord;
     FBucketCount: LongWord;
-    FBucket: PPHashItem;
+    FBucket: PTabPHashItem;
     FOwnsObjects: Boolean;
     FOwnsObjects: Boolean;
     function Lookup(Key: PWideChar; KeyLength: Integer; var Found: Boolean; CanCreate: Boolean): PHashItem;
     function Lookup(Key: PWideChar; KeyLength: Integer; var Found: Boolean; CanCreate: Boolean): PHashItem;
     procedure Resize(NewCapacity: LongWord);
     procedure Resize(NewCapacity: LongWord);
@@ -82,12 +90,15 @@ type
     lname: PWideChar;
     lname: PWideChar;
     lnameLen: Integer;
     lnameLen: Integer;
   end;
   end;
+  PTabExpHashEntry = ^TTabExpHashEntry;
+  tTabExpHashEntry = array[0..0] of   TExpHashEntry;
+
 
 
   TDblHashArray = class(TObject)
   TDblHashArray = class(TObject)
   private
   private
     FSizeLog: Integer;
     FSizeLog: Integer;
     FRevision: LongWord;
     FRevision: LongWord;
-    FData: PExpHashEntry;
+    FData: PTabExpHashEntry;
   public  
   public  
     procedure Init(NumSlots: Integer);
     procedure Init(NumSlots: Integer);
     function Locate(uri: PWideString; localName: PWideChar; localLength: Integer): Boolean;
     function Locate(uri: PWideString; localName: PWideChar; localLength: Integer): Boolean;
@@ -347,7 +358,11 @@ end;
 
 
 function KeyCompare(const Key1: WideString; Key2: Pointer; Key2Len: Integer): Boolean;
 function KeyCompare(const Key1: WideString; Key2: Pointer; Key2Len: Integer): Boolean;
 begin
 begin
+  {$IFDEF FPC}
   Result := (Length(Key1)=Key2Len) and (CompareWord(Pointer(Key1)^, Key2^, Key2Len) = 0);
   Result := (Length(Key1)=Key2Len) and (CompareWord(Pointer(Key1)^, Key2^, Key2Len) = 0);
+  {$ELSE}
+  Result := comparemem(Pointer(Key1),key2,key2len*2);
+  {$ENDIF}
 end;
 end;
 
 
 { THashTable }
 { THashTable }
@@ -461,7 +476,8 @@ end;
 
 
 procedure THashTable.Resize(NewCapacity: LongWord);
 procedure THashTable.Resize(NewCapacity: LongWord);
 var
 var
-  p, chain: PPHashItem;
+  p    : PTabPHashItem;
+  chain: PPHashItem;
   i: Integer;
   i: Integer;
   e, n: PHashItem;
   e, n: PHashItem;
 begin
 begin

+ 4 - 2
packages/fcl-xml/src/xmlwrite.pp

@@ -17,8 +17,10 @@
 
 
 unit XMLWrite;
 unit XMLWrite;
 
 
-{$MODE objfpc}
-{$H+}
+
+{$ifdef fpc}
+{$MODE objfpc}{$H+}
+{$endif}
 
 
 interface
 interface