Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: ppapi/c/ppb_var.h

Issue 6588085: Minor doc changes. Mostly commented out TODO and {PENDING notes that engineer... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 * @file 19 * @file
20 * Defines the API ... 20 * This file defines the PPB_Var struct.
21 */ 21 */
22 22
23 /** 23 /**
24 * 24 *
25 * @addtogroup Enums 25 * @addtogroup Enums
26 * @{ 26 * @{
27 */ 27 */
28 28
29 /** 29 /**
30 * Defines the PPB_Var struct.
31 * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript 30 * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
32 * for general information on using this interface. 31 * for general information on using this interface.
33 * {PENDING: Should the generated doc really be pointing to methods?}
34 */ 32 */
33 // PENDING: Should the generated doc really be pointing to methods?
35 enum PP_ObjectProperty_Modifier { 34 enum PP_ObjectProperty_Modifier {
36 PP_OBJECTPROPERTY_MODIFIER_NONE = 0, 35 PP_OBJECTPROPERTY_MODIFIER_NONE = 0,
37 PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0, 36 PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0,
38 PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1, 37 PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1,
39 PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2, 38 PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2,
40 PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3 39 PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3
41 }; 40 };
42 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4); 41 PP_COMPILE_ASSERT_ENUM_SIZE_IN_BYTES(PP_ObjectProperty_Modifier, 4);
43 /** 42 /**
44 * @} 43 * @}
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 * 92 *
94 * Make sure not to intermix non-JS with JS calls when relying on this behavior 93 * Make sure not to intermix non-JS with JS calls when relying on this behavior
95 * to catch JS exceptions, as non-JS functions will still execute! 94 * to catch JS exceptions, as non-JS functions will still execute!
96 95
97 * JS engine's exceptions will always be of type PP_VARTYPE_OBJECT. However, 96 * JS engine's exceptions will always be of type PP_VARTYPE_OBJECT. However,
98 * PP_Var interface can also throw PP_VARTYPE_STRING exceptions, in situations 97 * PP_Var interface can also throw PP_VARTYPE_STRING exceptions, in situations
99 * where there's no JS execution context defined. These are usually invalid 98 * where there's no JS execution context defined. These are usually invalid
100 * parameter errors - passing an invalid PP_Var value, for example, will always 99 * parameter errors - passing an invalid PP_Var value, for example, will always
101 * result in an PP_VARTYPE_STRING exception. Exceptions will not be of any other 100 * result in an PP_VARTYPE_STRING exception. Exceptions will not be of any other
102 * type. 101 * type.
103 * TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module,
104 * instance, resource, string and object ids.
105 * 102 *
106 */ 103 */
104
105 // TODO(neb): Specify the exception for ill-formed PP_Vars, invalid module,
106 // instance, resource, string and object ids.
107 struct PPB_Var { 107 struct PPB_Var {
108 /** 108 /**
109 * Adds a reference to the given var. If this is not a refcounted object, 109 * Adds a reference to the given var. If this is not a refcounted object,
110 * this function will do nothing so you can always call it no matter what the 110 * this function will do nothing so you can always call it no matter what the
111 * type. 111 * type.
112 */ 112 */
113 void (*AddRef)(struct PP_Var var); 113 void (*AddRef)(struct PP_Var var);
114 114
115 /** 115 /**
116 * Removes a reference to given var, deleting it if the internal refcount 116 * Removes a reference to given var, deleting it if the internal refcount
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 */ 163 */
164 struct PP_Var (*ConvertType)(PP_Instance instance, 164 struct PP_Var (*ConvertType)(PP_Instance instance,
165 struct PP_Var var, 165 struct PP_Var var,
166 PP_VarType new_type, 166 PP_VarType new_type,
167 struct PP_Var* exception); 167 struct PP_Var* exception);
168 168
169 /** 169 /**
170 * Sets a property on the object, similar to Object.prototype.defineProperty. 170 * Sets a property on the object, similar to Object.prototype.defineProperty.
171 * 171 *
172 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 172 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
173 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
174 * don't have the JS context to create new objects, we might throw a string.
175 * Then, the property's 'name' field is converted to string using 173 * Then, the property's 'name' field is converted to string using
176 * ConvertType (ToString [9.8]). 174 * ConvertType (ToString [9.8]).
177 * After that, defineOwnProperty [8.12.9, 15.4.5.1] is called with the 175 * After that, defineOwnProperty [8.12.9, 15.4.5.1] is called with the
178 * property. 176 * property.
179 * To set a simple property, set the value and set modifiers to default 177 * To set a simple property, set the value and set modifiers to default
180 * (Writable|Enumerable|Configurable|HasValue), see [8.12.15] and 178 * (Writable|Enumerable|Configurable|HasValue), see [8.12.15] and
181 * function PPB_MakeSimpleProperty. 179 * function PPB_MakeSimpleProperty.
182 */ 180 */
181
182 // TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
183 // don't have the JS context to create new objects, we might throw a string.
183 void (*DefineProperty)(struct PP_Var object, 184 void (*DefineProperty)(struct PP_Var object,
184 struct PP_ObjectProperty property, 185 struct PP_ObjectProperty property,
185 struct PP_Var* exception); 186 struct PP_Var* exception);
186 187
187 /** 188 /**
188 * Tests whether an object has a property with a given name. 189 * Tests whether an object has a property with a given name.
189 * 190 *
190 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 191 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
191 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
192 * don't have the JS context to create new objects, we might throw a string.
193 * Then, convert 'property' to string using ConvertType (ToString [9.8]). 192 * Then, convert 'property' to string using ConvertType (ToString [9.8]).
194 * Then return true if the given property exists on the object [8.12.6]. 193 * Then return true if the given property exists on the object [8.12.6].
195 */ 194 */
195
196 // TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
197 // don't have the JS context to create new objects, we might throw a string.
196 PP_Bool (*HasProperty)(struct PP_Var object, 198 PP_Bool (*HasProperty)(struct PP_Var object,
197 struct PP_Var property, 199 struct PP_Var property,
198 struct PP_Var* exception); 200 struct PP_Var* exception);
199 201
200 /** 202 /**
201 * Returns a given property of the object. 203 * Returns a given property of the object.
202 * 204 *
203 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 205 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
204 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
205 * don't have the JS context to create new objects, we might throw a string.
206 * Then, convert 'property' to string using ConvertType (ToString [9.8]). 206 * Then, convert 'property' to string using ConvertType (ToString [9.8]).
207 * Then return the given property of the object [8.12.2]. 207 * Then return the given property of the object [8.12.2].
208 */ 208 */
209
210 // TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
211 // don't have the JS context to create new objects, we might throw a string.
209 struct PP_Var (*GetProperty)(struct PP_Var object, 212 struct PP_Var (*GetProperty)(struct PP_Var object,
210 struct PP_Var property, 213 struct PP_Var property,
211 struct PP_Var* exception); 214 struct PP_Var* exception);
212 215
213 /** 216 /**
214 * Delete a property from the object, return true if succeeded. 217 * Delete a property from the object, return true if succeeded.
215 * 218 *
216 * True is returned if the property didn't exist in the first place. 219 * True is returned if the property didn't exist in the first place.
217 * 220 *
218 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 221 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
219 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
220 * don't have the JS context to create new objects, we might throw a string.
221 * Then, convert 'property' to string using ConvertType (ToString [9.8]). 222 * Then, convert 'property' to string using ConvertType (ToString [9.8]).
222 * Then delete the given property of the object [8.12.7]. 223 * Then delete the given property of the object [8.12.7].
223 */ 224 */
225
226 // TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
227 // don't have the JS context to create new objects, we might throw a string.
224 PP_Bool (*DeleteProperty)(struct PP_Var object, 228 PP_Bool (*DeleteProperty)(struct PP_Var object,
225 struct PP_Var property, 229 struct PP_Var property,
226 struct PP_Var* exception); 230 struct PP_Var* exception);
227 231
228 /** 232 /**
229 * Retrieves all property names on the given object. Property names include 233 * Retrieves all property names on the given object. Property names include
230 * methods. 234 * methods.
231 * 235 *
232 * If object is not PP_VARTYPE_OBJECT, throw an exception. 236 * If object is not PP_VARTYPE_OBJECT, throw an exception.
233 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
234 * don't have the JS context to create new objects, we might throw a string.
235 * 237 *
236 * If there is a failure, the given exception will be set (if it is non-NULL). 238 * If there is a failure, the given exception will be set (if it is non-NULL).
237 * On failure, |*properties| will be set to NULL and |*property_count| will be 239 * On failure, |*properties| will be set to NULL and |*property_count| will be
238 * set to 0. 240 * set to 0.
239 * 241 *
240 * A pointer to the array of property names will be placed in |*properties|. 242 * A pointer to the array of property names will be placed in |*properties|.
241 * The caller is responsible for calling Release() on each of these properties 243 * The caller is responsible for calling Release() on each of these properties
242 * (as per normal refcounted memory management) as well as freeing the array 244 * (as per normal refcounted memory management) as well as freeing the array
243 * pointer with PPB_Core.MemFree(). 245 * pointer with PPB_Core.MemFree().
244 * 246 *
245 * This function returns all "enumerable" properties. Some JavaScript 247 * This function returns all "enumerable" properties. Some JavaScript
246 * properties are "hidden" and these properties won't be retrieved by this 248 * properties are "hidden" and these properties won't be retrieved by this
247 * function, yet you can still set and get them. You can use JS 249 * function, yet you can still set and get them. You can use JS
248 * Object.getOwnPropertyNames() to access these properties. 250 * Object.getOwnPropertyNames() to access these properties.
249 * 251 *
250 * Example: 252 * Example:
251 * <pre> uint32_t count; 253 * <pre> uint32_t count;
252 * PP_Var* properties; 254 * PP_Var* properties;
253 * ppb_var.EnumerateProperties(object, &count, &properties); 255 * ppb_var.EnumerateProperties(object, &count, &properties);
254 * 256 *
255 * ...use the properties here... 257 * ...use the properties here...
256 * 258 *
257 * for (uint32_t i = 0; i < count; i++) 259 * for (uint32_t i = 0; i < count; i++)
258 * ppb_var.Release(properties[i]); 260 * ppb_var.Release(properties[i]);
259 * ppb_core.MemFree(properties); </pre> 261 * ppb_core.MemFree(properties); </pre>
260 */ 262 */
263
264 // TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
265 // don't have the JS context to create new objects, we might throw a string.
261 void (*EnumerateProperties)(struct PP_Var object, 266 void (*EnumerateProperties)(struct PP_Var object,
262 uint32_t* property_count, 267 uint32_t* property_count,
263 struct PP_Var** properties, 268 struct PP_Var** properties,
264 struct PP_Var* exception); 269 struct PP_Var* exception);
265 270
266 /** 271 /**
267 * Check if an object is a JS Function [9.11]. 272 * Check if an object is a JS Function [9.11].
268 */ 273 */
269 PP_Bool (*IsCallable)(struct PP_Var object); 274 PP_Bool (*IsCallable)(struct PP_Var object);
270 275
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 result.setter = PP_MakeUndefined(); 334 result.setter = PP_MakeUndefined();
330 result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE; 335 result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE;
331 return result; 336 return result;
332 } 337 }
333 /** 338 /**
334 * @} 339 * @}
335 */ 340 */
336 341
337 #endif /* PPAPI_C_PPB_VAR_H_ */ 342 #endif /* PPAPI_C_PPB_VAR_H_ */
338 343
OLDNEW
« ppapi/c/ppb_core.h ('K') | « ppapi/c/ppb_core.h ('k') | ppapi/c/ppp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698