Commit graph

699 commits

Author SHA1 Message Date
Timothy Flynn
a338e9403b LibUnicode: Port the CLDR locale generator to the stream API
This adds a generator utility to read an entire file and parse it as a
JSON value. This is heavily used by the CLDR generators. The idea here
is to put the file reading details in the utility so that when we have a
good story for generically reading an entire stream in LibCore, we can
update the generators to use that by only touching this helper.
2022-02-14 11:39:46 -05:00
Timothy Flynn
a64a7940e4 LibUnicode: Port the UCD generator to the stream API 2022-02-14 11:39:46 -05:00
Timothy Flynn
9327c2233f LibTimeZone: Port the TZDB generator to the stream API
This also moves the open_file helper to the utility file. It's currently
a lambda redefined in each TZDB/Unicode generator. It used to display
the missing command line flag and other info local to each generator.
After switching to LibMain, it just returns a generic error message, and
is duplicated several times.
2022-02-14 11:39:46 -05:00
Luke Wilde
b7c435de17 LibWeb: Add support for record<K, V> types as input 2022-02-14 11:32:17 +01:00
Andreas Kling
4b412e8fee Revert "LibJS: Get rid of unnecessary work from canonical_numeric_index_string"
This reverts commit 3a184f7841.

This broke a number of test262 tests under "TypedArrayConstructors".
The issue is that the CanonicalNumericIndexString AO should not fail
for inputs like "1.1", despite them not being integral indices.
2022-02-13 16:01:32 +01:00
Anonymous
3a184f7841 LibJS: Get rid of unnecessary work from canonical_numeric_index_string
The spec version of canonical_numeric_index_string is absurdly complex,
and ends up converting from a string to a number, and then back again
which is both slow and also requires a few allocations and a string
compare.

Instead lets use the logic we already have as that is much more
efficient.

This improves performance of all non-numeric property names.
2022-02-13 14:44:36 +01:00
DerpyCrabs
2f828231c4 LibWeb: Implement Geometry::DOMRectList
Implement DOMRectList that is used as a return type of
getClientRects functions on Element and Range.
2022-02-12 22:43:10 +01:00
Andrew Kaster
820e99f97d LibWeb: Add initial implementation for WorkerGlobalScope
This initial implementation stubs out the WorkerGlobalScope,
WorkerLocation and WorkerNavigator classes. It doesn't take into account
all the things that actually need passed into the constructors for these
objects, nor the extra abstract operations that need to be performed on
them by the rest of the Browser infrastructure. However, it does create
bindings that compile and link :^)
2022-02-09 17:21:05 +01:00
Linus Groh
6508ff5bbd LibWeb: Stop using MVL for sequence storage in WrapperGenerator
Use MarkedVector<Value> instead.
2022-02-09 12:25:27 +00:00
Linus Groh
bc183dbbcb LibJS: Replace uses of MarkedValueList with MarkedVector<Value>
This is effectively a drop-in replacement.
2022-02-09 12:25:27 +00:00
Timothy Flynn
636a6a2fb8 Meta: Add a CPack installation target for js(1)
This adds a CPack configuration to generate a release package for js(1).
Our current CMake requirement is 3.16, which doesn't have a great story
for automatically installing a binary target's library dependencies. If
we eventually require CMake 3.21 or above, we can remove the helper
.cmake file added here in lieu of RUNTIME_DEPENDENCIES.
2022-02-09 12:19:56 +03:30
Luke Wilde
5aacec65ab LibWeb: Rewrite EventTarget to more closely match the spec
This isn't perfect (especially the global object situation in
activate_event_handler), but I believe it's in a much more complete
state now :^)

This fixes the issue of crashing in prepare_for_ordinary_call with the
`i < m_size` crash, as it now uses the IDL callback functions which
requires the Environment Settings Object. The environment settings
object for the callback is fetched at the time the callback is created,
for example, WrapperGenerator gets the incumbent settings object for
the callback at the time of wrapping. This allows us to remove passing
in ScriptExecutionContext into EventTarget's constructor.

With this, we can now drop ScriptExecutionContext.
2022-02-08 17:47:44 +00:00
davidot
1c4c251be3 LibJS+Everywhere: Remove all VM::clear_exception() calls
Since VM::exception() no longer exists this is now useless. All of these
calls to clear_exception were just to clear the VM state after some
(potentially) failed evaluation and did not use the exception itself.
2022-02-08 09:12:42 +00:00
kleines Filmröllchen
4931c88b13 LibGUI: Remove GML prefix in favor of proper namespace
Prefixes are very much a C thing which we don't need in C++. This commit
moves all GML-related classes in LibGUI into the GUI::GML namespace, a
change somewhat overdue.
2022-02-07 18:39:50 +01:00
James Puleo
2f646f4284 Meta: Add instructions on using Lagom in an external project 2022-02-07 11:04:07 +00:00
Andreas Kling
627ad6c37c LibWeb: Add a proper FocusEvent interface for "focus" and "blur" events 2022-02-07 00:04:50 +01:00
Linus Groh
6f20f49b21 Everywhere: Rename JS::PropertyKey variables from property_{name => key}
PropertyKey used to be called PropertyName, but got renamed. Let's
update all the variables of this type as well.
2022-02-06 22:02:45 +00:00
Morten Larsen
2c3b297895 Lagom: Exclude libraries with X86 code when building for macOS on Arm
The CMakeLists.txt for Lagom contains a few libraries and executables
with X86-specific code. By excluding those libraries, Lagom builds
for macOS on Arm as well. The places are marked FIXME to be removed
when the libraries will build for Arm.
2022-02-06 03:15:00 +00:00
Sam Atkins
e111e8e44e LibWeb: Type-check calc() in in property_accepts_value()
This means only CalculatedStyleValues that would return the desired type
will be accepted.
2022-02-04 13:52:02 +01:00
Andreas Kling
dc3bf32307 LibWeb: Add barebones CanvasGradient object
Also add the CanvasRenderingContext2D APIs to go along with it.
Note that it can't be used for anything yet.
2022-02-03 22:35:13 +01:00
Timothy Flynn
ea814a3ce6 LibTimeZone: Parse and generate time zone coordinate data 2022-02-03 16:11:15 +01:00
Idan Horowitz
2d50c08f34 LibUnicode: Download and parse {Grapheme,Word,Sentence} break props 2022-01-31 21:05:04 +02:00
Timothy Flynn
6efbafa6e0 Everywhere: Update copyrights with my new serenityos.org e-mail :^) 2022-01-31 18:23:22 +00:00
Luke Wilde
68813fbe70 LibWeb: Add initial support for passing union types into IDL functions
This currently does not accept ArrayBuffer, DataView, TypedArrays,
callback functions, nullable types, dictionaries, records and frozen
arrays.
2022-01-31 15:25:36 +01:00
Luke Wilde
fb7ca09f04 LibWeb: Add support for passing sequences into IDL functions 2022-01-31 15:25:36 +01:00
Timothy Flynn
2e1db1b090 LibTimeZone: Use new generator util to generate all time zones
Added the call to generate_available_values(), then realized it is the
exact same as the existing, manually written implementation. So let's
use the new utility.
2022-01-31 00:32:41 +00:00
Timothy Flynn
bb0f548614 LibUnicode: Generate a list of available currencies 2022-01-31 00:32:41 +00:00
Timothy Flynn
481ced53d8 LibUnicode: Generate a list of available numbering systems 2022-01-31 00:32:41 +00:00
Timothy Flynn
ebd33e580b LibUnicode: Generate a list of available calendars 2022-01-31 00:32:41 +00:00
Timothy Flynn
4d43aeae30 LibUnicode: Fill in case-first and numeric BCP47 keywords
Unlike other BCP47 keywords that we are parsing, these only appear in
the BCP47 XML file itself within the CLDR. The values are very simple
though, so just hard code them until the Unicode org re-releases the
CLDR with BCP47: https://unicode-org.atlassian.net/browse/CLDR-15158
2022-01-29 20:27:24 +00:00
Itamar
1aa8f73ddb IPCCompiler: Don't loop endlessly on nameless parameters
Previously, given a malformed IPC call declaration, where a parameter
does not have a name, the IPCCompiler would spin endlessly while
consuming more and more memory.

