From c1220db0bd1f07464f6dcb5488f6e9f3b4c814b9 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 25 Oct 2021 07:51:25 +0200 Subject: [PATCH] [DEV] uptate new lutin declaration model --- .gitignore | 5 ++++ GLD_ememory-test.json | 28 +++++++++++++++++++ GLD_ememory.json | 44 ++++++++++++++++++++++++++++++ ememory/RefCounter.cpp | 6 ++++ ememory/RefCounter.hpp | 9 ++++++ lutin_ememory-test.py | 44 ------------------------------ lutin_ememory.py | 62 ------------------------------------------ 7 files changed, 92 insertions(+), 106 deletions(-) create mode 100644 GLD_ememory-test.json create mode 100644 GLD_ememory.json delete mode 100644 lutin_ememory-test.py delete mode 100644 lutin_ememory.py diff --git a/.gitignore b/.gitignore index e5fcee4..2748ba5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +__pycache__ +.bck +out +target +build # Compiled Object files *.slo *.lo diff --git a/GLD_ememory-test.json b/GLD_ememory-test.json new file mode 100644 index 0000000..89ce7f1 --- /dev/null +++ b/GLD_ememory-test.json @@ -0,0 +1,28 @@ +{ + "type":"BINARY", + "sub-type":"TEST", + "group-id":"com.atria-soft", + "description":"e-memory test-unit", + "license":"MPL-2", + "license-file":"file://LICENCE.txt", + "maintainer":"file://authors.txt", + "author":"file://authors.txt", + "version":"file://version.txt", + "code-quality":"MEDIUM", + + "source": [ + "test/main.cpp", + "test/testUnique.cpp", + "test/testRef.cpp", + "test/testShared.cpp", + "test/testWeak.cpp", + "test/testEnableSharedFromThis.cpp", + "test/testCasts.cpp" + ], + "dependency": [ + "cxx", + "ememory", + "test-debug", + "etest" + ] +} \ No newline at end of file diff --git a/GLD_ememory.json b/GLD_ememory.json new file mode 100644 index 0000000..70e8fee --- /dev/null +++ b/GLD_ememory.json @@ -0,0 +1,44 @@ +{ + "type":"LIBRARY", + "group-id":"com.atria-soft", + "description":"Ewol memory basic interface (have a thread safe shared_ptr with constness)", + "license":"MPL-2", + "license-file":"file://LICENCE.txt", + "maintainer":"file://authors.txt", + "author":"file://authors.txt", + "version":"file://version.txt", + "code-quality":"MEDIUM", + + "source": [ + "ememory/debug.cpp", + "ememory/Counter.cpp", + "ememory/RefCounter.cpp" + ], + "header": [ + "ememory/debug.hpp", + "ememory/memory.hpp", + "ememory/Counter.hpp", + "ememory/RefCounter.hpp", + "ememory/RefPtr.hpp", + "ememory/SharedPtr.hpp", + "ememory/UniquePtr.hpp", + "ememory/WeakPtr.hpp", + "ememory/EnableSharedFromThis.hpp", + "ememory/details/memory.hxx", + "ememory/details/SharedPtr.hxx", + "ememory/details/RefPtr.hxx", + "ememory/details/WeakPtr.hxx", + "ememory/details/EnableSharedFromThis.hxx" + ], + "path":[ + "." + ], + "compilation-version": { + "language": "c++", + "version": 2011 + }, + "dependency": [ + "etk-core", + "elog" + ] +} \ No newline at end of file diff --git a/ememory/RefCounter.cpp b/ememory/RefCounter.cpp index 8ef9c98..1d47f48 100644 --- a/ememory/RefCounter.cpp +++ b/ememory/RefCounter.cpp @@ -39,6 +39,12 @@ void ememory::RefCounter::refKeep() { void ememory::RefCounter::refRelease() { int refCount = --m_refCount; if (refCount == 0) { + m_refCount++; + destroyRequested(); + refCount = --m_refCount; + if (refCount != 0) { + return; + } // No more element ==> remove it. this->~RefCounter(); ETK_DELETE(ememory::RefCounter, this); diff --git a/ememory/RefCounter.hpp b/ememory/RefCounter.hpp index 7077d5f..bf56705 100644 --- a/ememory/RefCounter.hpp +++ b/ememory/RefCounter.hpp @@ -50,11 +50,20 @@ namespace ememory { * @return Request const SharedPtr */ //const ememory::RefPtr refFromThis() const; + #ifdef DEBUG + int32_t getUid() const { + return m_uid; + } + #endif protected: /** * @brief get the RAW pointer value of this element (for debug only) */ uint64_t getRawPointer() const; + /** + * @brief Call befor destroy the object. + */ + virtual void destroyRequested() {} }; #ifdef DEBUG void resetDebugRefCounter(); diff --git a/lutin_ememory-test.py b/lutin_ememory-test.py deleted file mode 100644 index 7784b71..0000000 --- a/lutin_ememory-test.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python -import realog.debug as debug -import lutin.tools as tools - - -def get_type(): - return "BINARY" - -def get_sub_type(): - return "TEST" - -def get_desc(): - return "e-memory test-unit" - -def get_licence(): - return "MPL-2" - -def get_compagny_type(): - return "com" - -def get_compagny_name(): - return "atria-soft" - -def get_maintainer(): - return "authors.txt" - -def configure(target, my_module): - my_module.add_src_file([ - 'test/main.cpp', - 'test/testUnique.cpp', - 'test/testRef.cpp', - 'test/testShared.cpp', - 'test/testWeak.cpp', - 'test/testEnableSharedFromThis.cpp', - 'test/testCasts.cpp' - ]) - my_module.add_depend([ - 'cxx', - 'ememory', - 'test-debug', - 'etest', - ]) - return True - diff --git a/lutin_ememory.py b/lutin_ememory.py deleted file mode 100644 index 999b982..0000000 --- a/lutin_ememory.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python -import realog.debug as debug -import lutin.tools as tools - - -def get_type(): - return "LIBRARY" - -def get_desc(): - return "Ewol memory basic interface (have a thread safe shared_ptr with constness)" - -def get_licence(): - return "MPL-2" - -def get_compagny_type(): - return "com" - -def get_compagny_name(): - return "atria-soft" - -def get_maintainer(): - return "authors.txt" - -def get_version(): - return "version.txt" - -def configure(target, my_module): - my_module.add_extra_flags() - # add the file to compile: - my_module.add_src_file([ - 'ememory/debug.cpp', - 'ememory/Counter.cpp', - 'ememory/RefCounter.cpp', - ]) - - my_module.add_header_file([ - 'ememory/debug.hpp', - 'ememory/memory.hpp', - 'ememory/Counter.hpp', - 'ememory/RefCounter.hpp', - 'ememory/RefPtr.hpp', - 'ememory/SharedPtr.hpp', - 'ememory/UniquePtr.hpp', - 'ememory/WeakPtr.hpp', - 'ememory/EnableSharedFromThis.hpp', - 'ememory/details/memory.hxx', - 'ememory/details/SharedPtr.hxx', - 'ememory/details/RefPtr.hxx', - 'ememory/details/WeakPtr.hxx', - 'ememory/details/EnableSharedFromThis.hxx', - ]) - - # build in C++ mode - my_module.compile_version("c++", 2011) - # add dependency of the generic C++ library: - my_module.add_depend('etk-core') - my_module.add_optionnal_depend('elog') - - my_module.add_path(".") - return True - -