Skip to content
Permalink
Browse files

Android ARM/AARCH64 compatibility by Alfred

- from #275
  • Loading branch information
Arnaud Bouchez
Arnaud Bouchez committed Mar 4, 2020
1 parent 11049be commit 7fb7546ebd0d941c014df3ece09b7e73f00b8ab7
Showing with 91 additions and 74 deletions.
  1. +59 −32 SQLite3/mORMot.pas
  2. +7 −11 SynCommons.pas
  3. +16 −22 SynFPCTypInfo.pas
  4. +2 −4 SynSelfTests.pas
  5. +2 −4 SynTests.pas
  6. +4 −0 Synopse.inc
  7. +1 −1 SynopseCommit.inc
@@ -627,7 +627,8 @@ procedure AddID(var Values: TIDDynArray; Value: TID); overload;
// - this is the main process for marshalling JSON into SQL statements
// - used e.g. by GetJSONObjectAsSQL() function or ExecuteFromJSON and
// InternalBatchStop methods
{$ifdef UNICODE}TJSONObjectDecoder = record{$else}TJSONObjectDecoder = object{$endif}
{$ifdef FPC_OR_UNICODE}TJSONObjectDecoder = record
{$else}TJSONObjectDecoder = object{$endif}
public
/// contains the decoded field names
FieldNames: array[0..MAX_SQLFIELDS-1] of RawUTF8;
@@ -1127,7 +1128,8 @@ function JSONFileToObject(const JSONFile: TFileName; var ObjectInstance;
/// store information about a class, able to easily create new instances
// - using this temporary storage will speed up the creation process
// - any virtual constructor will be used, including for TCollection types
{$ifdef UNICODE}TClassInstance = record{$else}TClassInstance = object{$endif}
{$ifdef FPC_OR_UNICODE}TClassInstance = record
{$else}TClassInstance = object{$endif}
public
/// the class type itself
ItemClass: TClass;
@@ -1186,7 +1188,8 @@ {$ifdef UNICODE}TClassInstance = record{$else}TClassInstance = object{$endif}
// as in the TypInfo.GetPropInfos() PPropList usage
// - for TSQLRecord, you should better use the RecordProps.Fields[] array,
// which is faster and contains the properties published in parent classes
{$ifdef UNICODE}TClassProp = record{$else}TClassProp = object{$endif}
{$ifdef FPC_OR_UNICODE}TClassProp = record
{$else}TClassProp = object{$endif}
public
/// number of published properties in this object
PropCount: Word;
@@ -1206,7 +1209,8 @@ {$ifdef UNICODE}TClassProp = record{$else}TClassProp = object{$endif}

PClassType = ^TClassType;
/// a wrapper to class type information, as defined by the Delphi RTTI
{$ifdef UNICODE}TClassType = record{$else}TClassType = object{$endif}
{$ifdef FPC_OR_UNICODE}TClassType = record
{$else}TClassType = object{$endif}
public
/// the class type
ClassType: TClass;
@@ -1235,7 +1239,8 @@ {$ifdef UNICODE}TClassType = record{$else}TClassType = object{$endif}
// - we use this to store the enumeration values as integer, but easily provide
// a text equivalent, translated if necessary, from the enumeration type
// definition itself
{$ifdef UNICODE}TEnumType = record{$else}TEnumType = object{$endif}
{$ifdef FPC_OR_UNICODE}TEnumType = record
{$else}TEnumType = object{$endif}
public
/// specify ordinal storage size and sign
// - is prefered to MaxValue to identify the number of stored bytes
@@ -1409,7 +1414,8 @@ TInterfaceTypeData = record
{$push}
{$PACKRECORDS 1}
{$endif}
{$ifdef UNICODE}TTypeInfo = record{$else}TTypeInfo = object{$endif}
{$ifdef FPC_OR_UNICODE}TTypeInfo = record
{$else}TTypeInfo = object{$endif}
public
/// the value type family
Kind: TTypeKind;
@@ -1493,7 +1499,8 @@ {$ifdef UNICODE}TTypeInfo = record{$else}TTypeInfo = object{$endif}
/// a wrapper containing a RTTI property definition
// - used for direct Delphi / UTF-8 SQL type mapping/conversion
// - doesn't depend on RTL's TypInfo unit, to enhance cross-compiler support
{$ifdef UNICODE}TPropInfo = packed record{$else}TPropInfo = packed object{$endif}
{$ifdef FPC_OR_UNICODE}TPropInfo = packed record
{$else}TPropInfo = object{$endif} { "packed" above is needed on ARM (alf) }
public
/// raw retrieval of the property read access definition
// - note: 'var Call' generated incorrect code on Delphi XE4 -> use PMethod
@@ -1820,7 +1827,8 @@ {$ifdef UNICODE}TTypeInfo = record{$else}TTypeInfo = object{$endif}
PParamInfo = ^TParamInfo;

/// a wrapper around method returned result definition
{$ifdef UNICODE}TReturnInfo = record{$else}TReturnInfo = object{$endif}
{$ifdef FPC_OR_UNICODE}TReturnInfo = record
{$else}TReturnInfo = object{$endif}
public
/// RTTI version
// - 2 up to Delphi 2010, 3 for Delphi XE and up
@@ -1840,7 +1848,8 @@ {$ifdef UNICODE}TReturnInfo = record{$else}TReturnInfo = object{$endif}
end;

/// a wrapper around an individual method parameter definition
{$ifdef UNICODE}TParamInfo = record{$else}TParamInfo = object{$endif}
{$ifdef FPC_OR_UNICODE}TParamInfo = record
{$else}TParamInfo = object{$endif}
public
/// the kind of parameter
Flags: TParamFlags;
@@ -1863,7 +1872,8 @@ {$ifdef UNICODE}TParamInfo = record{$else}TParamInfo = object{$endif}
end;

/// a wrapper around a method definition
{$ifdef UNICODE}TMethodInfo = record{$else}TMethodInfo = object{$endif}
{$ifdef FPC_OR_UNICODE}TMethodInfo = packed record
{$else}TMethodInfo = object{$endif}
public
{$ifdef FPC}
/// method name
@@ -1907,7 +1917,7 @@ {$ifdef UNICODE}TMethodInfo = record{$else}TMethodInfo = object{$endif}
/// =$ff for a ptField address, or =$fe for a ptVirtual method
Kind: byte;
end;
{$A+}
{$A+} // back to normal alignment
{$endif FPC}

const
@@ -3616,7 +3626,8 @@ function ToMethod(const method: RawUTF8): TSQLURIMethod;
// consolidated statistics
// - it will therefore store up to 24*365+365+12+1 = 9138 records per year
// in the associated storage engine (so there is no actual need to purge it)
{$ifdef UNICODE}TSynMonitorUsageID = record{$else}TSynMonitorUsageID = object{$endif}
{$ifdef FPC_OR_UNICODE}TSynMonitorUsageID = record
{$else}TSynMonitorUsageID = object{$endif}
public
/// the TID, as computed from time and granularity
Value: integer;
@@ -4484,7 +4495,8 @@ TServiceFactoryServer = class;

/// store all parameters for a Client or Server method call
// - as used by TSQLRestServer.URI or TSQLRestClientURI.InternalURI
{$ifdef UNICODE}TSQLRestURIParams = record{$else}TSQLRestURIParams = object{$endif}
{$ifdef FPC_OR_UNICODE}TSQLRestURIParams = record
{$else}TSQLRestURIParams = object{$endif}
public
/// input parameter containing the caller URI
Url: RawUTF8;
@@ -4750,7 +4762,8 @@ TSQLRestServerURIContextClass = class of TSQLRestServerURIContext;
/// set the User Access Rights, for each Table
// - one property for every and each URI method (GET/POST/PUT/DELETE)
// - one bit for every and each Table in Model.Tables[]
{$ifdef UNICODE}TSQLAccessRights = record{$else}TSQLAccessRights = object{$endif}
{$ifdef FPC_OR_UNICODE}TSQLAccessRights = record
{$else}TSQLAccessRights = object{$endif}
public
/// set of allowed actions on the server side
AllowRemoteExecute: TSQLAllowRemoteExecute;
@@ -7912,7 +7925,8 @@ TSQLTableWritable = class(TSQLTableJSON)
/// used to store the locked record list, in a specified table
// - the maximum count of the locked list if fixed to 512 by default,
// which seems correct for common usage
{$ifdef UNICODE}TSQLLocks = record{$else}TSQLLocks = object{$endif}
{$ifdef FPC_OR_UNICODE}TSQLLocks = record
{$else}TSQLLocks = object{$endif}
public
/// the number of locked records stored in this object
Count: integer;
@@ -8205,7 +8219,8 @@ TSQLModelRecordPropertiesSQL = record
// - in end user code, mostly MapField/MapFields/Options methods
// should be used, if needed as a fluent chained interface - other lower
// level methods will be used by the framework internals
{$ifdef UNICODE}TSQLRecordPropertiesMapping = record{$else}TSQLRecordPropertiesMapping = object{$endif}
{$ifdef FPC_OR_UNICODE}TSQLRecordPropertiesMapping = record
{$else}TSQLRecordPropertiesMapping = object{$endif}
private
/// storage of main read-only properties
fProps: TSQLRecordProperties;
@@ -8775,7 +8790,8 @@ TSQLModel = class
// depends on it to store the Table type
// - since 6 bits are used for the table index, the corresponding table
// MUST appear in the first 64 items of the associated TSQLModel.Tables[]
{$ifdef UNICODE}RecordRef = record{$else}RecordRef = object{$endif}
{$ifdef FPC_OR_UNICODE}RecordRef = record
{$else}RecordRef = object{$endif}
public
/// the value itself
// - (value and 63) is the TableIndex in the current database Model
vIsObjArray, vIsSPI, vIsQword, vIsDynArrayString, vIsDateTimeMS);