This is because it parses the parameter type incorrectly
(it consumes superfluous characters into the parameter type).

An example for such malformed declaration is:
tokens_info_result(Vector<GUI::AutocompleteProvider::TokenInfo>) =|

As a temporary fix, this adds VERIFY calls that would fail if we're at
EOF when parsing parameter names.

A real solution would be to parse C++ parameter types correctly.
LibCpp's Parser could be used for this task.
2022-01-29 12:44:15 +01:00
Timothy Flynn
789f093b2e LibUnicode: Parse and generate relative-time format patterns
Relative-time format patterns are of one of two forms:

    * Tensed - refer to the past or the future, e.g. "N years ago" or
      "in N years".
    * Numbered - refer to a specific numeric value, e.g. "in 1 year"
      becomes "next year" and "in 0 years" becomes "this year".

In ECMA-402, tensed and numbered refer to the numeric formatting options
of "always" and "auto", respectively.
2022-01-27 21:16:44 +00:00
Timothy Flynn
27eda77c97 LibUnicode: Create a nearly empty generator for relative-time formatting
This sets up the generator plumbing to create the relative-time data
files. This data could probably be included in the date-time generator,
but that generator is large enough that I'd rather put this tangentially
related data in its own file.
2022-01-27 21:16:44 +00:00
Timothy Flynn
589e7354fb LibUnicode: Remove extraneous semi-colons at end of generator functions 2022-01-27 21:16:44 +00:00
Timothy Flynn
2d2f713426 LibUnicode: Generate per-locale minimum grouping digit values
Previously, we were breaking up digits into groups without regard for
the locale's minimumGroupingDigits value in the CLDR. This value is 1 in
most locales, but is 2 in locales such as pl-PL. What this means is that
in those locales, the group separator should only be inserted if the
thousands group has at least 2 digits. So 1000 is formatted as "1,000"
in en-US, but "1000" in pl-PL. And 10000 is "10,000" in en-US and
"10 000" in pl-PL.
2022-01-27 20:30:52 +00:00
davidot
b40308d0a4 Tests+LibJS: Add very simple bytecode LibJS tests
These tests are not meant as a replacement to test-js with the -b option
but are meant to test simple cases until that works.
Before this it was very easy to accidentally break bytecode since no
tests were run in bytecode mode. This hopefully makes it easier to spot
such regressions :^).
2022-01-25 23:26:14 +00:00
Timothy Flynn
bced4e9324 LibJS+LibUnicode: Convert Intl.ListFormat to use Unicode::Style
Remove ListFormat's own definition of the Style enum, which was further
duplicated by a generated ListPatternStyle enum with the same values.
2022-01-25 19:02:59 +00:00
Timothy Flynn
1f051a8e25 LibTimeZone: Handle time zones which begin the year in daylight savings 2022-01-25 18:39:36 +00:00
Timothy Flynn
7103012c7d LibTimeZone: Add an API to retrieve both daylight and standard offsets
This API will also include the formatted name of the time zone, with
respect for DST (e.g. EST vs EDT for America/New_York).
2022-01-25 18:39:36 +00:00
Timothy Flynn
fc0c88344b LibTimeZone: Slightly refactor the generated DST rule finding method
This just splits up the method to find the active DST rule for specified
time and time zone. This is to allow re-using the now split-off function
in upcoming commits.
2022-01-25 18:39:36 +00:00
Timothy Flynn
ef0155932b LibTimeZone: Parse and generate time zone abbreviation format strings
For example, today, America/New_York has the format string "E%sT" and
uses US DST rules. Those rules indicate the %s should be replaced by a
"D" in daylight time and "S" in standard time.
2022-01-25 18:39:36 +00:00
Idan Horowitz
67ce9e28a5 AK: Standardize the behaviour of GenericLexer::consume_until overloads
Before this commit all consume_until overloads aside from the Predicate
one would consume (and ignore) the stop char/string, while the
Predicate overload would not, in order to keep behaviour consistent,
the other overloads no longer consume the stop char/string as well.
2022-01-25 13:41:09 +03:30
Tom
869c20b05d Meta+LibEDID: Download and generate the PNP ID database
This downloads the UEFI's published PNP ID database and generates a
lookup table for use in LibEDID. The lookup table isn't optimized at
all, but this can be easily done at a later point if needed.
2022-01-23 22:45:21 +00:00
Idan Horowitz
ace36681ff LibJS+LibIMAP: Use the new Optional<U>(Optional<T>) constructor
These look much nicer than these repeated ternaries :^)
2022-01-23 18:53:42 +02:00
mjz19910
1ef633472b Everywhere: Convert VM::call() to JS::call() 2022-01-23 15:24:45 +00:00
Timothy Flynn
da27937144 LibTimeZone: Add an API to retrieve a list of all known IANA time zones 2022-01-23 12:48:26 +00:00
Nico Weber
3831e5fcff Utilities+Lagom: Remove test-crypto
After 4d5ffd364a, Tests/{LibCrypto,LibTLS} test the same things
and test-crypto has been redundant since then.
2022-01-22 01:44:05 +00:00
Luke Wilde
631bbcd00a LibJS: Refactor interpreter to use Script and Source Text Modules
This also refactors interpreter creation to follow
InitializeHostDefinedRealm, but I couldn't fit it in the title :^)

This allows us to follow the spec much more closely rather than being
completely ad-hoc with just the parse node instead of having all the
surrounding data such as the realm of the parse node.

The interpreter creation refactor creates the global execution context
once and doesn't take it off the stack. This allows LibWeb to take the
global execution context and manually handle it, following the HTML
spec. The HTML spec calls this the "realm execution context" of the
environment settings object.

It also allows us to specify the globalThis type, as it can be
different from the global object type. For example, on the web, Window
global objects use a WindowProxy global this value to enforce the same
origin policy on operations like [[GetOwnProperty]].

Finally, it allows us to directly call Program::execute in perform_eval
and perform_shadow_realm_eval as this moves
global_declaration_instantiation into Interpreter::run
(ScriptEvaluation) as per the spec.

Note that this doesn't evalulate Source Text Modules yet or refactor
the bytecode interpreter, that's work for future us :^)

This patch was originally build by Luke for the environment settings
object change but was also needed for modules. So I (davidot) have
modified it with the new completion changes and setup for that.

