aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/animator/SkScriptCallBack.h
blob: b2a1958517e68f0dad136933e75f3209b392a04b (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

/*
 * 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 SkScriptCallBack_DEFINED
#define SkScriptCallBack_DEFINED

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

class SkScriptCallBack {
public:
	enum Type {
		kBox,
		kFunction,
		kMember,
		kMemberFunction,
		kProperty,
		kUnbox
	};

	virtual bool getReference(const char* , size_t len, SkScriptValue2* result) {  return false; }
	virtual SkOperand2::OpType getReturnType(size_t ref, SkOperand2*) { 
		return SkOperand2::kS32; }
	virtual Type getType() const = 0;
};

class SkScriptCallBackConvert : public SkScriptCallBack {
public:
	virtual bool convert(SkOperand2::OpType type, SkOperand2* operand) = 0;
};

class SkScriptCallBackFunction : public SkScriptCallBack {
public:
	virtual void getParamTypes(SkIntArray(SkOperand2::OpType)* types) = 0;
	virtual Type getType() const { return kFunction; }
	virtual bool invoke(size_t ref, SkOpArray* params, SkOperand2* value) = 0;
};

class SkScriptCallBackMember: public SkScriptCallBack {
public:
	bool getMemberReference(const char* , size_t len, void* object, SkScriptValue2* ref);
	virtual Type getType() const { return kMember; }
	virtual bool invoke(size_t ref, void* object, SkOperand2* value) = 0;
};

class SkScriptCallBackMemberFunction : public SkScriptCallBack {
public:
	bool getMemberReference(const char* , size_t len, void* object, SkScriptValue2* ref);
	virtual void getParamTypes(SkIntArray(SkOperand2::OpType)* types) = 0;
	virtual Type getType() const { return kMemberFunction; }
	virtual bool invoke(size_t ref, void* object, SkOpArray* params, SkOperand2* value) = 0;
};

class SkScriptCallBackProperty : public SkScriptCallBack {
public:
	virtual bool getConstValue(const char* name, size_t len, SkOperand2* value) { return false; }
	virtual bool getResult(size_t ref, SkOperand2* answer) { return false; }
	virtual Type getType() const { return kProperty; }
};

#endif // SkScriptCallBack_DEFINED