1 #ifndef SkScriptCallBack_DEFINED 2 #define SkScriptCallBack_DEFINED 3 4 #include "SkOperand2.h" 5 #include "SkTDArray_Experimental.h" 6 7 class SkScriptCallBack { 8 public: 9 enum Type { 10 kBox, 11 kFunction, 12 kMember, 13 kMemberFunction, 14 kProperty, 15 kUnbox 16 }; 17 18 virtual bool getReference(const char* , size_t len, SkScriptValue2* result) { return false; } 19 virtual SkOperand2::OpType getReturnType(size_t ref, SkOperand2*) { 20 return SkOperand2::kS32; } 21 virtual Type getType() const = 0; 22 }; 23 24 class SkScriptCallBackConvert : public SkScriptCallBack { 25 public: 26 virtual bool convert(SkOperand2::OpType type, SkOperand2* operand) = 0; 27 }; 28 29 class SkScriptCallBackFunction : public SkScriptCallBack { 30 public: 31 virtual void getParamTypes(SkIntArray(SkOperand2::OpType)* types) = 0; 32 virtual Type getType() const { return kFunction; } 33 virtual bool invoke(size_t ref, SkOpArray* params, SkOperand2* value) = 0; 34 }; 35 36 class SkScriptCallBackMember: public SkScriptCallBack { 37 public: 38 bool getMemberReference(const char* , size_t len, void* object, SkScriptValue2* ref); 39 virtual Type getType() const { return kMember; } 40 virtual bool invoke(size_t ref, void* object, SkOperand2* value) = 0; 41 }; 42 43 class SkScriptCallBackMemberFunction : public SkScriptCallBack { 44 public: 45 bool getMemberReference(const char* , size_t len, void* object, SkScriptValue2* ref); 46 virtual void getParamTypes(SkIntArray(SkOperand2::OpType)* types) = 0; 47 virtual Type getType() const { return kMemberFunction; } 48 virtual bool invoke(size_t ref, void* object, SkOpArray* params, SkOperand2* value) = 0; 49 }; 50 51 class SkScriptCallBackProperty : public SkScriptCallBack { 52 public: 53 virtual bool getConstValue(const char* name, size_t len, SkOperand2* value) { return false; } 54 virtual bool getResult(size_t ref, SkOperand2* answer) { return false; } 55 virtual Type getType() const { return kProperty; } 56 }; 57 58 #endif // SkScriptCallBack_DEFINED 59