Skip to content
Permalink
Browse files

small refactoring pass (no functional change)

  • Loading branch information...
Arnaud Bouchez
Arnaud Bouchez committed Jul 26, 2019
1 parent d2fcf4c commit dce39104cef9f391dddaaa098e9640dc3099e788
Showing with 29 additions and 35 deletions.
  1. +13 −15 SQLite3/mORMot.pas
  2. +0 −1 SQLite3/mORMotHttpClient.pas
  3. +10 −9 SynCrypto.pas
  4. +1 −1 SynMongoDB.pas
  5. +1 −3 SynPdf.pas
  6. +3 −5 SynTable.pas
  7. +1 −1 SynopseCommit.inc
wasSQLString^ := false;
i := fPropInfo.GetOrdProp(Instance);
if (fSQLFieldType=sftBoolean) and not ToSQL then
JSONBoolean(i<>0,result) else
result := BOOL_UTF8[i<>0] else
UInt32ToUtf8(i,result);
end;

end;
end;

procedure TSQLTable.GetCSVValues(Dest: TStream; Tab: boolean; CommaSep: AnsiChar=',';
AddBOM: boolean=false; RowFirst: integer=0; RowLast: integer=0);
procedure TSQLTable.GetCSVValues(Dest: TStream; Tab: boolean; CommaSep: AnsiChar;
AddBOM: boolean; RowFirst,RowLast: integer);
var U: PPUTF8Char;
F,R,FMax: integer;
W: TTextWriter;
end;
end;

function TSQLTable.GetCSVValues(Tab: boolean; CommaSep: AnsiChar=',';
AddBOM: boolean=false; RowFirst: integer=0; RowLast: integer=0): RawUTF8;
function TSQLTable.GetCSVValues(Tab: boolean; CommaSep: AnsiChar;
AddBOM: boolean; RowFirst,RowLast: integer): RawUTF8;
var MS: TRawByteStringStream;
begin
MS := TRawByteStringStream.Create;
end;
{$endif}

procedure TSQLTable.ToObjectList(DestList: TObjectList; RecordType: TSQLRecordClass=nil);
procedure TSQLTable.ToObjectList(DestList: TObjectList; RecordType: TSQLRecordClass);
var R: TSQLRecord;
row: PPUtf8Char;
rec: ^TSQLRecord;
end;
end;

procedure TEnumType.AddCaptionStrings(Strings: TStrings; UsedValuesBits: Pointer=nil);
procedure TEnumType.AddCaptionStrings(Strings: TStrings; UsedValuesBits: Pointer);
var i, L: PtrInt;
Line: array[byte] of AnsiChar;
P: PAnsiChar;

procedure TSQLRecordProperties.RegisterCustomRTTIRecordProperty(aTable: TClass;
aRecordInfo: PTypeInfo; const aName: RawUTF8; aPropertyPointer: pointer;
aAttributes: TSQLPropInfoAttributes=[]; aFieldWidth: integer=0;
aData2Text: TOnSQLPropInfoRecord2Text=nil;
aText2Data: TOnSQLPropInfoRecord2Data=nil);
aAttributes: TSQLPropInfoAttributes; aFieldWidth: integer;
aData2Text: TOnSQLPropInfoRecord2Text; aText2Data: TOnSQLPropInfoRecord2Data);
begin
Fields.Add(TSQLPropInfoRecordRTTI.Create(aRecordInfo,aName,Fields.Count,
aPropertyPointer,aAttributes,aFieldWidth,aData2Text,aText2Data));
end;

procedure TSQLRecordProperties.RegisterCustomPropertyFromRTTI(aTable: TClass;
aTypeInfo: PTypeInfo; const aName: RawUTF8; aPropertyPointer: pointer;
aAttributes: TSQLPropInfoAttributes=[]; aFieldWidth: integer=0);
aAttributes: TSQLPropInfoAttributes; aFieldWidth: integer);
begin
Fields.Add(TSQLPropInfoCustomJSON.Create(aTypeInfo,aName,Fields.Count,
aPropertyPointer,aAttributes,aFieldWidth));
end;

procedure TSQLRecordProperties.RegisterCustomPropertyFromTypeName(aTable: TClass;
const aTypeName, aName: RawUTF8; aPropertyPointer: pointer;
aAttributes: TSQLPropInfoAttributes=[]; aFieldWidth: integer=0);
aAttributes: TSQLPropInfoAttributes; aFieldWidth: integer);
begin
Fields.Add(TSQLPropInfoCustomJSON.Create(aTypeName,aName,Fields.Count,
aPropertyPointer,aAttributes,aFieldWidth));
HR(P);
Add('"');
if (IsObj=oSynPersistentWithPassword) and (codepage=CP_UTF8) and
((woHideSynPersistentPassword in Options) or
(woFullExpand in Options)) and
((woHideSynPersistentPassword in Options) or (woFullExpand in Options)) and
P^.GetterIsField and (P^.GetterAddr(Value)=
TSynPersistentWithPassword(Value).GetPasswordFieldAddress) then begin
if tmp<>'' then
begin
case ValueType of // some direct conversion of simple types
smvBoolean:
JSONBoolean(PBoolean(V)^,DestValue);
DestValue := BOOL_UTF8[PBoolean(V)^];
smvEnum..smvInt64:
case SizeInStorage of
1: UInt32ToUtf8(PByte(V)^,DestValue);
@@ -513,7 +513,6 @@ TSQLHttpClientCurl = class(TSQLHttpClientRequest)

