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_PP_VAR_H_ | 5 #ifndef PPAPI_C_PP_VAR_H_ |
6 #define PPAPI_C_PP_VAR_H_ | 6 #define PPAPI_C_PP_VAR_H_ |
7 | 7 |
8 /** | 8 /** |
9 * @file | 9 * @file |
10 * Defines the API ... | 10 * Defines the API ... |
11 * | 11 * |
12 * @addtogroup PP | 12 * @addtogroup PP |
13 * @{ | 13 * @{ |
14 */ | 14 */ |
15 | 15 |
16 #include "ppapi/c/pp_bool.h" | 16 #include "ppapi/c/pp_bool.h" |
17 #include "ppapi/c/pp_macros.h" | 17 #include "ppapi/c/pp_macros.h" |
18 #include "ppapi/c/pp_stdint.h" | 18 #include "ppapi/c/pp_stdint.h" |
19 | 19 |
20 typedef enum { | 20 typedef enum { |
21 PP_VARTYPE_UNDEFINED, | 21 PP_VARTYPE_UNDEFINED, |
22 PP_VARTYPE_NULL, | 22 PP_VARTYPE_NULL, |
23 PP_VARTYPE_BOOL, | 23 PP_VARTYPE_BOOL, |
24 PP_VARTYPE_INT32, | 24 PP_VARTYPE_INT32, |
25 PP_VARTYPE_DOUBLE, | 25 PP_VARTYPE_DOUBLE, |
26 PP_VARTYPE_STRING, | 26 PP_VARTYPE_STRING, |
27 PP_VARTYPE_OBJECT | 27 PP_VARTYPE_OBJECT |
28 } PP_VarType; | 28 } PP_VarType; |
29 | 29 |
30 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_VarType, 4); | |
31 | |
32 /** | 30 /** |
33 * Do not rely on having a predictable and reproducible | 31 * Do not rely on having a predictable and reproducible |
34 * int/double differentiation. | 32 * int/double differentiation. |
35 * JavaScript has a "number" type for holding a number, and | 33 * JavaScript has a "number" type for holding a number, and |
36 * does not differentiate between floating point and integer numbers. The | 34 * does not differentiate between floating point and integer numbers. The |
37 * JavaScript library will try to optimize operations by using integers | 35 * JavaScript library will try to optimize operations by using integers |
38 * when possible, but could end up with doubles depending on how the number | 36 * when possible, but could end up with doubles depending on how the number |
39 * was arrived at. | 37 * was arrived at. |
40 * | 38 * |
41 * Your best bet is to have a wrapper for variables | 39 * Your best bet is to have a wrapper for variables |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 struct PP_Var result = { PP_VARTYPE_DOUBLE, {PP_FALSE} }; | 81 struct PP_Var result = { PP_VARTYPE_DOUBLE, {PP_FALSE} }; |
84 result.value.as_double = value; | 82 result.value.as_double = value; |
85 return result; | 83 return result; |
86 } | 84 } |
87 | 85 |
88 /** | 86 /** |
89 * @} | 87 * @} |
90 * End addtogroup PP | 88 * End addtogroup PP |
91 */ | 89 */ |
92 #endif // PPAPI_C_PP_VAR_H_ | 90 #endif // PPAPI_C_PP_VAR_H_ |
OLD | NEW |