Commit graph

838 commits

Author SHA1 Message Date
Diego Iastrubni 18257604eb Lagom: Win32 support baby steps
This is the initial port of Lagom to win32. This will enable developers
to use Lagom as an alternative to vanilla STL/StandardC++Library - which
gives a much richer environment (think QtCore - but modern).

My main incentive - is to have a native Windows Ladybird working.

I am starting with AK, which does not yet fully compile (on mingw). When
AK is compiling (currently fails building StringBuffer.cpp) - I will
continue to LibCore and then the rest of the user space libraries
(excluding the GUI, which will be another different effort).

Most of the code is happily stollen from Andrew Kaster's fork - he
deserves the credit.

Co-authored-by: Andrew Kaster <akaster@serenityos.org>
2022-09-29 17:01:22 +01:00
Timothy Flynn 9a1b24d5be LibTimeZone: Use the last DST rule in the TZDB if a match isn't found
Some time zones, like "Asia/Shanghai", use a set of DST rules that end
before present day. In these cases, we should fall back to last possible
RULE entry from the TZDB. The time zone compiler published by IANA (zic)
performs the same fallback starting with version 2 of the time zone file
format.
2022-09-28 23:52:51 +01:00
Linus Groh 9fb672e981 LibWeb: Implement '5.4. Request class' from the Fetch API :^) 2022-09-27 14:56:17 +01:00
Linus Groh b9d626d6b2 LibWeb: Don't always assign values to nullable IDL dictionary members
IDL dictionary members are nullable by default (unless marked as
`required`) and should not get any value assigned unless one was
provided by the userland code that isn't undefined, or if the member has
a default value.

This is so that we can use Optional<T> in the internal representation
and check for "is present" via Optional::has_value().
2022-09-27 14:56:17 +01:00
Linus Groh d38f1fb5b2 LibWeb: Fix bindings codegen for IDL enums with only one member
The SourceGenerator's @else@ mapping is only set in the second iteration
of the loop, causing the generated return for unrecognized values to not
be guarded by an else statement.
We can simply use a hardcoded 'else' here, @else@ is only to create the
first comparison as a plain 'if' and subsequent ones as 'else if'.
2022-09-27 14:56:17 +01:00
Timothy Flynn eb0657c23e LibWeb: Add WebIDL to the IDL generator's list of web namespaces
Without this, the generated DOMExceptionConstructor does not refer to
the WebIDL::DOMException with its fully qualified name. This caused an
ambiguity error on my machine.
2022-09-26 14:00:31 +01:00
Linus Groh bbaa05fcf9 LibWeb: Move DOMException from DOM/ to WebIDL/ 2022-09-25 19:13:31 +01:00
Andreas Kling 34c232def7 Lagom: Build DOMTreeModel from LibWebView
This will be used in Ladybird.
2022-09-25 12:10:28 +02:00
Andreas Kling 5778da765d Lagom: Build a tiny slice of LibGUI
We now build Model, ModelIndex and Icon from LibGUI. These will be used
in Ladybird to view the DOM tree model.
2022-09-25 12:09:36 +02:00
Linus Groh 2b2ccb3815 LibWeb: Replace 'heycam.github.io' links with 'webidl.spec.whatwg.org' 2022-09-24 19:32:09 +01:00
Linus Groh 86f68eb3c3 LibWeb: Move IDLOverloadResolution from Bindings/ to WebIDL/ 2022-09-24 19:31:39 +01:00
Linus Groh 4f73851afc LibWeb: Move CallbackType from Bindings/ to WebIDL/
Let's stop putting generic types and AOs from the Web IDL spec into
the Bindings namespace and directory in LibWeb, and instead follow our
usual naming rules of 'directory = namespace = spec name'. The IDL
namespace is already used by LibIDL, so Web::WebIDL seems like a good
choice.
2022-09-24 19:31:39 +01:00
Andrew Kaster d6a741af6c Meta: Don't build Core::LocalServer on Android
We won't be able to use local servers on Android without some serious
Android work to create background tasks, so just disable this for now,
as it currently relies on Core::Account to take over from SystemServer.
2022-09-22 11:07:21 -04:00
Linus Groh edfef8e2f5 Everywhere: Rename WrapperGenerator to BindingsGenerator
This code generator no longer creates JS wrappers for platform objects
in the old sense, instead they're JS objects internally themselves.
Most of what we generate now are prototypes - which can be seen as
bindings for the internal C++ methods implementing getters, setters, and
methods - as well as object constructors, i.e. bindings for the internal
create_with_global_object() method.