implementation


{ TSQLHttpClientGeneric }

procedure TSQLHttpClientGeneric.InternalURI(var Call: TSQLRestURIParams);
@@ -2280,6 +2280,7 @@ function CryptDataForCurrentUserDPAPI(const Data,AppSecret: RawByteString; Encry
// ! end;
function CryptDataForCurrentUser(const Data,AppSecret: RawByteString; Encrypt: boolean): RawByteString;


const
SHA1DIGESTSTRLEN = sizeof(TSHA1Digest)*2;
SHA256DIGESTSTRLEN = sizeof(TSHA256Digest)*2;
@@ -3171,7 +3172,7 @@ procedure XorMemoryPtrInt(dest, source: PPtrIntArray; count: integer);
{$ifdef USEPADLOCK}
ViaCtx: pointer; // padlock_*() context
{$endif}
DoBlock: procedure(const ctxt, source, dest);
DoBlock: procedure(const ctxt, source, dest); // main AES function
{$ifdef USEAESNI32}AesNi32: pointer;{$endif}
Initialized: boolean;
Rounds: byte; // Number of rounds
ComputeAesStaticTables;
{$ifdef USEPADLOCK}
PadlockInit;
{$endif}
{$ifdef CRC32C_X64} // use SSE4.2+pclmulqdq instructions
if (cfSSE42 in CpuFeatures) and (cfAesNi in CpuFeatures) then
crc32c := @crc32c_sse42_aesni;
{$endif}
{$endif USEPADLOCK}
{$ifdef CPUX64}
{$ifdef CRC32C_X64} // use SSE4.2+pclmulqdq instructions
if (cfSSE42 in CpuFeatures) and (cfAesNi in CpuFeatures) then
crc32c := @crc32c_sse42_aesni;
{$endif CRC32C_X64}
if cfSSE41 in CpuFeatures then begin // optimized Intel's sha256_sse4.asm ?
if K256AlignedStore='' then
GetMemAligned(K256AlignedStore,@K256,SizeOf(K256),K256Aligned);
{$ifdef USEPADLOCKDLL}
if PadLockLibHandle<>0 then
FreeLibrary(PadLockLibHandle); // same on Win+Linux, thanks to SysUtils
{$endif}
{$endif USEPADLOCKDLL}
FillZero(__h);
{$ifdef MSWINDOWS}
if CryptoAPI.Handle<>0 then begin
{$ifdef USE_PROV_RSA_AES}
if (CryptoAPIAESProvider<>nil) and (CryptoAPIAESProvider<>HCRYPTPROV_NOTTESTED) then
CryptoAPI.ReleaseContext(CryptoAPIAESProvider,0);
{$endif}
{$endif USE_PROV_RSA_AES}
FreeLibrary(CryptoAPI.Handle);
end;
{$endif}
{$endif MSWINDOWS}
end.
@@ -5847,7 +5847,7 @@ procedure TMongoClient.Auth(const DatabaseName,UserName,Digest: RawUTF8;
resp.Clear;
CheckPayload;
if (err='') and (resp.U['v']<>BinToBase64(@server,SizeOf(server))) then
err := 'Server returned an invalid signature';
err := 'Server returned an invalid signature';
if err<>'' then
raise EMongoException.CreateUTF8('%.OpenAuthSCRAM("%") step2: % - res=%',
[self,DatabaseName,err,res]);
@@ -3793,9 +3793,7 @@ procedure TPdfNull.InternalWriteTo(W: TPdfWrite);

procedure TPdfBoolean.InternalWriteTo(W: TPdfWrite);
begin
if Value then
W.Add('true') else
W.Add('false');
W.Add(BOOL_UTF8[Value]);
end;

constructor TPdfBoolean.Create(AValue: Boolean);
@@ -2571,8 +2571,7 @@ TSynPersistentWithPassword = class(TSynPersistent)
protected
fPassWord: RawUTF8;
fKey: cardinal;
function GetKey: cardinal;
{$ifdef HASINLINE}inline;{$endif}
function GetKey: cardinal; {$ifdef HASINLINE}inline;{$endif}
function GetPassWordPlain: RawUTF8;
function GetPassWordPlainInternal(AppSecret: RawUTF8): RawUTF8;
procedure SetPassWordPlain(const Value: RawUTF8);
@@ -2598,8 +2597,7 @@ TSynPersistentWithPassword = class(TSynPersistent)
/// low-level function used to identify if a given field is a Password
// - this method is used e.g. by TJSONSerializer.WriteObject to identify the
// password field, since its published name is set by the inherited classes
function GetPasswordFieldAddress: pointer;
{$ifdef HASINLINE}inline;{$endif}
function GetPasswordFieldAddress: pointer; {$ifdef HASINLINE}inline;{$endif}
/// the private key used to cypher the password storage on serialization
// - application can override the default 0 value at runtime
property Key: cardinal read GetKey write fKey;
@@ -4992,7 +4990,7 @@ function TSynTableFieldProperties.GetValue(FieldBuffer: pointer): RawUTF8;
case FieldType of
// fixed-sized field value
tftBoolean:
JSONBoolean(PBoolean(FieldBuffer)^,result);
result := BOOL_UTF8[PBoolean(FieldBuffer)^];
tftUInt8:
UInt32ToUtf8(PB^,result);
tftUInt16:
@@ -1 +1 @@
'1.18.5293'
'1.18.5294'

0 comments on commit dce3910

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