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

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

Issue 4310002: Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on W... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « ppapi/c/ppb_instance.h ('k') | ppapi/c/ppp_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_instance.h" 9 #include "ppapi/c/pp_instance.h"
10 #include "ppapi/c/pp_macros.h"
9 #include "ppapi/c/pp_module.h" 11 #include "ppapi/c/pp_module.h"
10 #include "ppapi/c/pp_resource.h" 12 #include "ppapi/c/pp_resource.h"
11 #include "ppapi/c/pp_stdint.h" 13 #include "ppapi/c/pp_stdint.h"
12 #include "ppapi/c/pp_var.h" 14 #include "ppapi/c/pp_var.h"
13 15
14 #define PPB_VAR_INTERFACE "PPB_Var;0.1" 16 #define PPB_VAR_INTERFACE "PPB_Var;0.2"
15 17
16 /** 18 /**
17 * @file 19 * @file
18 * Defines the PPB_Var struct. 20 * Defines the PPB_Var struct.
19 * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript 21 * See http://code.google.com/p/ppapi/wiki/InterfacingWithJavaScript
20 * for general information on using this interface. 22 * for general information on using this interface.
21 * {PENDING: Should the generated doc really be pointing to methods?} 23 * {PENDING: Should the generated doc really be pointing to methods?}
22 * 24 *
23 * @addtogroup PPB 25 * @addtogroup PPB
24 * @{ 26 * @{
25 */ 27 */
26 28
27 enum PP_ObjectProperty_Modifier { 29 enum PP_ObjectProperty_Modifier {
28 PP_OBJECTPROPERTY_MODIFIER_NONE = 0, 30 PP_OBJECTPROPERTY_MODIFIER_NONE = 0,
29 PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0, 31 PP_OBJECTPROPERTY_MODIFIER_READONLY = 1 << 0,
30 PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1, 32 PP_OBJECTPROPERTY_MODIFIER_DONTENUM = 1 << 1,
31 PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2, 33 PP_OBJECTPROPERTY_MODIFIER_DONTDELETE = 1 << 2,
32 PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3 34 PP_OBJECTPROPERTY_MODIFIER_HASVALUE = 1 << 3
33 }; 35 };
34 36
35 struct PP_ObjectProperty { 37 struct PP_ObjectProperty {
36 PP_Var name; 38 struct PP_Var name;
37 PP_Var value; 39 struct PP_Var value;
38 PP_Var getter; 40 struct PP_Var getter;
39 PP_Var setter; 41 struct PP_Var setter;
40 uint32_t modifiers; 42 uint32_t modifiers;
41 }; 43 };
42 44
43 /** 45 /**
44 * PPB_Var API 46 * PPB_Var API
45 * 47 *
46 * JavaScript specification: 48 * JavaScript specification:
47 * 49 *
48 * When referencing JS specification, we will refer to ECMAScript, 5th edition, 50 * When referencing JS specification, we will refer to ECMAScript, 5th edition,
49 * and we will put section numbers in square brackets. 51 * and we will put section numbers in square brackets.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 */ 122 */
121 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); 123 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len);
122 124
123 /** 125 /**
124 * Convert a variable to a different type using rules from ECMAScript 126 * Convert a variable to a different type using rules from ECMAScript
125 * specification, section [9]. 127 * specification, section [9].
126 * 128 *
127 * For conversions from/to PP_VARTYPE_OBJECT, the instance must be specified, 129 * For conversions from/to PP_VARTYPE_OBJECT, the instance must be specified,
128 * or an exception of type PP_VARTYPE_STRING will be thrown. 130 * or an exception of type PP_VARTYPE_STRING will be thrown.
129 */ 131 */
130 PP_Var (*ConvertType)(PP_Instance instance, 132 struct PP_Var (*ConvertType)(PP_Instance instance,
131 struct PP_Var var, 133 struct PP_Var var,
132 PP_VarType new_type, 134 PP_VarType new_type,
133 PP_Var* exception); 135 struct PP_Var* exception);
134 136
135 /** 137 /**
136 * Sets a property on the object, similar to Object.prototype.defineProperty. 138 * Sets a property on the object, similar to Object.prototype.defineProperty.
137 * 139 *
138 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 140 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
139 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but 141 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
140 * don't have the JS context to create new objects, we might throw a string. 142 * don't have the JS context to create new objects, we might throw a string.
141 * Then, the property's 'name' field is converted to string using 143 * Then, the property's 'name' field is converted to string using
142 * ConvertType (ToString [9.8]). 144 * ConvertType (ToString [9.8]).
143 * After that, defineOwnProperty [8.12.9, 15.4.5.1] is called with the 145 * After that, defineOwnProperty [8.12.9, 15.4.5.1] is called with the
144 * property. 146 * property.
145 * To set a simple property, set the value and set modifiers to default 147 * To set a simple property, set the value and set modifiers to default
146 * (Writable|Enumerable|Configurable|HasValue), see [8.12.15] and 148 * (Writable|Enumerable|Configurable|HasValue), see [8.12.15] and
147 * function PPB_MakeSimpleProperty. 149 * function PPB_MakeSimpleProperty.
148 */ 150 */
149 void (*DefineProperty)(struct PP_Var object, 151 void (*DefineProperty)(struct PP_Var object,
150 struct PP_ObjectProperty property, 152 struct PP_ObjectProperty property,
151 PP_Var* exception); 153 struct PP_Var* exception);
152 154
153 /** 155 /**
154 * Tests whether an object has a property with a given name. 156 * Tests whether an object has a property with a given name.
155 * 157 *
156 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 158 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
157 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but 159 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
158 * don't have the JS context to create new objects, we might throw a string. 160 * don't have the JS context to create new objects, we might throw a string.
159 * Then, convert 'property' to string using ConvertType (ToString [9.8]). 161 * Then, convert 'property' to string using ConvertType (ToString [9.8]).
160 * Then return true if the given property exists on the object [8.12.6]. 162 * Then return true if the given property exists on the object [8.12.6].
161 */ 163 */
162 bool (*HasProperty)(struct PP_Var object, 164 PP_Bool (*HasProperty)(struct PP_Var object,
163 struct PP_Var property, 165 struct PP_Var property,
164 struct PP_Var* exception); 166 struct PP_Var* exception);
165 167
166 /** 168 /**
167 * Returns a given property of the object. 169 * Returns a given property of the object.
168 * 170 *
169 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 171 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
170 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but 172 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
171 * don't have the JS context to create new objects, we might throw a string. 173 * don't have the JS context to create new objects, we might throw a string.
172 * Then, convert 'property' to string using ConvertType (ToString [9.8]). 174 * Then, convert 'property' to string using ConvertType (ToString [9.8]).
173 * Then return the given property of the object [8.12.2]. 175 * Then return the given property of the object [8.12.2].
174 */ 176 */
175 PP_Var (*GetProperty)(struct PP_Var object, 177 struct PP_Var (*GetProperty)(struct PP_Var object,
176 struct PP_Var property, 178 struct PP_Var property,
177 struct PP_Var* exception); 179 struct PP_Var* exception);
178 180
179 /** 181 /**
180 * Delete a property from the object, return true if succeeded. 182 * Delete a property from the object, return true if succeeded.
181 * 183 *
182 * True is returned if the property didn't exist in the first place. 184 * True is returned if the property didn't exist in the first place.
183 * 185 *
184 * First, if object is not PP_VARTYPE_OBJECT, throw an exception. 186 * First, if object is not PP_VARTYPE_OBJECT, throw an exception.
185 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but 187 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
186 * don't have the JS context to create new objects, we might throw a string. 188 * don't have the JS context to create new objects, we might throw a string.
187 * Then, convert 'property' to string using ConvertType (ToString [9.8]). 189 * Then, convert 'property' to string using ConvertType (ToString [9.8]).
188 * Then delete the given property of the object [8.12.7]. 190 * Then delete the given property of the object [8.12.7].
189 */ 191 */
190 bool (*DeleteProperty)(struct PP_Var object, 192 PP_Bool (*DeleteProperty)(struct PP_Var object,
191 struct PP_Var property, 193 struct PP_Var property,
192 struct PP_Var* exception); 194 struct PP_Var* exception);
193 195
194 /** 196 /**
195 * Retrieves all property names on the given object. Property names include 197 * Retrieves all property names on the given object. Property names include
196 * methods. 198 * methods.
197 * 199 *
198 * If object is not PP_VARTYPE_OBJECT, throw an exception. 200 * If object is not PP_VARTYPE_OBJECT, throw an exception.
199 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but 201 * TODO(neb): Specify the exception. Ideally, it would be a TypeError, but
200 * don't have the JS context to create new objects, we might throw a string. 202 * don't have the JS context to create new objects, we might throw a string.
201 * 203 *
202 * If there is a failure, the given exception will be set (if it is non-NULL). 204 * If there is a failure, the given exception will be set (if it is non-NULL).
(...skipping 22 matching lines...) Expand all
225 * ppb_core.MemFree(properties); </pre> 227 * ppb_core.MemFree(properties); </pre>
226 */ 228 */
227 void (*EnumerateProperties)(struct PP_Var object, 229 void (*EnumerateProperties)(struct PP_Var object,
228 uint32_t* property_count, 230 uint32_t* property_count,
229 struct PP_Var** properties, 231 struct PP_Var** properties,
230 struct PP_Var* exception); 232 struct PP_Var* exception);
231 233
232 /** 234 /**
233 * Check if an object is a JS Function [9.11]. 235 * Check if an object is a JS Function [9.11].
234 */ 236 */
235 bool (*IsCallable)(struct PP_Var object); 237 PP_Bool (*IsCallable)(struct PP_Var object);
236 238
237 /** 239 /**
238 * Call the functions. 240 * Call the functions.
239 * 241 *
240 * Similar to Function.prototype.call [15.3.4.4]. It will throw a TypeError 242 * Similar to Function.prototype.call [15.3.4.4]. It will throw a TypeError
241 * and return undefined if object is not PP_VARTYPE_OBJECT, or is not 243 * and return undefined if object is not PP_VARTYPE_OBJECT, or is not
242 * callable. 244 * callable.
243 * 245 *
244 * Pass the arguments to the function in order in the |argv| array, and the 246 * Pass the arguments to the function in order in the |argv| array, and the
245 * number of arguments in the |argc| parameter. |argv| can be NULL if |argc| 247 * number of arguments in the |argc| parameter. |argv| can be NULL if |argc|
(...skipping 26 matching lines...) Expand all
272 * 274 *
273 * For examples, to construct an empty object, do: 275 * For examples, to construct an empty object, do:
274 * GetWindow().GetProperty("Object").Construct(0, NULL); 276 * GetWindow().GetProperty("Object").Construct(0, NULL);
275 */ 277 */
276 struct PP_Var (*Construct)(struct PP_Var object, 278 struct PP_Var (*Construct)(struct PP_Var object,
277 uint32_t argc, 279 uint32_t argc,
278 struct PP_Var* argv, 280 struct PP_Var* argv,
279 struct PP_Var* exception); 281 struct PP_Var* exception);
280 }; 282 };
281 283
282 inline struct PP_ObjectProperty PP_MakeSimpleProperty(PP_Var name, 284 PP_INLINE struct PP_ObjectProperty PP_MakeSimpleProperty(struct PP_Var name,
283 PP_Var value) { 285 struct PP_Var value) {
284 struct PP_ObjectProperty result = { 286 struct PP_ObjectProperty result;
285 name, value, PP_MakeUndefined(), PP_MakeUndefined(), 287 result.name = name;
286 PP_OBJECTPROPERTY_MODIFIER_HASVALUE }; 288 result.value = value;
289 result.getter = PP_MakeUndefined();
290 result.setter = PP_MakeUndefined();
291 result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE;
287 return result; 292 return result;
288 } 293 }
289 294
290 /** 295 /**
291 * @} 296 * @}
292 * End addtogroup PPB 297 * End addtogroup PPB
293 */ 298 */
294 #endif // PPAPI_C_PPB_VAR_H_ 299 #endif // PPAPI_C_PPB_VAR_H_
295
OLDNEW
« no previous file with comments | « ppapi/c/ppb_instance.h ('k') | ppapi/c/ppp_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698