Also tweak the naming of various CMake glue code existing around this.
2022-09-21 23:06:08 +01:00
Linus Groh 6055b0e850 LibWeb: Remove no-op impl() methods from the WEB_PLATFORM_OBJECT macro
These are leftovers from when wrapper objects still had an internal
implementation, which is no longer the case.
2022-09-21 21:12:24 +01:00
Linus Groh 2cab2a8e8f LibWeb: Turn is_platform_object() ifs into an Array 2022-09-21 21:12:24 +01:00
Linus Groh 464368f94a LibWeb: Rename is_wrappable_type() to is_platform_object()
This name more accurately reflects what we are checking. Also add an
explanatory note that only a hand-curated subset of platform object
types is checked in the absence of a full generated list.
2022-09-21 21:12:24 +01:00
Linus Groh daf0a8dd91 LibWeb: Remove impl_is_wrapper() check from WrapperGenerator
This concept no longer applies to GC'd platform objects. The only place
where this was still used can use is_wrappable_type() instead.
2022-09-21 21:12:24 +01:00
Linus Groh 64a1992040 LibWeb: Remove support for RefPtr types in idl_type_name_to_cpp_type()
This is not used anymore.
2022-09-21 21:12:24 +01:00
Linus Groh 38b3ce8f03 LibIDL+LibWeb: Remove stale references to "wrapper class" concept
There are no wrappers for the platform object types anymore :^)
2022-09-21 21:12:24 +01:00
Timothy Flynn 739798e075 LibUnicode: Use recently added Core::Stream::read_all in code generators
The generators had a manual implementation when Core::Stream did not
have a read_all method.
2022-09-21 14:04:22 +01:00
Federico Guerinoni 4f46a0e4aa StateMachineGenerator: Remove unused variable
This fixes build on MacOS m1 arch.
2022-09-20 18:54:16 +01:00
Sam Atkins 684c3efc04 StateMachineGenerator: Port to LibMain and Core::Stream 2022-09-20 07:48:45 -04:00
Sam Atkins cb45fa79ee LibEDID: Use Core::Stream API to generate PnpIDs 2022-09-20 07:48:45 -04:00
Sam Atkins 32810f6d1a IPCCompiler: Use Core::Stream API 2022-09-20 07:48:45 -04:00
Andreas Kling 9743849ddb LibWeb: Allow passing null to a nullable IDL union type
This fixes an issue on Twitter where they were instantiating an
IntersectionObserver with a null root. The root IDL type is
`(Element or Document)?` so null needs to be allowed.
2022-09-18 12:53:06 +02:00
Andreas Kling 530675993b LibWeb: Rename Attribute to Attr
This name is not very good, but it's what the specification calls it.
2022-09-18 02:08:01 +02:00
Timothy Flynn 302b6e966f LibTimeZone: Generate DST rule timestamps at compile time
Rather than invoking AK::Time::from_timestamp at runtime, we can do so
at compile time. This reduces invoking TimeZone::get_time_zone_offset
100,000 times in a loop from about 7 seconds to 30 milliseconds.
2022-09-17 23:21:32 +02:00
Sam Atkins 07a0d9df30 WrapperGenerator: Use the new shiny Overload Resolution Algorithm :^)
We compute the effective overload sets for each argument count at build
time, to save us having to do it every time a function with overloads
is called.
2022-09-17 21:27:17 +02:00
Sam Atkins 8b4cc07a54 LibIDL+WrapperGenerator: Implement Type::is_distinguishable_from()
As part of this, I've moved a couple of methods for checking for
null/undefined from UnionType to Type, and filled in more of their
steps.

This now detects more, and so causes us to hit a `TODO()` which is too
big for me to go after right now, so I've replaced that assertion with
a log message.
2022-09-17 21:27:17 +02:00
Sam Atkins 7c8ef79898 LibIDL+WrapperGenerator: Make it easier to work with IDL::Type classes
Track the kind of Type it is, and use that to provide some convenient
`is_foo()` / `as_foo()` methods. While I was at it, made these all
classes instead of structs and made their data private.
2022-09-17 21:27:17 +02:00
Sam Atkins c4668053d1 LibIDL+WrapperGenerator: Move IDL code into a library
IDL function overload resolution requires knowing each IDL function's
parameters and their types at runtime. The simplest way to do that is
just to make the types the generator uses available to the runtime.