Co-authored-by: davidot <davidot@serenityos.org>
2022-01-22 01:21:18 +00:00
kleines Filmröllchen
8a92573732 LibAudio: Convert FlacLoader to use new Core::Stream APIs :^)
For this change to work "easily", Loader can't take const ByteBuffer's
anymore, which is fine for now.
2022-01-22 01:13:42 +03:30
mjz19910
2cf02c6f38 adjtime: Port to LibMain 2022-01-21 01:52:22 +01:00
Sam Atkins
cff44831a8 LibWeb: Remove Length::Type::Percentage :^)
All `<percentage>`s in the CSS grammar are now represented by the
`Percentage` class, and `<length-percentage>` by `LengthPercentage`.
2022-01-20 00:04:10 +01:00
Sam Atkins
01b57fa8b7 LibWeb: Add CSS::Percentage, PercentageOr and LengthPercentage types
Length and Percentage are different types, and sometimes only one or the
other is allowed in a given CSS property. This is a first step towards
separating them.
2022-01-20 00:04:10 +01:00
Timothy Flynn
4400150cd2 LibJS+LibUnicode: Return the appropriate time zone name depending on DST 2022-01-19 21:20:41 +00:00
Timothy Flynn
bf677eb485 LibUnicode: Generate both standard and daylight time zone names
While LibTimeZone didn't support DST, we only generated one of them,
preferring the standard name. Now that DST can be tested, generate both
names.
2022-01-19 21:20:41 +00:00
Timothy Flynn
70f49d0696 LibJS+LibTimeZone+LibUnicode: Indicate whether a time zone is in DST
Return whether the time zone is in DST during the provided time from
TimeZone::get_time_zone_offset,
2022-01-19 21:20:41 +00:00
Timothy Flynn
42c9c57141 LibJS+LibTimeZone: Begin handling DST when computing time zone offsets
This also updates some expectations in a Temporal time zone offset test
that is using a time stamp which is in DST for a few time zones.
2022-01-19 21:20:41 +00:00
Timothy Flynn
9dd4602636 LibTimeZone: Parse and generate DST rule links for each ZONE entry
Each ZONE entry contains a RULES segment with one of the following:

  * A DST rule name, which links the ZONE to a RULE entry holding the
    DST rules to apply.
  * A static offset to be applied to the STDOFF offset. This implicitly
    means that the time zone is in DST during that time frame.
  * A "-" string, meaning no offset is applied to the STDOFF offset, and
    the time zone is in standard time during that time frame.
2022-01-19 21:20:41 +00:00
Timothy Flynn
0e58b04b5c LibTimeZone: Begin parsing and generating DaylightSavings rules 2022-01-19 21:20:41 +00:00
Timothy Flynn
701b7810ba LibUnicode: Generate code point abbreviations 2022-01-18 15:13:25 +00:00
Idan Horowitz
877ae85017 LibJS+LibUnicode: Make static const Utf8View variables constexpr 2022-01-17 14:46:07 +00:00
sin-ack
2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30
Lucas CHOLLET
9e1e80954b gml-format: Port to LibMain 2022-01-14 19:42:19 +02:00
Lucas CHOLLET
affef5d1a9 disasm: Port to LibMain 2022-01-14 19:42:19 +02:00
Timothy Flynn
c86f7a675d LibUnicode: Do not limit language display names to known locales
Currently, the UnicodeLocale generator collects a list of known locales
from the CLDR before processing language display names. For each locale,
the identifier is broken into language, script, and region subtags, and
we create a list of seen languages. When processing display names, we
skip languages we hadn't seen in that first step.

This is insufficient for language display names like "en-GB", which do
not have an locale entry in the CLDR, and thus are skipped. So instead,
create the list of known languages by actually reading through the list
of languages which have a display name.
2022-01-13 23:05:31 +01:00
Timothy Flynn
91acc2e9c5 LibUnicode: Parse and generate locale display patterns
These patterns indicate how to display locale strings when that locale
contains multiple subtags. For example, "en-US" would be displayed as
"English (United States)".
2022-01-13 23:05:31 +01:00
Timothy Flynn
0d75949827 LibUnicode: Parse and generate locale display names for date fields 2022-01-13 13:43:57 +01:00
Timothy Flynn
7f162c471d LibUnicode: Parse and generate locale display names for calendars
Note there's a bit of an unfortunate duplication in the calendar enum
generated by UnicodeLocale and the existing enum generated by
UnicodeDateTimeFormat. The former contains every calendar known to the
CLDR, whereas the latter contains the calendars we've actually parsed
for DateTimeFormat (currently only Gregorian). The new enum generated
here can be removed once DateTimeFormat knows about all calendars.
2022-01-13 13:43:57 +01:00
Timothy Flynn
bdf02c21e1 LibUnicode: Swap the preferred order of standard time zone display names
Our generator is currently preferring the DST variant of the time zone
display names over the non-DST variant. LibTimeZone currently does not
have DST support, and operates in a mode that basically assumes DST does
not exist. Swap the display names for now just to be consistent until we
have DST support.

Note we will need to generate both of these variants and select the
appropriate one at runtime once we have DST support.
2022-01-12 15:43:12 +01:00
Timothy Flynn
0d8120eeb2 LibUnicode: Perform number system lookups by enumeration value
Now that number systems are generated as an enum, we can generated the
number system data in the order of that enum. This lets us perform
lookups of that data by index instead of a loop of string comparisons.
2022-01-12 10:49:07 +01:00
Timothy Flynn
c5138f0f2b LibUnicode: Parse number system digits from the CLDR
We had a hard-coded table of number system digits copied from ECMA-402.
Turns out these digits are in the CLDR, so let's parse the digits from
there instead of hard-coding them.
2022-01-12 10:49:07 +01:00
Timothy Flynn
e2dfbe8f67 LibUnicode: Parse and generate long and short generic time zone names
This implements the CalendarPatternStyle::{Long,Short}Generic styles of
time zone name formatting.
2022-01-11 23:56:35 +01:00
Timothy Flynn
8d35563f28 LibUnicode: Implement TR-35's localized GMT offset formatting
This adds an API to use LibTimeZone to convert a time zone such as
"America/New_York" to a GMT offset string like "GMT-5" (short form) or
"GMT-05:00" (long form).
2022-01-11 23:56:35 +01:00
Timothy Flynn
5aa144193c LibTimeZone: Use new AK::Time factory method in generated code 2022-01-11 23:56:35 +01:00
Timothy Flynn
09c0324880 LibTimeZone: Begin generating GMT offset rules for each time zone
This is a rather naive implementation, but serves as a first pass at
determining the GMT offset for a time zone at a particular point in
time. This implementation ignores DST (because we are not parsing any
RULE entries yet), and ignores any offset patterns of the form "Mon>4"
or "lastSun".
2022-01-11 00:36:45 +01:00
Timothy Flynn
1c2c98ac5d LibTimeZone: Add method to convert a time zone to a string 2022-01-11 00:36:45 +01:00
Timothy Flynn
14535fb67a LibTimeZone: Perform time-zone-from-string lookups case insensitively
Time zone names in the TZDB are defined to be case insensitive.
2022-01-11 00:36:45 +01:00
Timothy Flynn
b493c2ca90 LibTimeZone: Add a unit test for generated time zone data 2022-01-11 00:36:45 +01:00
Timothy Flynn
ccce9e5c7f LibTimeZone: Tweak the enumeration generated for parsed time zones
For example, generate "Etc/GMT+12" as "Etc_GMT_Ahead_12" (instead of as
"Etc_GMT_P12"). A little clearer what the name means without having to
know off-hand what "P" was representing.
2022-01-11 00:36:45 +01:00
Timothy Flynn
b543c3e490 Meta: Don't assume how each generator wants to generate keyed map names
The generate_mapping helper generates a series of structs like:

    Array<SomeType, 1> s_mapping_key_0 {};
    Array<SomeType, 2> s_mapping_key_1 {};
    Array<SomeType, 3> s_mapping_key_2 {};
    Array<Span<SomeType const>> s_mapping { {
        s_mapping_key_0.span(),
        s_mapping_key_1.span(),
        s_mapping_key_2.span(),
    } };

