• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
getReference(const char *,size_t len,SkScriptValue2 * result)18 	virtual bool getReference(const char* , size_t len, SkScriptValue2* result) {  return false; }
getReturnType(size_t ref,SkOperand2 *)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;
getType()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);
getType()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;
getType()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:
getConstValue(const char * name,size_t len,SkOperand2 * value)53 	virtual bool getConstValue(const char* name, size_t len, SkOperand2* value) { return false; }
getResult(size_t ref,SkOperand2 * answer)54 	virtual bool getResult(size_t ref, SkOperand2* answer) { return false; }
getType()55 	virtual Type getType() const { return kProperty; }
56 };
57 
58 #endif // SkScriptCallBack_DEFINED
59