Commit Graph

26 Commits

Author SHA1 Message Date
kleines Filmröllchen
c1323febc2 AK: Introduce UnixDateTime
This is a generic wrapper for a time instant relative to the unix epoch,
and does not account for leap seconds. It should be used in place of
Duration in most current cases.
2023-05-24 23:18:07 +02:00
kleines Filmröllchen
213025f210 AK: Rename Time to Duration
That's what this class really is; in fact that's what the first line of
the comment says it is.

This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
2023-05-24 23:18:07 +02:00
Ben Wiederhake
943ecaede6 LibIPC: Remove redundant IPC::Dictionary type
We already have and use HashMap<DeprecatedString, DeprecatedString>
nearly everywhere, which is essentially equivalent.
2023-05-21 07:53:45 +02:00
Timothy Flynn
a7bb72a3d6 LibIPC: Support transferring String over IPC
Note that unlike the StringView encoder, we do not handle any "null"
state, as the new String cannot be null.
2023-03-05 23:50:05 +00:00
Timothy Flynn
1858163d3c LibIPC: Add a built-in encoder/decoder for AK::Time 2023-02-24 15:50:42 -05:00
Timothy Flynn
9d2884603e LibIPC: Remove declarations of unimplemented IPC::Encoder methods
Should have been removed in af2ae7fda1.
2023-01-04 20:13:54 +01:00
Timothy Flynn
7c6b5ed161 LibIPC+LibC: Add and use a helper to encode/decoder container sizes
While refactoring the IPC encoders and decoders for fallibility, the
inconsistency in which we transfer container sizes was a frequent thing
to trip over. We currently transfer sizes as any of i32, u32, and u64.
This adds a helper to transfer sizes in one consistent way.

Two special cases here are DeprecatedString and Vector, whose encoding
is depended upon by netdb, so that is also updated here.
2023-01-04 20:13:54 +01:00
Timothy Flynn
4819ebe831 LibIPC: Remove now-unused stream operator from IPC::Encoder
The fallible encoders are now the only option to encode values.
2023-01-04 11:49:15 +01:00
Timothy Flynn
ab99ed5fba LibIPC+Everywhere: Change IPC::encode's return type to ErrorOr
In doing so, this removes all uses of the Encoder's stream operator,
except for where it is currently still used in the generated IPC code.
So the stream operator currently discards any errors, which is the
existing behavior. A subsequent commit will propagate the errors.
2023-01-04 11:49:15 +01:00
Timothy Flynn
af2ae7fda1 LibIPC: Replace Encoder::encode methods with IPC::encode specializations
Currently, the stream operator overload hides most encoding errors. In
an effort to make IPC encoding fallible, this first replaces the Encoder
overloads with IPC::encode specializations. The return type is still a
boolean, a future commit will change it to ErrorOr.

Note that just like in the analogous decoder commit (9b48362), these
specializations must be defined at the namespace scope. Further, all
arithmetic specializations are now in one method.
2023-01-04 11:49:15 +01:00
Timothy Flynn
4abafbbe3c LibIPC: Remove requirement that Variant types must begin with Empty
This is no longer required by the decoder.
2022-12-26 09:36:16 +01:00
kleines Filmröllchen
a06b277471 LibIPC: Support sending Variants over IPC
The format is quite simply the type index followed by the type in its
own native encoding; just implementing the receive side with static
typing is a bit convoluted. The only limitation of this implementation
is that the variant type has to contain an Empty somewhere as it is not
default constructible otherwise.

Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
2022-12-13 10:24:59 -05:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Timothy Flynn
b1ea418d14 LibIPC: Forward declare the encode() and decode() template functions
For the most part, we try to provide specializations of these functions
in various headers by including "LibIPC/Forward.h" and then declaring
encode() and decode() specializations. However, without any forward
declaration of these types, we aren't actually specializing anything.
Rather, we are just declaring overloads, which trips up the base encode
and decode template definitions.

The result is that LibIPC is very sensitive to include order, and the
DependentFalse<> static assertion would fail if the includes weren't
perfectly ordered.

By properly forward declaring these templates, we can make sure the
specializations receive precedence over the base templates.
2022-11-15 13:25:51 -05:00
Timothy Flynn
3994a79718 AK+LibIPC: Add a convenience encoder/decoder for JsonValue
This requires that JsonValue is implicitly default-constructible.
2022-11-08 19:58:34 -05:00
Ben Wiederhake
a99cd09891 Libraries: Add missing includes, add namespace qualifiers
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:

    // file: compile_me.cpp
    #include <LibDNS/Question.h>
    // That's it, this was enough to cause a compilation error.

Likewise for most other files touched by this commit.
2022-09-18 13:27:24 -04:00
kleines Filmröllchen
fc7d231b00 LibIPC: Allow transporting a SharedCircularQueue over IPC 2022-04-21 13:55:00 +02:00
Valtteri Koskivuori
f2b4c044db LibIPC: Add encoder and decoder for AK::OrderedHashMap
Seems like a useful thing to have.
2022-04-03 13:13:10 +01:00
Andreas Kling
ddce053f6c LibIPC: Replace u32/u64 value coders with u/ul/ull value coders
We can and should do more cleanups of this kind, but this is a quick fix
to unbreak the 32-bit HackStudio build.
2021-11-29 02:45:27 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
kleines Filmröllchen
2909c3a931 LibIPC: Add support for transferring doubles over IPC messages
I'm still wondering why nobody did this yet :^) Also changes the use of
unions for the more cleaner / less undefined AK::bit_cast.
2021-09-12 23:38:57 +02:00
Andreas Kling
7df8483379 LibIPC: Convert Encoder class to east-const style 2021-09-03 15:36:51 +02:00
Timothy
e42484bb65 AK+LibIPC: Make all enums codable
If an enum has a supported underlying type we can provide encoding and
decoding for the enum as well.
2021-07-04 13:48:20 +04:30
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00