Where the names of the struct were generated by the format_mapping_name
lambda inside the helper. Rather than this lambda making assumptions on
how each generator wants to name its structs, add a parameter for the
caller to provide a naming formatter.

This is because the TimeZoneData generator will want pretty specific
identifier formatting rules.
2022-01-11 00:36:45 +01:00
Timothy Flynn
6da1bfeeea Meta: Support generating case-insensitive value-from-string methods
This also extracts the default parameters for generate_value_from_string
to a structure. This is just to make it cleaner to add new options.
2022-01-11 00:36:45 +01:00
Timothy Flynn
7d9b6b41c3 LibTimeZone: Remove accidental pluralization of generator variable names 2022-01-11 00:36:45 +01:00
Michel Hermier
e1685b6b69 Lagom: Avoid declaring Time in the global namespace
When compiled using clang, an ambiguity error is detected between
`class AK::Time` aliased to `::Time` and the `struct ::Time` provided
in `GenerateTimeZoneData.cpp`. Solve this by moving most of the code in
an anonymous namespace.
2022-01-10 15:57:59 +01:00
Federico Guerinoni
9aa556fdf0 Userland: Port wasm to LibMain 2022-01-09 04:26:16 -08:00
Lucas CHOLLET
ed0f4bdfaf Shell: Port to LibMain 2022-01-09 03:22:10 +03:30
Linus Groh
eb60d16549 LibJS: Convert Interpreter::run() to ThrowCompletionOr<Value>
Instead of making it a void function, checking for an exception, and
then receiving the relevant result via VM::last_value(), we can
consolidate all of this by using completions.

This allows us to remove more uses of VM::exception(), and all uses of
VM::last_value().
2022-01-08 23:43:03 +01:00
Simon Woertz
47f4e54cdc Lagom: Execute LibPDF unit tests on the host
Add lagom unit tests for `LibPDF`.
2022-01-08 18:57:55 +01:00
Timothy Flynn
498b741434 LibUnicode: Use LibTimeZone's list of time zone names
LibUnicode no longer needs to generate a list of time zone names that it
parsed from metaZones.json. We can defer to the TZDB for a golden list
of time zones.
2022-01-08 12:45:34 +01:00
Timothy Flynn
ca9123f66f LibUnicode: Rename DateTimeFormat's generator's TimeZone struct
Before using LibTimeZone within LibUnicode, rename this structure to
avoid naming conflicts with the TimeZone namespace.
2022-01-08 12:45:34 +01:00
Timothy Flynn
87abf00f7c LibTimeZone: Extract and parse the backwards compatibility LINK entries
This set of LINK entries contains the link from "UTC" to "Etc/UTC",
which LibJS will heavily depend upon.
2022-01-08 12:45:34 +01:00
Timothy Flynn
b5758a0623 LibTimeZone: Parse and generate LINK entries from the TZDB as aliases
For example, "GMT" should be linked to the golden time zone "Etc/GMT".
2022-01-08 12:45:34 +01:00
Timothy Flynn
9253e695d1 LibTimeZone: Parse ZONE entries from the TZDB and generate their names 2022-01-08 12:45:34 +01:00
Timothy Flynn
8669b25cea LibTimeZone+Meta: Add plumbing for an IANA Time Zone Database generator
The IANA Time Zone Database contains data needed, at least, for various
JavaScript objects. This adds plumbing for a parser and code generator
for this data. The generated data will be made available by LibTimeZone,
much like how UCD and CLDR data is available through LibUnicode.
2022-01-08 12:45:34 +01:00
Timothy Flynn
363eafbc44 Meta: Remove -ldl linkage from LagomUnicode
This was needed for dlopen() on some systems, but is no longer needed as
of commit 1116a29c19.
2022-01-08 12:45:34 +01:00
mjz19910
10ec98dd38 Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
Andrew Kaster
c62c10caf0 Meta+CI+Documentation: Bump host gcc requirement up to gcc 11
Bump macOS CI version to macOS 11 while we're here.
2022-01-07 11:02:30 +01:00
mjz19910
3102d8e160 Everywhere: Fix many spelling errors 2022-01-07 10:56:59 +01:00
Guilherme Gonçalves
f91d471843 LibSQL: Implement LIKE SQL expressions 2022-01-07 10:50:39 +03:30
Timothy Flynn
6d7d9dd324 LibUnicode: Do not assume time zones & meta zones have a 1-to-1 mapping
The generator parses metaZones.json to form a mapping of meta zones to
time zones (AKA "golden zone" in TR-35). This parser errantly assumed
this was a 1-to-1 mapping.
2022-01-06 22:28:01 +01:00
Timothy Flynn
62d8d1fdfd LibUnicode: Move UTC verification to the scope that requires it
In Unicode::get_time_zone_name(), we don't need to require that the time
zone is UTC for long- and short-style name lookups. This is required for
other styles, because they will depend on TZDB data - so move the VERIFY
to that scope.
2022-01-06 22:28:01 +01:00
Timothy Flynn
ec7d5351ed LibJS+LibUnicode: Handle flexible day periods that roll over midnight
When searching for the locale-specific flexible day period for a given
hour, we were neglecting to handle cases where the period crosses 00:00.
For example, the en locale defines a day period range of [21:00, 06:00).
When given the hour of 05:00, we were checking if (21 <= 5 && 5 < 6),
thus not recognizing that the hour falls in that period.
2022-01-05 16:22:55 +01:00
Timothy Flynn
dd88ff70ac LibUnicode: Remove now unused value-from-string generator overload 2022-01-04 22:49:43 +00:00
Timothy Flynn
437b9fe204 LibUnicode: Convert UnicodeData to link with weak symbols 2022-01-04 22:49:43 +00:00
Timothy Flynn
f576142fe8 LibJS+LibUnicode: Convert UnicodeLocale to link with weak symbols 2022-01-04 22:49:43 +00:00
Timothy Flynn
cf8e11a562 LibUnicode: Add temporary overload of value-from-string generator
This is a temporary mechanism while LibUnicode is in an in-between state
where some symbols are weakly linked and others are dynamically loaded.
The latter require an asm() label to be loaded.
2022-01-04 22:49:43 +00:00
Timothy Flynn
ba4cdf34f8 LibUnicode: Convert UnicodeDateTimeFormat to link with weak symbols 2022-01-04 22:49:43 +00:00
Timothy Flynn
98709d9be1 LibUnicode: Convert UnicodeNumberFormat to link with weak symbols
Currently, we load the generated Unicode symbols with dlopen at runtime.
This is unnecessary as of 565a880ce5.

Applications that want Unicode data now link directly against the shared
library holding that data. So the same functionality can be achieved
with weak symbols.
2022-01-04 22:49:43 +00:00
sin-ack
9121cc7cae LibWeb: Implement CanvasRenderingContext2D.measureText
This requires an implementation of the "text preparation algorithm" as
specified here:

html.spec.whatwg.org/multipage/canvas.html#text-preparation-algorithm

However, we're missing a lot of things such as the
CanvasTextDrawingStyles interface, so most of the algorithm was not
implemented. Additionally, we also are not able to use a LineBox like
the algorithm suggests, because our layouting infra is not up to the
task yet. The prepare_text function does nothing other than figuring out
the width of the given text and return glyphs with offsets at the
moment.
2022-01-04 22:41:07 +00:00
Timothy Flynn
126a3fe180 LibUnicode: Add minimal support for generic & offset-based time zones
ECMA-402 now supports short-offset, long-offset, short-generic, and
long-generic time zone name formatting. For example, in the en-US locale
the America/Eastern time zone would be formatted as:

    short-offset: GMT-5
    long-offset: GMT-05:00
    short-generic: ET
    long-generic: Eastern Time

We currently only support the UTC time zone, however. Therefore, this
very minimal implementation does not consider GMT offset or generic
display names. Instead, the CLDR defines specific strings for UTC.
2022-01-03 15:11:59 +01:00
tuftedocelot
5810467c97 Build: Remove gzip -k usage in PCI/USB ID files and crypt for OpenBSD
OpenBSD gzip does not have the -k flag to keep the original after
extraction. Work around this by copying the original gzip to the dest
and then extracting. A bit of a hack, but only needs to be done for the
first-time or rebuilds

OpenBSD provides crypt in libc, not libcrypt. Adjust if/else to check
for either and proceed accordingly

Remove outdated OpenBSD checks when building the toolchain
2021-12-29 03:46:56 -08:00
Stephan Unverwerth
ad3d5d43bd LibGL+LibSoftGPU: Move rendering related code to LibSoftGPU library
This introduces a new library, LibSoftGPU, that incorporates all
rendering related features that formerly resided within LibGL itself.

Going forward we will make both libraries completely independent from
each other allowing LibGL to load different, possibly accelerated,
rendering backends.
2021-12-24 05:10:28 -08:00
Brian Gianforcaro
39e5b42f36 IPCCompiler: Default initialize all parameter member variables
PVS Studio static analysis noticed we didn't initialize these in a
bunch of cases. This change fixes that so we will always initialize
these using universal initialization.
2021-12-22 13:29:31 -08:00
Ali Mohammad Pur
f20e0036bd Meta: Add a cmake flag for building for compiler explorer
We don't need to build tests/binaries for CE.
2021-12-22 20:49:28 +03:30
Timothy Flynn
52394deece LibUnicode: Remove now unused value-from-string generator overload
The generate_value_from_string_for_dynamic_loading() overload was just
temporary until all generates were switched over to dynamic loading.
2021-12-21 13:09:49 -08:00
Timothy Flynn
15e1498419 LibUnicode: Dynamically load the generated UnicodeDateTimeFormat symbols 2021-12-21 13:09:49 -08:00
Timothy Flynn
a1f0ca59ae LibUnicode: Dynamically load the generated UnicodeNumberFormat symbols 2021-12-21 13:09:49 -08:00
Timothy Flynn
09be26b5d2 LibUnicode: Dynamically load the generated UnicodeLocale symbols 2021-12-21 13:09:49 -08:00
Timothy Flynn
3fd53baa25 LibUnicode: Dynamically load the generated UnicodeData symbols
The generated data for libunicodedata.so is quite large, and loading it
is a price paid by nearly every application by way of depending on
LibRegex. In order to defer this cost until an application actually uses
one of the surrounding APIs, dynamically load the generated symbols.

To be able to load the symbols dynamically, the generated methods must
have demangled names. Typically, this is accomplished with `extern "C"`
blocks. The clang toolchain complains about this here because the types
returned from the generators are strictly C++ types. So to demangle the
names, we use the asm() compiler directive to manually define a symbol
name; the caveat is that we *must* be sure the symbols are unique. As an
extra precaution, we prefix each symbol name with "unicode_". For more
details, see: https://gcc.gnu.org/onlinedocs/gcc/Asm-Labels.html

This symbol loader used in this implementation provides the additional
benefit of removing many [[maybe_unused]] attributes from the LibUnicode
methods. Internally, if ENABLE_UNICODE_DATABASE_DOWNLOAD is OFF, the
loader is able to stub out the function pointers it returns.

Note that as of this commit, LibUnicode is still directly linked against
LibUnicodeData. This commit is just a first step towards removing that.
2021-12-21 13:09:49 -08:00
Linus Groh
92672b1520 Meta: Add a fuzzer for the QOILoader 2021-12-21 13:27:27 +01:00
Michel Hermier
060e5ccbbc Lagom: Bind time_zone_list_index_type in the generator
The variable `s_time_zone_list_index_type` seems to be unused (detected
when compiling with clang), and it seems logical to bind it even it if
it is not used for now.
2021-12-18 21:01:10 -08:00
Simon Woertz
c2df6b597a Lagom: Add argument WORKING_DIRECTORY to lagom_test(...)
So far the working directory was set in some cases using
`set_tests_properties(...)`, but this requires to know which name is
picked by `lagom_test(...)` when calling `add_test(...)`.
In case of adding multiple test cases using a globbing pattern this
would require to duplicate code to construct the test name from the file
name.
2021-12-15 10:33:27 -08:00
Linus Groh
976ab23b9c LibWeb: Add support for the BufferSource IDL parameter type 2021-12-14 09:01:06 +01:00
Linus Groh
615be9eb7c LibWeb: Add the SubtleCrypto interface
Just some boilerplate code to get started :^)
This adds both the SubtleCrypto constructor to the window object, as
well as the crypto.subtle instance attribute.
2021-12-14 09:01:06 +01:00
Timothy Flynn
ce6c515873 LibUnicode: Generate unique list patterns and lists of list patterns 2021-12-13 21:28:56 -08:00
Timothy Flynn
0ad2decd04 LibUnicode: Generate unique list of keyword values 2021-12-13 21:28:56 -08:00
Timothy Flynn
0c6cc4ad96 LibUnicode: Generate unique lists of localized currencies 2021-12-13 21:28:56 -08:00
Timothy Flynn
a45f2ccc25 LibUnicode: Generate unique lists of languages, territories, and scripts 2021-12-13 21:28:56 -08:00
Timothy Flynn
6e5f0b139b LibUnicode: Remove unused fields from generated structures
A couple of structures held a string index that is unused. Removing them
also removes the string values from the unique string list.
2021-12-13 21:28:56 -08:00
Timothy Flynn
77fc877c04 LibUnicode: Generate unique lists of hour cycles 2021-12-13 21:28:56 -08:00
Timothy Flynn
6f17696176 LibUnicode: Generate unique lists of time zone structures 2021-12-13 21:28:56 -08:00
Timothy Flynn
df33156462 LibUnicode: Generate unique lists of day period structures 2021-12-13 21:28:56 -08:00
Timothy Flynn
265785e847 LibUnicode: Generate unique day period structures 2021-12-13 21:28:56 -08:00
Timothy Flynn
7af1818e76 LibUnicode: Generate unique time zone structures
Each of the 374 locales contain 156 time zone structures. Of these
58,344 structures, 13,578 are unique.
2021-12-13 21:28:56 -08:00
Timothy Flynn
b14b37f386 LibUnicode: Generate unique calendar structures
Of the 374 generated calendars, 173 are unique.
2021-12-13 21:28:56 -08:00
Timothy Flynn
4b721597d7 LibUnicode: Generate unique lists of calendar range patterns
Of the 374 range pattern lists and 374 range12 pattern lists, 230 are
unique.
2021-12-13 21:28:56 -08:00
Timothy Flynn
9fc2442e7d LibUnicode: Generate unique lists of calendar patterns
Of the 374 generated lists, 152 are unique. These lists have upwards of
1000 entries as well, so the de-duplication is particularly nice.
2021-12-13 21:28:56 -08:00
Timothy Flynn
09547f4084 LibUnicode: Generate unique lists of calendar symbols structures
Of the 374 generated lists, 120 are unique.
2021-12-13 21:28:56 -08:00
Timothy Flynn
f681ec9d98 LibUnicode: Generate unique calendar symbols structures
Each of the 374 generated calendars include 4 symbols structures. Of
these 1496 structures, only 386 are unique.
2021-12-13 21:28:56 -08:00
Timothy Flynn
62ff029890 LibUnicode: Generate CalendarSymbols in a predetermined order
Similar to commit 2a7f36b392, this change moves the generated
CalendarSymbol enumeration to the public LibUnicode/NumberFormat.h
header with a pre-defined set of symbols that we need. This is to
prepare for uniquely generating the CalendarSymbols structure.
2021-12-13 21:28:56 -08:00
Timothy Flynn
cf8ef954e5 LibUnicode: Generate unique lists of calendar symbols
Each of the 374 generated calendars include 4 sets of symbols, each of
which have 3 lists of symbols (narrow, short, long). Of these 4488
lists, only 819 are unique.
2021-12-13 21:28:56 -08:00
Timothy Flynn
af7caa97c8 LibUnicode: Generate unique calendar format structures
There are currently 374 calendars generated, each of which include 3
CalendarFormat structures. Of these 1122 instances, only 167 are unique.
2021-12-13 21:28:56 -08:00
Timothy Flynn
415763b1b3 LibUnicode: Define traits for a vector of integral/enum types
Any generator which defines a unique storage instance for a list of
numbers will need this.
2021-12-13 21:28:56 -08:00
Linus Groh
f37d00c07b LibWeb: Implement TextEncoder.prototype.encode() 2021-12-12 20:58:36 +01:00
Linus Groh
35d3a1e77b LibWeb: Add the TextEncoder interface
This is from the Encoding Standard (https://encoding.spec.whatwg.org),
and therefore gets its own namespace and subdirectory within LibWeb :^)
2021-12-12 20:58:36 +01:00
Daniel Bertalan
4a81b33c07 Everywhere: Fix -Winconsistent-missing-override warnings from Clang
This option is already enabled when building Lagom, so let's enable it
for the main build too. We will no longer be surprised by Lagom Clang
CI builds failing while everything compiles locally.

