aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lua/common/Proxy.h88
-rw-r--r--src/lua/common/Reference.hpp152
-rw-r--r--src/lua/main.cpp4
-rw-r--r--src/lua/modules/graphics/graphics.cpp14
4 files changed, 129 insertions, 129 deletions
diff --git a/src/lua/common/Proxy.h b/src/lua/common/Proxy.h
index 4fec5ff..5ebb5b2 100644
--- a/src/lua/common/Proxy.h
+++ b/src/lua/common/Proxy.h
@@ -5,63 +5,63 @@
namespace JinEngine
{
-namespace Lua
-{
-
- class Proxy
+ namespace Lua
{
- public:
- void bind(RefBase* ref)
- {
- if (ref == nullptr)
- return;
- reference = ref;
- }
- void release()
+ class Proxy
{
- if (reference != nullptr)
+ public:
+ void bind(RefBase* ref)
{
- reference->release();
- reference = nullptr;
+ if (ref == nullptr)
+ return;
+ reference = ref;
}
- }
- void retain()
- {
- if (reference != nullptr)
- reference->retain();
- }
+ void release()
+ {
+ if (reference != nullptr)
+ {
+ reference->release();
+ reference = nullptr;
+ }
+ }
- void setUserdata(void* data)
- {
- if (reference != nullptr)
- reference->setUserdata(data);
- }
+ void retain()
+ {
+ if (reference != nullptr)
+ reference->retain();
+ }
- template<class T>
- Ref<T>& getRef()
- {
- return *(Ref<T>*) reference;
- }
+ void setUserdata(void* data)
+ {
+ if (reference != nullptr)
+ reference->setUserdata(data);
+ }
- template<class T>
- T* getObject()
- {
- Ref<T>& ref = getRef<T>();
- return ref.getObject();
- }
+ template<class T>
+ Ref<T>& getRef()
+ {
+ return *(Ref<T>*) reference;
+ }
- const char* getObjectType()
- {
- return reference->type;
- }
+ template<class T>
+ T* getObject()
+ {
+ Ref<T>& ref = getRef<T>();
+ return ref.getObject();
+ }
+
+ const char* getObjectType()
+ {
+ return reference->type;
+ }
- RefBase* reference;
+ RefBase* reference;
- };
+ };
-} // namespace Lua
+ } // namespace Lua
} // namespace JinEngine
#endif // __JIN_COMMON_PROXY_H \ No newline at end of file
diff --git a/src/lua/common/Reference.hpp b/src/lua/common/Reference.hpp
index 618456d..ba918bb 100644
--- a/src/lua/common/Reference.hpp
+++ b/src/lua/common/Reference.hpp
@@ -3,86 +3,86 @@
namespace JinEngine
{
-namespace Lua
-{
-
- /*abstract*/class RefBase
- {
- public:
- void retain()
- {
- ++count;
- }
-
- void release()
- {
- if (--count <= 0)
- delete this;
- }
-
- // object type string
- const char* const type;
-
- void setUserdata(void* data)
- {
- userdata = data;
- }
-
- void* getUserdata()
- {
- return userdata;
- }
-
- protected:
- RefBase(void* obj, const char* t)
- : count(1)
- , object(obj)
- , type(t)
- {
- }
-
- RefBase(const RefBase&);
-
- virtual ~RefBase()
- {
- }
-
- void* object;
- int count;
- void* userdata;
- };
-
- template<class T>
- class Ref : public RefBase
+ namespace Lua
{
- public:
- Ref(T* obj, const char* type)
- : RefBase(obj, type)
- {
- }
-
- ~Ref()
- {
- T* obj = (T*)object;
- delete obj;
- }
- T* operator->()
+ /*abstract*/class RefBase
{
- return (T*)object;
- }
-
- T* getObject()
+ public:
+ void retain()
+ {
+ ++count;
+ }
+
+ void release()
+ {
+ if (--count <= 0)
+ delete this;
+ }
+
+ // object type string
+ const char* const type;
+
+ void setUserdata(void* data)
+ {
+ userdata = data;
+ }
+
+ void* getUserdata()
+ {
+ return userdata;
+ }
+
+ protected:
+ RefBase(void* obj, const char* t)
+ : count(1)
+ , object(obj)
+ , type(t)
+ {
+ }
+
+ RefBase(const RefBase&);
+
+ virtual ~RefBase()
+ {
+ }
+
+ void* object;
+ int count;
+ void* userdata;
+ };
+
+ template<class T>
+ class Ref : public RefBase
{
- return (T*)object;
- }
-
- private:
- Ref(const Ref<T>& ref);
-
- };
-
-}
+ public:
+ Ref(T* obj, const char* type)
+ : RefBase(obj, type)
+ {
+ }
+
+ ~Ref()
+ {
+ T* obj = static_cast<T*>(object);
+ delete obj;
+ }
+
+ T* operator->()
+ {
+ return (T*)object;
+ }
+
+ T* getObject()
+ {
+ return (T*)object;
+ }
+
+ private:
+ Ref(const Ref<T>& ref);
+
+ };
+
+ }
}
#endif \ No newline at end of file
diff --git a/src/lua/main.cpp b/src/lua/main.cpp
index 495ca6f..95862ec 100644
--- a/src/lua/main.cpp
+++ b/src/lua/main.cpp
@@ -1,6 +1,6 @@
#ifdef _WIN32
-#include <SDL2/SDL_Main.h>
-#include <direct.h>
+ #include <SDL2/SDL_Main.h>
+ #include <direct.h>
#endif
#include "luax.h"
diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp
index 5ba8c13..0d34619 100644
--- a/src/lua/modules/graphics/graphics.cpp
+++ b/src/lua/modules/graphics/graphics.cpp
@@ -6,18 +6,18 @@
#include "lua/modules/types.h"
#include "lua/common/common.h"
+using namespace std;
+using namespace JinEngine;
+using namespace JinEngine::Graphics;
+using JinEngine::Filesystem::AssetDatabase;
+using JinEngine::Filesystem::Buffer;
+
namespace JinEngine
{
namespace Lua
{
- using namespace std;
- using namespace JinEngine;
- using namespace JinEngine::Graphics;
- using JinEngine::Filesystem::AssetDatabase;
- using JinEngine::Filesystem::Buffer;
-
- #include "../../resources/font.ttf.h"
+#include "../../resources/font.ttf.h"
static struct
{