/// describe a service provider method argument
{$ifdef UNICODE}TServiceMethodArgument = record{$else}TServiceMethodArgument = object{$endif}
{$ifdef FPC_OR_UNICODE}TServiceMethodArgument = record
{$else}TServiceMethodArgument = object{$endif}
public
/// the argument name, as declared in Delphi
ParamName: PShortString;
TServiceMethodParamsDocVariantKind = (pdvArray, pdvObject, pdvObjectFixed);

/// describe an interface-based service provider method
{$ifdef UNICODE}TServiceMethod = record{$else}TServiceMethod = object{$endif}
{$ifdef FPC_OR_UNICODE}TServiceMethod = record
{$else}TServiceMethod = object{$endif}
public
/// the method URI, i.e. the method name
// - as declared in Delphi code, e.g. 'Add' for ICalculator.Add
end;

/// define the rules for a given method as used internaly by TInterfaceStub
{$ifdef UNICODE}TInterfaceStubRules = record{$else}TInterfaceStubRules = object{$endif}
{$ifdef FPC_OR_UNICODE}TInterfaceStubRules = record
{$else}TInterfaceStubRules = object{$endif}
public
/// the mocking / stubing rules associated to this method
Rules: array of TInterfaceStubRule;
TInterfaceStubLogLayouts = set of TInterfaceStubLogLayout;

