[aseprite] 06/64: script: add className to Context::pushThis()

Tobias Hansen thansen at moszumanska.debian.org
Tue Jun 21 14:43:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 5665ac848da64db0ce43dbc3f3b731fc8988712b
Author: David Capello <davidcapello at gmail.com>
Date:   Fri May 6 16:51:07 2016 -0300

    script: add className to Context::pushThis()
---
 src/app/script/sprite_class.cpp | 2 +-
 src/script/engine.cpp           | 8 +++++++-
 src/script/engine.h             | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/app/script/sprite_class.cpp b/src/app/script/sprite_class.cpp
index 07aff91..ee8d33b 100644
--- a/src/app/script/sprite_class.cpp
+++ b/src/app/script/sprite_class.cpp
@@ -45,7 +45,7 @@ script::result_t Sprite_ctor(script::ContextHandle handle)
     sprite.release();
 
     doc->setContext(UIContext::instance());
-    ctx.pushThis(unwrap_engine(ctx)->wrapSprite(doc.release()));
+    ctx.pushThis(unwrap_engine(ctx)->wrapSprite(doc.release()), "Sprite");
   }
   return 0;
 }
diff --git a/src/script/engine.cpp b/src/script/engine.cpp
index eea3c58..7d1588b 100644
--- a/src/script/engine.cpp
+++ b/src/script/engine.cpp
@@ -284,11 +284,17 @@ void Context::pushThis()
   duk_push_this(m_handle);
 }
 
-void Context::pushThis(void* ptr)
+void Context::pushThis(void* ptr, const char* className)
 {
   duk_push_this(m_handle);
   duk_push_pointer(m_handle, ptr);
   duk_put_prop_string(m_handle, -2, kPtrId);
+
+  // TODO classes in modules isn't supported yet
+  duk_get_global_string(m_handle, className);
+  duk_get_prototype(m_handle, -1);
+  duk_set_prototype(m_handle, -3);
+  duk_pop_2(m_handle);
 }
 
 void Context::pushPointer(void* ptr)
diff --git a/src/script/engine.h b/src/script/engine.h
index fc6e2a5..451121c 100644
--- a/src/script/engine.h
+++ b/src/script/engine.h
@@ -94,7 +94,7 @@ namespace script {
     void pushUInt(unsigned int val);
     void pushString(const char* str);
     void pushThis();
-    void pushThis(void* ptr);
+    void pushThis(void* ptr, const char* className);
     void pushPointer(void* ptr);
     index_t pushObject();
     index_t pushObject(void* ptr, const char* className);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list