aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/animator/SkScriptRuntime.h
blob: 3e73801148945ccf03747154b4928daff2c6e24d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

/*
 * Copyright 2011 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SkScriptRuntime_DEFINED
#define SkScriptRuntime_DEFINED

#include "SkOperand2.h"
#include "SkTDArray_Experimental.h"
#include "SkTDStack.h"

class SkScriptCallBack;

typedef SkLongArray(SkString*) SkTDStringArray;
typedef SkLongArray(SkScriptCallBack*) SkTDScriptCallBackArray;

class SkScriptRuntime {
public:
    enum SkError {
        kNoError,
        kArrayIndexOutOfBounds,
        kCouldNotFindReferencedID,
        kFunctionCallFailed,
        kMemberOpFailed,
        kPropertyOpFailed
    };

    SkScriptRuntime(SkTDScriptCallBackArray& callBackArray) : fCallBackArray(callBackArray)
        {  }
    ~SkScriptRuntime();
    bool executeTokens(unsigned char* opCode);
    bool getResult(SkOperand2* result);
    void untrack(SkOpArray* array);
    void untrack(SkString* string);
private:
    void track(SkOpArray* array);
    void track(SkString* string);
    SkTDScriptCallBackArray& fCallBackArray;
    SkError fError;
    SkTDStack<SkOperand2> fRunStack;
    SkLongArray(SkOpArray*) fTrackArray;
    SkTDStringArray fTrackString;
    // illegal
    SkScriptRuntime& operator=(const SkScriptRuntime&);
};

#endif // SkScriptRuntime_DEFINED