DelphiFMX4Python icon indicating copy to clipboard operation
DelphiFMX4Python copied to clipboard

Legal question

Open andre2007 opened this issue 3 years ago • 38 comments

Dear Embarcadero, Similiar to DelphiFMX4Python I build an API to make use of Delphi FMX from the D Programming Language

https://github.com/andre2007/delta-core-10-2-1 https://github.com/andre2007/delta-fmx-10-2-1

Sample

import delta.core;
import System.Classes, System.UITypes, System.Types, FMX.Forms, FMX.Memo, FMX.Types;

void main()
{
    deltaLibrary.load(`.\views\Win32\Debug\Project1.dll`);
    
    Application.Initialize;
    Application.MainForm = TCustomForm.CreateNew(Application);
    Application.MainForm.Caption = "Sample";
    
    auto memo = TMemo.Create(Application.MainForm);
    memo.Lines.Add("Hello World!");
    memo.Align = TAlignLayout.Client;
    memo.Parent = Application.MainForm;

    Application.MainForm.Show();
    Application.Run();
}

No binary artifact (Dll containing FMX code) is distributed on the Github repository but an user of the repository needs to compile itself a DLL using an official Delphi IDE.

Dll sample source

library Project1;

{$STRONGLINKTYPES ON}

uses
  System.SysUtils,
  System.Classes,
  System.Types,
  System.UiTypes,
  FMX.Forms,
  FMX.Types,
  FMX.Memo,
  FMX.Graphics,
  Delta.Methods,
  Delta.Properties,
  Delta.System.Classes,
  Delta.FMX.Forms,
  Delta.FMX.Objects,
  Delta.FMX.Controls;

{$R *.res}

begin
end.

But the repository contains D wrapper classes for Delphi classes like https://github.com/andre2007/delta-core-10-2-1/blob/master/source/System/Classes.d https://github.com/andre2007/delta-fmx-10-2-1/blob/master/source/FMX/Graphics.d

module FMX.ActnList;

import delta.core;
import System.Actions;
import System.Classes: TComponent;

class TCustomActionList: TContainedActionList
{
 mixin!DelphiClass("FMX.ActnList.TCustomActionList");
}

class TActionList: TCustomActionList
{
	mixin!DelphiClass("FMX.ActnList.TActionList")
	
	static TActionList Create(TComponent owner);
}

The mixin template generates the method bodies automatically based on the signatures.

Do you see any legal issue with providing this API and especially providing D wrapper classes for Delphi System/FMX classes on the Github repository?

Also the question when I want to ship an application, I have to distribute the compiled Delphi DLL as part of my application (like https://github.com/andre2007/delta-fmx-10-2-1/blob/master/examples/gui_custom_form/views/Project1.dpr). Do you see any legal issue here?

Kind regards Andre

andre2007 avatar Nov 04 '22 16:11 andre2007

Check out the "2.2.6.4 - Restrictions" and any further section:

https://www.embarcadero.com/products/rad-studio/rad-studio-eula

lmbelo avatar Nov 04 '22 20:11 lmbelo

Is my understanding right, that I should not open source the 2 repositories but it is OK to use the approach for the closed source applications I want to sell?

My goal is to use Delphi (registered version) for creating the UI, while writing the majority of the application coding in D.

andre2007 avatar Nov 04 '22 20:11 andre2007

I set the repositories to private access to avoid any legal issues until clarification.

andre2007 avatar Nov 07 '22 16:11 andre2007

Hi @andre2007, your project sounds really interesting. Would you be willing to share at least how you achieved this? I would be very interested to try using the Firemonkey UI Framework in a small project written in Rust. Kind regards and happy new year! :)

pointermess avatar Jan 01 '23 03:01 pointermess

Hi @pointermess, Thanks, I wish you also a happy new year. Currently I cutting the repositories into a pure framework repository, containing only uncritical source code (from a licence point of view). This repository will be publically available on github. I will leave a comment here, when I am finished.

The idea is, that you have a Delphi dll, containing only System/FMX uses statements. In addition you add 3 Delta units which exposes generic extern C functions to access Extended RTTI. This functions can be used to call instance/static methods (including constructors and destructors) and properties of Delphi components.

