blob: dcbaf11886ddc756e07af95a1f1c7b9a85f79cbd [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkScriptCallBack_DEFINED
9#define SkScriptCallBack_DEFINED
10
11#include "SkOperand2.h"
12#include "SkTDArray_Experimental.h"
13
14class SkScriptCallBack {
15public:
rmistry@google.comd6176b02012-08-23 18:14:13 +000016 enum Type {
17 kBox,
18 kFunction,
19 kMember,
20 kMemberFunction,
21 kProperty,
22 kUnbox
23 };
reed@android.com8a1c16f2008-12-17 15:59:43 +000024
rmistry@google.comd6176b02012-08-23 18:14:13 +000025 virtual bool getReference(const char* , size_t len, SkScriptValue2* result) { return false; }
26 virtual SkOperand2::OpType getReturnType(size_t ref, SkOperand2*) {
27 return SkOperand2::kS32; }
28 virtual Type getType() const = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +000029};
30
31class SkScriptCallBackConvert : public SkScriptCallBack {
32public:
rmistry@google.comd6176b02012-08-23 18:14:13 +000033 virtual bool convert(SkOperand2::OpType type, SkOperand2* operand) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +000034};
35
36class SkScriptCallBackFunction : public SkScriptCallBack {
37public:
rmistry@google.comd6176b02012-08-23 18:14:13 +000038 virtual void getParamTypes(SkIntArray(SkOperand2::OpType)* types) = 0;
39 virtual Type getType() const { return kFunction; }
40 virtual bool invoke(size_t ref, SkOpArray* params, SkOperand2* value) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +000041};
42
43class SkScriptCallBackMember: public SkScriptCallBack {
44public:
rmistry@google.comd6176b02012-08-23 18:14:13 +000045 bool getMemberReference(const char* , size_t len, void* object, SkScriptValue2* ref);
46 virtual Type getType() const { return kMember; }
47 virtual bool invoke(size_t ref, void* object, SkOperand2* value) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +000048};
49
50class SkScriptCallBackMemberFunction : public SkScriptCallBack {
51public:
rmistry@google.comd6176b02012-08-23 18:14:13 +000052 bool getMemberReference(const char* , size_t len, void* object, SkScriptValue2* ref);
53 virtual void getParamTypes(SkIntArray(SkOperand2::OpType)* types) = 0;
54 virtual Type getType() const { return kMemberFunction; }
55 virtual bool invoke(size_t ref, void* object, SkOpArray* params, SkOperand2* value) = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +000056};
57
58class SkScriptCallBackProperty : public SkScriptCallBack {
59public:
rmistry@google.comd6176b02012-08-23 18:14:13 +000060 virtual bool getConstValue(const char* name, size_t len, SkOperand2* value) { return false; }
61 virtual bool getResult(size_t ref, SkOperand2* answer) { return false; }
62 virtual Type getType() const { return kProperty; }
reed@android.com8a1c16f2008-12-17 15:59:43 +000063};
64
65#endif // SkScriptCallBack_DEFINED