Furthermore, the stronger `-Wsuggest-override` warning is enabled in
this commit, which enforces the use of the `override` keyword in all
classes, not just those which already have some methods marked as
`override`. This works with both GCC and Clang.
2021-12-11 13:14:15 -08:00
Timothy Flynn
1e95e7716b LibUnicode: Generate unique units 2021-12-11 14:17:47 +00:00
Timothy Flynn
4c2c8b8e33 LibUnicode: Generate unique number systems 2021-12-11 14:17:47 +00:00
Timothy Flynn
2a7f36b392 LibJS+LibUnicode: Generate unique numeric symbol lists
There are 443 number system objects generated, each of which held an
array of number system symbols. Of those 443 arrays, only 39 are unique.

To uniquely store these, this change moves the generated NumericSymbol
enumeration to the public LibUnicode/NumberFormat.h header with a pre-
defined set of symbols that we need. This is to ensure the generated,
unique arrays are created in a known order with known symbols. While it
is unfortunate to no longer discover these symbols at generation time,
it does allow us to ignore unwanted symbols and perform less string-to-
enumeration conversions at lookup time.
2021-12-11 14:17:47 +00:00
Timothy Flynn
9cc323b0b0 LibUnicode: Generate unique NumberFormat lists for each Unit 2021-12-11 14:17:47 +00:00
Timothy Flynn
cdbfe01827 LibUnicode: Generate unique NumberFormat lists for each NumberSystem 2021-12-11 14:17:47 +00:00
Timothy Flynn
76af9fae63 LibUnicode: Support storing lists in UniqueStorage for code generators
The evolution of UniqueStorage has been as follows:

1. It was created as UniqueStringStorage to ensure only one copy of each
   unique string is generated. Interested parties stored an index into
   a unique string list, rather than the string itself.
   Commits: f9e605397c and 04e6b43f05

2. It became apparent that non-string structures could also be de-
   duplicated to reduce the size of libunicode.so. UniqueStringStorage
   was generalized to UniqueStorage for this purpose.
   Commit: d8e6beb14f

It's now also apparent that there's heavy duplication of lists of
structures. For example, the NumberFormat generator stores 4 lists of
NumberFormat objects. In total, we currently generate nearly 2,000 lists
of these objects, of which 275 are unique.

This change updates UniqueStorage to support storing lists. The only
change is how the storage is generated - we generate each stored list
individually, then an array storing spans of those lists.
2021-12-11 14:17:47 +00:00
Timothy Flynn
a417c23de0 LibUnicode: Parse and generate per-locale day period ranges 2021-12-10 21:27:24 +00:00
Timothy Flynn
fa8e881cfa LibUnicode: Parse and generate secondary day period symbols
Generate morning2, afternoon2, evening2, and night2 symbols.
2021-12-10 21:27:24 +00:00
Timothy Flynn
76aab821f4 LibJS+LibUnicode: Rename some Unicode::DayPeriod values
In the CLDR, there aren't "night" values, there are "night1" & "night2"
values. This is for locales which use a different name for nighttime
depending on the hour. For example, the ja locale uses "夜" between the
hours of 19:00 and 23:00, and "夜中" between the hours of 23:00 and
04:00. Our CLDR parser is currently ignoring "night2", so this rename
is to prepare for that.

We could probably come up with better names, but in the end, the API in
LibUnicode will be such that outside callers won't even see Night1, etc.
2021-12-10 21:27:24 +00:00
Timothy Flynn
9d4c4303fd LibUnicode: Parse and generate date time range format patterns 2021-12-09 23:43:04 +00:00
Timothy Flynn
fe84a365c2 LibUnicode: Parse and generate format pattern skeletons
Pattern skeletons are more or less the "key" of format patterns. Every
format pattern is assigned a skeleton. Interval patterns (which are not
yet parsed) are also assigned a skeleton - this is used to match them to
an "owning" format pattern. So we will use the skeleton generated here
to match format patterns at runtime with their available interval
patterns.

An alternative approach would be to append interval patterns directly to
their owning format pattern, but this has some draw backs:

    1. Skeletons aren't totally unique. A skeleton may appear in both
       the "dateFormats" and "availableFormats" objects, in which case
       the same interval formats would be generated more than once.

    2. Otherwise unique format patterns may only differ by the interval
       patterns assigned to them. This would cause the UniqueStorage for
       the format patterns to increase in size, impacting both compile
       times and libunicode.so size.
