mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:17:45 +00:00
Lagom: Move this into Meta/
This is more of a meta thing, since it's not seeing active development, but is just a way for me to build some Serenity parts and include them in other projects. Move it out of the root to keep things tidy.
This commit is contained in:
parent
618aebdd8a
commit
dcd10149fe
7 changed files with 0 additions and 0 deletions
5
Meta/Lagom/.gitignore
vendored
Normal file
5
Meta/Lagom/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
liblagom.a
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
32
Meta/Lagom/CMakeLists.txt
Normal file
32
Meta/Lagom/CMakeLists.txt
Normal file
|
@ -0,0 +1,32 @@
|
|||
cmake_minimum_required (VERSION 3.0)
|
||||
project (Lagom)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall -Wextra -Werror -std=c++17 -fPIC -g")
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconsumed")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-expansion-to-defined")
|
||||
endif()
|
||||
|
||||
file(GLOB AK_SOURCES "../AK/*.cpp")
|
||||
file(GLOB LIBCORE_SOURCES "../Libraries/LibCore/*.cpp")
|
||||
file(GLOB LIBIPC_SOURCES "../Libraries/LibIPC/*.cpp")
|
||||
|
||||
set(SOURCES ${AK_SOURCES} ${LIBCORE_SOURCES} ${LIBIPC_SOURCES})
|
||||
|
||||
include_directories (../)
|
||||
include_directories (../Libraries/)
|
||||
add_library(lagom ${SOURCES})
|
||||
|
||||
add_executable(TestApp TestApp.cpp)
|
||||
target_link_libraries(TestApp lagom)
|
||||
target_link_libraries(TestApp stdc++)
|
||||
|
||||
#add_executable(SimpleIPCClient SimpleIPCClient.cpp)
|
||||
#target_link_libraries(SimpleIPCClient lagom)
|
||||
#target_link_libraries(SimpleIPCClient stdc++)
|
||||
|
||||
#add_executable(SimpleIPCServer SimpleIPCServer.cpp)
|
||||
#target_link_libraries(SimpleIPCServer lagom)
|
||||
#target_link_libraries(SimpleIPCServer stdc++)
|
9
Meta/Lagom/ReadMe.md
Normal file
9
Meta/Lagom/ReadMe.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Lagom
|
||||
|
||||
The Serenity C++ library, for other Operating Systems.
|
||||
|
||||
## About
|
||||
|
||||
If you want to bring the comfortable Serenity classes with you to another system, look no further. This is basically a "port" of the `AK` and `LibCore` libraries to generic \*nix systems.
|
||||
|
||||
*Lagom* is a Swedish word that means "just the right amount." ([Wikipedia](https://en.wikipedia.org/wiki/Lagom))
|
3
Meta/Lagom/SimpleIPC.ipc
Normal file
3
Meta/Lagom/SimpleIPC.ipc
Normal file
|
@ -0,0 +1,3 @@
|
|||
endpoint Simple {
|
||||
ComputeSum(i32 a, i32 b, i32 c) => (i32 sum)
|
||||
}
|
39
Meta/Lagom/SimpleIPCClient.cpp
Normal file
39
Meta/Lagom/SimpleIPCClient.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <LibCore/CEventLoop.h>
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibCore/CoreIPCClient.h>
|
||||
#include <stdio.h>
|
||||
#include "SimpleEndpoint.h"
|
||||
|
||||
class SimpleIPCClient : public IPC::Client::ConnectionNG<SimpleEndpoint> {
|
||||
C_OBJECT(SimpleIPCClient)
|
||||
public:
|
||||
SimpleIPCClient()
|
||||
: ConnectionNG("/tmp/simple-ipc")
|
||||
{}
|
||||
|
||||
virtual void handshake() override {}
|
||||
|
||||
i32 compute_sum(i32 a, i32 b, i32 c)
|
||||
{
|
||||
return send_sync<Simple::ComputeSum>(a, b, c)->sum();
|
||||
}
|
||||
};
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
CEventLoop event_loop;
|
||||
|
||||
SimpleIPCClient client;
|
||||
|
||||
CTimer timer(100, [&] {
|
||||
i32 sum = client.compute_sum(1, 2, 3);
|
||||
dbg() << "Sum: " << sum;
|
||||
});
|
||||
|
||||
CTimer kill_timer(5000, [&] {
|
||||
dbg() << "Timer fired, good-bye! :^)";
|
||||
event_loop.quit(0);
|
||||
});
|
||||
|
||||
return event_loop.exec();
|
||||
}
|
40
Meta/Lagom/SimpleIPCServer.cpp
Normal file
40
Meta/Lagom/SimpleIPCServer.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <LibCore/CEventLoop.h>
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <LibCore/CoreIPCServer.h>
|
||||
#include <LibCore/CLocalServer.h>
|
||||
#include <stdio.h>
|
||||
#include "SimpleEndpoint.h"
|
||||
|
||||
class SimpleIPCServer final :
|
||||
public IPC::Server::ConnectionNG<SimpleEndpoint>,
|
||||
public SimpleEndpoint {
|
||||
|
||||
C_OBJECT(SimpleIPCServer)
|
||||
public:
|
||||
SimpleIPCServer(CLocalSocket& socket, int client_id)
|
||||
: ConnectionNG(*this, socket, client_id)
|
||||
{
|
||||
}
|
||||
|
||||
virtual OwnPtr<Simple::ComputeSumResponse> handle(const Simple::ComputeSum& message)
|
||||
{
|
||||
return make<Simple::ComputeSumResponse>(message.a() + message.b() + message.c());
|
||||
}
|
||||
};
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
CEventLoop event_loop;
|
||||
|
||||
unlink("/tmp/simple-ipc");
|
||||
auto server = CLocalServer::construct();
|
||||
server->listen("/tmp/simple-ipc");
|
||||
server->on_ready_to_accept = [&] {
|
||||
auto client_socket = server->accept();
|
||||
ASSERT(client_socket);
|
||||
static int next_client_id = 0;
|
||||
IPC::Server::new_connection_ng_for_client<SimpleIPCServer>(*client_socket, ++next_client_id);
|
||||
};
|
||||
|
||||
return event_loop.exec();
|
||||
}
|
15
Meta/Lagom/TestApp.cpp
Normal file
15
Meta/Lagom/TestApp.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include <LibCore/CEventLoop.h>
|
||||
#include <LibCore/CTimer.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
CEventLoop event_loop;
|
||||
|
||||
auto timer = CTimer::construct(100, [&] {
|
||||
dbg() << "Timer fired, good-bye! :^)";
|
||||
event_loop.quit(0);
|
||||
});
|
||||
|
||||
return event_loop.exec();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue