Skip to content

Commit

Permalink
let's follow Kotlin good naming rules for our types
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed Dec 31, 2020
1 parent b892fb9 commit 4b34dec
Show file tree
Hide file tree
Showing 54 changed files with 3,392 additions and 3,376 deletions.
12 changes: 12 additions & 0 deletions src/README.md
Expand Up @@ -37,6 +37,18 @@ By convention:
- Unit names are dot-separated, and start with the `mormot.` prefix;
- Unit names follow their location in the `src` sub folder, e.g. `mormot.core.json.pas` is located in the `src/core` folder.

## Types Naming

In respect to *mORMot 1.18*, some confusing/deprecated naming like `TSQLRecord` or `TSQLRest` prefix have been renamed as `TOrm` and `TRest`, since our ORM is not SQL-only, but works e.g. with NoSQL engines like MongoDB.

Generally speaking, we followed the [Kotlin good naming rules](https://kotlinlang.org/docs/reference/coding-conventions.html#choosing-good-names):
> When using an acronym as part of a declaration name, capitalize it if it consists of two letters (IOStream); capitalize only the first letter if it is longer (XmlFormatter, HttpInputStream).
Some types have been changed or enhanced:
- `TSQLRawBlob` renamed as `RawBlob`;
- `RawUTF8` is an alias to `System.UTF8String` type so you can use either of them in your code.

Note that the `PUREMORMOT2` conditional can be defined for your project, to disable the type names backward compatible redirection enabled by default.

## Include Files

Expand Down
2 changes: 1 addition & 1 deletion src/core/mormot.core.base.pas
Expand Up @@ -736,7 +736,7 @@ function DateTimeToIsoString(dt: TDateTime): string;

// backward compatibility types redirections
type
TSQLRawBlob = RawBlob;
TSqlRawBlob = RawBlob;

{$endif PUREMORMOT2}

Expand Down
2 changes: 1 addition & 1 deletion src/core/mormot.core.interfaces.pas
Expand Up @@ -1840,7 +1840,7 @@ TInterfaceMethodExecute = class;
// a RunningThread.Synchronize() call - it can be used e.g. if your
// implementation rely heavily on COM servers - by default, service methods
// are called within the thread which received them, on multi-thread server
// instances (e.g. TSQLite3HttpServer or TRestServerNamedPipeResponse),
// instances (e.g. TSqlite3HttpServer or TRestServerNamedPipeResponse),
// for better response time and CPU use (this is the technical reason why
// service implementation methods have to handle multi-threading safety
// carefully, e.g. by using TRTLCriticalSection mutex on purpose)
Expand Down
2 changes: 1 addition & 1 deletion src/core/mormot.core.json.pas
Expand Up @@ -1240,7 +1240,7 @@ TRawByteStringGroup = record

type
/// implement a cache of some key/value pairs, e.g. to improve reading speed
// - used e.g. by TSQLDataBase for caching the SELECT statements results in an
// - used e.g. by TSqlDataBase for caching the SELECT statements results in an
// internal JSON format (which is faster than a query to the SQLite3 engine)
// - internally make use of an efficient hashing algorithm for fast response
// (i.e. TSynNameValue will use the TDynArrayHashed wrapper mechanism)
Expand Down
20 changes: 11 additions & 9 deletions src/core/mormot.core.log.pas
Expand Up @@ -346,12 +346,12 @@ TSynLogFamily = class;
{$endif UNICODE}
/// call this method to add the content of an object to the log at a
// specified level
// - TSynLog will write the class and hexa address - TSQLLog will write the
// - TSynLog will write the class and hexa address - TSqlLog will write the
// object JSON content
procedure Log(Level: TSynLogInfo; Instance: TObject); overload;
/// call this method to add the content of most low-level types to the log
// at a specified level
// - TSynLog will handle enumerations and dynamic array; TSQLLog will be
// - TSynLog will handle enumerations and dynamic array; TSqlLog will be
// able to write TObject/TOrm and sets content as JSON
procedure Log(Level: TSynLogInfo; const aName: RawUTF8; aTypeInfo: PRttiInfo;
const aValue; Instance: TObject); overload;
Expand Down Expand Up @@ -550,7 +550,7 @@ TSynLogFamily = class

/// you can add some exceptions to be ignored to this list
// - for instance, EConvertError may be added to the list, as such:
// ! TSQLLog.Family.ExceptionIgnore.Add(EConvertError);
// ! TSqlLog.Family.ExceptionIgnore.Add(EConvertError);
// - you may also trigger ESynLogSilent exceptions for silent process
// - see also ExceptionIgnoreCurrentThread property, if you want a per-thread
// filtering of all exceptions
Expand Down Expand Up @@ -1033,7 +1033,7 @@ TSynLog = class(TObject, ISynLog)
// - if Instance is set and Text is not '', it will log the corresponding
// class name and address (to be used e.g. if you didn't call TSynLog.Enter()
// method first) - for instance
// ! TSQLLog.Add.Log(sllDebug,'GarbageCollector',GarbageCollector);
// ! TSqlLog.Add.Log(sllDebug,'GarbageCollector',GarbageCollector);
// will append this line to the log:
// $ 0000000000002DB9 debug TObjectList(00425E68) GarbageCollector
// - if Instance is set and Text is '', will behave the same as
Expand All @@ -1055,14 +1055,14 @@ TSynLog = class(TObject, ISynLog)
// $ 20110330 10010005 debug {"TObjectList(00B1AD60)":["TObjectList(00B1AE20)","TObjectList(00B1AE80)"]}
// - if aInstance is an Exception, it will handle its class name and Message:
// $ 20110330 10010005 debug "EClassName(00C2129A)":"Exception message"
// - use TSQLLog from mORMot.pas unit to add the record content, written
// - use TSqlLog from mORMot.pas unit to add the record content, written
// as human readable JSON
procedure Log(Level: TSynLogInfo; aInstance: TObject); overload;
/// call this method to add the content of most low-level types to the log
// at a specified level
// - this overridden implementation will write the value content,
// written as human readable JSON: handle dynamic arrays and enumerations
// - TSQLLog from mORMot.pas unit will be able to write
// - TSqlLog from mORMot.pas unit will be able to write
// TObject/TOrm and sets content as JSON
procedure Log(Level: TSynLogInfo; const aName: RawUTF8; aTypeInfo: PRttiInfo;
const aValue; Instance: TObject); overload;
Expand Down Expand Up @@ -1501,7 +1501,7 @@ TSynLogFile = class(TMemoryMapText)
property DetailedOS: RawUTF8
read fOSDetailed;
/// the associated framework information
// - returns e.g. 'TSQLLog 1.18.2765 ERTL FTS3'
// - returns e.g. 'TSynLog 2.0.1 x64MMs'
property Framework: RawUTF8
read fFramework;
/// the date and time at which the log file was started
Expand Down Expand Up @@ -4807,8 +4807,10 @@ procedure _SetThreadName(ThreadID: TThreadID; const Format: RawUTF8;
if name[i] < ' ' then
name[i] := ' '; // ensure on same line
name := StringReplaceAll(name, [
'TSQLRest', '',
'TSqlRest', '',
'TRest', '',
'TSql', '',
'TSQLRest', '',
'TSQL', '',
'TOrmRest', '',
'TOrm', '',
Expand Down Expand Up @@ -5275,7 +5277,7 @@ procedure TSynLogFile.LoadFromMap(AverageLineLength: integer);
fOS := TWindowsVersion(GetNextItemCardinal(P, '.'));
if fOS <> wUnknown then
fOSServicePack := GetNextItemCardinal(P);
P := fLines[fHeaderLinesCount - 2]; // TSQLLog 1.18.2765 ERTL FTS3 2016-07-17T22:38:03
P := fLines[fHeaderLinesCount - 2]; // TSqlLog 1.18.2765 ERTL FTS3 2016-07-17T22:38:03
i := LineSize(fHeaderLinesCount - 2) - 19; // length('2016-07-17T22:38:03')=19
if i > 0 then
begin
Expand Down
2 changes: 1 addition & 1 deletion src/core/mormot.core.mustache.pas
Expand Up @@ -393,7 +393,7 @@ TSynMustache = class
// - you can also retrieve the context from an ORM query of mORMot.pas:
// ! dummy := TSynMustache.Parse(
// ! '{{#items}}'#13#10'{{Int}}={{Test}}'#13#10'{{/items}}').Render(
// ! aClient.RetrieveDocVariantArray(TSQLRecordTest,'items','Int,Test'));
// ! aClient.RetrieveDocVariantArray(TOrmTest,'items','Int,Test'));
// - set EscapeInvert = true to force {{value}} NOT to escape HTML chars
// and {{{value}} escaping chars (may be useful e.g. for code generation)
function Render(const Context: variant;
Expand Down
4 changes: 2 additions & 2 deletions src/core/mormot.core.os.pas
Expand Up @@ -2065,7 +2065,7 @@ procedure SetCurrentThreadName(const Name: RawUTF8); overload;
// - default implementation does nothing, unless mormot.core.log is included
// - you can force this function to do nothing by setting the NOSETTHREADNAME
// conditional, if you have issues with this feature when debugging your app
// - most meaningless patterns (like 'TSQL') are trimmed to reduce the
// - most meaningless patterns (like 'TSql') are trimmed to reduce the
// resulting length - which is convenient e.g. with POSIX truncation to 16 chars
// - you can retrieve the name later on using CurrentThreadName
// - this method will register TSynLog.LogThreadName(), so threads calling it
Expand Down Expand Up @@ -2252,7 +2252,7 @@ function StartServiceCtrlDispatcher(
{ *** high level classes to define and manage Windows Services }

var
/// you can set this global variable to TSynLog or TSQLLog to enable logging
/// you can set this global variable to TSynLog or TSqlLog to enable logging
// - default is nil, i.e. disabling logging, since it may interfere with the
// logging process of the service itself
// - can be assigned from TSynLog.DoLog class method for proper logging
Expand Down
6 changes: 3 additions & 3 deletions src/core/mormot.core.rtti.pas
Expand Up @@ -1361,13 +1361,13 @@ function GetCaptionFromEnum(aTypeInfo: PRttiInfo; aIndex: integer): string;
procedure GetCaptionFromTrimmed(PS: PShortString; var result: string);

/// will get a class name as UTF-8
// - will trim 'T', 'TSyn', 'TSQL' or 'TOrm' left side of the class name
// - will trim 'T', 'TSyn', 'TSql' or 'TOrm' left side of the class name
// - will encode the class name as UTF-8 (for Unicode Delphi versions)
// - is used e.g. to extract the SQL table name for a TOrm class
function GetDisplayNameFromClass(C: TClass): RawUTF8;

/// UnCamelCase and translate the class name, triming any left 'T', 'TSyn',
// 'TSQL' or 'TOrm'
// 'TSql' or 'TOrm'
// - return generic VCL string type, i.e. UnicodeString for Delphi 2009+
function GetCaptionFromClass(C: TClass): string;

Expand Down Expand Up @@ -4480,7 +4480,7 @@ function GetDisplayNameFromClass(C: TClass): RawUTF8;
if name^[0] > #4 then
// fast case-insensitive compare
case PInteger(@name^[1])^ and $DFDFDFDF of
// backward compatibility trim of left-sided TSQL* or TSQLRecord*
// backward compatibility trim of left-sided TSql* or TSqlRecord*
ord('T') + ord('S') shl 8 + ord('Q') shl 16 + ord('L') shl 24:
if (name^[0] <= #10) or
(PInteger(@name^[5])^ and $DFDFDFDF <>
Expand Down
10 changes: 5 additions & 5 deletions src/core/mormot.core.secure.pas
Expand Up @@ -106,20 +106,20 @@ TSynUserPassword = class(TSynPersistentWithPassword)
end;

/// handle safe storage of any connection properties
// - would be used by mormot.db to serialize TSQLDBConnectionProperties, or
// - would be used by mormot.db to serialize TSqlDBConnectionProperties, or
// by mormot.rest.core.pas to serialize TRest instances
// - the password will be stored as Base64, after a simple encryption as
// defined by TSynPersistentWithPassword
// - typical content could be:
// $ {
// $ "Kind": "TSQLDBSQLite3ConnectionProperties",
// $ "Kind": "TSqlDBSQLite3ConnectionProperties",
// $ "ServerName": "server",
// $ "DatabaseName": "",
// $ "User": "",
// $ "Password": "PtvlPA=="
// $ }
// - the "Kind" value will be used to let the corresponding TRest or
// TSQLDBConnectionProperties NewInstance*() class methods create the
// TSqlDBConnectionProperties NewInstance*() class methods create the
// actual instance, from its class name
TSynConnectionDefinition = class(TSynPersistentWithPassword)
protected
Expand Down Expand Up @@ -231,8 +231,8 @@ TSynAuthenticationAbstract = class
/// simple authentication class, implementing safe token/challenge security
// - maintain a list of user / name credential pairs, and a list of sessions
// - is not meant to handle authorization, just plain user access validation
// - used e.g. by TSQLDBConnection.RemoteProcessMessage (on server side) and
// TSQLDBProxyConnectionPropertiesAbstract (on client side) in mormot.db.proxy
// - used e.g. by TSqlDBConnection.RemoteProcessMessage (on server side) and
// TSqlDBProxyConnectionPropertiesAbstract (on client side) in mormot.db.proxy
TSynAuthentication = class(TSynAuthenticationAbstract)
protected
fCredentials: TSynNameValue; // store user/password pairs
Expand Down
2 changes: 1 addition & 1 deletion src/core/mormot.core.test.pas
Expand Up @@ -365,7 +365,7 @@ TSynTests = class(TSynTest)
// - a typical use will first assign the same log class for the whole
// framework - in such case, before calling RunAsConsole(), the caller
// should execute:
// ! TSynLogTestLog := TSQLLog;
// ! TSynLogTestLog := TSqlLog;
// ! TMyTestsClass.RunAsConsole('My Automated Tests',LOG_VERBOSE);
class procedure RunAsConsole(const CustomIdent: string = '';
withLogs: TSynLogInfos = [sllLastError, sllError, sllException, sllExceptionOS, sllFail];
Expand Down
2 changes: 1 addition & 1 deletion src/core/mormot.core.unicode.pas
Expand Up @@ -1255,7 +1255,7 @@ function UTF8UpperCopy255(dest: PAnsiChar; const source: RawUTF8): PUTF8Char;
/// fast UTF-8 comparison using the NormToUpper[] array for all 8 bits values
// - this version expects u1 and u2 not to be necessary zero-terminated, but
// uses L1 and L2 as length for u1 and u2 respectively
// - use this function for SQLite3 collation (TSQLCollateFunc)
// - use this function for SQLite3 collation (TSqlCollateFunc)
// - this version will decode the UTF-8 content before using NormToUpper[]
// - current implementation handles UTF-16 surrogates
function UTF8ILComp(u1, u2: PUTF8Char; L1, L2: cardinal): PtrInt;
Expand Down
2 changes: 1 addition & 1 deletion src/core/mormot.core.variants.pas
Expand Up @@ -240,7 +240,7 @@ TSynInvokeableVariantTypeClass = class of TSynInvokeableVariantType;
// - the registration process is thread-safe
// - this will implement an internal mechanism used to bypass the default
// _DispInvoke() implementation in Variant.pas, to use a faster version
// - is called in case of TDocVariant, TBSONVariant or TSQLDBRowVariant
// - is called in case of TDocVariant, TBSONVariant or TSqlDBRowVariant
function SynRegisterCustomVariantType(
aClass: TSynInvokeableVariantTypeClass): TSynInvokeableVariantType;

Expand Down

0 comments on commit 4b34dec

Please sign in to comment.