فهرست منبع

* Fcl-DB with namespaces

Michaël Van Canneyt 1 سال پیش
والد
کامیت
eab8c5f3af

+ 3 - 0
packages/fcl-db/namespaced/Data.Consts.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.Consts;
+{$include ../src/dbconst.pas}

+ 3 - 0
packages/fcl-db/namespaced/Data.Db.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.Db;
+{$include ../src/db.pas}

+ 3 - 0
packages/fcl-db/namespaced/Data.ExtJS.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.ExtJS;
+{$include ../src/extjsdataset.pas}

+ 3 - 0
packages/fcl-db/namespaced/Data.FieldMap.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.FieldMap;
+{$include ../src/fieldmap.pp}

+ 3 - 0
packages/fcl-db/namespaced/Data.HTML.Actions.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.HTML.Actions;
+{$include ../src/data.htmlactions.pp}

+ 3 - 0
packages/fcl-db/namespaced/Data.JsonDataset.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.JsonDataset;
+{$include ../src/jsondataset.pas}

+ 3 - 0
packages/fcl-db/namespaced/Data.LocalDataset.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.LocalDataset;
+{$include ../src/localjsondataset.pas}

+ 3 - 0
packages/fcl-db/namespaced/Data.Rest.Connection.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.Rest.Connection;
+{$include ../src/restconnection.pas}

+ 3 - 0
packages/fcl-db/namespaced/Data.Rest.SqlDb.pas

@@ -0,0 +1,3 @@
+{$DEFINE FPC_DOTTEDUNITS}
+unit Data.Rest.SqlDb;
+{$include ../src/sqldbrestdataset.pp}

+ 73 - 0
packages/fcl-db/namespaced/pas2js_fcldb_namespaced.lpk

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+  <Package Version="5">
+    <Name Value="pas2js_fcldb_namespaced"/>
+    <Type Value="RunTimeOnly"/>
+    <AutoUpdate Value="Manually"/>
+    <CompilerOptions>
+      <Version Value="11"/>
+      <SearchPaths>
+        <UnitOutputDirectory Value="."/>
+      </SearchPaths>
+      <Other>
+        <ExecuteBefore>
+          <Command Value="$MakeExe(IDE,pas2js) -O- -Jc -vbq pas2js_fcldb_namespaced.pas"/>
+          <Parsers Count="1">
+            <Item1 Value="Pas2JS"/>
+          </Parsers>
+        </ExecuteBefore>
+      </Other>
+      <SkipCompiler Value="True"/>
+    </CompilerOptions>
+    <Files Count="9">
+      <Item1>
+        <Filename Value="Data.Db.pas"/>
+        <UnitName Value="Data.Db"/>
+      </Item1>
+      <Item2>
+        <Filename Value="Data.Consts.pas"/>
+        <UnitName Value="Data.Consts"/>
+      </Item2>
+      <Item3>
+        <Filename Value="Data.JsonDataset.pas"/>
+        <UnitName Value="Data.JsonDataset"/>
+      </Item3>
+      <Item4>
+        <Filename Value="Data.Rest.Connection.pas"/>
+        <UnitName Value="Data.Rest.Connection"/>
+      </Item4>
+      <Item5>
+        <Filename Value="Data.ExtJS.pas"/>
+        <UnitName Value="Data.ExtJS"/>
+      </Item5>
+      <Item6>
+        <Filename Value="Data.FieldMap.pas"/>
+        <UnitName Value="Data.FieldMap"/>
+      </Item6>
+      <Item7>
+        <Filename Value="Data.HTML.Actions.pas"/>
+        <UnitName Value="Data.HTML.Actions"/>
+      </Item7>
+      <Item8>
+        <Filename Value="Data.LocalDataset.pas"/>
+        <UnitName Value="Data.LocalDataset"/>
+      </Item8>
+      <Item9>
+        <Filename Value="Data.Rest.SqlDb.pas"/>
+        <UnitName Value="Data.Rest.SqlDb"/>
+      </Item9>
+    </Files>
+    <CompatibilityMode Value="True"/>
+    <RequiredPkgs Count="1">
+      <Item1>
+        <PackageName Value="pas2js_rtl"/>
+      </Item1>
+    </RequiredPkgs>
+    <UsageOptions>
+      <UnitPath Value="$(PkgOutDir)"/>
+    </UsageOptions>
+    <PublishOptions>
+      <Version Value="2"/>
+    </PublishOptions>
+  </Package>
+</CONFIG>

