| OLD | NEW |
| 1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 #ifndef PPAPI_C_PPB_CLASS_H_ | 5 #ifndef PPAPI_C_PPB_CLASS_H_ |
| 6 #define PPAPI_C_PPB_CLASS_H_ | 6 #define PPAPI_C_PPB_CLASS_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_module.h" | 8 #include "ppapi/c/pp_module.h" |
| 9 #include "ppapi/c/pp_resource.h" | 9 #include "ppapi/c/pp_resource.h" |
| 10 #include "ppapi/c/pp_stdint.h" | 10 #include "ppapi/c/pp_stdint.h" |
| 11 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
| 12 #include "ppapi/c/ppb_var.h" | 12 #include "ppapi/c/ppb_var.h" |
| 13 | 13 |
| 14 #define PPB_CLASS_INTERFACE "PPB_Class;0.4" | 14 #define PPB_CLASS_INTERFACE "PPB_Class;0.4" |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * @file | 17 * @file |
| 18 * Defines the PPB_Class struct. | 18 * Defines the PPB_Class struct. |
| 19 * | 19 * |
| 20 * @addtogroup PPB | 20 */ |
| 21 |
| 22 /** |
| 23 * @addtogroup Typedefs |
| 21 * @{ | 24 * @{ |
| 22 */ | 25 */ |
| 23 | 26 |
| 24 /** | 27 /** |
| 25 * Function callback. | 28 * Function callback. |
| 26 * | 29 * |
| 27 * native_ptr will always be the native_ptr used to create this_object. If | 30 * native_ptr will always be the native_ptr used to create this_object. If |
| 28 * this object was not created in this module, native_ptr will be NULL. There | 31 * this object was not created in this module, native_ptr will be NULL. There |
| 29 * is no other type protection - if your module contains two objects with | 32 * is no other type protection - if your module contains two objects with |
| 30 * different native_ptr information, make sure you can handle the case of | 33 * different native_ptr information, make sure you can handle the case of |
| 31 * JS calling one object's function with another object set as this. | 34 * JS calling one object's function with another object set as this. |
| 35 * |
| 32 */ | 36 */ |
| 33 typedef struct PP_Var (*PP_ClassFunction)(void* native_ptr, | 37 typedef struct PP_Var (*PP_ClassFunction)(void* native_ptr, |
| 34 struct PP_Var this_object, /*NOLINT*/ | 38 struct PP_Var this_object, /*NOLINT*/ |
| 35 struct PP_Var* args, | 39 struct PP_Var* args, |
| 36 uint32_t argc, | 40 uint32_t argc, |
| 37 struct PP_Var* exception); | 41 struct PP_Var* exception); |
| 42 /** |
| 43 * @} |
| 44 */ |
| 38 | 45 |
| 46 /** |
| 47 * @addtogroup Typedefs |
| 48 * @{ |
| 49 */ |
| 39 typedef void (*PP_ClassDestructor)(void* native_ptr); | 50 typedef void (*PP_ClassDestructor)(void* native_ptr); |
| 51 /** |
| 52 * @} |
| 53 */ |
| 54 |
| 55 /** |
| 56 * @addtogroup Structs |
| 57 * @{ |
| 58 */ |
| 40 | 59 |
| 41 /** | 60 /** |
| 42 * One property of a class. | 61 * One property of a class. |
| 43 * | 62 * |
| 44 * It can be either a value property, in which case it need to have getter | 63 * It can be either a value property, in which case it need to have getter |
| 45 * and/or setter fields set, and method NULL, or a function, in which case it | 64 * and/or setter fields set, and method NULL, or a function, in which case it |
| 46 * needs to have method set, and getter/setter set to NULL. It is an error to | 65 * needs to have method set, and getter/setter set to NULL. It is an error to |
| 47 * have method and either getter or setter set, as it is an error to not provide | 66 * have method and either getter or setter set, as it is an error to not provide |
| 48 * any of them. | 67 * any of them. |
| 49 * | 68 * |
| 50 * Not providing a getter will be equivalent to having a getter which returns | 69 * Not providing a getter will be equivalent to having a getter which returns |
| 51 * undefined. Not providing a setter will be equivalent to providing a setter | 70 * undefined. Not providing a setter will be equivalent to providing a setter |
| 52 * which doesn't do anything. | 71 * which doesn't do anything. |
| 72 * |
| 53 */ | 73 */ |
| 54 struct PP_ClassProperty { | 74 struct PP_ClassProperty { |
| 55 const char* name; | 75 const char* name; |
| 56 PP_ClassFunction method; | 76 PP_ClassFunction method; |
| 57 PP_ClassFunction getter; | 77 PP_ClassFunction getter; |
| 58 PP_ClassFunction setter; | 78 PP_ClassFunction setter; |
| 59 uint32_t modifiers; | 79 uint32_t modifiers; |
| 60 }; | 80 }; |
| 81 /** |
| 82 * @} |
| 83 */ |
| 84 |
| 85 /** |
| 86 * @addtogroup Interfaces |
| 87 * @{ |
| 88 */ |
| 61 | 89 |
| 62 /** Interface for implementing JavaScript-accessible objects. | 90 /** Interface for implementing JavaScript-accessible objects. |
| 63 * | 91 * |
| 64 * | 92 * |
| 65 * Example usage: | 93 * Example usage: |
| 66 * | 94 * |
| 67 * struct PP_ClassProperty properties[] = { | 95 * struct PP_ClassProperty properties[] = { |
| 68 * { "method", methodFunc }, | 96 * { "method", methodFunc }, |
| 69 * { "hiddenMethod", hiddenMethodFunc, NULL, NULL, | 97 * { "hiddenMethod", hiddenMethodFunc, NULL, NULL, |
| 70 * PP_OBJECTPROPERTY_MODIFIER_DONTENUM }, | 98 * PP_OBJECTPROPERTY_MODIFIER_DONTENUM }, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 /** | 137 /** |
| 110 * Creates an instance of the given class, and attaches given native pointer | 138 * Creates an instance of the given class, and attaches given native pointer |
| 111 * to it. | 139 * to it. |
| 112 * | 140 * |
| 113 * If the class_object is invalid, throws an exception. | 141 * If the class_object is invalid, throws an exception. |
| 114 */ | 142 */ |
| 115 struct PP_Var (*Instantiate)(PP_Resource class_object, | 143 struct PP_Var (*Instantiate)(PP_Resource class_object, |
| 116 void* native_ptr, | 144 void* native_ptr, |
| 117 struct PP_Var* exception); | 145 struct PP_Var* exception); |
| 118 }; | 146 }; |
| 119 | |
| 120 /** | 147 /** |
| 121 * @} | 148 * @} |
| 122 * End addtogroup PPP | |
| 123 */ | 149 */ |
| 150 |
| 151 |
| 124 #endif /* PPAPI_C_PPP_CLASS_H_ */ | 152 #endif /* PPAPI_C_PPP_CLASS_H_ */ |
| 125 | 153 |
| OLD | NEW |