2021-12-09 23:43:04 +00:00
Timothy Flynn
b17c6ab661 LibUnicode: Fix typo in format pattern parser
See: https://unicode.org/reports/tr35/tr35-dates.html#dfst-day
2021-12-09 23:43:04 +00:00
Sam Atkins
c9062b4ed5 LibWeb: Remove now-unused CustomStyleValue 2021-12-09 21:30:31 +01:00
Timothy Flynn
b76e44f66f LibUnicode: Parse and generate time zone names in long and short form 2021-12-08 11:29:36 +00:00
Timothy Flynn
2bbf8aa24c LibUnicode: Generate era, month, weekday and day period calendar symbols
The parsing in parse_calendar_symbols() might be a bit more verbose than
it really needs to be, but it is to ensure the symbols are generated in
a known order that we can control with enumerations.
2021-12-08 11:29:36 +00:00
Timothy Flynn
9f7c727720 LibJS+LibUnicode: Generate missing patterns with fractionalSecondDigits
TR-35's Matching Skeleton algorithm dictates how user requests including
fractional second digits should be handled when the CLDR format pattern
does not include that field. When the format pattern contains {second},
but does not contain {fractionalSecondDigits}, generate a second pattern
which appends "{decimal}{fractionalSecondDigits}" to the {second} field.
2021-12-08 11:29:36 +00:00
Timothy Flynn
6ace4000bf LibJS+LibUnicode: Supply field type in CalendarPattern's for-each method
Some callers will want different behavior depending on what field is
being provided to the callback.
2021-12-08 11:29:36 +00:00
Timothy Flynn
80ea6e664d LibUnicode: Do not set day period format length for {ampm} segments
TR-35 does define lengths for {ampm}, but they are unused by ECMA-402.
To the contrary, defining the day_period length for this segment will
prevent BasicFormatMatcher from ever selecting a pattern that contains
this segment. Instead, ECMA-402 will only use the short length for
{ampm} segments.
2021-12-08 11:29:36 +00:00
Timothy Flynn
dfe8d02482 LibUnicode: Generate missing format patterns
TR-35 describes how to combine date, time, and available formats with
date-time format patterns to generate more available format patterns:
https://unicode.org/reports/tr35/tr35-dates.html#Missing_Skeleton_Fields

Use these steps to generate ~400 new patterns for each calendar. These
are required for ECMA-402's BasicFormatMatcher to produce reasonable
results.
2021-12-06 15:46:34 +01:00
Timothy Flynn
439b06bf0f LibUnicode: Fully parse date-time formatting patterns
Similar to NumberFormat, replace the segments of date-time patterns with
partitions that can be split at runtime. Also generate the pattern style
fields for e.g. era, day, hour, etc.
2021-12-06 15:46:34 +01:00
Timothy Flynn
2772606527 LibUnicode: Generate unique calendar pattern structures
Add unique storage for parsed CalendarPattern structures to ensure only
one copy of each structure is generated.

This doesn't have any impact on libunicode.so with the current generated
data. Rather, this prevents the amount of generated data from needlessly
growing astronomically once date-time patterns are fully parsed. There
will be 173,459 patterns parsed, of which only 22,495 (about 12%) are
unique. This change will save a few MB, and will also help compilation
times.
2021-12-06 15:46:34 +01:00
Timothy Flynn
1d735105c3 LibUnicode: Generate per-locale, per-calendar formats out of line
Currently, there's only a handful of entries in these arrays, so it is
not a huge deal to generate them inline with the struct that holds them.
But they will each soon contain a few hundred entries. Generate them out
of line for easier viewing in the generated code.
2021-12-06 15:46:34 +01:00
Timothy Flynn
945ca81dd7 LibUnicode: Generate unique number format structures
Add unique storage for parsed NumberFormat structures to ensure only one
copy of each structure is generated. Reduces libunicode.so on x86 from
13.2 MB to 11.4 MB.
2021-12-06 15:46:34 +01:00
Timothy Flynn
d8e6beb14f LibUnicode: Generalize the generators' unique string storage
UniqueStringStorage is used to ensure only one copy of a string will be
generated, and interested parties store just an index into the generated
storage. Generalize this class to allow any* type to be stored uniquely.

* To actually be storable, the type must have both an AK::Format and an
AK::Traits overload available.
2021-12-06 15:46:34 +01:00
Sam Atkins
16e5f24e64 Fuzzers: Cast unused smart-pointer return values to void 2021-12-05 15:31:03 +01:00
Sam Atkins
f3d8f80e9c IPCCompiler: Cast return value of synchronous void IPC calls to void
The synchronous call returns a NonnullOwnPtr that we don't use, so we
have to cast to prevent a compiler warning once smart pointers become
[[nodiscard]].
2021-12-05 15:31:03 +01:00
Timothy Flynn
bf79c73158 LibUnicode: Do not generate data for "generic" calendars
This is not a calendar supported by ECMA-402, so let's not waste space
with its data.

Further, don't generate "gregorian" as a valid Unicode locale extension
keyword. It's an invalid type identifier, thus cannot be used in locales
such as "en-u-ca-gregorian".
2021-12-01 16:36:26 +00:00
Timothy Flynn
7e6ad172a4 LibUnicode: Support code point names that apply to ranges of code points
For example, consider the following adjacent entries in UnicodeData.txt:

    3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;
    4DBF;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;;

Our current implementation would assign the display name "CJK Ideograph
Extension A" to code points U+3400 & U+4DBF, but not to the code points
in between. Not only should those code points be assigned a name, but
the Unicode spec also has formatting rules on what the names should be
(the names for these ranged code points are not as they appear in
UnicodeData.txt).

The spec also defines names for code point ranges that actually are
listed individually in UnicodeData.txt. For example:

    2F800;CJK COMPATIBILITY IDEOGRAPH-2F800;Lo;0;L;4E3D;;;;N;;;;;
    2F801;CJK COMPATIBILITY IDEOGRAPH-2F801;Lo;0;L;4E38;;;;N;;;;;
    2F802;CJK COMPATIBILITY IDEOGRAPH-2F802;Lo;0;L;4E41;;;;N;;;;;

Code points are only coalesced into a range if all fields after the name
are equivalent. Our parser will insert the range and its name formatting
pattern when it comes across the first code point in that range, then
ignore other code points in that range. This reduces the number of names
we generated by nearly 2,000.
2021-11-30 11:24:02 +01:00
Timothy Flynn
f2f4980f15 LibUnicode: Remove unused field from UnicodeData generator 2021-11-30 11:24:02 +01:00
Timothy Flynn
71903ea7e1 LibUnicode: Parse and generate calendar (ca) Unicode keywords
Also removes a few fly-by "StringView x = nullptr;" unnecessary
initializers.
2021-11-29 22:48:46 +00:00
Timothy Flynn
48ce72e472 LibUnicode: Parse and generate regional hour cycles
Unlike most data in the CLDR, hour cycles are not stored on a per-locale
basis. Instead, they are keyed by a string that is usually a region, but
sometimes is a locale. Therefore, given a locale, to determine the hour
cycles for that locale, we:

    1. Check if the locale itself is assigned hour cycles.
    2. If the locale has a region, check if that region is assigned hour
       cycles.
    3. Otherwise, maximize that locale, and if the maximized locale has
       a region, check if that region is assigned hour cycles.
    4. If the above all fail, fallback to the "001" region.

