| 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_VAR_H_ | 5 #ifndef PPAPI_C_PPB_VAR_H_ |
| 6 #define PPAPI_C_PPB_VAR_H_ | 6 #define PPAPI_C_PPB_VAR_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_macros.h" | 10 #include "ppapi/c/pp_macros.h" |
| 11 #include "ppapi/c/pp_module.h" | 11 #include "ppapi/c/pp_module.h" |
| 12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
| 13 #include "ppapi/c/pp_stdint.h" | 13 #include "ppapi/c/pp_stdint.h" |
| 14 #include "ppapi/c/pp_var.h" | 14 #include "ppapi/c/pp_var.h" |
| 15 | 15 |
| 16 #define PPB_VAR_INTERFACE "PPB_Var;0.4" | 16 #define PPB_VAR_INTERFACE "PPB_Var;0.4" |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * |
| 20 * @addtogroup Enums |
| 21 * @{ |
| 22 */ |
| 23 |
| 24 /** |
| 19 * @file | 25 * @file |
| 20 * Defines the PPB_Var struct. | 26 * Defines the PPB_Var struct. |
| 21 * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript | 27 * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript |
| 22 * for general information on using this interface. | 28 * for general information on using this interface. |
| 23 * {PENDING: Should the generated doc really be pointing to methods?} | 29 * {PENDING: Should the generated doc really be pointing to methods?} |
| 24 * | |
| 25 * @addtogroup PPB | |
| 26 * @{ | |
| 27 */ | 30 */ |
| 28 | |
| 29 enum PP_ObjectProperty_Modifier { | 31 enum PP_ObjectProperty_Modifier { |
| 30 PP_OBJECTPROPERTY_MODIFIER_NONE = 0, | 32 PP_OBJECTPROPERTY_MODIFIER_NONE = 0, |
| 31 PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0, | 33 PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0, |
| 32 PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1, | 34 PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1, |
| 33 PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2, | 35 PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2, |
| 34 PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3 | 36 PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3 |
| 35 }; | 37 }; |
| 36 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4); | 38 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4); |
| 39 /** |
| 40 * @} |
| 41 */ |
| 37 | 42 |
| 43 /** |
| 44 * @addtogroup Structs |
| 45 * @{ |
| 46 */ |
| 38 struct PP_ObjectProperty { | 47 struct PP_ObjectProperty { |
| 39 struct PP_Var name; | 48 struct PP_Var name; |
| 40 struct PP_Var value; | 49 struct PP_Var value; |
| 41 struct PP_Var getter; | 50 struct PP_Var getter; |
| 42 struct PP_Var setter; | 51 struct PP_Var setter; |
| 43 uint32_t modifiers; | 52 uint32_t modifiers; |
| 44 | 53 |
| 45 /** Ensure that this struct is 72 bytes wide by padding the end. In some | 54 /** Ensure that this struct is 72 bytes wide by padding the end. In some |
| 46 * compilers, PP_Var is 8-byte aligned, so those compilers align this struct | 55 * compilers, PP_Var is 8-byte aligned, so those compilers align this struct |
| 47 * on 8-byte boundaries as well and pad it to 72 bytes even without this | 56 * on 8-byte boundaries as well and pad it to 72 bytes even without this |
| 48 * padding attribute. This padding makes its size consistent across | 57 * padding attribute. This padding makes its size consistent across |
| 49 * compilers. | 58 * compilers. |
| 50 */ | 59 */ |
| 51 int32_t padding; | 60 int32_t padding; |
| 52 }; | 61 }; |
| 53 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ObjectProperty, 72); | 62 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ObjectProperty, 72); |
| 63 /** |
| 64 * @} |
| 65 */ |
| 66 |
| 67 /** |
| 68 * @addtogroup Interfaces |
| 69 * @{ |
| 70 */ |
| 54 | 71 |
| 55 /** | 72 /** |
| 56 * PPB_Var API | 73 * PPB_Var API |
| 57 * | 74 * |
| 58 * JavaScript specification: | 75 * JavaScript specification: |
| 59 * | 76 * |
| 60 * When referencing JS specification, we will refer to ECMAScript, 5th edition, | 77 * When referencing JS specification, we will refer to ECMAScript, 5th edition, |
| 61 * and we will put section numbers in square brackets. | 78 * and we will put section numbers in square brackets. |
| 62 * | 79 * |
| 63 * Exception handling: | 80 * Exception handling: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 74 * to catch JS exceptions, as non-JS functions will still execute! | 91 * to catch JS exceptions, as non-JS functions will still execute! |
| 75 | 92 |
| 76 * JS engine's exceptions will always be of type PP_VARTYPE_OBJECT. However, | 93 * JS engine's exceptions will always be of type PP_VARTYPE_OBJECT. However, |
| 77 * PP_Var interface can also throw PP_VARTYPE_STRING exceptions, in situations | 94 * PP_Var interface can also throw PP_VARTYPE_STRING exceptions, in situations |
| 78 * where there's no JS execution context defined. These are usually invalid | 95 * where there's no JS execution context defined. These are usually invalid |
| 79 * parameter errors - passing an invalid PP_Var value, for example, will always | 96 * parameter errors - passing an invalid PP_Var value, for example, will always |
| 80 * result in an PP_VARTYPE_STRING exception. Exceptions will not be of any other | 97 * result in an PP_VARTYPE_STRING exception. Exceptions will not be of any other |
| 81 * type. | 98 * type. |
| 82 * TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module, | 99 * TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module, |
| 83 * instance, resource, string and object ids. | 100 * instance, resource, string and object ids. |
| 101 * |
| 84 */ | 102 */ |
| 85 struct PPB_Var { | 103 struct PPB_Var { |
| 86 /** | 104 /** |
| 87 * Adds a reference to the given var. If this is not a refcounted object, | 105 * Adds a reference to the given var. If this is not a refcounted object, |
| 88 * this function will do nothing so you can always call it no matter what the | 106 * this function will do nothing so you can always call it no matter what the |
| 89 * type. | 107 * type. |
| 90 */ | 108 */ |
| 91 void (*AddRef)(struct PP_Var var); | 109 void (*AddRef)(struct PP_Var var); |
| 92 | 110 |
| 93 /** | 111 /** |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 * JavaScript. Similar to the [[Construct]] internal method [13.2.2]. | 301 * JavaScript. Similar to the [[Construct]] internal method [13.2.2]. |
| 284 * | 302 * |
| 285 * For examples, to construct an empty object, do: | 303 * For examples, to construct an empty object, do: |
| 286 * GetWindow().GetProperty("Object").Construct(0, NULL); | 304 * GetWindow().GetProperty("Object").Construct(0, NULL); |
| 287 */ | 305 */ |
| 288 struct PP_Var (*Construct)(struct PP_Var object, | 306 struct PP_Var (*Construct)(struct PP_Var object, |
| 289 uint32_t argc, | 307 uint32_t argc, |
| 290 struct PP_Var* argv, | 308 struct PP_Var* argv, |
| 291 struct PP_Var* exception); | 309 struct PP_Var* exception); |
| 292 }; | 310 }; |
| 311 /** |
| 312 * @} |
| 313 */ |
| 293 | 314 |
| 315 /** |
| 316 * @addtogroup Functions |
| 317 * @{ |
| 318 */ |
| 294 PP_INLINE struct PP_ObjectProperty PP_MakeSimpleProperty(struct PP_Var name, | 319 PP_INLINE struct PP_ObjectProperty PP_MakeSimpleProperty(struct PP_Var name, |
| 295 struct PP_Var value) { | 320 struct PP_Var value) { |
| 296 struct PP_ObjectProperty result; | 321 struct PP_ObjectProperty result; |
| 297 result.name = name; | 322 result.name = name; |
| 298 result.value = value; | 323 result.value = value; |
| 299 result.getter = PP_MakeUndefined(); | 324 result.getter = PP_MakeUndefined(); |
| 300 result.setter = PP_MakeUndefined(); | 325 result.setter = PP_MakeUndefined(); |
| 301 result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE; | 326 result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE; |
| 302 return result; | 327 return result; |
| 303 } | 328 } |
| 304 | |
| 305 /** | 329 /** |
| 306 * @} | 330 * @} |
| 307 * End addtogroup PPB | |
| 308 */ | 331 */ |
| 332 |
| 309 #endif /* PPAPI_C_PPB_VAR_H_ */ | 333 #endif /* PPAPI_C_PPB_VAR_H_ */ |
| 310 | 334 |
| OLD | NEW |