| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkLuaCanvas.h" | 8 #include "SkLuaCanvas.h" |
| 9 #include "SkLua.h" | 9 #include "SkLua.h" |
| 10 | 10 |
| 11 extern "C" { | 11 extern "C" { |
| 12 #include "lua.h" | 12 #include "lua.h" |
| 13 #include "lauxlib.h" | 13 #include "lauxlib.h" |
| 14 } | 14 } |
| 15 | 15 |
| 16 class AutoCallLua : public SkLua { | 16 class AutoCallLua : public SkLua { |
| 17 public: | 17 public: |
| 18 AutoCallLua(lua_State* L, const char func[], const char verb[]) : INHERITED(
L) { | 18 AutoCallLua(lua_State* L, const char func[], const char verb[]) : INHERITED(
L) { |
| 19 lua_getglobal(L, func); | 19 lua_getglobal(L, func); |
| 20 if (!lua_isfunction(L, -1)) { | 20 if (!lua_isfunction(L, -1)) { |
| 21 int t = lua_type(L, -1); | 21 int t = lua_type(L, -1); |
| 22 SkDebugf("--- expected function %d\n", t); | 22 SkDebugf("--- expected function %d\n", t); |
| 23 } | 23 } |
| 24 | 24 |
| 25 lua_newtable(L); | 25 lua_newtable(L); |
| 26 this->pushString(verb, "verb"); | 26 this->pushString(verb, "verb"); |
| 27 } | 27 } |
| 28 | 28 |
| 29 ~AutoCallLua() { | 29 ~AutoCallLua() { |
| 30 lua_State* L = this->getL(); | 30 lua_State* L = this->get(); |
| 31 if (lua_pcall(L, 1, 0, 0) != LUA_OK) { | 31 if (lua_pcall(L, 1, 0, 0) != LUA_OK) { |
| 32 SkDebugf("lua err: %s\n", lua_tostring(L, -1)); | 32 SkDebugf("lua err: %s\n", lua_tostring(L, -1)); |
| 33 } | 33 } |
| 34 lua_settop(L, -1); | 34 lua_settop(L, -1); |
| 35 } | 35 } |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 typedef SkLua INHERITED; | 38 typedef SkLua INHERITED; |
| 39 }; | 39 }; |
| 40 | 40 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 const SkColor colors[], SkXfermode* xmode, | 251 const SkColor colors[], SkXfermode* xmode, |
| 252 const uint16_t indices[], int indexCount, | 252 const uint16_t indices[], int indexCount, |
| 253 const SkPaint& paint) { | 253 const SkPaint& paint) { |
| 254 AUTO_LUA("drawVertices"); | 254 AUTO_LUA("drawVertices"); |
| 255 lua.pushPaint(paint, "paint"); | 255 lua.pushPaint(paint, "paint"); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void SkLuaCanvas::drawData(const void* data, size_t length) { | 258 void SkLuaCanvas::drawData(const void* data, size_t length) { |
| 259 AUTO_LUA("drawData"); | 259 AUTO_LUA("drawData"); |
| 260 } | 260 } |
| OLD | NEW |