SkScript.h revision 80bacfeb4bda06541e8695bd502229727bccfea
180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkScript_DEFINED
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkScript_DEFINED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkOperand.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkIntArray.h"
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTDict.h"
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTDStack.h"
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkAnimateMaker;
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkScriptEngine {
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Error {
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNoError,
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kArrayIndexOutOfBounds,
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kCouldNotFindReferencedID,
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDotOperatorExpectsObject,
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorInArrrayIndex,
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorInFunctionParameters,
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedArray,
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedBooleanExpression,
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedFieldName,
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedHex,
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedIntForConditionOperator,
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedNumber,
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedNumberForArrayIndex,
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedOperator,
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedToken,
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedTokenBeforeDotOperator,
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedValue,
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kHandleMemberFailed,
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kHandleMemberFunctionFailed,
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kHandleUnboxFailed,
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kIndexOutOfRange,
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMismatchedArrayBrace,
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMismatchedBrackets,
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNoFunctionHandlerFound,
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kPrematureEnd,
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTooManyParameters,
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTypeConversionFailed,
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUnterminatedString
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum SkOpType {
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNoType,
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kInt = 1,
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kScalar = 2,
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kString = 4,
5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kArray = 8,
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kObject = 16
6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//      kStruct = 32
6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef bool (*_boxCallBack)(void* userStorage, SkScriptValue* result);
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef bool (*_functionCallBack)(const char* func, size_t len, SkTDArray<SkScriptValue>& params,
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        void* userStorage, SkScriptValue* result);
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef bool (*_memberCallBack)(const char* member, size_t len, void* object,
6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        void* userStorage, SkScriptValue* result);
6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef bool (*_memberFunctionCallBack)(const char* member, size_t len, void* object,
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkTDArray<SkScriptValue>& params, void* userStorage, SkScriptValue* result);
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//  typedef bool (*_objectToStringCallBack)(void* object, void* userStorage, SkScriptValue* result);
7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef bool (*_propertyCallBack)(const char* prop, size_t len, void* userStorage, SkScriptValue* result);
7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef bool (*_unboxCallBack)(void* userStorage, SkScriptValue* result);
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScriptEngine(SkOpType returnType);
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ~SkScriptEngine();
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void boxCallBack(_boxCallBack func, void* userStorage);
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool convertTo(SkDisplayTypes , SkScriptValue* );
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool evaluateScript(const char** script, SkScriptValue* value);
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void forget(SkTypedArray* array);
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void functionCallBack(_functionCallBack func, void* userStorage);
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Error getError() const { return fError; }
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DEBUG
8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool getErrorString(SkString* err) const;
8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void memberCallBack(_memberCallBack , void* userStorage);
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void memberFunctionCallBack(_memberFunctionCallBack , void* userStorage);
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//  void objectToStringCallBack(_objectToStringCallBack , void* userStorage);
8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void propertyCallBack(_propertyCallBack prop, void* userStorage);
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void track(SkTypedArray* array);
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void track(SkString* string);
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void unboxCallBack(_unboxCallBack func, void* userStorage);
9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static bool ConvertTo(SkScriptEngine* , SkDisplayTypes toType, SkScriptValue* value);
9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static SkScalar IntToScalar(int32_t );
9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static SkDisplayTypes ToDisplayType(SkOpType type);
9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static SkOpType ToOpType(SkDisplayTypes type);
9580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static bool ValueToString(SkScriptValue value, SkString* string);
9680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum CallBackType {
9880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBox,
9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFunction,
10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMember,
10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMemberFunction,
10280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    //  kObjectToString,
10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kProperty,
10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUnbox
10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    struct UserCallBack {
10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        CallBackType fCallBackType;
10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        void* fUserStorage;
11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        union {
11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            _boxCallBack fBoxCallBack;
11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            _functionCallBack fFunctionCallBack;
11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            _memberCallBack fMemberCallBack;
11480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            _memberFunctionCallBack fMemberFunctionCallBack;
11580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    //      _objectToStringCallBack fObjectToStringCallBack;
11680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            _propertyCallBack fPropertyCallBack;
11780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            _unboxCallBack fUnboxCallBack;
11880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        };
11980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum SkOp {
12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUnassigned,
12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kAdd,
12480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kAddInt = kAdd,
12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kAddScalar,
12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kAddString, // string concat
12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kArrayOp,
12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBitAnd,
12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBitNot,
13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBitOr,
13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDivide,
13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDivideInt = kDivide,
13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDivideScalar,
13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kElse,
13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kEqual,
13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kEqualInt = kEqual,
13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kEqualScalar,
13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kEqualString,
13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFlipOps,
14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGreaterEqual,
14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGreaterEqualInt = kGreaterEqual,
14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGreaterEqualScalar,
14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGreaterEqualString,
14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kIf,
14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLogicalAnd,
14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLogicalNot,
14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLogicalOr,
14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMinus,
14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMinusInt = kMinus,
15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMinusScalar,
15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kModulo,
15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kModuloInt = kModulo,
15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kModuloScalar,
15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMultiply,
15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMultiplyInt = kMultiply,
15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMultiplyScalar,
15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kParen,
15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kShiftLeft,
15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kShiftRight,    // signed
16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSubtract,
16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSubtractInt = kSubtract,
16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSubtractScalar,
16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kXor,
16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kArtificialOp = 0x40
16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum SkOpBias {
16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNoBias,
16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTowardsNumber = 0,
17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTowardsString
17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected:
17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    struct SkOperatorAttributes {
17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        unsigned int fLeftType : 3; // SkOpType, but only lower values
17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        unsigned int fRightType : 3;     // SkOpType, but only lower values
17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkOpBias fBias : 1;
17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    struct SkSuppress { // !!! could be compressed to a long
18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkOp fOperator; // operand which enabled suppression
18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        int fOpStackDepth; // depth when suppression operator was found
18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkBool8 fSuppress; // set if suppression happens now, as opposed to later
18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkBool8 fElse; // set on the : half of ? :
18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static const SkOperatorAttributes gOpAttributes[];
18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static const signed char gPrecedence[];
19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int arithmeticOp(char ch, char nextChar, bool lastPush);
19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void commonCallBack(CallBackType type, UserCallBack& callBack, void* userStorage);
19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool convertParams(SkTDArray<SkScriptValue>&, const SkFunctionParamType* ,
19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                    int paramTypeCount);
19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void convertToString(SkOperand& operand, SkDisplayTypes type) {
19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScriptValue scriptValue;
19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        scriptValue.fOperand = operand;
19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        scriptValue.fType = type;
19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        convertTo(SkType_String, &scriptValue);
19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        operand = scriptValue.fOperand;
20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool evaluateDot(const char*& script, bool suppressed);
20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool evaluateDotParam(const char*& script, bool suppressed, const char* field, size_t fieldLength);
20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool functionParams(const char** scriptPtr, SkTDArray<SkScriptValue>& params);
20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool handleArrayIndexer(const char** scriptPtr, bool suppressed);
20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool handleBox(SkScriptValue* value);
20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool handleFunction(const char** scriptPtr, bool suppressed);
20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool handleMember(const char* field, size_t len, void* object);
20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool handleMemberFunction(const char* field, size_t len, void* object, SkTDArray<SkScriptValue>& params);
20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru//  bool handleObjectToString(void* object);
21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool handleProperty(bool suppressed);
21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool handleUnbox(SkScriptValue* scriptValue);
21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool innerScript(const char** scriptPtr, SkScriptValue* value);
21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int logicalOp(char ch, char nextChar);
21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Error opError();
21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool processOp();
21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setAnimateMaker(SkAnimateMaker* maker) { fMaker = maker; }
21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool setError(Error , const char* pos);
21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum SkBraceStyle {
21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    //  kStructBrace,
22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kArrayBrace,
22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFunctionBrace
22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if 0
22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkIntArray(SkBraceStyle) fBraceStack;       // curly, square, function paren
22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkIntArray(SkOp) fOpStack;
22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkIntArray(SkOpType) fTypeStack;
22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDOperandArray fOperandStack;
22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDArray<SkSuppress> fSuppressStack;
23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#else
23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDStack<SkBraceStyle> fBraceStack;        // curly, square, function paren
23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDStack<SkOp> fOpStack;
23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDStack<SkOpType> fTypeStack;
23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDStack<SkOperand> fOperandStack;
23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDStack<SkSuppress> fSuppressStack;
23680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkAnimateMaker* fMaker;
23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDTypedArrayArray fTrackArray;
23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDStringArray fTrackString;
24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const char* fToken; // one-deep stack
24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    size_t fTokenLength;
24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDArray<UserCallBack> fUserCallBacks;
24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkOpType fReturnType;
24480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Error fError;
24580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int fErrorPosition;
24680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
24780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkTypedArray;
24880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_SUPPORT_UNITTEST
24980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
25080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static void UnitTest();
25180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
25280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
25380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
25480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_SUPPORT_UNITTEST
25580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
25680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkScriptNAnswer {
25780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const char* fScript;
25880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayTypes fType;
25980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int32_t fIntAnswer;
26080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar fScalarAnswer;
26180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const char* fStringAnswer;
26280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
26380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
26480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
26580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
26680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif // SkScript_DEFINED
267