The Dll can be used from almost any language. Therefore on Rust side you just need wrapper classes for all Delphi components you want to use. The wrapper classes forwards the calls to the right Dll functions. In sample above (TActionList) the code for calling the Dll functions is generated by the Mixin Template by introspecting the class.

But as already said by @lmbelo, publishing the FMX/System wrapper classes (Rust) is a legal issue. Therefore I keep this part closed source.

Unfortunately Embarcadero currently opened the door only for python, it would be great if it could be allowed for other languages too.

Kind regards Andre

andre2007 avatar Jan 01 '23 10:01 andre2007

@andre2007 I really like the idea to take FMX to Rust. I'll try to get you in touch with someone else that can help.

lmbelo avatar Jan 02 '23 20:01 lmbelo

@lmbelo That sounds great. I assume in the end there will be a Delphi FMX Dll / SO with C interfaces which will be used by the Rust wrapper classes. It would be great if you would allow that I create also wrapper classes for the D Programming Language and publish it under a license you are comfortable with.

You can find the source code of my 2 repositories here. The source code is under BSL, therefore you can do whatever you like with the code. The source code has some obvious issues, like it is architecture dependent (x86).

delta-fmx-10-2-1-master.zip delta-core-10-2-1-master.zip

The interesting part for you in the source code are likely the Delphi units. If you have questions, just ask.

andre2007 avatar Jan 03 '23 19:01 andre2007

I am interested in both D and Rust support with FMX and VCL..... I need to do some more research on how we can support you in these projects.

jimmckeeth avatar Jan 03 '23 21:01 jimmckeeth

In case your research is succesful, I have following proposal we can discuss. In the Embarcadero Github Organization a new repository e.g. DelphiFMXLib is created.

This repository has following content:

  1. The shared library files for the different operation systems and architectures to be supported (win64 dll, win32 dll, linux 64 so, osx64 dylib, ...). This is the dynamic library file which contains stdcall functions/procedures to call static / instance methods and properties of Delphi classes. By specifying the units to be included (System.Classes, FMX.Forms, ...) you decide what should go in and what not.

  2. You decide whether you want also to include the Delphi Source code of the DLL. The benefit of including it, is that it serves as technical information for the persons creating the Rust / D / ... wrapper coding. If you not including it, a small documentation file describing the DLL stdcall functions / procedures will also do it.

  3. It would be fantastic if you could also add a machine readable file (preferable JSON) containing the Delphi classes for each unit with its public interfaces. That means, what is the super class of a class, which interfacess are implemented, what are the public properties (including its types and whether they are read / write or both). Also the public functions / producedures and its arguments... My assumption is you have s.th. like that and already used it for DelphiFMX4Python. In the end the language dependent wrapper coding needs to create for each Delphi class to be used, some wrapper code: e.g.

enum TShiftState {ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMidldle, ssDouble, ssTouch, ssPen, ssCommand, ssHorizontal};

class TStrings: TPersistent
{
	mixin PascalClass!("System.Classes.TStrings");
	@property string Text();
	@property void Text(string value);
	
	int Add(string value);
	
	int AddObject(string value, TObject aObject);
	
	void Clear();
}

If there isn't something like that, it is not bad, but it would avoid a lot of manual work.

  1. License file

Based on this repository wrapper for Rust and other languages could be easily build. In a separate Github repository I could then create the D wrapper coding. I copy the dynamic libraries and the API specification JSON into it. A generator script will create based on the API specification JSON the wrapper coding for D. Using a package manager and the online package repository (code.dlang.org) the package can be easily used by the community. The same thing can be done by a Rust developer. To be precise, by having the dynamic libraries and the API specification JSON it could be used for any language. You can decide whether you want to have the language dependent repositories (for Rust and D) in your Github Repository or if you want to have it Community driven and they are in there own organizations.

andre2007 avatar Jan 04 '23 20:01 andre2007

@andre2007 can we schedule a review of these projects next week?

lmbelo avatar Jan 04 '23 22:01 lmbelo

Yes, @andre2007 , Let us schedule a meet to review these projects once..

Priyatham10 avatar Jan 05 '23 00:01 Priyatham10

@lmbelo @Priyatham10 Yes, we can schedule a meeting. My time zone is Berlin (UTC+1). Is your time zone Texas (UTC-6)? Would be 9 am or 10 am Texas time ok for you?

