1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PPAPI_CPP_SCRIPTABLE_OBJECT_DEPRECATED_H_
6 #define PPAPI_CPP_SCRIPTABLE_OBJECT_DEPRECATED_H_
10 struct PPP_Class_Deprecated
;
19 namespace deprecated
{
21 // This class allows you to implement objects accessible by JavaScript. Derive
22 // from this class and override the virtual functions you support. pp::Var has
23 // a constructor that takes a pointer to a ScriptableObject for when you want
24 // to convert your custom object to a var.
26 // Please see the PPB_Core C interface for more information on how to implement
27 // these functions. These functions are the backend implementation for the
28 // functions in PPB_Var, which contains further information.
31 // http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
32 // for a general overview of interfacing with JavaScript.
33 class ScriptableObject
{
36 virtual ~ScriptableObject() {}
38 // The default implementation returns false.
39 virtual bool HasProperty(const Var
& name
, Var
* exception
);
41 // The default implementation returns false.
42 virtual bool HasMethod(const Var
& name
, Var
* exception
);
44 // The default implementation sets an exception that the property doesn't
46 virtual Var
GetProperty(const Var
& name
, Var
* exception
);
48 // The default implementation returns no properties.
49 virtual void GetAllPropertyNames(std::vector
<Var
>* properties
,
52 // The default implementation sets an exception that the property can not be
54 virtual void SetProperty(const Var
& name
,
58 // The default implementation sets an exception that the method does not
60 virtual void RemoveProperty(const Var
& name
,
63 // TODO(brettw) need native array access here.
65 // method_name is guaranteed to be either a string or an integer.
67 // The default implementation sets an exception that the method does not
69 virtual Var
Call(const Var
& method_name
,
70 const std::vector
<Var
>& args
,
73 // The default implementation sets an exception that the method does not
75 virtual Var
Construct(const std::vector
<Var
>& args
,
79 friend class ::pp::Var
;
80 friend class ::pp::VarPrivate
;
81 static const PPP_Class_Deprecated
* GetClass();
83 // Unimplemented, copy and assignment is not allowed.
84 ScriptableObject(const ScriptableObject
& other
);
85 ScriptableObject
& operator=(const ScriptableObject
& other
);
88 } // namespace deprecated
92 #endif // PPAPI_CPP_SCRIPTABLE_OBJECT_DEPRECATED_H_