2013-05-22 15:13:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkLua_DEFINED
|
|
|
|
#define SkLua_DEFINED
|
|
|
|
|
|
|
|
#include "SkColor.h"
|
2014-05-14 16:03:14 +00:00
|
|
|
#include "SkPathEffect.h"
|
2013-05-22 15:13:18 +00:00
|
|
|
#include "SkScalar.h"
|
2013-05-22 20:12:50 +00:00
|
|
|
#include "SkString.h"
|
2013-05-22 15:13:18 +00:00
|
|
|
|
|
|
|
struct lua_State;
|
|
|
|
|
|
|
|
class SkCanvas;
|
|
|
|
class SkMatrix;
|
|
|
|
class SkPaint;
|
|
|
|
class SkPath;
|
|
|
|
struct SkRect;
|
|
|
|
class SkRRect;
|
2014-08-26 14:56:44 +00:00
|
|
|
class SkTextBlob;
|
2013-05-22 15:13:18 +00:00
|
|
|
|
|
|
|
#define SkScalarToLua(x) SkScalarToDouble(x)
|
|
|
|
#define SkLuaToScalar(x) SkDoubleToScalar(x)
|
|
|
|
|
|
|
|
class SkLua {
|
|
|
|
public:
|
|
|
|
static void Load(lua_State*);
|
|
|
|
|
2013-05-22 20:12:50 +00:00
|
|
|
SkLua(const char termCode[] = NULL); // creates a new L, will close it
|
|
|
|
SkLua(lua_State*); // uses L, will not close it
|
2013-05-22 15:13:18 +00:00
|
|
|
~SkLua();
|
|
|
|
|
2013-05-22 20:12:50 +00:00
|
|
|
lua_State* get() const { return fL; }
|
|
|
|
lua_State* operator*() const { return fL; }
|
|
|
|
lua_State* operator->() const { return fL; }
|
2013-05-23 07:01:22 +00:00
|
|
|
|
2013-05-22 20:12:50 +00:00
|
|
|
bool runCode(const char code[]);
|
|
|
|
bool runCode(const void* code, size_t size);
|
2013-05-23 07:01:22 +00:00
|
|
|
|
2013-05-22 15:13:18 +00:00
|
|
|
void pushBool(bool, const char tableKey[] = NULL);
|
|
|
|
void pushString(const char[], const char tableKey[] = NULL);
|
2013-05-30 18:55:14 +00:00
|
|
|
void pushString(const char[], size_t len, const char tableKey[] = NULL);
|
2013-05-22 15:13:18 +00:00
|
|
|
void pushString(const SkString&, const char tableKey[] = NULL);
|
2013-05-30 18:55:14 +00:00
|
|
|
void pushArrayU16(const uint16_t[], int count, const char tableKey[] = NULL);
|
2014-03-17 23:09:47 +00:00
|
|
|
void pushArrayPoint(const SkPoint[], int count, const char key[] = NULL);
|
2014-05-14 16:03:14 +00:00
|
|
|
void pushArrayScalar(const SkScalar[], int count, const char key[] = NULL);
|
2013-05-22 15:13:18 +00:00
|
|
|
void pushColor(SkColor, const char tableKey[] = NULL);
|
2013-05-30 18:55:14 +00:00
|
|
|
void pushU32(uint32_t, const char tableKey[] = NULL);
|
2013-05-22 15:13:18 +00:00
|
|
|
void pushScalar(SkScalar, const char tableKey[] = NULL);
|
|
|
|
void pushRect(const SkRect&, const char tableKey[] = NULL);
|
|
|
|
void pushRRect(const SkRRect&, const char tableKey[] = NULL);
|
2014-05-14 16:03:14 +00:00
|
|
|
void pushDash(const SkPathEffect::DashInfo&, const char tableKey[] = NULL);
|
2013-05-22 15:13:18 +00:00
|
|
|
void pushMatrix(const SkMatrix&, const char tableKey[] = NULL);
|
|
|
|
void pushPaint(const SkPaint&, const char tableKey[] = NULL);
|
|
|
|
void pushPath(const SkPath&, const char tableKey[] = NULL);
|
|
|
|
void pushCanvas(SkCanvas*, const char tableKey[] = NULL);
|
2014-08-26 14:56:44 +00:00
|
|
|
void pushTextBlob(const SkTextBlob*, const char tableKey[] = NULL);
|
2014-02-26 20:22:32 +00:00
|
|
|
|
2013-05-22 15:13:18 +00:00
|
|
|
private:
|
2013-05-22 20:12:50 +00:00
|
|
|
lua_State* fL;
|
|
|
|
SkString fTermCode;
|
|
|
|
bool fWeOwnL;
|
2013-05-22 15:13:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|