* FCL-Base namespaced version

This commit is contained in:
Michaël Van Canneyt 2023-11-26 14:08:56 +01:00
parent f3907ef818
commit 6637b6307b
18 changed files with 230 additions and 10 deletions

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Browser.DebugCapture;
{$include ../src/debugcapture.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.App.Browser;
{$include ../src/browserapp.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.App.NodeJs;
{$include ../src/nodejsapp.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.App.ServiceWorker;
{$include ../src/serviceworkerapp.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.CustApp;
{$include ../src/custapp.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Fcl.Expressions;
{$include ../src/fpexprpars.pas}

View File

@ -0,0 +1,3 @@
{$DEFINE FPC_DOTTEDUNITS}
unit Pascal.CodeGenerator;
{$include ../src/pascodegen.pp}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="5">
<Name Value="fcl_base_pas2js_namespaced"/>
<Type Value="RunTimeOnly"/>
<Author Value="Mattias Gaertner"/>
<AutoUpdate Value="Manually"/>
<CompilerOptions>
<Version Value="11"/>
<SearchPaths>
<UnitOutputDirectory Value="."/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<AllowLabel Value="False"/>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<GenerateDebugInfo Value="False"/>
</Debugging>
</Linking>
<Other>
<CustomOptions Value="-Jc"/>
<CompilerPath Value="$(pas2js)"/>
<ExecuteBefore>
<Command Value="$MakeExe(IDE,pas2js) -O- -Jc -vbq fcl_base_pas2js_namespaced.pas"/>
<Parsers Count="1">
<Item1 Value="Pas2JS"/>
</Parsers>
</ExecuteBefore>
</Other>
<SkipCompiler Value="True"/>
</CompilerOptions>
<Description Value="Free Pascal Component Library - Base
Port to pas2js."/>
<License Value="Modified LGPL-2"/>
<Version Major="1"/>
<Files Count="6">
<Item1>
<Filename Value="Fcl.CustApp.pas"/>
<UnitName Value="Fcl.CustApp"/>
</Item1>
<Item2>
<Filename Value="Fcl.App.NodeJs.pas"/>
<UnitName Value="Fcl.App.NodeJs"/>
</Item2>
<Item3>
<Filename Value="Fcl.App.Browser.pas"/>
<UnitName Value="Fcl.App.Browser"/>
</Item3>
<Item4>
<Filename Value="Fcl.Expressions.pas"/>
<UnitName Value="Fcl.Expressions"/>
</Item4>
<Item5>
<Filename Value="Fcl.App.ServiceWorker.pas"/>
<UnitName Value="Fcl.App.ServiceWorker"/>
</Item5>
<Item6>
<Filename Value="Pascal.CodeGenerator.pas"/>
<UnitName Value="Pascal.CodeGenerator"/>
</Item6>
</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>

View File

@ -0,0 +1,15 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit fcl_base_pas2js_namespaced;
{$warn 5023 off : no warning about unused units}
interface
uses
Fcl.CustApp, Fcl.App.NodeJs, Fcl.App.Browser, Fcl.Expressions, Fcl.App.ServiceWorker, Pascal.CodeGenerator;
implementation
end.

View File

@ -1,11 +1,33 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2003 by the Free Pascal development team
Pascal code generator class.
Port to pas2js by Mattias Gaertner mattias@freepascal.org
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 BrowserApp;
{$ENDIF}
{$mode objfpc}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils, System.Types, JSApi.JS, BrowserApi.Web, Fcl.CustApp;
{$ELSE}
Classes, SysUtils, Types, JS, web, CustApp;
{$ENDIF}
type
TServiceWorkerRegisteredEvent = reference to procedure(Registration: TJSServiceWorkerRegistration);

View File

@ -14,14 +14,20 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{$IFNDEF FPC_DOTTEDUNITS}
unit CustApp;
{$ENDIF}
{$mode objfpc}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils, System.Types, JSApi.JS;
{$ELSE}
Classes, SysUtils, Types, JS;
{$ENDIF}
Const
SErrInvalidOption: String = 'Invalid option at position %s: "%s"';
@ -234,7 +240,7 @@ begin
end
else begin
ExceptObject:=nil;
ExceptObjectJS := JS.JSExceptValue;
ExceptObjectJS := {$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.JSExceptValue;
HandleException(Self);
end;
end;

View File

@ -12,15 +12,20 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{$IFNDEF FPC_DOTTEDUNITS}
unit debugcapture;
{$ENDIF}
{$mode ObjFPC}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Types, System.Classes, System.SysUtils;
{$ELSE}
Types, Classes, SysUtils;
{$ENDIF}
Const
DefaultURL = '/debugcapture';

View File

@ -24,7 +24,14 @@
<Other>
<CustomOptions Value="-Jc"/>
<CompilerPath Value="$(pas2js)"/>
<ExecuteBefore>
<Command Value="$MakeExe(IDE,pas2js) -O- -Jc -vbq fcl_base_pas2js.pas"/>
<Parsers Count="1">
<Item1 Value="Pas2JS"/>
</Parsers>
</ExecuteBefore>
</Other>
<SkipCompiler Value="True"/>
</CompilerOptions>
<Description Value="Free Pascal Component Library - Base
Port to pas2js."/>
@ -33,15 +40,15 @@ Port to pas2js."/>
<Files Count="5">
<Item1>
<Filename Value="custapp.pas"/>
<UnitName Value="custapp"/>
<UnitName Value="CustApp"/>
</Item1>
<Item2>
<Filename Value="nodejsapp.pas"/>
<UnitName Value="nodejsapp"/>
<UnitName Value="NodeJSApp"/>
</Item2>
<Item3>
<Filename Value="browserapp.pas"/>
<UnitName Value="browserapp"/>
<UnitName Value="BrowserApp"/>
</Item3>
<Item4>
<Filename Value="fpexprpars.pas"/>

View File

@ -8,7 +8,7 @@ unit fcl_base_pas2js;
interface
uses
CustApp, NodeJSApp, browserapp;
CustApp, NodeJSApp, BrowserApp, fpexprpars, ServiceWorkerApp;
implementation

View File

@ -13,14 +13,21 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{$IFNDEF FPC_DOTTEDUNITS}
unit fpexprpars;
{$ENDIF}
{$mode objfpc}
{$h+}
unit fpexprpars;
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils, System.Contnrs;
{$ELSE}
Classes, SysUtils, contnrs;
{$ENDIF}
Type
// tokens
@ -801,7 +808,12 @@ function ArgToFloat(Arg: TFPExpressionResult): TExprFloat;
implementation
uses typinfo;
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Typinfo;
{$ELSE}
typinfo;
{$ENDIF}
{ TFPExpressionParser }

View File

@ -14,14 +14,20 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{$IFNDEF FPC_DOTTEDUNITS}
unit NodeJSApp;
{$ENDIF}
{$mode objfpc}
interface
uses
{$IFNDEF FPC_DOTTEDUNITS}
NodeApi.JS, System.Classes, System.SysUtils, System.Types, JSApi.JS, Fcl.CustApp;
{$ELSE}
NodeJS, Classes, SysUtils, Types, JS, CustApp;
{$ENDIF}
type

View File

@ -1,11 +1,33 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2003 by the Free Pascal development team
Pascal code generator class.
Port to pas2js by Mattias Gaertner mattias@freepascal.org
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 pascodegen;
{$ENDIF}
{$mode objfpc}{$H+}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils;
{$ELSE}
Classes, SysUtils;
{$ENDIF}
Type
TCodegenLogType = (cltInfo);
@ -77,6 +99,8 @@ Type
end;
implementation
{ TPascalCodeGenerator }
procedure TPascalCodeGenerator.Indent;
begin

View File

@ -1,15 +1,38 @@
{
This file is part of the Free Pascal run time library.
Copyright (c) 2003 by the Free Pascal development team
Service Worker Application class.
Port to pas2js by Mattias Gaertner mattias@freepascal.org
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.
**********************************************************************}
{
A service worker functions like a proxy server, allowing to modify requests
and responses, and replace them with items from its own cache, and more.
}
{$IFNDEF FPC_DOTTEDUNITS}
unit ServiceWorkerApp;
{$ENDIF}
{$mode objfpc}
interface
uses
{$IFDEF FPC_DOTTEDUNITS}
System.Classes, System.SysUtils, System.Types, JSApi.JS, BrowserApi.WebOrWorker, BrowserApi.Worker, Fcl.CustApp;
{$ELSE}
Classes, SysUtils, Types, JS, weborworker, webworker, CustApp;
{$ENDIF}
type
@ -151,10 +174,10 @@ begin
// when even the fallback response is not available,
// there is nothing we can do, but we must always
// return a Response object
Result:=TJSResponse.new('Network error happened', js.new([
Result:=TJSResponse.new('Network error happened', {$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.new([
'status', 408,
'headers',
js.new(['Content-Type', 'text/plain' ])
{$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.new(['Content-Type', 'text/plain' ])
]) );
end;
end;