/// used to keep track of one stubbed method call
{$ifdef UNICODE}TInterfaceStubLog = record{$else}TInterfaceStubLog = object{$endif}
{$ifdef FPC_OR_UNICODE}TInterfaceStubLog = record
{$else}TInterfaceStubLog = object{$endif}
public
/// call timestamp, in milliseconds
// - is filled with GetTickCount64() API returned value
/// server-side service provider uses this to store one internal instance
// - used by TServiceFactoryServer in sicClientDriven, sicPerSession,
// sicPerUser or sicPerGroup mode
{$ifdef UNICODE}TServiceFactoryServerInstance = record{$else}TServiceFactoryServerInstance = object{$endif}
{$ifdef FPC_OR_UNICODE}TServiceFactoryServerInstance = record
{$else}TServiceFactoryServerInstance = object{$endif}
public
/// the internal Instance ID, as remotely sent in "id":1
// - is set to 0 when an entry in the array is free
TSQLRestCacheEntryValueDynArray = array of TSQLRestCacheEntryValue;

/// for TSQLRestCache, stores a table settings and values
{$ifdef UNICODE}TSQLRestCacheEntry = record{$else}TSQLRestCacheEntry = object{$endif}
{$ifdef FPC_OR_UNICODE}TSQLRestCacheEntry = record
{$else}TSQLRestCacheEntry = object{$endif}
public
/// TRUE if this table should use caching
// - i.e. if was not set, or worth it for this table (e.g. in-memory table)
/// used to access a TSQLRestServer from its TSQLRestServerURIString URI
// - URI format is 'address:port/root', and may be transmitted as
// TSQLRestServerURIString text instances
{$ifdef UNICODE}TSQLRestServerURI = record{$else}TSQLRestServerURI = object{$endif}
{$ifdef FPC_OR_UNICODE}TSQLRestServerURI = record
{$else}TSQLRestServerURI = object{$endif}
private
function GetURI: TSQLRestServerURIString;
procedure SetURI(const Value: TSQLRestServerURIString);
/// used to publish all Services supported by a TSQLRestServer instance
// - as expected by TSQLRestServer.ServicesPublishedInterfaces
// - can be serialized as a JSON object via RecordLoadJSON/RecordSaveJSON
{$ifdef UNICODE}TServicesPublishedInterfaces = record{$else}TServicesPublishedInterfaces = object{$endif}
{$ifdef FPC_OR_UNICODE}TServicesPublishedInterfaces = record
{$else}TServicesPublishedInterfaces = object{$endif}
public
/// how this TSQLRestServer could be accessed
PublicURI: TSQLRestServerURI;

