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

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

Issue 7399016: More trivial cleanupi of ppapi/c headers (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
« no previous file with comments | « ppapi/c/pp_time.h ('k') | ppapi/c/ppb.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) 2011 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2011 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
6 /* From pp_var.idl modified Tue Jul 12 15:26:30 2011. */
7
5 #ifndef PPAPI_C_PP_VAR_H_ 8 #ifndef PPAPI_C_PP_VAR_H_
6 #define PPAPI_C_PP_VAR_H_ 9 #define PPAPI_C_PP_VAR_H_
7 10
8 #include "ppapi/c/pp_bool.h" 11 #include "ppapi/c/pp_bool.h"
9 #include "ppapi/c/pp_macros.h" 12 #include "ppapi/c/pp_macros.h"
10 #include "ppapi/c/pp_stdint.h" 13 #include "ppapi/c/pp_stdint.h"
11 14
12 /** 15 /**
13 * @file 16 * @file
14 * This file defines the API for handling the passing of data types between 17 * This file defines the API for handling the passing of data types between
15 * your module and the page. 18 * your module and the page.
16 */ 19 */
17 20
21
18 /** 22 /**
19 *
20 * @addtogroup Enums 23 * @addtogroup Enums
21 * @{ 24 * @{
22 */ 25 */
23
24 /** 26 /**
25 * The <code>PP_VarType</code> is an enumeration of the different types that 27 * The <code>PP_VarType</code> is an enumeration of the different types that
26 * can be contained within a <code>PP_Var</code> structure. 28 * can be contained within a <code>PP_Var</code> structure.
27 */ 29 */
28 typedef enum { 30 typedef enum {
29 /** 31 /**
30 * An undefined value. 32 * An undefined value.
31 */ 33 */
32 PP_VARTYPE_UNDEFINED, 34 PP_VARTYPE_UNDEFINED,
33
34 /** 35 /**
35 * A NULL value. This is similar to undefined, but JavaScript differentiates 36 * A NULL value. This is similar to undefined, but JavaScript differentiates
36 * the two so it is exposed here as well. 37 * the two so it is exposed here as well.
37 */ 38 */
38 PP_VARTYPE_NULL, 39 PP_VARTYPE_NULL,
39
40 /** 40 /**
41 * A boolean value, use the <code>as_bool</code> member of the var. 41 * A boolean value, use the <code>as_bool</code> member of the var.
42 */ 42 */
43 PP_VARTYPE_BOOL, 43 PP_VARTYPE_BOOL,
44
45 /** 44 /**
46 * A 32-bit integer value. Use the <code>as_int</code> member of the var. 45 * A 32-bit integer value. Use the <code>as_int</code> member of the var.
47 */ 46 */
48 PP_VARTYPE_INT32, 47 PP_VARTYPE_INT32,
49
50 /** 48 /**
51 * A double-precision floating point value. Use the <code>as_double</code> 49 * A double-precision floating point value. Use the <code>as_double</code>
52 * member of the var. 50 * member of the var.
53 */ 51 */
54 PP_VARTYPE_DOUBLE, 52 PP_VARTYPE_DOUBLE,
55
56 /** 53 /**
57 * The Var represents a string. The <code>as_id</code> field is used to 54 * The Var represents a string. The <code>as_id</code> field is used to
58 * identify the string, which may be created and retrieved from the 55 * identify the string, which may be created and retrieved from the
59 * <code>PPB_Var</code> interface. 56 * <code>PPB_Var</code> interface.
60 */ 57 */
61 PP_VARTYPE_STRING, 58 PP_VARTYPE_STRING,
62
63 /** 59 /**
64 * Represents a JavaScript object. This vartype is not currently usable 60 * Represents a JavaScript object. This vartype is not currently usable
65 * from modules, although it is used internally for some tasks. 61 * from modules, although it is used internally for some tasks.
66 */ 62 */
67 PP_VARTYPE_OBJECT, 63 PP_VARTYPE_OBJECT,
68
69 /** 64 /**
70 * Arrays and dictionaries are not currently supported but will be added 65 * Arrays and dictionaries are not currently supported but will be added
71 * in future revisions. These objects are reference counted so be sure 66 * in future revisions. These objects are reference counted so be sure
72 * to properly AddRef/Release them as you would with strings to ensure your 67 * to properly AddRef/Release them as you would with strings to ensure your
73 * module will continue to work with future versions of the API. 68 * module will continue to work with future versions of the API.
74 */ 69 */
75 PP_VARTYPE_ARRAY, 70 PP_VARTYPE_ARRAY,
76 PP_VARTYPE_DICTIONARY 71 PP_VARTYPE_DICTIONARY
77 } PP_VarType; 72 } PP_VarType;
78 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4); 73 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4);
79 /** 74 /**
80 * @} 75 * @}
81 */ 76 */
82 77
83
84 /** 78 /**
85 * @addtogroup Structs 79 * @addtogroup Structs
86 * @{ 80 * @{
87 */ 81 */
88
89 /** 82 /**
90 * The PP_VarValue union stores the data for any one of the types listed 83 * The PP_VarValue union stores the data for any one of the types listed
91 * in the PP_VarType enum. 84 * in the PP_VarType enum.
92 */ 85 */
93 union PP_VarValue { 86 union PP_VarValue {
94 /** 87 /**
95 * If <code>type</code> is <code>PP_VARTYPE_BOOL</code>, 88 * If <code>type</code> is <code>PP_VARTYPE_BOOL</code>,
96 * <code>as_bool</code> represents the value of this <code>PP_Var</code> as 89 * <code>as_bool</code> represents the value of this <code>PP_Var</code> as
97 * <code>PP_Bool</code>. 90 * <code>PP_Bool</code>.
98 */ 91 */
99 PP_Bool as_bool; 92 PP_Bool as_bool;
100
101 /** 93 /**
102 * If <code>type</code> is <code>PP_VARTYPE_INT32</code>, 94 * If <code>type</code> is <code>PP_VARTYPE_INT32</code>,
103 * <code>as_int</code> represents the value of this <code>PP_Var</code> as 95 * <code>as_int</code> represents the value of this <code>PP_Var</code> as
104 * <code>int32_t</code>. 96 * <code>int32_t</code>.
105 */ 97 */
106 int32_t as_int; 98 int32_t as_int;
107
108 /** 99 /**
109 * If <code>type</code> is <code>PP_VARTYPE_DOUBLE</code>, 100 * If <code>type</code> is <code>PP_VARTYPE_DOUBLE</code>,
110 * <code>as_double</code> represents the value of this <code>PP_Var</code> 101 * <code>as_double</code> represents the value of this <code>PP_Var</code>
111 * as <code>double</code>. 102 * as <code>double</code>.
112 */ 103 */
113 double as_double; 104 double as_double;
114
115 /** 105 /**
116 * If <code>type</code> is <code>PP_VARTYPE_STRING</code>, 106 * If <code>type</code> is <code>PP_VARTYPE_STRING</code>,
117 * <code>PP_VARTYPE_OBJECT</code>, <code>PP_VARTYPE_ARRAY</code>, or 107 * <code>PP_VARTYPE_OBJECT</code>, <code>PP_VARTYPE_ARRAY</code>, or
118 * <code>PP_VARTYPE_DICTIONARY</code>, 108 * <code>PP_VARTYPE_DICTIONARY</code>,
119 * <code>as_id</code> represents the value of this <code>PP_Var</code> as 109 * <code>as_id</code> represents the value of this <code>PP_Var</code> as
120 * an opaque handle assigned by the browser. This handle is guaranteed 110 * an opaque handle assigned by the browser. This handle is guaranteed
121 * never to be 0, so a module can initialize this ID to 0 to indicate a 111 * never to be 0, so a module can initialize this ID to 0 to indicate a
122 * "NULL handle." 112 * "NULL handle."
123 */ 113 */
124 int64_t as_id; 114 int64_t as_id;
125 }; 115 };
126 /**
127 * @}
128 */
129
130
131 /**
132 * @addtogroup Structs
133 * @{
134 */
135 116
136 /** 117 /**
137 * The <code>PP_VAR</code> struct is a variant data type and can contain any 118 * The <code>PP_VAR</code> struct is a variant data type and can contain any
138 * value of one of the types named in the <code>PP_VarType</code> enum. This 119 * value of one of the types named in the <code>PP_VarType</code> enum. This
139 * structure is for passing data between native code which can be strongly 120 * structure is for passing data between native code which can be strongly
140 * typed and the browser (JavaScript) which isn't strongly typed. 121 * typed and the browser (JavaScript) which isn't strongly typed.
141 * 122 *
142 * JavaScript has a "number" type for holding a number, and does not 123 * JavaScript has a "number" type for holding a number, and does not
143 * differentiate between floating point and integer numbers. The 124 * differentiate between floating point and integer numbers. The
144 * JavaScript operations will try to optimize operations by using 125 * JavaScript operations will try to optimize operations by using
145 * integers when possible, but could end up with doubles. Therefore, 126 * integers when possible, but could end up with doubles. Therefore,
146 * you can't assume a numeric <code>PP_Var</code> will be the type you expect. 127 * you can't assume a numeric <code>PP_Var</code> will be the type you expect.
147 * Your code should be capable of handling either int32_t or double for numeric 128 * Your code should be capable of handling either int32_t or double for numeric
148 * PP_Vars sent from JavaScript. 129 * PP_Vars sent from JavaScript.
149 */ 130 */
150 struct PP_Var { 131 struct PP_Var {
151 PP_VarType type; 132 PP_VarType type;
152
153 /** 133 /**
154 * The <code>padding</code> ensures <code>value</code> is aligned on an 134 * The <code>padding</code> ensures <code>value</code> is aligned on an
155 * 8-byte boundary relative to the start of the struct. Some compilers 135 * 8-byte boundary relative to the start of the struct. Some compilers
156 * align doubles on 8-byte boundaries for 32-bit x86, and some align on 136 * align doubles on 8-byte boundaries for 32-bit x86, and some align on
157 * 4-byte boundaries. 137 * 4-byte boundaries.
158 */ 138 */
159 int32_t padding; 139 int32_t padding;
160
161 /** 140 /**
162 * This <code>value</code> represents the contents of the PP_Var. Only one of 141 * This <code>value</code> represents the contents of the PP_Var. Only one of
163 * the fields of <code>value</code> is valid at a time based upon 142 * the fields of <code>value</code> is valid at a time based upon
164 * <code>type</code>. 143 * <code>type</code>.
165 */ 144 */
166 union PP_VarValue value; 145 union PP_VarValue value;
167 }; 146 };
168 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Var, 16); 147 PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Var, 16);
169 /** 148 /**
170 * @} 149 * @}
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 struct PP_Var result = { PP_VARTYPE_DOUBLE, 0, {PP_FALSE} }; 217 struct PP_Var result = { PP_VARTYPE_DOUBLE, 0, {PP_FALSE} };
239 result.value.as_double = value; 218 result.value.as_double = value;
240 return result; 219 return result;
241 } 220 }
242 /** 221 /**
243 * @} 222 * @}
244 */ 223 */
245 224
246 #endif /* PPAPI_C_PP_VAR_H_ */ 225 #endif /* PPAPI_C_PP_VAR_H_ */
247 226
OLDNEW
« no previous file with comments | « ppapi/c/pp_time.h ('k') | ppapi/c/ppb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698