+ 16 - 0
packages/fcl-db/namespaced/pas2js_fcldb_namespaced.pas

@@ -0,0 +1,16 @@
+{ This file was automatically created by Lazarus. Do not edit!
+  This source is only used to compile and install the package.
+ }
+
+unit pas2js_fcldb_namespaced;
+
+{$warn 5023 off : no warning about unused units}
+interface
+
+uses
+  Data.Db, Data.Consts, Data.JsonDataset, Data.Rest.Connection, Data.ExtJS, Data.FieldMap, Data.HTML.Actions, Data.LocalDataset, 
+  Data.Rest.SqlDb;
+
+implementation
+
+end.

+ 29 - 2
packages/fcl-db/data.htmlactions.pp → packages/fcl-db/src/data.htmlactions.pp

@@ -1,8 +1,30 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Michael Van Canneyt, member of the
+    Free Pascal development team
+
+    Data-Aware HTML actions (ActionLists).
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
 unit Data.HTMLActions;
+{$ENDIF}
 
 interface
 
-uses sysutils, classes, web, Rtl.HTMLEventNames, Rtl.HTMLActions, db;
+uses
+{$IFDEF FPC_DOTTEDUNITS}
+  System.SysUtils, System.Classes, BrowserApi.Web, HTML.EventNames, HTML.Actions, Data.Db;
+{$ELSE}
+  sysutils, classes, web, Rtl.HTMLEventNames, Rtl.HTMLActions, db;
+{$ENDIF}
 
 Type
   TDBCustomHTMLElementAction = class;
@@ -202,7 +224,12 @@ Type
 
 Implementation
 
-uses strutils, rtl.HTMLUtils;
+uses 
+{$IFDEF FPC_DOTTEDUNITS}
+  System.StrUtils, HTML.Utils;
+{$ELSE}
+  strutils, rtl.HTMLUtils;
+{$ENDIF}
 
 { TButtonActionDataLink }
 

+ 20 - 8
packages/fcl-db/db.pas → packages/fcl-db/src/db.pas

@@ -13,14 +13,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
 unit DB;
+{$ENDIF}
 
 {$mode objfpc}
 
 { $define dsdebug}
 interface
 
-uses Classes, SysUtils, JS, Types, DateUtils;
+uses 
+{$IFDEF FPC_DOTTEDUNITS}
+  System.Classes, System.SysUtils, JSApi.JS, System.Types, System.DateUtils;
+{$ELSE}
+  Classes, SysUtils, JS, Types, DateUtils;
+{$ENDIF}
 
 const
   dsMaxBufferCount = MAXINT div 8;
@@ -1791,7 +1798,12 @@ Function ExtractFieldName(Const Fields: String; var Pos: Integer): String;
 
 implementation
 
