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 #ifndef SkLua_DEFINED | 8 #ifndef SkLua_DEFINED |
9 #define SkLua_DEFINED | 9 #define SkLua_DEFINED |
10 | 10 |
11 #include "SkColor.h" | 11 #include "SkColor.h" |
12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
| 13 #include "SkString.h" |
13 | 14 |
14 struct lua_State; | 15 struct lua_State; |
15 | 16 |
16 class SkCanvas; | 17 class SkCanvas; |
17 class SkMatrix; | 18 class SkMatrix; |
18 class SkPaint; | 19 class SkPaint; |
19 class SkPath; | 20 class SkPath; |
20 struct SkRect; | 21 struct SkRect; |
21 class SkRRect; | 22 class SkRRect; |
22 class SkString; | |
23 | 23 |
24 #define SkScalarToLua(x) SkScalarToDouble(x) | 24 #define SkScalarToLua(x) SkScalarToDouble(x) |
25 #define SkLuaToScalar(x) SkDoubleToScalar(x) | 25 #define SkLuaToScalar(x) SkDoubleToScalar(x) |
26 | 26 |
27 class SkLua { | 27 class SkLua { |
28 public: | 28 public: |
29 static void Load(lua_State*); | 29 static void Load(lua_State*); |
30 | 30 |
31 SkLua(lua_State*); | 31 SkLua(const char termCode[] = NULL); // creates a new L, will close it |
| 32 SkLua(lua_State*); // uses L, will not close it |
32 ~SkLua(); | 33 ~SkLua(); |
33 | 34 |
34 lua_State* getL() const { return fL; } | 35 lua_State* get() const { return fL; } |
35 | 36 lua_State* operator*() const { return fL; } |
| 37 lua_State* operator->() const { return fL; } |
| 38 |
| 39 bool runCode(const char code[]); |
| 40 bool runCode(const void* code, size_t size); |
| 41 |
36 void pushBool(bool, const char tableKey[] = NULL); | 42 void pushBool(bool, const char tableKey[] = NULL); |
37 void pushString(const char[], const char tableKey[] = NULL); | 43 void pushString(const char[], const char tableKey[] = NULL); |
38 void pushString(const SkString&, const char tableKey[] = NULL); | 44 void pushString(const SkString&, const char tableKey[] = NULL); |
39 void pushColor(SkColor, const char tableKey[] = NULL); | 45 void pushColor(SkColor, const char tableKey[] = NULL); |
40 void pushScalar(SkScalar, const char tableKey[] = NULL); | 46 void pushScalar(SkScalar, const char tableKey[] = NULL); |
41 void pushRect(const SkRect&, const char tableKey[] = NULL); | 47 void pushRect(const SkRect&, const char tableKey[] = NULL); |
42 void pushRRect(const SkRRect&, const char tableKey[] = NULL); | 48 void pushRRect(const SkRRect&, const char tableKey[] = NULL); |
43 void pushMatrix(const SkMatrix&, const char tableKey[] = NULL); | 49 void pushMatrix(const SkMatrix&, const char tableKey[] = NULL); |
44 void pushPaint(const SkPaint&, const char tableKey[] = NULL); | 50 void pushPaint(const SkPaint&, const char tableKey[] = NULL); |
45 void pushPath(const SkPath&, const char tableKey[] = NULL); | 51 void pushPath(const SkPath&, const char tableKey[] = NULL); |
46 void pushCanvas(SkCanvas*, const char tableKey[] = NULL); | 52 void pushCanvas(SkCanvas*, const char tableKey[] = NULL); |
47 | 53 |
48 private: | 54 private: |
49 lua_State* fL; | 55 lua_State* fL; |
| 56 SkString fTermCode; |
| 57 bool fWeOwnL; |
50 }; | 58 }; |
51 | 59 |
52 #endif | 60 #endif |
OLD | NEW |