/// the WHERE and ORDER BY statements as set by TSQLVirtualTable.Prepare
// - Where[] and OrderBy[] are fixed sized arrays, for fast and easy code
{$ifdef UNICODE}TSQLVirtualTablePrepared = record{$else}TSQLVirtualTablePrepared = object{$endif}
{$ifdef FPC_OR_UNICODE}TSQLVirtualTablePrepared = record
{$else}TSQLVirtualTablePrepared = object{$endif}
public
/// number of WHERE statement parameters in Where[] array
WhereCount: integer;
// - code generated is very optimized: stack and memory usage, CPU registers
// prefered, multiplication avoided to calculate memory position from index,
// hand tuned assembler...
{$ifdef UNICODE}TUTF8QuickSort = record{$else}TUTF8QuickSort = object{$endif}
{$ifdef FPC_OR_UNICODE}TUTF8QuickSort = record
{$else}TUTF8QuickSort = object{$endif}
public
// sort parameters
Results: PPUtf8CharArray;
end;

type
{$ifdef UNICODE}TUTF8QuickSortMulti = record{$else}TUTF8QuickSortMulti = object{$endif}
{$ifdef FPC_OR_UNICODE}TUTF8QuickSortMulti = record
{$else}TUTF8QuickSortMulti = object{$endif}
public
Results: PPUtf8CharArray;
IDColumn: PPUtf8CharArray;
end;

type
/// wrapper class to ease JSONToObject() maintainability
{$ifdef UNICODE}TJSONToObject = record{$else}TJSONToObject = object{$endif}
/// wrapper object to ease JSONToObject() maintainability
TJSONToObject = object
public
// input parameters
From: PUTF8Char;
procedure Parse;
private
ValueClass: TClass;
IsObj: TJSONObject;
parser: PJSONCustomParser;
PropName, PropValue: PUTF8Char;
PropNameLen, PropValueLen: integer;
P: PPropInfo;
IsObj: TJSONObject;
Kind: TTypeKind;
EndOfObject: AnsiChar;
NestedValid, wasString: boolean;
parser.Value := TObject(ObjectInstance);
parser.Parse;
Valid := parser.Valid;
TObject(ObjectInstance) := parser.Value; // 'null' -> FreeAndNil()
TObject(ObjectInstance) := parser.Value; // e.g. 'null' -> FreeAndNil()
result := parser.Dest;
end;

