| 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/ppb_var.h" | 12 #include "ppapi/c/ppb_var.h" |
| 12 | 13 |
| 13 #define PPB_CLASS_INTERFACE "PPB_Class;0.1" | 14 #define PPB_CLASS_INTERFACE "PPB_Class;0.2" |
| 14 | 15 |
| 15 /** | 16 /** |
| 16 * @file | 17 * @file |
| 17 * Defines the PPB_Class struct. | 18 * Defines the PPB_Class struct. |
| 18 * | 19 * |
| 19 * @addtogroup PPB | 20 * @addtogroup PPB |
| 20 * @{ | 21 * @{ |
| 21 */ | 22 */ |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * Function callback. | 25 * Function callback. |
| 25 * | 26 * |
| 26 * native_ptr will always be the native_ptr used to create this_object. If | 27 * native_ptr will always be the native_ptr used to create this_object. If |
| 27 * this object was not created in this module, native_ptr will be NULL. There | 28 * this object was not created in this module, native_ptr will be NULL. There |
| 28 * is no other type protection - if your module contains two objects with | 29 * is no other type protection - if your module contains two objects with |
| 29 * different native_ptr information, make sure you can handle the case of | 30 * different native_ptr information, make sure you can handle the case of |
| 30 * JS calling one object's function with another object set as this. | 31 * JS calling one object's function with another object set as this. |
| 31 */ | 32 */ |
| 32 typedef PP_Var (*PP_ClassFunction)(void* native_ptr, PP_Var this_object, | 33 typedef struct PP_Var (*PP_ClassFunction)(void* native_ptr, |
| 33 PP_Var* args, uint32_t argc, | 34 struct PP_Var this_object, /*NOLINT*/ |
| 34 PP_Var* exception); | 35 struct PP_Var* args, |
| 36 uint32_t argc, |
| 37 struct PP_Var* exception); |
| 35 | 38 |
| 36 typedef void (*PP_ClassDestructor)(void* native_ptr); | 39 typedef void (*PP_ClassDestructor)(void* native_ptr); |
| 37 | 40 |
| 38 /** | 41 /** |
| 39 * One property of a class. | 42 * One property of a class. |
| 40 * | 43 * |
| 41 * It can be either a value property, in which case it need to have getter | 44 * It can be either a value property, in which case it need to have getter |
| 42 * and/or setter fields set, and method NULL, or a function, in which case it | 45 * and/or setter fields set, and method NULL, or a function, in which case it |
| 43 * needs to have method set, and getter/setter set to NULL. It is an error to | 46 * needs to have method set, and getter/setter set to NULL. It is an error to |
| 44 * have method and either getter or setter set, as it is an error to not provide | 47 * have method and either getter or setter set, as it is an error to not provide |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 * created using Instantiate(). Each instance carries one void* of native | 97 * created using Instantiate(). Each instance carries one void* of native |
| 95 * state, which is passed to Instantiate(). When the instance is finalized, | 98 * state, which is passed to Instantiate(). When the instance is finalized, |
| 96 * the destructor function is called to destruct the native state. | 99 * the destructor function is called to destruct the native state. |
| 97 * | 100 * |
| 98 * If invoke handler is specified, then the instances can be used as | 101 * If invoke handler is specified, then the instances can be used as |
| 99 * functions. | 102 * functions. |
| 100 */ | 103 */ |
| 101 PP_Resource (*Create)(PP_Module module, | 104 PP_Resource (*Create)(PP_Module module, |
| 102 PP_ClassDestructor destruct, | 105 PP_ClassDestructor destruct, |
| 103 PP_ClassFunction invoke, | 106 PP_ClassFunction invoke, |
| 104 PP_ClassProperty* properties); | 107 struct PP_ClassProperty* properties); |
| 105 | 108 |
| 106 /** | 109 /** |
| 107 * Creates an instance of the given class, and attaches given native pointer | 110 * Creates an instance of the given class, and attaches given native pointer |
| 108 * to it. | 111 * to it. |
| 109 * | 112 * |
| 110 * If the class_object is invalid, throws an exception. | 113 * If the class_object is invalid, throws an exception. |
| 111 */ | 114 */ |
| 112 PP_Var (*Instantiate)(PP_Resource class_object, | 115 struct PP_Var (*Instantiate)(PP_Resource class_object, |
| 113 void* native_ptr, PP_Var* exception); | 116 void* native_ptr, |
| 117 struct PP_Var* exception); |
| 114 }; | 118 }; |
| 115 | 119 |
| 116 /** | 120 /** |
| 117 * @} | 121 * @} |
| 118 * End addtogroup PPP | 122 * End addtogroup PPP |
| 119 */ | 123 */ |
| 120 #endif // PPAPI_C_PPP_CLASS_H_ | 124 #endif // PPAPI_C_PPP_CLASS_H_ |
| 121 | |
| OLD | NEW |