summaryrefslogtreecommitdiff
path: root/Source/Asura.Engine/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Asura.Engine/scripting')
-rw-r--r--Source/Asura.Engine/scripting/portable.cpp9
-rw-r--r--Source/Asura.Engine/scripting/portable.h19
-rw-r--r--Source/Asura.Engine/scripting/portable.hpp43
-rw-r--r--Source/Asura.Engine/scripting/portable.inl30
4 files changed, 73 insertions, 28 deletions
diff --git a/Source/Asura.Engine/scripting/portable.cpp b/Source/Asura.Engine/scripting/portable.cpp
deleted file mode 100644
index 0aa5f08..0000000
--- a/Source/Asura.Engine/scripting/portable.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "Portable.h"
-
-namespace AsuraEngine
-{
- namespace Scripting
- {
-
- }
-}
diff --git a/Source/Asura.Engine/scripting/portable.h b/Source/Asura.Engine/scripting/portable.h
deleted file mode 100644
index 0527308..0000000
--- a/Source/Asura.Engine/scripting/portable.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __ASURA_ENGINE_PORTABLE_H__
-#define __ASURA_ENGINE_PORTABLE_H__
-
-#include "Luax.hpp"
-#include "Config.h"
-#include "Type.h"
-
-namespace AsuraEngine
-{
- namespace Scripting
- {
-
- template<typename T>
- using Portable = Luax::LuaxClass<T>;
-
- }
-}
-
-#endif \ No newline at end of file
diff --git a/Source/Asura.Engine/scripting/portable.hpp b/Source/Asura.Engine/scripting/portable.hpp
new file mode 100644
index 0000000..773e7ad
--- /dev/null
+++ b/Source/Asura.Engine/scripting/portable.hpp
@@ -0,0 +1,43 @@
+#ifndef __ASURA_ENGINE_PORTABLE_H__
+#define __ASURA_ENGINE_PORTABLE_H__
+
+#include "Config.h"
+#include "Luax.hpp"
+#include "Type.h"
+
+namespace AsuraEngine
+{
+ namespace Scripting
+ {
+
+ template<typename T>
+ class Portable : public Luax::LuaxClass<T>
+ {
+ public:
+
+ Portable();
+ virtual ~Portable();
+
+ void Retain();
+ void Release();
+
+ private:
+
+ ///
+ /// ̱߳luagc߳˴native objectdelete
+ ///
+ int mRefCount;
+
+ ///
+ /// deleteգ̳portable࣬޷ʹdeleteֻʹRelease
+ ///
+ bool mSafer;
+
+ };
+
+#include "portable.inl"
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/Source/Asura.Engine/scripting/portable.inl b/Source/Asura.Engine/scripting/portable.inl
new file mode 100644
index 0000000..a27b2e8
--- /dev/null
+++ b/Source/Asura.Engine/scripting/portable.inl
@@ -0,0 +1,30 @@
+
+template<typename T>
+Portable<T>::Portable()
+ : mRefCount(1)
+ , mSafer(false)
+{
+}
+
+template<typename T>
+Portable<T>::~Portable()
+{
+ ASSERT(mSafer);
+}
+
+template<typename T>
+void Portable<T>::Retain()
+{
+ ++mRefCount;
+}
+
+template<typename T>
+void Portable<T>::Release()
+{
+ if (--mRefCount <= 0)
+ {
+ mSafer = true;
+ delete this;
+ }
+}
+