@@ -3695,7 +3695,7 @@ function TemporaryFileName: TFileName;
/// file found result item, as returned by FindFiles()
// - Delphi "object" is buggy on stack -> also defined as record with methods
{$ifdef FPC_OR_UNICODE}TFindFiles = record
{$else}TFindFiles = object{$endif}
{$else}TFindFiles = object{$endif}
public
/// the matching file name, including its folder name
Name: TFileName;
@@ -4541,7 +4541,7 @@ function FromU64(const Values: array of QWord): TQWordDynArray;
/// used to store and retrieve Words in a sorted array
// - Delphi "object" is buggy on stack -> also defined as record with methods
{$ifdef FPC_OR_UNICODE}TSortedWordArray = record
{$else}TSortedWordArray = object{$endif}
{$else}TSortedWordArray = object{$endif}
public
/// the actual 16-bit word storage
Values: TWordDynArray;
@@ -4560,7 +4560,7 @@ {$ifdef FPC_OR_UNICODE}TSortedWordArray = record
/// used to store and retrieve Integers in a sorted array
// - Delphi "object" is buggy on stack -> also defined as record with methods
{$ifdef FPC_OR_UNICODE}TSortedIntegerArray = record
{$else}TSortedIntegerArray = object{$endif}
{$else}TSortedIntegerArray = object{$endif}
public
/// the actual 32-bit integers storage
Values: TIntegerDynArray;
@@ -6415,7 +6415,7 @@ TSynPersistentClass = class of TSynPersistent;
/// used to store one list of hashed RawUTF8 in TRawUTF8Interning pool
// - Delphi "object" is buggy on stack -> also defined as record with methods
{$ifdef FPC_OR_UNICODE}TRawUTF8InterningSlot = record
{$else}TRawUTF8InterningSlot = object{$endif}
{$else}TRawUTF8InterningSlot = object{$endif}
public
/// actual RawUTF8 storage
Value: TRawUTF8DynArray;
modname^ := #0;
FormatUTF8('% x % ('+CPU_ARCH_TEXT+')',[SystemInfo.dwNumberOfProcessors,beg],CpuInfoText);
end;
if Length(CpuInfoText)=0 then begin
CpuInfoText:=CPU_ARCH_TEXT;
end;
if CpuInfoText='' then
CpuInfoText := CPU_ARCH_TEXT;
end;

{$ifdef KYLIX3}
c := byte(P^);
until false;
dec(c,48);
c := byte(P^)-48;
if c>9 then
exit;
result := c;
recInitData := PFPCRecInitData(AlignTypeDataClean(PTypeInfo(info^.RecInitInfo+2+PByte(info^.RecInitInfo+1)^)));
firstfield := PFieldInfo(PtrUInt(@recInitData^.ManagedFieldCount));
inc(PByte(firstfield),SizeOf(recInitData^.ManagedFieldCount));
//firstfield := AlignToPtr(firstfield);
firstfield := AlignPTypeInfo(firstfield);
result := recInitData^.ManagedFieldCount;
end else begin
recInitData := PFPCRecInitData(aPointer);
firstfield := PFieldInfo(PtrUInt(@recInitData^.ManagedFieldCount));
inc(PByte(firstfield),SizeOf(recInitData^.ManagedFieldCount));
//firstfield := AlignToPtr(firstfield);
firstfield := AlignPTypeInfo(firstfield);
result := recInitData^.ManagedFieldCount;
end;

type
{$ifdef FPC_OR_UNICODE}TQuickSortDocVariantValuesByField = record
{$else}TQuickSortDocVariantValuesByField = object{$endif}
{$else}TQuickSortDocVariantValuesByField = object{$endif}
Lookup: array of PVariant;
Compare: TVariantCompare;
Doc: PDocVariantData;

0 comments on commit 7fb7546

Please sign in to comment.
You can’t perform that action at this time.