diff options
author | ancarola <raffaele.ancarola@epfl.ch> | 2019-01-26 23:21:33 +0100 |
---|---|---|
committer | ancarola <raffaele.ancarola@epfl.ch> | 2019-01-26 23:21:33 +0100 |
commit | b04597405eaca00add8eddc7cb82518618c416d0 (patch) | |
tree | 5200cccf718b0dc2f567bcc8c3351a4b6f460176 | |
parent | Fix signal template error (diff) | |
download | flatland-b04597405eaca00add8eddc7cb82518618c416d0.tar.gz flatland-b04597405eaca00add8eddc7cb82518618c416d0.zip |
Testing signal
-rwxr-xr-x | configure.py | 2 | ||||
-rw-r--r-- | engine/flatland.cpp | 10 | ||||
-rw-r--r-- | engine/include/flatland.hpp | 2 | ||||
-rw-r--r-- | engine/serial.cpp | 2 | ||||
-rw-r--r-- | engine/signal.cpp | 9 | ||||
m--------- | lib/libmm | 0 | ||||
m--------- | lib/libwrapsdl2 | 0 | ||||
-rw-r--r-- | ninja/rules.ninja | 7 | ||||
-rw-r--r-- | test/signal_test.cpp | 10 |
9 files changed, 34 insertions, 8 deletions
diff --git a/configure.py b/configure.py index b14369e..1329123 100755 --- a/configure.py +++ b/configure.py @@ -70,5 +70,5 @@ with open("build.ninja", "w") as bf: for s, o, b in zip(sources, objects, binaries): print("build {}: cpp {}".format(o, s), file=bf) print("build {}: link {}".format(b, o), file=bf) - print(" lflags = $lflags ../build/libflatland.so", file=bf) + print(" lflags = $lflags build/libflatland.so", file=bf) print("\n", file=bf) diff --git a/engine/flatland.cpp b/engine/flatland.cpp index 62cdfd1..da0f58d 100644 --- a/engine/flatland.cpp +++ b/engine/flatland.cpp @@ -88,19 +88,19 @@ uint32_t status_to_flags(const flat_status& s) /* Accessors */ -core::channel& core_channel() +core::channel& flat::core_channel() { return core_chan; } -core::job& main_job() +core::job& flat::main_job() { return mainsync_job; } /* Main loop */ -int init_flatland(FlatWindow* w, const flat_status& s, float _fps) +int flat::init_flatland(FlatWindow* w, const flat_status& s, float _fps) { cout << "Flatland: Initializing flatland" << endl; @@ -218,13 +218,13 @@ int init_flatland(FlatWindow* w, const flat_status& s, float _fps) return status.error; } -void quit() +void flat::quit() { status.running = 0; status.loop = 0; } -flat_status flatland_status() +flat_status flat::flatland_status() { return status; } diff --git a/engine/include/flatland.hpp b/engine/include/flatland.hpp index 0ccf59c..f12dc65 100644 --- a/engine/include/flatland.hpp +++ b/engine/include/flatland.hpp @@ -61,7 +61,7 @@ flat_status flatland_status(); /* Window and status modifiers */ -void load_flatland_status(const flat_status&); +//void load_flatland_status(const flat_status&); } diff --git a/engine/serial.cpp b/engine/serial.cpp index b3218be..ad29f2f 100644 --- a/engine/serial.cpp +++ b/engine/serial.cpp @@ -93,6 +93,8 @@ const std::vector<SDL_Event>& SDL_EventCollector::getStack(uint32_t id) const // TODO other events } + + return user; } SDL_EventCollector * FlatSerial::collector = new SDL_EventCollector(); diff --git a/engine/signal.cpp b/engine/signal.cpp index 0e1935d..5434469 100644 --- a/engine/signal.cpp +++ b/engine/signal.cpp @@ -41,8 +41,11 @@ bool channel::map() return mapped; } +#include <iostream> + void channel::emit(const signal& sig) { + //cout << "React" << endl; stack.insert(sig); } @@ -117,8 +120,14 @@ channel::ptr channel::find(const string& id) void channel::check_and_call() { + //std::cout << "Signal check" << std::endl; + // check + //std::cout << "Stack size: " << stack.size() << endl; + if (!stack.empty()) { + std::cout << "Signal detected" << std::endl; + vector<weak_ptr<listener>> to_erase; // TODO, maybe it exists pop diff --git a/lib/libmm b/lib/libmm -Subproject e6595cf9c527e97198806c48aa0a14ae8e895e8 +Subproject ba03d198b82733043919fda918a80f4bb81800a diff --git a/lib/libwrapsdl2 b/lib/libwrapsdl2 -Subproject 66bb51fa6148d6910da054bacd4fcbd2fa7b5ba +Subproject 736ec71fce673d5aa88228b96acfe6c6862a223 diff --git a/ninja/rules.ninja b/ninja/rules.ninja index 6674672..bc3bdff 100644 --- a/ninja/rules.ninja +++ b/ninja/rules.ninja @@ -1,7 +1,8 @@ includes = -I lib/include -I engine/include cflags = -g -Wall -pedantic -fPIC -std=c++17 -DDEBUG $includes -libs = -lSDL2 lib/libmm/build/libmm.a lib/libwsdl2/build/libwsdl2.a +libs = -lSDL2 +#lib/libmm/build/libmm.a lib/libwsdl2/build/libwsdl2.a lflags = $libs flags = -fdiagnostics-color @@ -10,6 +11,10 @@ rule mkdir command = mkdir -p $out description = creating directory $out +rule clean + command = rm -r build/* + description = clean up builds + rule cpp command = g++ $flags $cflags -c $in -o $out description = compiling $in diff --git a/test/signal_test.cpp b/test/signal_test.cpp index cd487b0..db5b571 100644 --- a/test/signal_test.cpp +++ b/test/signal_test.cpp @@ -3,6 +3,7 @@ #include "object.hpp" #include "window.hpp" #include "flatland.hpp" +#include "exceptions/forcequit.hpp" #include <iostream> @@ -76,6 +77,9 @@ void lifeloop() // quit request flat::core_channel().emit(quit); } + + if (steps > 2100) + throw flat::ForceQuit("Too many steps"); } int main() @@ -85,6 +89,12 @@ int main() alpha = channel::create("alpha"); + if (alpha == nullptr) + { + cout << "Could not create channel alpha" << endl; + return -1; + } + // create sender m_sender = new sender("Ciao", alpha); m_listener = new c_listener(alpha); |