Chromium Code Reviews| Index: ppapi/c/pp_var.h |
| =================================================================== |
| --- ppapi/c/pp_var.h (revision 73298) |
| +++ ppapi/c/pp_var.h (working copy) |
| @@ -19,6 +19,11 @@ |
| * @addtogroup Enums |
| * @{ |
| */ |
| + |
| +/** |
| + * PP_VarType is an enumeration of the different types that can be contained |
| + * within a PP_VAR structure. |
| + */ |
| typedef enum { |
| PP_VARTYPE_UNDEFINED, |
| PP_VARTYPE_NULL, |
| @@ -39,17 +44,19 @@ |
| */ |
| /** |
| - * Do not rely on having a predictable and reproducible |
| - * int/double differentiation. |
| - * JavaScript has a "number" type for holding a number, and |
| - * does not differentiate between floating point and integer numbers. The |
| - * JavaScript library will try to optimize operations by using integers |
| - * when possible, but could end up with doubles depending on how the number |
| - * was arrived at. |
| + * PP_VAR is a struct that represents a variant data type and can contain any |
|
Sang Ahn
2011/02/01 19:19:00
PP_VAR does not represent a variant data type; it
jond
2011/02/02 16:54:51
Fixed.
|
| + * value, such as a bool, int32, double, or string. This structure is for |
|
dmichael(do not use this one)
2011/02/01 22:17:22
'int32' -> int32_t
'or string' -> 'string, or obje
jond
2011/02/02 16:54:51
It says this now:
"The PP_VAR struct is a variant
|
| + * passing data between native code which can be strongly typed and the browser |
| + * (JavaScript) which isn't strongly typed. |
| * |
| - * Your best bet is to have a wrapper for variables |
| - * that always gets out the type you expect, converting as necessary. |
| + * You cannot rely on having a predictable and reproducible int/double |
| + * differentiation in JavaScript. JavaScript has a "number" type for holding |
| + * a number, and does not differentiate between floating point and integer |
| + * numbers. The JavaScript library will try to optimize operations by using |
|
Sang Ahn
2011/02/01 19:19:00
Javascript library -> Javascript operations
ie
"Ja
jond
2011/02/02 16:54:51
Fixed.
On 2011/02/01 19:19:00, Sang Ahn wrote:
|
| + * integers when possible, but could end up with doubles. |
| * |
| + * PP_Var represents the best solution of using a wrapper for variables |
| + * that always returns the type you expect (converting as necessary). |
|
dmichael(do not use this one)
2011/02/01 22:17:22
I don't believe this is true. PPB_Var has a funct
|
| */ |
| struct PP_Var { |
| PP_VarType type; |
| @@ -82,28 +89,57 @@ |
| * @addtogroup Functions |
| * @{ |
| */ |
| + |
| +/** |
| + * PP_MakeUndefined() is a utility function used to wrap an undefined value |
| + * into a PP_VAR struct for passing to the browser. |
| + * @return A PP_Var structure |
| + */ |
| PP_INLINE struct PP_Var PP_MakeUndefined() { |
| struct PP_Var result = { PP_VARTYPE_UNDEFINED, 0, {PP_FALSE} }; |
| return result; |
| } |
| +/** |
| + * PP_MakeNull() is a utility function used to wrap a null value into a |
| + * PP_VAR struct for passing to the browser. |
| + * @return A PP_Var structure |
| + */ |
| PP_INLINE struct PP_Var PP_MakeNull() { |
| struct PP_Var result = { PP_VARTYPE_NULL, 0, {PP_FALSE} }; |
| return result; |
| } |
| +/** |
| + * PP_MakeBool() is a utility function used to wrap a boolean value into a |
| + * PP_VAR struct for passing to the browser. |
| + * @param[in] value A PP_Bool enumeration |
| + * @return A PP_Var structure |
| + */ |
| PP_INLINE struct PP_Var PP_MakeBool(PP_Bool value) { |
| struct PP_Var result = { PP_VARTYPE_BOOL, 0, {PP_FALSE} }; |
| result.value.as_bool = value; |
| return result; |
| } |
| +/** |
| + * PP_MakeInt32() is a utility function used to wrap a 32 bit integer value |
| + * into a PP_VAR struct for passing to the browser. |
| + * @param[in] value An int32 |
| + * @return A PP_Var structure |
| + */ |
| PP_INLINE struct PP_Var PP_MakeInt32(int32_t value) { |
| struct PP_Var result = { PP_VARTYPE_INT32, 0, {PP_FALSE} }; |
| result.value.as_int = value; |
| return result; |
| } |
| +/** |
| + * PP_MakeDouble() is a utility function used to wrap a double value into a |
| + * PP_VAR struct for passing to the browser. |
| + * @param[in] value A double |
| + * @return A PP_Var structure |
| + */ |
| PP_INLINE struct PP_Var PP_MakeDouble(double value) { |
| struct PP_Var result = { PP_VARTYPE_DOUBLE, 0, {PP_FALSE} }; |
| result.value.as_double = value; |