Import of Verdigris.

This commit is contained in:
David Given
2024-01-14 00:00:22 +01:00
parent 24df218897
commit 85a565dc82
6 changed files with 330 additions and 0 deletions

View File

@@ -257,6 +257,10 @@ package, written by Robert Leslie et al, taken from
https://www.mars.org/home/rob/proj/hfs. It is GPL 2.0 licensed. Please see the
contents of the directory for the full text.
As an exception, `dep/verdigris` contains a partial copy of the verdigris
package, taken from https://github.com/woboq/verdigris. It is dual LGPL/GPLv2
licensed. Please see the contents of the directory for the full text.
__Important:__ Because of all these exceptions, if you distribute the
FluxEngine package as a whole, you must comply with the terms of _all_ of the
licensing terms. This means that __effectively the FluxEngine package is

37
dep/verdigris/ChangeLog Normal file
View File

@@ -0,0 +1,37 @@
Version 1.3 (August 2022)
* Add C++ API to allow meta programming your properties
* Added Option to reduce macro spam a bit (W_NO_PROPERTY_MACRO)
* Build with MSVC 2017, 2019, 2022
* Support from Qt 5.9 to 5.15 and Qt 6.0.0 to Qt 6.3.0
Version 1.2 (Juli 2019)
* Added W_OBJECT_IMPL_INLINE / W_GADGET_IMPL_INLINE / W_NAMESPACE_IMPL_INLINE (#51)
* Fix multiple-definition linker errors caused by W_NAMESPACE macro (#54)
* Fix build with MSVC 2019 (#46)
* Massive compile time improvements (#66)
* Qbs project files (#63)
* Tested with to Qt 5.13
Version 1.1 (September 2018)
* Auto-detect the access specifier. (No need to add W_Access::Private or
W_Access::Protected anymore)
* Optimized compilation time for classes with many properties
* Removed the need to set feature macro on MSVC
* Don't make the staticMetaObject a constexpr as it breaks C++17 Q_GADGET
declared in another translation unit (#38)
* Workaround MSVC 2017 Update 7 compiler crash (#30)
* Automatically mark the properties as FINAL for final classes (#40)
* Added support for enum class in Q_ENUM
* Added support enum alias (Qt 5.12 freature)
Version 1.0 (February 2018)
* Error out early without C++14 (#2)
* Set Designable and Scriptable flags by default so it works with QML (#3)
* Fix usage of Q_PRIVATE_PROPERTY (#5)
* Added MSVC 2017 support (#6)
* Support C++17 noexcept function part of the function signature (#9)
* Added W_NAMESPACE/W_NAMESPACE_IMPL and W_ENUM_NS/W_FLAG_NS/W_CASSINFO_NS
* Support for NOTIFY signal in parent class (Qt 5.10 feature)
* Imported new tests from Qt 5.10
Initial Release (May 2016)

View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this
licensedocument, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, “this License” refers to version 3 of the GNU Lesser
General Public License, and the “GNU GPL” refers to version 3 of the
GNU General Public License.
“The Library” refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An “Application” is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A “Combined Work” is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the “Linked
Version”.
The “Minimal Corresponding Source” for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The “Corresponding Application Code” for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort
to ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this
license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken
together, effectively do not restrict modification of the portions of
the Library contained in the Combined Work and reverse engineering for
debugging such modifications, if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this
license document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of
this License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with
the Library. A suitable mechanism is one that (a) uses at run
time a copy of the Library already present on the user's
computer system, and (b) will operate properly with a modified
version of the Library that is interface-compatible with the
Linked Version.
e) Provide Installation Information, but only if you would
otherwise be required to provide such information under section 6
of the GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the Application
with a modified version of the Linked Version. (If you use option
4d0, the Installation Information must accompany the Minimal
Corresponding Source and Corresponding Application Code. If you
use option 4d1, you must provide the Installation Information in
the manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library
side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities, conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of
it is a work based on the Library, and explaining where to find
the accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
as you received it specifies that a certain numbered version of the
GNU Lesser General Public License “or any later version” applies to
it, you have the option of following the terms and conditions either
of that published version or of any later version published by the
Free Software Foundation. If the Library as you received it does not
specify a version number of the GNU Lesser General Public License,
you may choose any version of the GNU Lesser General Public License
ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the Library.

112
dep/verdigris/README.md Normal file
View File

@@ -0,0 +1,112 @@
## About
This (header-only) library can be used to create an application using Qt, without the need of the
moc (MetaObject Compiler). It uses a different set of macro than Qt and templated constexpr code to
generate the QMetaObject at compile-time. It is entirely binary compatible with Qt.
Blog post presenting the project: https://woboq.com/blog/verdigris-qt-without-moc.html (2016)
Blog post with some implementation details: https://woboq.com/blog/verdigris-implementation-tricks.html (2018)
Browse code online: https://code.woboq.org/woboq/verdigris
Github Actions: [![Clang Tests](https://github.com/woboq/verdigris/actions/workflows/clang.yml/badge.svg?branch=master)](https://github.com/woboq/verdigris/actions/workflows/clang.yml) [![Gcc Tests](https://github.com/woboq/verdigris/actions/workflows/gcc.yml/badge.svg?branch=master)](https://github.com/woboq/verdigris/actions/workflows/gcc.yml) [![Windows Tests](https://github.com/woboq/verdigris/actions/workflows/windows.yml/badge.svg?branch=master)](https://github.com/woboq/verdigris/actions/workflows/windows.yml)
Appveyor:
[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/povubj5thvlsu6sy/branch/master?svg=true)](https://ci.appveyor.com/project/ogoffart/verdigris)
## Documentation
For an introduction, see the [tutorial.cpp](https://code.woboq.org/woboq/verdigris/tutorial/tutorial.cpp.html).
See also a more detailed documetation of the macros in the source code.
## Status
Almost all features of Qt are working. The Qt test have been ported.
Features that are not yet working:
- Q_PLUGIN_METADATA: This would require compiling to the Qt's binary json. Out of scope for now.
- QML_ELEMENT: This is a Qt6 feature that automatically registers the QObjects for QML. Out of scope for now.
- BINDABLE: Needs to be backported to the current C++ and Qt requirements.
- QMetaMethod::tag(): Not yet implemented, could be supported if needed, but is not really needed
for anything. (not even tested by Qt's auto test)
- Q_ENUM: Working, but requires to repeat the name of every enum value. Could be improved.
**New features compared to Qt with moc:**
- Support for templated QObject.
- Support for QObject nested in another class.
## How to Use
The library consist of only two headers files. You can either copy these header files in your
project, or adjust the include paths so that the compiler finds them.
You will find the headers in the 'src/' sub-directory.
Also make sure to set your compiler in, at least, C++14 mode. With qmake, you can do that with
`CONFIG += c++14`.
Tested with Qt >= 5.9.
Need a compiler that can do C++14 relaxed constexpr such as GCC 5.1 or Clang 3.5, or MSVC 2017
### Translations
When running `lupdate`, add the argument `-tr-function-alias Q_DECLARE_TR_FUNCTIONS+=W_OBJECT` to
avoid the warning that your class are not using the Q_OBJECT macro.
### Correspondance Table
This table show the correspondence between Qt macro and Verdigris macro:
| Qt macro | Use the Verdigris macro instead |
|----------------------------------------------|---------------------------------------------------|
| `Q_OBJECT` | `W_OBJECT(MyClass)` ... `W_OBJECT_IMPL(MyClass)` |
| `public slots: void mySlot(int x);` | `void mySlot(int x); W_SLOT(mySlot)` |
| `signals: void mySignal(int x);` | `void mySignal(int x) W_SIGNAL(mySignal,x)` |
| `Q_PROPERTY(int myProperty WRITE setProp READ getProp NOTIFY propChanged)` | `W_PROPERTY(int, myProperty WRITE setProp READ getProp NOTIFY propChanged)` |
| `Q_GADGET` | `W_GADGET(MyClass)` ... `W_GADGET_IMPL(MyClass)` |
| `Q_INVOKABLE void myFunction(int foo);` | `void myFunction(int foo); W_INVOKABLE(myFunction)`
| `Q_INVOKABLE MyClass(int foo);` | `MyClass(int foo); W_CONSTRUCTOR(int)` |
| `Q_CLASSINFO("foo", "bar")` | `W_CLASSINFO("foo", "bar")` |
| `Q_DECLARE_INTERFACE(MyInterface, "my.interface")` ... `Q_INTERFACE(MyInterface)` | `Q_DECLARE_INTERFACE(MyInterface, "my.interface")` ... `W_INTERFACE(MyInterface)` |
| `Q_NAMESPACE` | `W_NAMESPACE(MyNs)` ... `W_NAMESPACE_IMPL(MyNs)` |
| Q_ENUM/Q_FLAG/Q_ENUM_NS/Q_FLAG_NS | W_ENUM/W_FLAG/W_ENUM_NS/W_FLAG_NS |
## Who uses Verdigris ?
* [Ossia Score](https://ossia.io/), an interactive intermedia sequencer. ([github](https://github.com/OSSIA/score))
It uses Verdigris in productions. Verdigris allowed ossia score to use template with their QObject's, and solve some trouble with the build system.
<img align="right" src="https://woboq.com/logos/isotronic.png">
* [ISOTRONIC GmbH](https://isotronic.de/), a provider for visual inspection QA systems for automatic glass vial manufacturing, uses Verdigris in production:
> The transition from standard Qt affected more than 100 source code files and was done in not much more than a day. The reason for the switch was to be able to use a build system that has no interface for Qt's MOC process. In the rare cases of questions or problems the Verdigris team was quick and competent in resolving the issues. After more than 6 months of real-world experience we are still very happy with that decision.
* If you are using Verdigris and want to appear here, please open an issue, or a pull request
## Context
The macros were inspired by [CopperSpice](http://www.copperspice.com/).
The template code was based on previous work:
https://woboq.com/blog/reflection-in-cpp-and-qt-moc.html
Differences with CopperSpice:
1. Contrary to CopperSpice, this is not a fork of Qt, but just an alternative set of macro to define
Qt objects and signals and slot in a way that is binary compatible with Qt, but does not require
moc. This is to be used with the normal Qt. CopperSpice being an entire fork of Qt, it has more
differences with Qt and is not kept up to date with all the new features coming in Qt.
2. The QMetaObject is built at compile time in the read only section (like what moc does).
CopperSpice builds it at run-time when the library is loaded. So CopperSpice takes more memory
and load slower.
3. With CopperSpice, you cannot declare your slot within the class definition.
4. CopperSpice uses `__LINE__` in its macro making it impossible to declare several things in one line
or to declare objects or properties from macros.
5. The usability of some macro was (in our opinion) improved.
6. The additional Q_OBJECT_IMPL
## Licence
Like Qt, this library is under the dual licence LGPLv3 and GPLv2.
Being header-only, this removes many of the obligations of the LGPLv3.
If you have any questions or remark please email info@woboq.com

View File

@@ -0,0 +1,2 @@
This is a trimmed version 1.3 of Verdigris, obtained from here:
https://github.com/woboq/verdigris/releases/tag/v1.3

10
dep/verdigris/build.py Normal file
View File

@@ -0,0 +1,10 @@
from build.c import clibrary
clibrary(
name="verdigris",
hdrs={
"wobjectcpp.h": "./src/wobjectcpp.h",
"wobjectdefs.h": "./src/wobjectdefs.h",
"wobjectimpl.h": "./src/wobjectimpl.h",
},
)