Further, each locale's default hour cycle is the first assigned hour
cycle.
2021-11-29 22:48:46 +00:00
Timothy Flynn
15fc03ef34 LibUnicode: Sort generated enums case-insensitively
This hasn't mattered yet by chance, because the source for all enums
contains names of the same case. But the enum generated for hour cycle
regions will have mixed case. Sort them case-insensitively in order to
traverse these names in the same order in both generate_enum and
generate_mapping.
2021-11-29 22:48:46 +00:00
Timothy Flynn
7872934861 LibUnicode: Parse and generate available candidate format patterns
These formats are used by ECMA-402 when neither a date nor time style is
specified. In that case, these patterns are searched for a best match.
2021-11-29 22:48:46 +00:00
Timothy Flynn
287d43f4be LibUnicode: Hard-code an alias from the Gregorian calendar to Gregory
This alias exists because the name "Gregorian" is too long to be used in
a locale identifier, i.e. "en-u-ca-gregorian" is invalid. Aliases for
calendars are defined here:
https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-bcp47/bcp47/calendar.json

However, CLDR version 40 neglected to actually include the cldr-bcp47
package in its release, so we don't have access to this data. So for now
hard-code this alias so that JavaScript can actually access it. See:
https://unicode-org.atlassian.net/browse/CLDR-15158
2021-11-29 22:48:46 +00:00
Timothy Flynn
f471ecdbe9 LibUnicode: Parse and generate date, time, and date-time format patterns 2021-11-29 22:48:46 +00:00
Timothy Flynn
5c57341672 LibUnicode: Create a nearly empty generator for date-time formatting
Similar to number formatting, the data for date-time formatting will be
located in its own generated file. This extracts the cldr-dates package
from the CLDR and sets up the generator plumbing to create the date-time
data files.
2021-11-29 22:48:46 +00:00
Timothy Flynn
914675e826 LibJS+LibUnicode: Separate number formatting methods from Locale.h
Currently, we generate separate data files for locale and number format
related tables/methods, but provide public accessors for all of the data
in one Locale.h file. Rather than continuing this trend for date-time,
relative time, etc. formatting, it's a bit easier to reason about if the
public accessors are also in separate files.
2021-11-29 22:48:46 +00:00
Hendiadyoin1
7a27ecc135 Tests: Add a simple LibGL render-test
At the moment we just check if we *can* render a simple triangle, we do
not yet actually test if the image is indeed the triangle we wanted.

This test also outputs the rendered image when GL_DEBUG is enabled to a
file called "picture.bmp" for manual verification.

Co-authored-by: sunverwerth <s.unverwerth@serenityos.org>
2021-11-29 23:17:05 +03:30
Hendiadyoin1
3a4dd5ff87 Lagom: Add LibGL to the libraries 2021-11-29 23:17:05 +03:30
Hendiadyoin1
849089c406 Lagom: Disable implicit-const-int-float-conversion warnings 2021-11-29 23:17:05 +03:30
Andreas Kling
cb9cac4e40 LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>
This allows us to use TRY() in decoding helpers, leading to a nice
reduction in line count.
2021-11-28 23:14:19 +01:00
Andreas Kling
8d76eb773f LibIPC: Make IPC::Connection::post_message() return ErrorOr 2021-11-28 23:14:18 +01:00
kleines Filmröllchen
96d02a3e75 LibAudio: New error propagation API in Loader and Buffer
Previously, a libc-like out-of-line error information was used in the
loader and its plugins. Now, all functions that may fail to do their job
return some sort of Result. The universally-used error type ist the new
LoaderError, which can contain information about the general error
category (such as file format, I/O, unimplemented features), an error
description, and location information, such as file index or sample
index.

Additionally, the loader plugins try to do as little work as possible in
their constructors. Right after being constructed, a user should call
initialize() and check the errors returned from there. (This is done
transparently by Loader itself.) If a constructor caused an error, the
call to initialize should check and return it immediately.

This opportunity was used to rework a lot of the internal error
propagation in both loader classes, especially FlacLoader. Therefore, a
couple of other refactorings may have sneaked in as well.

The adoption of LibAudio users is minimal. Piano's adoption is not
important, as the code will receive major refactoring in the near future
anyways. SoundPlayer's adoption is also less important, as changes to
refactor it are in the works as well. aplay's adoption is the best and
may serve as an example for other users. It also includes new buffering
behavior.

Buffer also gets some attention, making it OOM-safe and thereby also
propagating its errors to the user.
2021-11-28 13:33:51 -08:00
Timothy Flynn
0aa3e5c2ea LibUnicode: Port generator utility methods to ErrorOr
Most of these were VERIFY-ing for success, but propagating an error
message up to serenity_main() is much nicer than just a SIGABRT.
2021-11-23 22:58:05 +01:00
Timothy Flynn
55e0b91d8d LibUnicode: Port GenerateUnicodeNumberFormat to ErrorOr and LibMain 2021-11-23 22:58:05 +01:00
Timothy Flynn
8c5f19f7c8 LibUnicode: Port GenerateUnicodeLocale to ErrorOr and LibMain 2021-11-23 22:58:05 +01:00
Timothy Flynn
88dbf3c348 LibUnicode: Port GenerateUnicodeData to ErrorOr and LibMain
Also store command line arguments as StringViews rather than pointers.
2021-11-23 22:58:05 +01:00
Timothy Flynn
4c4b752ab8 Meta: Allow lagom_tool invocations to specify libraries to link 2021-11-23 22:58:05 +01:00
Timothy Flynn
a2ea704d21 Meta: Define LagomMain outside of the BUILD_LAGOM branch
This allows code generators to use LagomMain. Otherwise, during CI, they
are built during the superbuild without BUILD_LAGOM=ON.
2021-11-23 22:58:05 +01:00
Timothy Flynn
0e80c1ee6b LibUnicode: Invoke lagom_tool() with SOURCES inline 2021-11-23 22:58:05 +01:00
Linus Groh
cfecfbb214 js: Port to LibMain :^)
This wasn't particularly difficult, and there's not much use for the
nicer interface yet either. While unveil() is of limited use in js(1)
as it should be able to open arbitrary files, I feel like we should be
able to add a pledge() call.
2021-11-22 23:07:43 +01:00
Linus Groh
ba0f89a4d1 Lagom: Add LibMain as a lagom_lib() 2021-11-22 23:07:43 +01:00
Andreas Kling
5a79c69b02 LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>
This is a first step towards better error propagation from image codecs.
2021-11-21 20:22:48 +01:00
Ben Wiederhake
b06b54772e Meta+LibUnicode: Provide code point names through library 2021-11-20 00:31:55 +01:00
Timothy Flynn
93ee922027 LibUnicode: Support locales-without-script aliases for ECMA-402
As noted by ECMA-402, if a supported locale contains all of a language,
script, and region subtag, then the implementation must also support the
locale without the script subtag. The most complicated example of this
is the zh-TW locale.

The list of locales in the CLDR database does not include zh-TW or its
maximized zh-Hant-TW variant. Instead, it inlcudes the zh-Hant locale.
However, zh-Hant-TW is listed in the default-content locale list in the
cldr-core package. This defines an alias from zh-Hant-TW to zh-Hant. We
must then also support the zh-Hant-TW alias without the script subtag:
zh-TW. This transitively maps zh-TW to zh-Hant, which is a case quite
heavily tested by test262.
2021-11-19 11:45:35 +01:00
Timothy Flynn
4b535ce1c8 LibUnicode: Stop passing the cldr-core package to UnicodeNumberFormat
This is no longer needed now that this generator isn't parsing the
default-content locales.
2021-11-19 11:45:35 +01:00