Parsing has moved to LibIDL, but code generation has not, since that is
very specific to WrapperGenerator.
2022-09-17 21:27:17 +02:00
Sam Atkins 634a52b589 WrapperGenerator: Clarify function-length getter name
These all return the shortest length of the function, so let's name them
as such.
2022-09-17 21:27:17 +02:00
Sam Atkins 4424a50bc4 WrapperGenerator: Move generation code out of IDLTypes.h 2022-09-17 21:27:17 +02:00
Andrew Kaster b04de3090f Lagom: Skip IMPORTED targets in get_linked_lagom_libraries
This script is useful when wanting to install lagom libraries for
projects using Lagom via FetchContent, but trips over itself if the
project links other non-Lagom imported targets to itself. So, let's just
skip them.
2022-09-16 07:48:51 -04:00
MacDue d1b99282d8 LibWeb+Meta: Parse the backdrop-filter CSS property
Note: The parsing and style value completely ignores the SVG filters
part of the spec for now... That's a yak for another day :^)
2022-09-16 10:50:48 +01:00
MacDue 0829aa5df0 Meta: Use is_abstract_image() for the "image" CSS type 2022-09-16 10:50:48 +01:00
Timothy Flynn 6290a25224 Meta: Enable vptr sanitation by default for Lagom UBSAN builds 2022-09-15 09:45:13 +02:00
Timothy Flynn 10727ade4c Meta: Add Lagom option to disable building LibWeb
Compiling LibWeb for Lagom can add quite a bit of compile time. Add a
CMake option to disable it locally.
2022-09-13 17:05:20 +02:00
Timothy Flynn b7ef36aa36 LibUnicode: Parse and generate custom emoji added for SerenityOS
Parse emoji from emoji-serenity.txt to allow displaying their names and
grouping them together in the EmojiInputDialog.

This also adds an "Unknown" value to the EmojiGroup enum. This will be
useful for emoji that aren't found in the UCD, or for when UCD downloads
are disabled.
2022-09-11 20:33:57 +01:00
Timothy Flynn 0aadd4869d LibUnicode: Generate emoji data for non-fully-qualified emoji
This allows us to find emoji data for files such as /res/emoji/U+A9.png.
U+00A9 is not fully-qualified (its full form is U+00A9 U+FE0F). But the
UCD has unqualified data for this code point; generating it allows us to
categorize these emoji appropriately in the EmojiInputDialog.
2022-09-11 20:33:57 +01:00
davidot 7948897688 LibJS: Import the libjs-test262-runner from linusg/libjs-test262
For now this is a lagom only application as it is not compatible with
serenity in its current state.

The only change is that it is released under a different license with
permission from all the authors.
2022-09-11 20:25:51 +01:00
davidot d4736d17ae LibJS: Allow negative pointers in Value
Also ensure that all a nullptr input gives null object and you don't
accidentally dereference a nullptr.
2022-09-10 00:05:32 +01:00
Andrew Kaster 5ab3fcf710 Meta: Update jakt build support for fully bootstrapped compiler
Remove the Corrosion dependency, and use the now-builtin
add_jakt_executable function from the Jakt install rules to build our
example application.

By using find_package(Jakt), we now have to set ENABLE_JAKT manually on
both serenity and Lagom at the same time, so the preferred method to do
this for now is:

    cmake -B Build/superbuild<arch><toolchain> \
          -S Meta/CMake/Superbuild \
          -DENABLE_JAKT=ON \
          -DJAKT_SOURCE_DIR=/path/to/jakt

Where omitting JAKT_SOURCE_DIR will still pull from the main branch of
SerenityOS/jakt. This can be done after runing Meta/serenity.sh run.
2022-09-09 11:23:42 +02:00
Timothy Flynn b61eca0a1e LibUncode: Parse and generate emoji code point data
According to TR #51, the "best definition of the full set [of emojis] is
in the emoji-test.txt file". This defines not only the emoji themselves,
but the order in which they should be displayed, and what "group" of
emojis they belong to.
2022-09-08 23:12:31 +01:00
Andreas Kling ddc018fb75 LibWeb: Use fully qualified type names in the IDL generator more
There are still some remaining cases where generated code depends on the
existence of FooWrapper => Web::NS::Foo mappings. Fixing those will
require figuring out the appropriate namespace for all IDL types, not
just the currently parsed interface.
2022-09-06 00:27:09 +02:00
Andreas Kling 8f110e0fb1 LibWeb: Remove the NoInstanceWrapper extended IDL attribute
No interfaces require wrappers anymore, so we can just make this the
default mode.
2022-09-06 00:27:09 +02:00
Andreas Kling 266136b32f LibWeb: Stop using Bindings::wrap() in generated code 2022-09-06 00:27:09 +02:00
Andreas Kling bc74909308 LibWeb: Remove many unnecessary #includes in generated code 2022-09-06 00:27:09 +02:00
Andreas Kling b1b5d75ce6 LibWeb: Remove now-unused wrapper and iterator code generators
These are no longer used, as all wrappers have been folded into their
corresponding C++ objects.
2022-09-06 00:27:09 +02:00