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_C_PPP_CLASS_DEPRECATED_H_
6 #define PPAPI_C_PPP_CLASS_DEPRECATED_H_
8 #include "ppapi/c/dev/deprecated_bool.h"
9 #include "ppapi/c/pp_stdint.h"
10 #include "ppapi/c/pp_var.h"
14 * Defines the PPP_Class_Deprecated struct.
23 * Interface for the plugin to implement JavaScript-accessible objects.
25 * This interface has no interface name. Instead, the plugin passes a pointer
26 * to this interface to PPB_Var_Deprecated.CreateObject that corresponds to the
27 * object being implemented.
29 * See the PPB_Var_Deprecated interface for more information on these functions.
30 * This interface just allows you to implement the "back end" of those
31 * functions, so most of the contract is specified in that interface.
34 * http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
35 * for general information on using and implementing vars.
37 struct PPP_Class_Deprecated
{
39 * |name| is guaranteed to be an integer or string type var. Exception is
40 * guaranteed non-NULL. An integer is used for |name| when implementing
41 * array access into the object. This test should only return true for
42 * properties that are not methods. Use HasMethod() to handle methods.
44 bool (*HasProperty
)(void* object
,
46 struct PP_Var
* exception
);
49 * |name| is guaranteed to be a string-type. Exception is guaranteed non-NULL.
50 * If the method does not exist, return false and don't set the exception.
51 * Errors in this function will probably not occur in general usage, but
52 * if you need to throw an exception, still return false.
54 bool (*HasMethod
)(void* object
,
56 struct PP_Var
* exception
);
59 * |name| is guaranteed to be a string-type or an integer-type var. Exception
60 * is guaranteed non-NULL. An integer is used for |name| when implementing
61 * array access into the object. If the property does not exist, set the
62 * exception and return a var of type Void. A property does not exist if
63 * a call HasProperty() for the same |name| would return false.
65 struct PP_Var (*GetProperty
)(void* object
,
67 struct PP_Var
* exception
);
70 * Exception is guaranteed non-NULL.
72 * This should include all enumerable properties, including methods. Be sure
73 * to set |*property_count| to 0 and |properties| to NULL in all failure
74 * cases, these should never be unset when calling this function. The
75 * pointers passed in are guaranteed not to be NULL, so you don't have to
78 * If you have any properties, allocate the property array with
79 * PPB_Core.MemAlloc(sizeof(PP_Var) * property_count) and add a reference
80 * to each property on behalf of the caller. The caller is responsible for
81 * Release()ing each var and calling PPB_Core.MemFree on the property pointer.
83 void (*GetAllPropertyNames
)(void* object
,
84 uint32_t* property_count
,
85 struct PP_Var
** properties
,
86 struct PP_Var
* exception
);
89 * |name| is guaranteed to be an integer or string type var. Exception is
90 * guaranteed non-NULL.
92 void (*SetProperty
)(void* object
,
95 struct PP_Var
* exception
);
98 * |name| is guaranteed to be an integer or string type var. Exception is
99 * guaranteed non-NULL.
101 void (*RemoveProperty
)(void* object
,
103 struct PP_Var
* exception
);
105 // TODO(brettw) need native array access here.
108 * |name| is guaranteed to be a string type var. Exception is guaranteed
111 struct PP_Var (*Call
)(void* object
,
112 struct PP_Var method_name
,
115 struct PP_Var
* exception
);
117 /** Exception is guaranteed non-NULL. */
118 struct PP_Var (*Construct
)(void* object
,
121 struct PP_Var
* exception
);
124 * Called when the reference count of the object reaches 0. Normally, plugins
125 * would free their internal data pointed to by the |object| pointer.
127 void (*Deallocate
)(void* object
);
134 #endif /* PPAPI_C_PPP_CLASS_DEPRECATED_H_ */