From df24addf48a6de2c4ef4e1723ae7d9c1d261dabe Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 7 Aug 2018 11:52:27 +0800 Subject: *update --- libjin/Thread/Thread.cpp | 7 +++++++ libjin/Thread/Thread.h | 48 ++++++++++++++++++++++++++++++++---------------- libjin/Utils/Log.h | 10 +++++----- libjin/jin.h | 8 ++++---- 4 files changed, 48 insertions(+), 25 deletions(-) diff --git a/libjin/Thread/Thread.cpp b/libjin/Thread/Thread.cpp index 374778b..064d3db 100644 --- a/libjin/Thread/Thread.cpp +++ b/libjin/Thread/Thread.cpp @@ -296,6 +296,13 @@ namespace thread return v; } + void Thread::remove(int slot) + { + lock(); + common->remove(slot); + unlock(); + } + } // thread } // jin diff --git a/libjin/Thread/Thread.h b/libjin/Thread/Thread.h index aeb0d9e..37c978d 100644 --- a/libjin/Thread/Thread.h +++ b/libjin/Thread/Thread.h @@ -42,23 +42,36 @@ namespace thread class Thread { public: - - union Variant + struct Variant { - int integer; - bool boolean; - char character; - const char* cstring; - void* pointer; - float real; - - Variant() {}; - Variant(int i) : integer(i) {}; - Variant(float f) : real(f) {}; - Variant(bool b) : boolean(b) {}; - Variant(char c) : character(c) {}; - Variant(const char* s) : cstring(s) {}; - Variant(void* p) : pointer(p) {}; + enum Type + { + NONE = 0, + INTERGER, + BOOLEAN, + CHARACTER, + CSTRING, + POINTER, + REAL, + }; + Type type; + union + { + int integer; + bool boolean; + char character; + const char* cstring; + void* pointer; + float real; + }; + Variant() :type(NONE) {}; + Variant(const Variant& v){ memcpy(this, &v, sizeof(v)); } + Variant(int i) : integer(i), type(INTERGER) {}; + Variant(float f) : real(f), type(REAL) {}; + Variant(bool b) : boolean(b), type(BOOLEAN) {}; + Variant(char c) : character(c), type(CHARACTER) {}; + Variant(const char* s) : cstring(s), type(CSTRING) {}; + Variant(void* p) : pointer(p), type(POINTER) {}; }; private: @@ -76,6 +89,8 @@ namespace thread static const int SLOT_ERROR = -1; static const int SLOT_WARN = -2; + static const int SLOT_INFO = -3; + static const int SLOT_DEBUG = -4; private: std::map share; // threads shared value @@ -91,6 +106,7 @@ namespace thread bool receive(int slot); Variant fetch(int slot); Variant demand(int slot); + void remove(int slot); const char* getName(); bool isRunning(); void lock(); diff --git a/libjin/Utils/Log.h b/libjin/Utils/Log.h index b047402..50ec3c8 100644 --- a/libjin/Utils/Log.h +++ b/libjin/Utils/Log.h @@ -65,19 +65,19 @@ void Loghelper::log(Level _level, const char* _fmt, ...) switch (_level) { case LV_ERROR: - levelStr = "Error: "; + levelStr = "[Jin Error]:"; break; case LV_WARN: - levelStr = "Warn: "; + levelStr = "[Jin Warn]:"; break; case LV_INFO: - levelStr = "Info: "; + levelStr = "[Jin Info]:"; break; case LV_DEBUG: - levelStr = "Debug: "; + levelStr = "[Jin Debug]:"; break; default: - levelStr = "Unknown: "; + levelStr = "[Jin Unknown]:"; break; } char buffer[FORMAT_MSG_BUFFER_SIZE + 1] = { 0 }; diff --git a/libjin/jin.h b/libjin/jin.h index ad83fae..239fddd 100644 --- a/libjin/jin.h +++ b/libjin/jin.h @@ -15,9 +15,9 @@ #include "Time/Timer.h" #include "Thread/Thread.h" -const char* JIN_VERSION = "Jin 0.1"; -const char* JIN_AUTHOR = "Chai"; -const char* JIN_RELEASE = "Jin 0.1.1"; -const int JIN_VERSION_NUM = 101; +#define JIN_VERSION "Jin 0.1"; +#define JIN_AUTHOR "Chai"; +#define JIN_RELEASE "Jin 0.1.1"; +#define JIN_VERSION_NUM 101; #endif // __JIN_H \ No newline at end of file -- cgit v1.1-26-g67d0 From 35d0affb2b19a38ae43ac991021dd3c888dc3aa6 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 7 Aug 2018 12:56:28 +0800 Subject: *update --- build/.vs/libjin/v14/.suo | Bin 121856 -> 135168 bytes build/02Audio/02Audio.vcxproj | 2 +- build/02Audio/02Audio.vcxproj.filters | 2 +- build/03Thread/03Thread.vcxproj | 3 +- build/03Thread/03Thread.vcxproj.filters | 5 +- build/03Thread/main.cpp | 154 ------------------------------ build/04Network/04Network.vcxproj | 133 ++++++++++++++++++++++++++ build/04Network/04Network.vcxproj.filters | 22 +++++ build/libjin.sln | 10 ++ test/02Audio/audiotest.cpp | 70 -------------- test/02Audio/main.cpp | 70 ++++++++++++++ test/03Thread/main.cpp | 83 ++++++++++++++++ test/03Thread/threadtest.cpp | 83 ---------------- test/04Network/main.cpp | 83 ++++++++++++++++ 14 files changed, 405 insertions(+), 315 deletions(-) delete mode 100644 build/03Thread/main.cpp create mode 100644 build/04Network/04Network.vcxproj create mode 100644 build/04Network/04Network.vcxproj.filters delete mode 100644 test/02Audio/audiotest.cpp create mode 100644 test/02Audio/main.cpp create mode 100644 test/03Thread/main.cpp delete mode 100644 test/03Thread/threadtest.cpp create mode 100644 test/04Network/main.cpp diff --git a/build/.vs/libjin/v14/.suo b/build/.vs/libjin/v14/.suo index cf42b3a..4ee2374 100644 Binary files a/build/.vs/libjin/v14/.suo and b/build/.vs/libjin/v14/.suo differ diff --git a/build/02Audio/02Audio.vcxproj b/build/02Audio/02Audio.vcxproj index a06df79..5aa3542 100644 --- a/build/02Audio/02Audio.vcxproj +++ b/build/02Audio/02Audio.vcxproj @@ -120,7 +120,7 @@ - + diff --git a/build/02Audio/02Audio.vcxproj.filters b/build/02Audio/02Audio.vcxproj.filters index 30ce2ab..29e09e3 100644 --- a/build/02Audio/02Audio.vcxproj.filters +++ b/build/02Audio/02Audio.vcxproj.filters @@ -15,7 +15,7 @@ - + 源文件 diff --git a/build/03Thread/03Thread.vcxproj b/build/03Thread/03Thread.vcxproj index ddd8193..6cad582 100644 --- a/build/03Thread/03Thread.vcxproj +++ b/build/03Thread/03Thread.vcxproj @@ -125,8 +125,7 @@ - - + diff --git a/build/03Thread/03Thread.vcxproj.filters b/build/03Thread/03Thread.vcxproj.filters index d0d38cf..a9c0e02 100644 --- a/build/03Thread/03Thread.vcxproj.filters +++ b/build/03Thread/03Thread.vcxproj.filters @@ -15,10 +15,7 @@ - - 源文件 - - + 源文件 diff --git a/build/03Thread/main.cpp b/build/03Thread/main.cpp deleted file mode 100644 index ed12172..0000000 --- a/build/03Thread/main.cpp +++ /dev/null @@ -1,154 +0,0 @@ -//#include -//#include -//#include -//#include -//#include -// -//class SdlMutex -//{ -//public: -// SdlMutex() -// { -// mutex = SDL_CreateMutex(); -// if (!mutex) throw std::runtime_error("SDL_CreateMutex == NULL"); -// } -// -// ~SdlMutex() -// { -// SDL_DestroyMutex(mutex); -// } -// -// void lock() -// { -// if (SDL_mutexP(mutex) == -1) throw std::runtime_error("SDL_mutexP == -1"); -// // Note: -// // -1 does not mean it was already locked - it means there was an error in locking - -// // if it was locked it will just block - see SDL_mutexP(3) -// } -// -// void unlock() -// { -// if (SDL_mutexV(mutex) == -1) throw std::runtime_error("SDL_mutexV == -1"); -// } -// -// SDL_mutex* underlying() -// { -// return mutex; -// } -//private: -// SDL_mutex* mutex; -//}; -// -//class SdlScopedLock -//{ -//public: -// SdlScopedLock(SdlMutex& mutex) -// : -// mutex(mutex) -// { -// mutex.lock(); -// } -// ~SdlScopedLock() -// { -// try -// { -// this->unlock(); -// } -// catch (const std::exception& e) -// { -// // Destructors should never throw ... -// std::cerr << "SdlScopedLock::~SdlScopedLock - caught : " << e.what() << std::endl; -// } -// } -// void unlock() -// { -// mutex.unlock(); -// } -//private: -// SdlMutex& mutex; -//}; -// -//class ThreadData -//{ -//public: -// ThreadData() -// : -// dataReady(false), -// done(false) -// { -// condition = SDL_CreateCond(); -// } -// -// ~ThreadData() -// { -// SDL_DestroyCond(condition); -// } -// -// // Using stringstream so I can just shift on integers... -// std::stringstream data; -// bool dataReady; -// bool done; -// SdlMutex mutex; -// SDL_cond* condition; -//}; -// -//int threadFunction(void* data) -//{ -// try -// { -// ThreadData* threadData = static_cast< ThreadData* >(data); -// -// for (size_t i = 0; i < 100; i++) -// { -// { -// SdlScopedLock lock(threadData->mutex); -// // Everything in this scope is now syncronized with the mutex -// if (i != 0) threadData->data << ", "; -// threadData->data << i; -// threadData->dataReady = true; -// } // threadData->mutex is automatically unlocked here -// // Its important to note that condition should be signaled after mutex is unlocked -// if (SDL_CondSignal(threadData->condition) == -1) throw std::runtime_error("Failed to signal"); -// } -// { -// SdlScopedLock lock(threadData->mutex); -// threadData->done = true; -// } -// if (SDL_CondSignal(threadData->condition) == -1) throw std::runtime_error("Failed to signal"); -// return 0; -// } -// catch (const std::exception& e) -// { -// std::cerr << "Caught : " << e.what() << std::endl; -// return 1; -// } -//} -// -//int main(int argc, char* argv[]) -//{ -// ThreadData threadData; -// SDL_Thread* thread = SDL_CreateThread(threadFunction, "", &threadData); -// -// while (true) -// { -// SdlScopedLock lock(threadData.mutex); -// while (threadData.dataReady == false && threadData.done == false) -// { -// // NOTE: must call condition wait with mutex already locked -// if (SDL_CondWait(threadData.condition, threadData.mutex.underlying()) == -1) throw std::runtime_error("Failed to wait"); -// } -// // once dataReady == true or threadData.done == true we get here -// std::cout << "Got data = " << threadData.data.str() << std::endl; -// threadData.data.str(""); -// threadData.dataReady = false; -// if (threadData.done) -// { -// std::cout << "child done - ending" << std::endl; -// break; -// } -// } -// -// int status = 99; -// SDL_WaitThread(thread, &status); -// std::cerr << "Thread completed with : " << status << std::endl; -//} \ No newline at end of file diff --git a/build/04Network/04Network.vcxproj b/build/04Network/04Network.vcxproj new file mode 100644 index 0000000..b992a7a --- /dev/null +++ b/build/04Network/04Network.vcxproj @@ -0,0 +1,133 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {85071432-24B6-46D4-98D8-DAA63183093C} + My04Network + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + $(SolutionDir)..\libjin\;$(SolutionDir)\lib\SDL2-2.0.5\include\ + + + $(SolutionDir)\lib\SDL2-2.0.5\lib\x86\ + SDL2main.lib;SDL2.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) + Console + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + $(SolutionDir)..\libjin\;$(SolutionDir)\lib\SDL2-2.0.5\include\ + + + true + true + $(SolutionDir)\lib\SDL2-2.0.5\lib\x86\ + SDL2main.lib;SDL2.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies) + Console + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + {407e9199-d39c-4460-b218-0c29ab42483b} + + + + + + \ No newline at end of file diff --git a/build/04Network/04Network.vcxproj.filters b/build/04Network/04Network.vcxproj.filters new file mode 100644 index 0000000..01aea0c --- /dev/null +++ b/build/04Network/04Network.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + \ No newline at end of file diff --git a/build/libjin.sln b/build/libjin.sln index eb11a5f..7bdc3c3 100644 --- a/build/libjin.sln +++ b/build/libjin.sln @@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "02Audio", "02Audio\02Audio. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "03Thread", "03Thread\03Thread.vcxproj", "{0E49D105-2032-4825-9FA1-54B1B94E3655}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "04Network", "04Network\04Network.vcxproj", "{85071432-24B6-46D4-98D8-DAA63183093C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -51,6 +53,14 @@ Global {0E49D105-2032-4825-9FA1-54B1B94E3655}.Release|x64.Build.0 = Release|x64 {0E49D105-2032-4825-9FA1-54B1B94E3655}.Release|x86.ActiveCfg = Release|Win32 {0E49D105-2032-4825-9FA1-54B1B94E3655}.Release|x86.Build.0 = Release|Win32 + {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x64.ActiveCfg = Debug|x64 + {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x64.Build.0 = Debug|x64 + {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x86.ActiveCfg = Debug|Win32 + {85071432-24B6-46D4-98D8-DAA63183093C}.Debug|x86.Build.0 = Debug|Win32 + {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x64.ActiveCfg = Release|x64 + {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x64.Build.0 = Release|x64 + {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x86.ActiveCfg = Release|Win32 + {85071432-24B6-46D4-98D8-DAA63183093C}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/02Audio/audiotest.cpp b/test/02Audio/audiotest.cpp deleted file mode 100644 index 4576cfa..0000000 --- a/test/02Audio/audiotest.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include "jin.h" - -using namespace jin::core; -using namespace jin::graphics; -using namespace jin::input; -using namespace jin::audio; - -void onEvent(jin::input::Event* e) -{ - static Game* game = Game::get(); - if (e->type == EventType::QUIT) - game->stop(); -} - -void onUpdate(int ms) -{ - -} - -void onDraw() -{ - -} - -int main(int argc, char* argv[]) -{ - Game* game = Game::get(); - Game::Setting setting; - setting.eventHandler = onEvent; - setting.updater = onUpdate; - setting.drawer = onDraw; - setting.loader = nullptr; - game->init(&setting); - - Window* wnd = Window::get(); - Window::Setting wndSetting; - wndSetting.width = 600; - wndSetting.height = 512; - wndSetting.title = "test"; - wndSetting.fps = 60; - wndSetting.vsync = false; - wndSetting.fullscreen = false; - wndSetting.resizable = false; - wnd->init(&wndSetting); - - SDLAudio* audio = SDLAudio::get(); - SDLAudio::Setting audioSetting; - audioSetting.samplerate = 44100; - audioSetting.samples = 44100; - audio->init(&audioSetting); - - SDLSource* src = SDLSource::createSource("a.ogg"); - src->play(); - src->setLoop(false); - - SDLSource* src2 = SDLSource::createSource("a.wav"); - src2->setLoop(true); - src2->play(); - - audio->setVolume(0.7); - - game->run(); - - game->quit(); - audio->quit(); - wnd->quit(); - - return 0; -} \ No newline at end of file diff --git a/test/02Audio/main.cpp b/test/02Audio/main.cpp new file mode 100644 index 0000000..4576cfa --- /dev/null +++ b/test/02Audio/main.cpp @@ -0,0 +1,70 @@ +#include +#include "jin.h" + +using namespace jin::core; +using namespace jin::graphics; +using namespace jin::input; +using namespace jin::audio; + +void onEvent(jin::input::Event* e) +{ + static Game* game = Game::get(); + if (e->type == EventType::QUIT) + game->stop(); +} + +void onUpdate(int ms) +{ + +} + +void onDraw() +{ + +} + +int main(int argc, char* argv[]) +{ + Game* game = Game::get(); + Game::Setting setting; + setting.eventHandler = onEvent; + setting.updater = onUpdate; + setting.drawer = onDraw; + setting.loader = nullptr; + game->init(&setting); + + Window* wnd = Window::get(); + Window::Setting wndSetting; + wndSetting.width = 600; + wndSetting.height = 512; + wndSetting.title = "test"; + wndSetting.fps = 60; + wndSetting.vsync = false; + wndSetting.fullscreen = false; + wndSetting.resizable = false; + wnd->init(&wndSetting); + + SDLAudio* audio = SDLAudio::get(); + SDLAudio::Setting audioSetting; + audioSetting.samplerate = 44100; + audioSetting.samples = 44100; + audio->init(&audioSetting); + + SDLSource* src = SDLSource::createSource("a.ogg"); + src->play(); + src->setLoop(false); + + SDLSource* src2 = SDLSource::createSource("a.wav"); + src2->setLoop(true); + src2->play(); + + audio->setVolume(0.7); + + game->run(); + + game->quit(); + audio->quit(); + wnd->quit(); + + return 0; +} \ No newline at end of file diff --git a/test/03Thread/main.cpp b/test/03Thread/main.cpp new file mode 100644 index 0000000..a792e53 --- /dev/null +++ b/test/03Thread/main.cpp @@ -0,0 +1,83 @@ +#include +#include +#include "jin.h" + +using namespace std; +using namespace jin::core; +using namespace jin::graphics; +using namespace jin::input; +using namespace jin::audio; +using namespace jin::time; +using namespace jin::thread; + +Timers timers; + +void onEvent(jin::input::Event* e) +{ + static Game* game = Game::get(); + if (e->type == EventType::QUIT) + game->stop(); +} + +void onUpdate(int ms) +{ + timers.update(ms); +} + +void onDraw() +{ + +} + +void thread2Runner(Thread* t) +{ + int i = 0; + while (true) + { + if (i++ == 1000000000) + { + i = 0; + cout << (char*)(t->demand(1).pointer); + } + } +} + +void sendFunc(void* p) +{ + Thread* t = (Thread*)p; + t->send(1, "hello_"); +} + +int main(int argc, char* argv[]) +{ + Game* game = Game::get(); + Game::Setting setting; + setting.eventHandler = onEvent; + setting.updater = onUpdate; + setting.drawer = onDraw; + setting.loader = nullptr; + game->init(&setting); + + Window* wnd = Window::get(); + Window::Setting wndSetting; + wndSetting.width = 600; + wndSetting.height = 512; + wndSetting.title = "test"; + wndSetting.fps = 60; + wndSetting.vsync = false; + wndSetting.fullscreen = false; + wndSetting.resizable = false; + wnd->init(&wndSetting); + + Thread t("Count", thread2Runner); + + t.start(); + timers.after(2000, sendFunc, &t); + + game->run(); + + game->quit(); + wnd->quit(); + + return 0; +} \ No newline at end of file diff --git a/test/03Thread/threadtest.cpp b/test/03Thread/threadtest.cpp deleted file mode 100644 index a792e53..0000000 --- a/test/03Thread/threadtest.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include "jin.h" - -using namespace std; -using namespace jin::core; -using namespace jin::graphics; -using namespace jin::input; -using namespace jin::audio; -using namespace jin::time; -using namespace jin::thread; - -Timers timers; - -void onEvent(jin::input::Event* e) -{ - static Game* game = Game::get(); - if (e->type == EventType::QUIT) - game->stop(); -} - -void onUpdate(int ms) -{ - timers.update(ms); -} - -void onDraw() -{ - -} - -void thread2Runner(Thread* t) -{ - int i = 0; - while (true) - { - if (i++ == 1000000000) - { - i = 0; - cout << (char*)(t->demand(1).pointer); - } - } -} - -void sendFunc(void* p) -{ - Thread* t = (Thread*)p; - t->send(1, "hello_"); -} - -int main(int argc, char* argv[]) -{ - Game* game = Game::get(); - Game::Setting setting; - setting.eventHandler = onEvent; - setting.updater = onUpdate; - setting.drawer = onDraw; - setting.loader = nullptr; - game->init(&setting); - - Window* wnd = Window::get(); - Window::Setting wndSetting; - wndSetting.width = 600; - wndSetting.height = 512; - wndSetting.title = "test"; - wndSetting.fps = 60; - wndSetting.vsync = false; - wndSetting.fullscreen = false; - wndSetting.resizable = false; - wnd->init(&wndSetting); - - Thread t("Count", thread2Runner); - - t.start(); - timers.after(2000, sendFunc, &t); - - game->run(); - - game->quit(); - wnd->quit(); - - return 0; -} \ No newline at end of file diff --git a/test/04Network/main.cpp b/test/04Network/main.cpp new file mode 100644 index 0000000..a792e53 --- /dev/null +++ b/test/04Network/main.cpp @@ -0,0 +1,83 @@ +#include +#include +#include "jin.h" + +using namespace std; +using namespace jin::core; +using namespace jin::graphics; +using namespace jin::input; +using namespace jin::audio; +using namespace jin::time; +using namespace jin::thread; + +Timers timers; + +void onEvent(jin::input::Event* e) +{ + static Game* game = Game::get(); + if (e->type == EventType::QUIT) + game->stop(); +} + +void onUpdate(int ms) +{ + timers.update(ms); +} + +void onDraw() +{ + +} + +void thread2Runner(Thread* t) +{ + int i = 0; + while (true) + { + if (i++ == 1000000000) + { + i = 0; + cout << (char*)(t->demand(1).pointer); + } + } +} + +void sendFunc(void* p) +{ + Thread* t = (Thread*)p; + t->send(1, "hello_"); +} + +int main(int argc, char* argv[]) +{ + Game* game = Game::get(); + Game::Setting setting; + setting.eventHandler = onEvent; + setting.updater = onUpdate; + setting.drawer = onDraw; + setting.loader = nullptr; + game->init(&setting); + + Window* wnd = Window::get(); + Window::Setting wndSetting; + wndSetting.width = 600; + wndSetting.height = 512; + wndSetting.title = "test"; + wndSetting.fps = 60; + wndSetting.vsync = false; + wndSetting.fullscreen = false; + wndSetting.resizable = false; + wnd->init(&wndSetting); + + Thread t("Count", thread2Runner); + + t.start(); + timers.after(2000, sendFunc, &t); + + game->run(); + + game->quit(); + wnd->quit(); + + return 0; +} \ No newline at end of file -- cgit v1.1-26-g67d0 From ba6f366845f8b664be71938dc64b57d706f68a21 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 8 Aug 2018 15:52:34 +0800 Subject: +network --- build/libjin/libjin.vcxproj | 2 + libjin/3rdparty/tekcos/tekcos.c | 97 ++++++++++++----------- libjin/3rdparty/tekcos/tekcos.h | 11 --- libjin/Common/Data.h | 23 +++++- libjin/Net/Socket.cpp | 171 ++++++++++++++++++++++++++++++++++++++++ libjin/Net/Socket.h | 57 ++++++++++++++ libjin/modules.h | 1 + test/04Network/main.cpp | 6 +- 8 files changed, 304 insertions(+), 64 deletions(-) create mode 100644 libjin/Net/Socket.cpp create mode 100644 libjin/Net/Socket.h diff --git a/build/libjin/libjin.vcxproj b/build/libjin/libjin.vcxproj index d2f70d0..1e91426 100644 --- a/build/libjin/libjin.vcxproj +++ b/build/libjin/libjin.vcxproj @@ -48,6 +48,7 @@ + @@ -106,6 +107,7 @@ + diff --git a/libjin/3rdparty/tekcos/tekcos.c b/libjin/3rdparty/tekcos/tekcos.c index 9705fe2..17ce7ec 100644 --- a/libjin/3rdparty/tekcos/tekcos.c +++ b/libjin/3rdparty/tekcos/tekcos.c @@ -13,18 +13,18 @@ enum { TK_SUCCESS = 0, - TK_INITFAILED, // init tekcos failed + TK_INITFAILED, // init tekcos failed - TK_COULDNETCREATESOCKET, // couldn't create socket. - TK_CONNECTFAILED, // connect to remote server failed. - TK_BINDSOCKETFAILED, // couldn't bind socket to port - TK_LISTENSOCKETFAILED, // couldn't listen to port - TK_INVALIDSOCKET, // invalid socket - TK_WRONGSOCKETTPYE, // wrong socket type + TK_COULDNETCREATESOCKET, // couldn't create socket. + TK_CONNECTFAILED, // connect to remote server failed. + TK_BINDSOCKETFAILED, // couldn't bind socket to port + TK_LISTENSOCKETFAILED, // couldn't listen to port + TK_INVALIDSOCKET, // invalid socket + TK_WRONGSOCKETTPYE, // wrong socket type - TK_INVALIDTARGET, // cant sendto. + TK_INVALIDTARGET, // cant sendto. - TK_UNKNOWN, // unknown + TK_UNKNOWN, // unknown }; // error code @@ -74,7 +74,6 @@ uint32 tk_strtohl(const char* str) { struct in_addr inaddr; inet_pton(AF_INET, str, (void*)&inaddr); - // host long return ntohl(inaddr.s_addr); } @@ -105,11 +104,10 @@ tk_TCPsocket* tk_tcp_open(tk_IPaddress ip) struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_port = htons(ip.port); - // 32bit address and 16bit port number. addr.sin_family = AF_INET; if (ip.host != INADDR_NONE && (ip.host != INADDR_ANY)) - { // connet to an existed remote server. + { addr.sin_addr.s_addr = htonl(ip.host); if (connect(sk->id, (const struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) { @@ -117,8 +115,9 @@ tk_TCPsocket* tk_tcp_open(tk_IPaddress ip) goto error; } sk->type = SOCKET_TCLIENT; - }else - { // create a listenning server. + } + else + { addr.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(sk->id, (const struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) @@ -148,12 +147,12 @@ int tk_tcp_close(tk_TCPsocket* sk) { if (sk->id == INVALID_SOCKET) goto error; -#ifdef _WIN32 + #ifdef _WIN32 closesocket(sk->id); -#else - close(sk->id); -#endif - free(sk); + #else + close(sk->id); + #endif + free(sk); return 1; } error: @@ -161,23 +160,23 @@ error: return 0; } -int tk_tcp_send(tk_TCPsocket* client, const void* buffer, int bsize, int* sent) +int tk_tcp_send(tk_TCPsocket* client, const void* buffer, int size, int* sent) { - // byte poiter. const char *data = (const char*)buffer; if (client->type != SOCKET_TCLIENT) - {// only cliednt can send stuff. + { state = TK_WRONGSOCKETTPYE; goto error; } - //send(sk->id, buffer, bsize, 0); - int left = bsize; - if(sent) *sent = 0; + int left = size; + if(sent) + *sent = 0; int len = 0; do { len = send(client->id, data, left, 0); if (len > 0) { - if(sent) *sent += len; + if(sent) + *sent += len; left -= len; data += len; } @@ -187,24 +186,27 @@ error: return 0; } -int tk_tcp_recv(tk_TCPsocket* client, char* buffer, int bsize, int* len) +int tk_tcp_recv(tk_TCPsocket* client, char* buffer, int size, int* len) { *len = 0; if (client->type != SOCKET_TCLIENT) - {// only client can be recieved + { state = TK_WRONGSOCKETTPYE; goto error; } + int l = 0; do { - *len = recv(client->id, buffer, bsize, 0); - if (*len == SOCKET_ERROR) + l = recv(client->id, buffer, size - *len, 0); + if (l == SOCKET_ERROR) { state = TK_UNKNOWN; goto error; } - } while (*len == 0 || errno == EINTR); // if was suspended, recieve again. - buffer[*len] = '\0'; + *len += l; + buffer += l; + } while (l == 0 || errno == EINTR); + buffer[0] = '\0'; return 1; error: return 0; @@ -212,9 +214,10 @@ error: tk_TCPsocket* tk_tcp_accept(tk_TCPsocket* server) { + // client tk_TCPsocket* csk = (tk_TCPsocket*) malloc(sizeof(tk_TCPsocket)); if (server->type != SOCKET_TSERVER) - {// only server can accept connection + { state = TK_WRONGSOCKETTPYE; goto error; } @@ -240,38 +243,38 @@ error: int tk_tcp_nonblocking(tk_TCPsocket* sk) { -#if defined(__BEOS__) && defined(SO_NONBLOCK) + #if defined(__BEOS__) && defined(SO_NONBLOCK) { long b = 1; setsockopt(sk->id, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); } -#elif defined(WIN32) + #elif defined(WIN32) { unsigned long mode = 1; ioctlsocket(sk->id, FIONBIO, &mode); } -#elif defined(__OS2__) + #elif defined(__OS2__) { int dontblock = 1; ioctl(sk->id, FIONBIO, &dontblock); } -#endif + #endif return 1; } int tk_tcp_blocking(tk_TCPsocket* sk) { -#if defined(__BEOS__) && defined(SO_NONBLOCK) + #if defined(__BEOS__) && defined(SO_NONBLOCK) { long b = 0; setsockopt(sk->id, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); } -#elif defined(WIN32) + #elif defined(WIN32) { unsigned long mode = 0; ioctlsocket(sk->id, FIONBIO, &mode); } -#elif defined(__OS2__) + #elif defined(__OS2__) { int dontblock = 0; ioctl(sk->id, FIONBIO, &dontblock); @@ -307,11 +310,11 @@ tk_UDPsocket* tk_udp_open(uint16 portnumber) goto error; } if (portnumber <= 0) - {// client, just return + { return sk; } else - {// server, need to bind address to socket + { struct sockaddr_in addr; memset(&addr, 0, sizeof(addr)); addr.sin_addr.s_addr = htonl(INADDR_ANY); @@ -367,11 +370,11 @@ int tk_udp_close(tk_UDPsocket* sk) { if (sk->id != INVALID_SOCKET) { -#ifdef _WIN32 + #ifdef _WIN32 closesocket(sk->id); -#else - close(sk->id); -#endif + #else + close(sk->id); + #endif } free(sk); } @@ -383,4 +386,4 @@ int tk_freepack(tk_UDPpack* pack) free(pack->data); free(pack); return 1; -} +} \ No newline at end of file diff --git a/libjin/3rdparty/tekcos/tekcos.h b/libjin/3rdparty/tekcos/tekcos.h index e7d8662..0ec22fd 100644 --- a/libjin/3rdparty/tekcos/tekcos.h +++ b/libjin/3rdparty/tekcos/tekcos.h @@ -56,17 +56,11 @@ typedef struct // otherwise, connect to a remote server with given // ip address. tk_TCPsocket* tk_tcp_open(tk_IPaddress ip); - int tk_tcp_close(tk_TCPsocket* sk); - int tk_tcp_send(tk_TCPsocket* client, const void* buffer, int bsize, int* len); - int tk_tcp_recv(tk_TCPsocket* client, char* buffer, int bsize, int* len); - tk_TCPsocket* tk_tcp_accept(tk_TCPsocket* server); - int tk_tcp_nonblocking(tk_TCPsocket* sk); - int tk_tcp_blocking(tk_TCPsocket* sk); /* @@ -89,15 +83,10 @@ typedef struct }tk_UDPpack; tk_UDPsocket* tk_udp_open(uint16 portnumber); - int tk_udp_close(tk_UDPsocket* sk); - int tk_udp_sendto(tk_UDPsocket* sk, tk_UDPpack* pack); - int tk_udp_recvfrom(tk_UDPsocket* sk, tk_UDPpack* pack); - int tk_freepack(tk_UDPpack* pack); - // Get error message if some errors occured. const char* tk_errmsg(); diff --git a/libjin/Common/Data.h b/libjin/Common/Data.h index 38b8c7d..7fcc389 100644 --- a/libjin/Common/Data.h +++ b/libjin/Common/Data.h @@ -4,10 +4,27 @@ namespace jin { - struct DataBuffer + class DataBuffer { - unsigned int len; - char data[0]; + public: + DataBuffer(int n) + : len(n) + { + buffer = new char[len]; + memset(buffer, 0, len); + } + ~DataBuffer() + { + delete[] buffer; + } + char* operator&() + { + return buffer; + } + + private: + char* buffer; + int len; }; } // jin diff --git a/libjin/Net/Socket.cpp b/libjin/Net/Socket.cpp new file mode 100644 index 0000000..f688c74 --- /dev/null +++ b/libjin/Net/Socket.cpp @@ -0,0 +1,171 @@ +#include "Socket.h" + +namespace jin +{ +namespace net +{ + + Socket::Socket(SocketInformation info) + : tcpHandle(nullptr) + , udpHandle(nullptr) + { + type = info.type; + if (type == SocketType::TCP) + { + tk_IPaddress ip; + ip.host = info.address; + ip.port = info.port; + tcpHandle = tk_tcp_open(ip); + } + else if (type == SocketType::UDP) + { + udpHandle = tk_udp_open(info.port); + } + } + + Socket::Socket(SocketType type, unsigned int address, unsigned short port) + { + this->type = type; + if (type == SocketType::TCP) + { + tk_IPaddress ip; + ip.host = address; + ip.port = port; + tcpHandle = tk_tcp_open(ip); + } + else if (type == SocketType::UDP) + { + udpHandle = tk_udp_open(port); + } + } + + Socket::Socket(SocketType type, unsigned short port) + { + this->type = type; + if (type == SocketType::TCP) + { + tk_IPaddress ip; + ip.host = 0; + ip.port = port; + tcpHandle = tk_tcp_open(ip); + } + else if (type == SocketType::UDP) + { + udpHandle = tk_udp_open(port); + } + } + +#if JIN_NET_TEKCOS + + Socket::Socket(tk_TCPsocket* handle) + : tcpHandle(handle) + , udpHandle(nullptr) + { + } + + Socket::Socket(tk_UDPsocket* handle) + : tcpHandle(nullptr) + , udpHandle(handle) + { + } + +#endif // JIN_NET_TEKCOS + + Socket::~Socket() + { + } + + void Socket::configureBlocking(bool blocking) + { + if (type != SocketType::TCP) + return; + #if JIN_NET_TEKCOS + if (blocking) + tk_tcp_blocking(tcpHandle); + else + tk_tcp_nonblocking(tcpHandle); + #endif + } + + Socket* Socket::accept() + { + if (type != SocketType::TCP) + return nullptr; + Socket* client; + #if JIN_NET_TEKCOS + tk_TCPsocket* socket = tk_tcp_accept(tcpHandle); + client = new Socket(socket); + #endif + return client; + } + + int Socket::receive(char* buffer, int size) + { + if (type != SocketType::TCP) + return 0; + #if JIN_NET_TEKCOS + int len; + tk_tcp_recv(tcpHandle, buffer, size, &len); + return len; + #endif + } + + int Socket::send(char* buffer, int size) + { + if (type != SocketType::TCP) + return 0; + #if JIN_NET_TEKCOS + int len; + tk_tcp_send(tcpHandle, buffer, size, &len); + return len; + #endif + } + + void Socket::sendTo(char* buffer, int size, unsigned int address, unsigned int port) + { + if (type != SocketType::UDP) + return; + #if JIN_NET_TEKCOS + tk_UDPpack pack; + pack.data = buffer; + pack.len = size; + pack.ip.host = address; + pack.ip.port = port; + tk_udp_sendto(udpHandle, &pack); + #endif + } + + int Socket::receiveFrom(char* buffer, int size, unsigned int address, unsigned int port) + { + if (type != SocketType::UDP) + return; + int len; + #if JIN_NET_TEKCOS + tk_UDPpack pack; + pack.data = buffer; + pack.len = size; + pack.ip.host = address; + pack.ip.port = port; + tk_udp_recvfrom(udpHandle, &pack); + return pack.len; + #endif + } + + void Socket::close() + { + if (type == SocketType::TCP) + { + #if JIN_NET_TEKCOS + tk_tcp_close(tcpHandle); + #endif + } + else if (type == SocketType::UDP) + { + #if JIN_NET_TEKCOS + tk_udp_close(udpHandle); + #endif + } + } + +} +} \ No newline at end of file diff --git a/libjin/Net/Socket.h b/libjin/Net/Socket.h new file mode 100644 index 0000000..ec60eb9 --- /dev/null +++ b/libjin/Net/Socket.h @@ -0,0 +1,57 @@ +#ifndef __JIN_NET_SOCKET_H +#define __JIN_NET_SOCKET_H +#include "../modules.h" +#if JIN_MODULES_NET + +#include "../3rdparty/tekcos/tekcos.h" + +namespace jin +{ +namespace net +{ + + enum SocketType + { + TCP, + UDP + }; + + struct SocketInformation + { + unsigned int address; + unsigned short port; + SocketType type; + }; + + class Socket + { + public: + Socket(SocketInformation socketInformation); + Socket(SocketType type, unsigned short port); + Socket(SocketType type, unsigned int address, unsigned short port); + ~Socket(); + + void configureBlocking(bool bocking); + + Socket* accept(); + int receive(char* buffer, int size); + int send(char* buffer, int size); + void sendTo(char* buffer, int size, unsigned int address, unsigned int port); + int receiveFrom(char* buffer, int size, unsigned int address, unsigned int port); + void close(); + + private: + #if JIN_NET_TEKCOS + Socket(tk_TCPsocket* tcpHandle); + Socket(tk_UDPsocket* udpHandle); + tk_TCPsocket* tcpHandle; + tk_UDPsocket* udpHandle; + #endif + SocketType type; + }; + +} // net +} // jin + +#endif // JIN_MODULES_NET +#endif // __JIN_NET_SOCKET_H \ No newline at end of file diff --git a/libjin/modules.h b/libjin/modules.h index 06c14df..6cc9336 100644 --- a/libjin/modules.h +++ b/libjin/modules.h @@ -20,6 +20,7 @@ #define JIN_MODULES_MATH 1 #define JIN_MODULES_NET 1 +#define JIN_NET_TEKCOS 1 #define JIN_MODULES_PHYSICS 1 #define JIN_PHYSICS_BOX2D 1 diff --git a/test/04Network/main.cpp b/test/04Network/main.cpp index a792e53..d24e2b0 100644 --- a/test/04Network/main.cpp +++ b/test/04Network/main.cpp @@ -60,13 +60,13 @@ int main(int argc, char* argv[]) Window* wnd = Window::get(); Window::Setting wndSetting; - wndSetting.width = 600; - wndSetting.height = 512; + wndSetting.width = 400; + wndSetting.height = 300; wndSetting.title = "test"; wndSetting.fps = 60; wndSetting.vsync = false; wndSetting.fullscreen = false; - wndSetting.resizable = false; + wndSetting.resizable = true; wnd->init(&wndSetting); Thread t("Count", thread2Runner); -- cgit v1.1-26-g67d0 From a26aad9df5dfdfe752124a989fef0287783837f1 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 8 Aug 2018 17:24:32 +0800 Subject: *update --- build/libjin/libjin.vcxproj.filters | 6 ++++++ libjin/3rdparty/tekcos/tekcos.c | 12 ++++++++---- libjin/Net/Net.cpp | 24 ++++++++++++++++++++++++ libjin/Net/Net.h | 26 +++++++++++++++++++++++++- libjin/Net/Socket.cpp | 20 +++++++++++++++++++- libjin/Net/Socket.h | 1 + test/04Network/main.cpp | 29 +++++++++++++++-------------- 7 files changed, 98 insertions(+), 20 deletions(-) diff --git a/build/libjin/libjin.vcxproj.filters b/build/libjin/libjin.vcxproj.filters index 261d25d..edc9a94 100644 --- a/build/libjin/libjin.vcxproj.filters +++ b/build/libjin/libjin.vcxproj.filters @@ -216,6 +216,9 @@ Utils\XML + + Net + @@ -412,6 +415,9 @@ Utils\Proxy + + Net + diff --git a/libjin/3rdparty/tekcos/tekcos.c b/libjin/3rdparty/tekcos/tekcos.c index 17ce7ec..a1fc94e 100644 --- a/libjin/3rdparty/tekcos/tekcos.c +++ b/libjin/3rdparty/tekcos/tekcos.c @@ -106,7 +106,13 @@ tk_TCPsocket* tk_tcp_open(tk_IPaddress ip) addr.sin_port = htons(ip.port); addr.sin_family = AF_INET; - if (ip.host != INADDR_NONE && (ip.host != INADDR_ANY)) +//ws2def.h +//#define INADDR_ANY (ULONG)0x00000000 +//#define INADDR_LOOPBACK 0x7f000001 +//#define INADDR_BROADCAST (ULONG)0xffffffff +//#define INADDR_NONE 0xffffffff + + if (ip.host != INADDR_NONE && ip.host != INADDR_ANY) { addr.sin_addr.s_addr = htonl(ip.host); if (connect(sk->id, (const struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) @@ -206,7 +212,6 @@ int tk_tcp_recv(tk_TCPsocket* client, char* buffer, int size, int* len) *len += l; buffer += l; } while (l == 0 || errno == EINTR); - buffer[0] = '\0'; return 1; error: return 0; @@ -214,7 +219,7 @@ error: tk_TCPsocket* tk_tcp_accept(tk_TCPsocket* server) { - // client + // client socket tk_TCPsocket* csk = (tk_TCPsocket*) malloc(sizeof(tk_TCPsocket)); if (server->type != SOCKET_TSERVER) { @@ -360,7 +365,6 @@ int tk_udp_recvfrom(tk_UDPsocket* sk, tk_UDPpack* pack) return 0; } pack->len = n; - pack->data[n] = '\0'; return 1; } diff --git a/libjin/Net/Net.cpp b/libjin/Net/Net.cpp index e69de29..db39be7 100644 --- a/libjin/Net/Net.cpp +++ b/libjin/Net/Net.cpp @@ -0,0 +1,24 @@ +#include "Net.h" + +namespace jin +{ +namespace net +{ + + bool Net::initSystem(const SettingBase* setting) + { + #ifdef _WIN32 + #if JIN_NET_TEKCOS + tk_init(); + #endif + #endif + return true; + } + + void Net::quitSystem() + { + + } + +} +} diff --git a/libjin/Net/Net.h b/libjin/Net/Net.h index 6b86a45..54ffede 100644 --- a/libjin/Net/Net.h +++ b/libjin/Net/Net.h @@ -1,6 +1,30 @@ #ifndef __JIN_NET_H #define __JIN_NET_H +#include "../modules.h" +#if JIN_MODULES_NET +#include "../Common/Subsystem.hpp" +#include "Socket.h" +namespace jin +{ +namespace net +{ -#endif \ No newline at end of file + class Net : public Subsystem + { + public: + + protected: + Net() {}; + ~Net() {}; + SINGLETON(Net); + bool initSystem(const SettingBase* setting) override; + void quitSystem() override; + }; + +} +} + +#endif // JIN_MODULES_NET +#endif // __JIN_NET_H \ No newline at end of file diff --git a/libjin/Net/Socket.cpp b/libjin/Net/Socket.cpp index f688c74..b7c621e 100644 --- a/libjin/Net/Socket.cpp +++ b/libjin/Net/Socket.cpp @@ -23,6 +23,24 @@ namespace net } } + Socket::Socket(SocketType type, const char* address, unsigned short port) + { + this->type = type; + if (type == SocketType::TCP) + { + tk_IPaddress ip; + #if JIN_NET_TEKCOS + ip.host = tk_strtohl(address); + ip.port = port; + tcpHandle = tk_tcp_open(ip); + #endif + } + else if (type == SocketType::UDP) + { + udpHandle = tk_udp_open(port); + } + } + Socket::Socket(SocketType type, unsigned int address, unsigned short port) { this->type = type; @@ -138,7 +156,7 @@ namespace net int Socket::receiveFrom(char* buffer, int size, unsigned int address, unsigned int port) { if (type != SocketType::UDP) - return; + return 0; int len; #if JIN_NET_TEKCOS tk_UDPpack pack; diff --git a/libjin/Net/Socket.h b/libjin/Net/Socket.h index ec60eb9..0eb27e0 100644 --- a/libjin/Net/Socket.h +++ b/libjin/Net/Socket.h @@ -29,6 +29,7 @@ namespace net Socket(SocketInformation socketInformation); Socket(SocketType type, unsigned short port); Socket(SocketType type, unsigned int address, unsigned short port); + Socket(SocketType type, const char* address, unsigned short port); ~Socket(); void configureBlocking(bool bocking); diff --git a/test/04Network/main.cpp b/test/04Network/main.cpp index d24e2b0..6db72ab 100644 --- a/test/04Network/main.cpp +++ b/test/04Network/main.cpp @@ -9,6 +9,7 @@ using namespace jin::input; using namespace jin::audio; using namespace jin::time; using namespace jin::thread; +using namespace jin::net; Timers timers; @@ -29,25 +30,22 @@ void onDraw() } -void thread2Runner(Thread* t) +void netWorkThread(Thread* t) { - int i = 0; + Thread::Variant v = t->demand(1); + Socket* socket = (Socket*)v.pointer; + char buffer[2048] = {0}; while (true) { - if (i++ == 1000000000) + Socket* client = socket->accept(); + if (client != nullptr) { - i = 0; - cout << (char*)(t->demand(1).pointer); + client->receive(buffer, sizeof(buffer)); + cout << buffer; } } } -void sendFunc(void* p) -{ - Thread* t = (Thread*)p; - t->send(1, "hello_"); -} - int main(int argc, char* argv[]) { Game* game = Game::get(); @@ -69,11 +67,14 @@ int main(int argc, char* argv[]) wndSetting.resizable = true; wnd->init(&wndSetting); - Thread t("Count", thread2Runner); + Net::get()->init(nullptr); - t.start(); - timers.after(2000, sendFunc, &t); + Socket socket(SocketType::TCP, 6438); + Thread t("Receive Network Data", netWorkThread); + t.start(); + t.send(1, &socket); + game->run(); game->quit(); -- cgit v1.1-26-g67d0 From eabafd27dd22866673a1e777c74126f53e27b3e7 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 8 Aug 2018 21:32:43 +0800 Subject: *update --- libjin/3rdparty/tekcos/tekcos.h | 1 + libjin/Common/Subsystem.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libjin/3rdparty/tekcos/tekcos.h b/libjin/3rdparty/tekcos/tekcos.h index 0ec22fd..a212aae 100644 --- a/libjin/3rdparty/tekcos/tekcos.h +++ b/libjin/3rdparty/tekcos/tekcos.h @@ -1,3 +1,4 @@ +// copyright chai #ifndef _TEKCOS_H #define _TEKCOS_H diff --git a/libjin/Common/Subsystem.hpp b/libjin/Common/Subsystem.hpp index f4e270b..c3af3dc 100644 --- a/libjin/Common/Subsystem.hpp +++ b/libjin/Common/Subsystem.hpp @@ -14,7 +14,7 @@ namespace jin struct Setting {}; typedef Setting SettingBase; - bool init(const SettingBase* setting) + bool init(const SettingBase* setting = nullptr) { static bool success = initSystem(setting); return success; -- cgit v1.1-26-g67d0 From 1019479c017bc42fa48bb5e825d26b5f70b00787 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 8 Aug 2018 21:37:55 +0800 Subject: *update --- build/.vs/libjin/v14/.suo | Bin 135168 -> 153600 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/build/.vs/libjin/v14/.suo b/build/.vs/libjin/v14/.suo index 4ee2374..5c85708 100644 Binary files a/build/.vs/libjin/v14/.suo and b/build/.vs/libjin/v14/.suo differ -- cgit v1.1-26-g67d0