andre2007 avatar Jan 05 '23 06:01 andre2007

@andre2007, Yeah, I'll be available during the times you mentioned. We'll think of the day, and we can schedule a meeting.

Priyatham10 avatar Jan 05 '23 14:01 Priyatham10

Wednesdays are busy for me. How about Thursday ?

jimmckeeth avatar Jan 06 '23 18:01 jimmckeeth

Thursday is fine for me. I made some progress. Attached you can see, how the repository "DelphiFMXLib" could look like. This is the programming language independent repository, containing the dynamic libraries, the Delphi source code of the library (OPTIONAL), and the specification JSON files.

-> I found here https://github.com/Embarcadero/DelphiFMX4Python/wiki/Included-Types the information, which units are included in DelphiFMX4Python. I used this information in Project1.dpr. (Some units are not available or might have different names as my Delphi Version is 10.2 different)

-> I just wonder, whether the Wiki is outdated. TImageControl needs TBitmapImage, which is located in "FMX.Graphics". But FMX.Graphics is not in the Wiki list. Where can I see, what is actually used in DelphiFMX4Python?

-> The tool "pasdoc" is able to analyze Delphi pascal files and output XML files containing the public parts. I used a tool to convert the XML files to JSON, as JSON is a little bit easier to handle (read & manipulate) than XML. As the Wiki page (https://github.com/Embarcadero/DelphiFMX4Python/wiki/Included-Types) also contains a list of elements per unit (e.g. TPoint , TRect and TSize for System.Types) the JSON content could be reduced to the used classes & records. The JSON files you can find in folder "spec". This JSON files will be used by language dependent generators.

I created an incident for pasdoc, as it is not able to parse System.Types (https://github.com/pasdoc/pasdoc/issues/171) DelphiFMXLib.zip

andre2007 avatar Jan 06 '23 20:01 andre2007

@andre2007 the source code distributed with Delphi has minimal documentation. We have extracted it from the DocWiki. It will be available in the VCL and FMX libraries in the coming release.

lmbelo avatar Jan 06 '23 22:01 lmbelo

@lmbelo I do not use pasdoc for its original purpose (generating documentation based on source code) but just for analyzing the Delphi units source code (Fmx.* and System.*). Pasdoc writes into an XML file, which classes are contained in Delphi unit and which methods and properties the classes have. These information can be used by coding generators to automatically generate Rust / D wrapper coding instead of manually writing it.

But what I need to know is, whether the Wiki page https://github.com/Embarcadero/DelphiFMX4Python/wiki/Included-Types is up to date. I would like to provide the exact same set of Delphi units / classes as DelphiFMX4Python provides.

andre2007 avatar Jan 06 '23 22:01 andre2007

Okay, let's meet on Thursday. @andre2007 , I just updated the wiki page with the updated Units and Types: https://github.com/Embarcadero/DelphiFMX4Python/wiki/Included-Types . It now includes all the Types that are wrapped under the correct Units. There might be some mistakenly wrapped types with a different parent for a given type. We need to update those in our upcoming releases. Our major focus at this point is to release minimal documentation for Python packages for whatever existing wrapped Types.

Priyatham10 avatar Jan 07 '23 04:01 Priyatham10

@Priyatham10 Thanks for updating the wiki.

I created 2 private repositories for the discussion. You should have received access: https://github.com/andre2007/DelphiFMXLib https://github.com/andre2007/DelphiFMX4D

I created a file spec.json, which contains the content from the wiki in a machine readable format:

{
    "units": {
        "System": {
            "types": ["Object"]
        },
		"System.Types": {
            "types": ["TPoint", "TPointF", "TRect", "TRectF", "TSize", "TSizeF"]
        },

The idea is, the lib folder and the spec folder are copied to language dependent repositories (D / Rust). You can see as example the repository DelphiFMX4D. In folder "scripts" I currently working on a script, which generates the D wrapper classes based on the spec.json and the output of pasdoc. But here I have some work to do.

andre2007 avatar Jan 08 '23 22:01 andre2007

Great @andre2007 . Please invite @lmbelo and @jimmckeeth also to those repos for access. We can have a conversation.

Priyatham10 avatar Jan 09 '23 09:01 Priyatham10

@Priyatham10 Yes, invitation was sent to all three of you.

I also started to make a list of discussion points for thursday: https://github.com/andre2007/DelphiFMXLib/issues/2

andre2007 avatar Jan 09 '23 21:01 andre2007

I'll try to get a meeting scheduled for next Thursday

jimmckeeth avatar Jan 11 '23 16:01 jimmckeeth

@jimmckeeth as non native speaker, next Thursday means tomorrow or January 19?

andre2007 avatar Jan 11 '23 17:01 andre2007

Good question. That is ambiguous even for native English speakers too. The 19th, so not this week, but next. The 19th.

jimmckeeth avatar Jan 11 '23 17:01 jimmckeeth

@Priyatham10 I have a question regarding the list of included types (https://github.com/Embarcadero/DelphiFMX4Python/wiki/Included-Types) The class TCollection is in the list of included types. It has a function function Add: TCollectionItem;. The class TCollectionItem is not in the list of included tpes. Can I also include all classes / types which are used in the public section of the included types. Therefore I can add TCollectionItem. Or should I skip the generation of functions / procedures which uses classes / types not specified in the wiki list.

andre2007 avatar Jan 19 '23 20:01 andre2007

It is probably an oversight on our side. I'm not aware of any reason to exclude it.

BTW, I realize today is the 19th, when I said we would meet. I had my meeting last week, and we are moving forward with another meeting, so it will still be a while before we have a "final" answer, but it is certainly optimistic.

jimmckeeth avatar Jan 19 '23 21:01 jimmckeeth

Thanks for the answer. This class just serve as example for the general case that the public functions / procedures/ properties using classes/ types which aren't listed.
I will add them, but keep them on a separate list, which could be checked in a later step.

andre2007 avatar Jan 19 '23 22:01 andre2007

Hi @andre2007 , Yes there are some types that we missed wrapping. It might be one of them. We're working adding missing ones. Please contribute by noting down the list of missed types so that we can improve. You can add those ones.

Priyatham10 avatar Jan 21 '23 01:01 Priyatham10

@Priyatham10 Yes, I like to contribute here. I assume we are using different Delphi versions (Mine is Delphi 10.2). Could you do me a favor and provide for the targeted Delphi version the Pasdoc SimpleXML files? Then we are working on the same base.

Here some info regarding Pasdoc

  • I use arguments --visible-members public,published and --write-uses-list to only include the public and published members and to include the uses list.
  • The latest binary of Pasdoc can be found via Github Actions (e.g. https://github.com/pasdoc/pasdoc/actions/runs/3954612471). This version has some fixes regarding properties
  • The current version of Pasdoc has some issues regarding the IFDEF statements in 2 system units. This is a known issue. For these 2 files no SimpleXml output can be generated at the moment. I have opened an issue in the Pasdoc repository.

The commands could look like this:

pasdoc --visible-members public,published --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\rtl\sys\System.Types.pas"
pasdoc --visible-members public,published --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\rtl\common\System.Classes.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\rtl\common\System.Actions.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\rtl\win\WinAPI.Windows.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Controls.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Controls.Presentation.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\databinding\components\Data.Bind.Components.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\databinding\components\Data.Bind.ObjectScope.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\databinding\components\FMX.Bind.Navigator.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Types.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.StdCtrls.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Edit.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.SearchBox.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.ComboEdit.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.EditBox.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.SpinBox.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.ListBox.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.ListView.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Dialogs.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.ActnList.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.StdActns.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.TabControl.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.MultiView.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Forms.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Objects.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Layouts.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.BufferedLayout.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.ScrollBox.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Grid.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Media.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Menus.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Styles.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Memo.pas"
pasdoc --visible-members public,published  --format simplexml --write-uses-list --output output "C:\Program Files (x86)\Embarcadero\Studio\19.0\source\fmx\FMX.Colors.pas"

andre2007 avatar Jan 21 '23 12:01 andre2007

@Priyatham10 I just noticed the SimpleXML output of Pasdoc is incomplete in case a Property is defined protected in an ancestor class and set to published in the child class. Either protected must be included in --visible-members argument or the Pasdoc behavior can be improved. I will file an issue for Pasdoc (https://github.com/pasdoc/pasdoc/issues/176)

andre2007 avatar Jan 22 '23 08:01 andre2007