epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #ifndef SkScriptRuntime_DEFINED |
| 9 | #define SkScriptRuntime_DEFINED |
| 10 | |
| 11 | #include "SkOperand2.h" |
| 12 | #include "SkTDArray_Experimental.h" |
| 13 | #include "SkTDStack.h" |
| 14 | |
| 15 | class SkScriptCallBack; |
| 16 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 17 | typedef SkLongArray(SkString*) SkTDStringArray; |
| 18 | typedef SkLongArray(SkScriptCallBack*) SkTDScriptCallBackArray; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 19 | |
| 20 | class SkScriptRuntime { |
| 21 | public: |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 22 | enum SkError { |
| 23 | kNoError, |
| 24 | kArrayIndexOutOfBounds, |
| 25 | kCouldNotFindReferencedID, |
| 26 | kFunctionCallFailed, |
| 27 | kMemberOpFailed, |
| 28 | kPropertyOpFailed |
| 29 | }; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 30 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 31 | SkScriptRuntime(SkTDScriptCallBackArray& callBackArray) : fCallBackArray(callBackArray) |
| 32 | { } |
| 33 | ~SkScriptRuntime(); |
| 34 | bool executeTokens(unsigned char* opCode); |
| 35 | bool getResult(SkOperand2* result); |
| 36 | void untrack(SkOpArray* array); |
| 37 | void untrack(SkString* string); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 38 | private: |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 39 | void track(SkOpArray* array); |
| 40 | void track(SkString* string); |
| 41 | SkTDScriptCallBackArray& fCallBackArray; |
| 42 | SkError fError; |
| 43 | SkTDStack<SkOperand2> fRunStack; |
| 44 | SkLongArray(SkOpArray*) fTrackArray; |
| 45 | SkTDStringArray fTrackString; |
| 46 | // illegal |
| 47 | SkScriptRuntime& operator=(const SkScriptRuntime&); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
caryclark@google.com | 16230cb | 2012-06-06 12:11:55 +0000 | [diff] [blame] | 50 | #endif // SkScriptRuntime_DEFINED |