summaryrefslogtreecommitdiffstats
path: root/gpu/np_utils/default_np_object.h
blob: b3b5fc0d9a0435d42a0e9c5b1efc8ed6a4142ff4 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_NP_UTILS_DEFAULT_NP_OBJECT_H_
#define GPU_NP_UTILS_DEFAULT_NP_OBJECT_H_

#include "base/basictypes.h"
#include "gpu/np_utils/np_headers.h"

namespace np_utils {

class BaseNPDispatcher;

// This class implements each of the functions in the NPClass interface. They
// all return error by default. Note that these are not virtual functions and
// this is not an interface. This class can be used as a mixin so that an
// NPObject class does not need to implement every NPClass function but rather
// inherits a default from DefaultNPObject.
template <typename RootClass>
class DefaultNPObject : public RootClass {
 public:
  void Invalidate() {}

  bool HasMethod(NPIdentifier name) {
    return false;
  }

  bool Invoke(NPIdentifier name,
              const NPVariant* args,
              uint32_t num_args,
              NPVariant* result) {
    return false;
  }

  bool InvokeDefault(const NPVariant* args,
                     uint32_t num_args,
                     NPVariant* result) {
    return false;
  }

  bool HasProperty(NPIdentifier name) {
    return false;
  }

  bool GetProperty(NPIdentifier name, NPVariant* result) {
    return false;
  }

  bool SetProperty(NPIdentifier name, const NPVariant* value) {
    return false;
  }

  bool RemoveProperty(NPIdentifier name) {
    return false;
  }

  bool Enumerate(NPIdentifier** names,
                 uint32_t* count) {
    *names = NULL;
    *count = 0;
    return true;
  }

  bool Construct(const NPVariant* args,
                 uint32_t num_args,
                 NPVariant* result) {
    return false;
  }

  static BaseNPDispatcher* GetDispatcherChain() {
    return NULL;
  }

 protected:
  DefaultNPObject() {}
  virtual ~DefaultNPObject() {}

 private:
  DISALLOW_COPY_AND_ASSIGN(DefaultNPObject);
};
}  // namespace np_utils

#endif  // GPU_NP_UTILS_DEFAULT_NP_OBJECT_H_