-uses DBConst,TypInfo;
+uses 
+{$IFDEF FPC_DOTTEDUNITS}
+  Data.Consts, System.TypInfo;
+{$ELSE}
+  DBConst,TypInfo;
+{$ENDIF}
 
 { ---------------------------------------------------------------------
     Auxiliary functions
@@ -5806,7 +5818,7 @@ end;
 function TField.GetIsNull: Boolean;
 
 begin
-  Result:=js.IsNull(GetData);
+  Result:={$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.IsNull(GetData);
 end;
 
 function TField.GetParentComponent: TComponent;
@@ -5911,7 +5923,7 @@ end;
 procedure TField.SetAsJSValue(const AValue: JSValue);
 
 begin
-  if js.IsNull(AValue) then
+  if {$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.IsNull(AValue) then
     Clear
   else
     try
@@ -6960,7 +6972,7 @@ end;
 
 function TDateTimeField.ConvertToDateTime(aValue: JSValue; aRaiseError: Boolean): TDateTime;
 begin
-  if JS.isNull(aValue) then
+  if {$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.isNull(aValue) then
     Result:=0
   else if Assigned(Dataset) then
     Result:=Dataset.ConvertToDateTime(Self,aValue,aRaiseError)
@@ -8937,7 +8949,7 @@ end;
 
 Function TParam.GetIsNull: Boolean;
 begin
-  Result:= JS.IsNull(FValue);
+  Result:= {$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.IsNull(FValue);
 end;
 
 Function TParam.IsEqual(AValue: TParam): Boolean;
@@ -9022,7 +9034,7 @@ Procedure TParam.SetAsJSValue(const AValue: JSValue);
 
 begin
   FValue:=AValue;
-  FBound:=not JS.IsNull(AValue);
+  FBound:=not {$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.IsNull(AValue);
   if FBound then
     case GetValueType(aValue) of
       jvtBoolean : FDataType:=ftBoolean;
@@ -9142,7 +9154,7 @@ begin
       FDataType := ftString
     else
       FDataType := Field.DataType;
-    if JS.IsNull(AValue) then
+    if {$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.IsNull(AValue) then
       Clear
     else
       Value:=AValue;

+ 2 - 1
packages/fcl-db/dbconst.pas → packages/fcl-db/src/dbconst.pas

@@ -13,8 +13,9 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-
+{$IFNDEF FPC_DOTTEDUNITS}
 unit DBConst;
+{$ENDIF}
 
 Interface
 

+ 6 - 0
packages/fcl-db/extjsdataset.pas → packages/fcl-db/src/extjsdataset.pas

@@ -13,14 +13,20 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
 unit ExtJSDataset;
+{$ENDIF}
 
 {$mode objfpc}
 
 interface
 
 uses
+{$IFDEF FPC_DOTTEDUNITS}
+  System.Classes, System.SysUtils, Data.Db, JSApi.JS, Data.JsonDataset;
+{$ELSE}
   Classes, SysUtils, db, JS, jsondataset;
+{$ENDIF}
 
 type
   { TExtJSJSONDataSet }

+ 25 - 1
packages/fcl-db/fieldmap.pp → packages/fcl-db/src/fieldmap.pp

@@ -1,9 +1,33 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Michael Van Canneyt, member of the
+    Free Pascal development team
+
+    Fieldmap class for direct field access.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
 unit fieldmap;
+{$ENDIF}
+
 {$mode objfpc}
 {$H+}
+
 interface
 
-uses SysUtils, db;
+uses 
+{$IFDEF FPC_DOTTEDUNITS}
+  System.SysUtils, Data.Db;
+{$ELSE}
+  SysUtils, db;
+{$ENDIF}
 
 { ---------------------------------------------------------------------
   TFieldMap

+ 14 - 3
packages/fcl-db/jsondataset.pas → packages/fcl-db/src/jsondataset.pas

@@ -13,14 +13,20 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-{$mode objfpc}
-
+{$IFNDEF FPC_DOTTEDUNITS}
 unit JSONDataset;
+{$ENDIF}
+
+{$mode objfpc}
 
 interface
 
 uses
+{$IFDEF FPC_DOTTEDUNITS}
+  System.Types, JSApi.JS, Data.DB, System.Classes, System.SysUtils, System.Typinfo, Fcl.Expressions;
+{$ELSE}
   Types, JS, DB, Classes, SysUtils, typinfo, fpexprpars;
+{$ENDIF}
 
 type
   TBaseJSONDataset = Class;
@@ -469,7 +475,12 @@ type
   
 implementation
 
-uses DateUtils;
+uses
+{$IFDEF FPC_DOTTEDUNITS}
+  System.DateUtils;
+{$ELSE}
+  DateUtils;
+{$ENDIF}
 
 Function atob (s : String) : string; external name 'atob';
 Function btoa (s : String) : string; external name 'btoa';

+ 21 - 0
packages/fcl-db/localjsondataset.pas → packages/fcl-db/src/localjsondataset.pas

@@ -1,11 +1,32 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2019 by Michael Van Canneyt, member of the
+    Free Pascal development team
+
+    Simple Local JSON dataset component.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
 unit localjsondataset;
+{$ENDIF}
 
 {$mode ObjFPC}
 
 interface
 
 uses
+{$IFDEF FPC_DOTTEDUNITS}
+  System.Classes, System.SysUtils, Data.Db, Data.JsonDataset, JSApi.JS, BrowserApi.web;
+{$ELSE}
   Classes, SysUtils, db, jsondataset, js, web;
+{$ENDIF}
 
 Type
   { TCustomLocalJSONDataset }

+ 16 - 2
packages/fcl-db/pas2js_fcldb.lpk → packages/fcl-db/src/pas2js_fcldb.lpk

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <CONFIG>
-  <Package Version="4">
+  <Package Version="5">
     <Name Value="pas2js_fcldb"/>
     <Type Value="RunTimeOnly"/>
     <AutoUpdate Value="Manually"/>
@@ -17,7 +17,7 @@
       </Other>
       <SkipCompiler Value="True"/>
     </CompilerOptions>
-    <Files Count="5">
+    <Files Count="9">
       <Item1>
         <Filename Value="db.pas"/>
         <UnitName Value="DB"/>
@@ -38,7 +38,21 @@
         <Filename Value="extjsdataset.pas"/>
         <UnitName Value="ExtJSDataset"/>
       </Item5>
+      <Item6>
+        <Filename Value="data.htmlactions.pp"/>
+        <UnitName Value="data.htmlactions"/>
+      </Item6>
+      <Item7>
+        <Filename Value="fieldmap.pp"/>
+      </Item7>
+      <Item8>
+        <Filename Value="localjsondataset.pas"/>
+      </Item8>
+      <Item9>
+        <Filename Value="sqldbrestdataset.pp"/>
+      </Item9>
     </Files>
+    <CompatibilityMode Value="True"/>
     <RequiredPkgs Count="1">
       <Item1>
         <PackageName Value="pas2js_rtl"/>

+ 1 - 1
packages/fcl-db/pas2js_fcldb.pas → packages/fcl-db/src/pas2js_fcldb.pas

@@ -8,7 +8,7 @@ unit pas2js_fcldb;
 interface
 
 uses
-  DB, DBConst, JSONDataset, RestConnection, extjsdataset;
+  DB, DBConst, JSONDataset, RestConnection, ExtJSDataset, data.htmlactions, sqldbrestdataset;
 
 implementation
 

+ 12 - 2
packages/fcl-db/restconnection.pas → packages/fcl-db/src/restconnection.pas

@@ -13,15 +13,20 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
-
+{$IFNDEF FPC_DOTTEDUNITS}
 unit RestConnection;
+{$ENDIF}
 
 {$mode objfpc}
 
 interface
 
 uses
+{$IFDEF FPC_DOTTEDUNITS}
+  System.Classes, System.SysUtils, BrowserApi.Web, Data.Db;
+{$ELSE}
   Classes, SysUtils, Web, DB;
+{$ENDIF}
 
 Type
   
@@ -95,7 +100,12 @@ Type
 
 implementation
 
-uses js;
+uses 
+{$IFDEF FPC_DOTTEDUNITS}
+  JSApi.JS;
+{$ELSE}
+  js;
+{$ENDIF}
 
 { TRESTUpdateRequest }
 

+ 14 - 3
packages/fcl-db/sqldbrestdataset.pp → packages/fcl-db/src/sqldbrestdataset.pp

@@ -13,14 +13,20 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  **********************************************************************}
+{$IFNDEF FPC_DOTTEDUNITS}
 unit sqldbrestdataset;
+{$ENDIF}
 
 {$mode objfpc}
 
 interface
 
 uses
+{$IFDEF FPC_DOTTEDUNITS}
+  System.Classes, System.SysUtils, JSApi.JS, BrowserApi.Web, Data.Db, Data.JsonDataset, Data.Rest.Connection;
+{$ELSE}
   Classes, SysUtils, JS, web, db, JSONDataset, restconnection;
+{$ENDIF}
 
 Type
 
@@ -167,7 +173,12 @@ Type
 
 implementation
 
-uses Types, StrUtils, DateUtils;
+uses 
+{$IFDEF FPC_DOTTEDUNITS}
+  System.Types, System.StrUtils, System.DateUtils;
+{$ELSE}
+  Types, StrUtils, DateUtils;
+{$ENDIF}
 
 Type
 
@@ -464,8 +475,8 @@ begin
     For I:=0 to Params.Count-1 do
       AddToResult(Params[I].AsQuery);
     Sort:='';
-    DFN:=StrUtils.SplitString(ServerSortDescFields,',');
-    For S in StrUtils.SplitString(ServerSortFields,',') do
+    DFN:=SplitString(ServerSortDescFields,',');
+    For S in SplitString(ServerSortFields,',') do
       begin
       FN:=Trim(S);
       if (FN<>'') then