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 }; |
| 38 /** |
| 39 * @} |
| 40 */ |
| 41 |
36 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4); | 42 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4); |
37 | 43 |
| 44 /** |
| 45 * @addtogroup Structs |
| 46 * @{ |
| 47 */ |
38 struct PP_ObjectProperty { | 48 struct PP_ObjectProperty { |
39 struct PP_Var name; | 49 struct PP_Var name; |
40 struct PP_Var value; | 50 struct PP_Var value; |
41 struct PP_Var getter; | 51 struct PP_Var getter; |
42 struct PP_Var setter; | 52 struct PP_Var setter; |
43 uint32_t modifiers; | 53 uint32_t modifiers; |
44 | 54 |
45 /** Ensure that this struct is 72 bytes wide by padding the end. In some | 55 /** 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 | 56 * 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 | 57 * 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 | 58 * padding attribute. This padding makes its size consistent across |
49 * compilers. | 59 * compilers. |
50 */ | 60 */ |
51 int32_t padding; | 61 int32_t padding; |
52 }; | 62 }; |
| 63 /** |
| 64 * @} |
| 65 */ |
| 66 |
53 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ObjectProperty, 72); | 67 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_ObjectProperty, 72); |
54 | 68 |
55 /** | 69 /** |
| 70 * @addtogroup Interfaces |
| 71 * @{ |
| 72 */ |
| 73 |
| 74 /** |
56 * PPB_Var API | 75 * PPB_Var API |
57 * | 76 * |
58 * JavaScript specification: | 77 * JavaScript specification: |
59 * | 78 * |
60 * When referencing JS specification, we will refer to ECMAScript, 5th edition, | 79 * When referencing JS specification, we will refer to ECMAScript, 5th edition, |
61 * and we will put section numbers in square brackets. | 80 * and we will put section numbers in square brackets. |
62 * | 81 * |
63 * Exception handling: | 82 * Exception handling: |
64 * | 83 * |
65 * If an exception parameter is NULL, then any exceptions that happen during the | 84 * If an exception parameter is NULL, then any exceptions that happen during the |
66 * execution of the function will be ignored. If it is non-NULL, and has a type | 85 * execution of the function will be ignored. If it is non-NULL, and has a type |
67 * of PP_VARTYPE_UNDEFINED, then if an exception is thrown it will be stored in | 86 * of PP_VARTYPE_UNDEFINED, then if an exception is thrown it will be stored in |
68 * the exception variable. It it is non-NULL and not PP_VARTYPE_UNDEFINED, then | 87 * the exception variable. It it is non-NULL and not PP_VARTYPE_UNDEFINED, then |
69 * the function is a no-op, and, if it returns a value, it will return | 88 * the function is a no-op, and, if it returns a value, it will return |
70 * PP_VARTYPE_UNDEFINED. This can be used to chain together multiple calls and | 89 * PP_VARTYPE_UNDEFINED. This can be used to chain together multiple calls and |
71 * only check the exception at the end. | 90 * only check the exception at the end. |
72 * | 91 * |
73 * Make sure not to intermix non-JS with JS calls when relying on this behavior | 92 * Make sure not to intermix non-JS with JS calls when relying on this behavior |
74 * to catch JS exceptions, as non-JS functions will still execute! | 93 * to catch JS exceptions, as non-JS functions will still execute! |
75 | 94 |
76 * JS engine's exceptions will always be of type PP_VARTYPE_OBJECT. However, | 95 * 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 | 96 * 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 | 97 * 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 | 98 * 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 | 99 * result in an PP_VARTYPE_STRING exception. Exceptions will not be of any other |
81 * type. | 100 * type. |
82 * TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module, | 101 * TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module, |
83 * instance, resource, string and object ids. | 102 * instance, resource, string and object ids. |
| 103 * |
84 */ | 104 */ |
85 struct PPB_Var { | 105 struct PPB_Var { |
86 /** | 106 /** |
87 * Adds a reference to the given var. If this is not a refcounted object, | 107 * 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 | 108 * this function will do nothing so you can always call it no matter what the |
89 * type. | 109 * type. |
90 */ | 110 */ |
91 void (*AddRef)(struct PP_Var var); | 111 void (*AddRef)(struct PP_Var var); |
92 | 112 |
93 /** | 113 /** |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 * JavaScript. Similar to the [[Construct]] internal method [13.2.2]. | 303 * JavaScript. Similar to the [[Construct]] internal method [13.2.2]. |
284 * | 304 * |
285 * For examples, to construct an empty object, do: | 305 * For examples, to construct an empty object, do: |
286 * GetWindow().GetProperty("Object").Construct(0, NULL); | 306 * GetWindow().GetProperty("Object").Construct(0, NULL); |
287 */ | 307 */ |
288 struct PP_Var (*Construct)(struct PP_Var object, | 308 struct PP_Var (*Construct)(struct PP_Var object, |
289 uint32_t argc, | 309 uint32_t argc, |
290 struct PP_Var* argv, | 310 struct PP_Var* argv, |
291 struct PP_Var* exception); | 311 struct PP_Var* exception); |
292 }; | 312 }; |
| 313 /** |
| 314 * @} |
| 315 */ |
293 | 316 |
| 317 /** |
| 318 * @addtogroup Functions |
| 319 * @{ |
| 320 */ |
294 PP_INLINE struct PP_ObjectProperty PP_MakeSimpleProperty(struct PP_Var name, | 321 PP_INLINE struct PP_ObjectProperty PP_MakeSimpleProperty(struct PP_Var name, |
295 struct PP_Var value) { | 322 struct PP_Var value) { |
296 struct PP_ObjectProperty result; | 323 struct PP_ObjectProperty result; |
297 result.name = name; | 324 result.name = name; |
298 result.value = value; | 325 result.value = value; |
299 result.getter = PP_MakeUndefined(); | 326 result.getter = PP_MakeUndefined(); |
300 result.setter = PP_MakeUndefined(); | 327 result.setter = PP_MakeUndefined(); |
301 result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE; | 328 result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE; |
302 return result; | 329 return result; |
303 } | 330 } |
304 | |
305 /** | 331 /** |
306 * @} | 332 * @} |
307 * End addtogroup PPB | |
308 */ | 333 */ |
| 334 |
309 #endif /* PPAPI_C_PPB_VAR_H_ */ | 335 #endif /* PPAPI_C_PPB_VAR_H_ */ |
310 | 336 |
OLD | NEW |