rename CallableFunc to CallableLambda

This commit is contained in:
Nishi 2026-05-29 01:10:45 +09:00
commit aa7189dd25
8 changed files with 43 additions and 19 deletions

View file

@ -11,25 +11,14 @@ static void cleanup(int sig){
#endif
int main(){
fishbone::SoundDriver* drv;
fishbone::Sound* snd;
fishbone::Window* wnd;
#ifndef _WIN32
signal(SIGINT, cleanup);
signal(SIGTERM, cleanup);
#endif
drv = new fishbone::SoundDriver();
snd = drv->mixer.open("shanghai.mp3");
snd->setLoop(true);
snd->position[0] = -1;
snd->position[1] = 0;
snd->position[2] = 0;
snd->is3d = true;
snd->resume();
wnd = new fishbone::Window("Fishbowl", 640, 480);
while(!quit);
delete drv;
}

View file

@ -7,11 +7,13 @@ namespace fishbone {
#include <fishbone/machdep.h>
#include <fishbone/sound.h>
#include <fishbone/window.h>
namespace fishbone {
class Client {
public:
fishbone::SoundDriver sound;
fishbone::Window window;
};
}; // namespace fishbone

View file

@ -6,5 +6,6 @@
#include <fishbone/mixer.h>
#include <fishbone/thread.h>
#include <fishbone/file.h>
#include <fishbone/window.h>
#endif

View file

@ -15,10 +15,10 @@ namespace fishbone {
public:
using Callable = void(*)(fishbone::Thread* thread, void* arg);
using CallableFunc = std::function<void(fishbone::Thread* thread)>;
using CallableLambda = std::function<void(fishbone::Thread* thread)>;
Thread(Callable call, void* arg);
Thread(CallableFunc call);
Thread(CallableLambda call);
~Thread();
void join();

View file

@ -0,0 +1,21 @@
#ifndef __FISHBONE_WINDOW_H__
#define __FISHBONE_WINDOW_H__
namespace fishbone {
class Window;
}; // namespace fishbone
#include <fishbone/machdep.h>
namespace fishbone {
class Window {
struct Impl;
Impl* impl;
public:
Window(std::string title, int width, int height);
~Window();
};
};
#endif

View file

@ -9,7 +9,7 @@ struct call_arg {
};
struct call_arg2 {
fishbone::Thread::CallableFunc call;
fishbone::Thread::CallableLambda call;
fishbone::Thread* thread;
};
@ -48,7 +48,7 @@ fishbone::Thread::Thread(Callable call, void* arg) {
this->impl->thread = SDL_CreateThread(thread_call, "FBThread", data);
}
fishbone::Thread::Thread(CallableFunc call) {
fishbone::Thread::Thread(CallableLambda call) {
struct call_arg2* data = new struct call_arg2();
data->call = call;

View file

@ -1,4 +1,15 @@
#include <fishbone/config.h>
#ifdef FISHBONE_WINDOW_USE_SDL2
#include <fishbone/foundation.h>
struct fishbone::Window::Impl {
};
fishbone::Window::Window(std::string title, int width, int height){
this->impl = new fishbone::Window::Impl();
}
fishbone::Window::~Window(){
delete this->impl;
}
#endif

View file

@ -40,7 +40,7 @@ TEST_CASE("Mutex") {
int a = 0;
fishbone::Mutex m;
fishbone::Thread::CallableFunc func = [&a, &m](auto) {
fishbone::Thread::CallableLambda func = [&a, &m](auto) {
m.lock();
for (int j = 0; j < 2; j++) {
int b = a;