aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/utils
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-22 20:12:50 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-22 20:12:50 +0000
commit3597b73bc6e3e169f1d360de80d77e6e0ab65e96 (patch)
tree8d5b8e905d7642fa3891bda2b38d2bd49ce521ac /include/utils
parentbe1d02e52862f8afa5a4056f66d0eacb4f16e6fd (diff)
expand SkLua to handle creation of its own State
add lua sample BUG= R=robertphillips@google.com Review URL: https://codereview.chromium.org/15742009 git-svn-id: http://skia.googlecode.com/svn/trunk@9247 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/SkLua.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/include/utils/SkLua.h b/include/utils/SkLua.h
index 232ba9b8ee..8f48bc1ee1 100644
--- a/include/utils/SkLua.h
+++ b/include/utils/SkLua.h
@@ -10,6 +10,7 @@
#include "SkColor.h"
#include "SkScalar.h"
+#include "SkString.h"
struct lua_State;
@@ -19,7 +20,6 @@ class SkPaint;
class SkPath;
struct SkRect;
class SkRRect;
-class SkString;
#define SkScalarToLua(x) SkScalarToDouble(x)
#define SkLuaToScalar(x) SkDoubleToScalar(x)
@@ -28,11 +28,17 @@ class SkLua {
public:
static void Load(lua_State*);
- SkLua(lua_State*);
+ SkLua(const char termCode[] = NULL); // creates a new L, will close it
+ SkLua(lua_State*); // uses L, will not close it
~SkLua();
- lua_State* getL() const { return fL; }
-
+ lua_State* get() const { return fL; }
+ lua_State* operator*() const { return fL; }
+ lua_State* operator->() const { return fL; }
+
+ bool runCode(const char code[]);
+ bool runCode(const void* code, size_t size);
+
void pushBool(bool, const char tableKey[] = NULL);
void pushString(const char[], const char tableKey[] = NULL);
void pushString(const SkString&, const char tableKey[] = NULL);
@@ -46,7 +52,9 @@ public:
void pushCanvas(SkCanvas*, const char tableKey[] = NULL);
private:
- lua_State* fL;
+ lua_State* fL;
+ SkString fTermCode;
+ bool fWeOwnL;
};
#endif