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

Unified Diff: ppapi/c/pp_var.h

Issue 6286018: Updated descriptions to several functions, structs, enums (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ppapi/c/ppp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/c/pp_var.h
===================================================================
--- ppapi/c/pp_var.h (revision 73298)
+++ ppapi/c/pp_var.h (working copy)
@@ -11,7 +11,8 @@
/**
* @file
- * Defines the API ...
+ * This file defines the API for handling the passing of data types between
+ * your module and the page.
*/
/**
@@ -19,6 +20,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 +45,18 @@
*/
/**
- * 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.
+ * The PP_VAR struct is a variant data type and can contain any
+ * value of one of the types named in the PP_VarType enum. This structure is
+ * for 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.
- *
+ * JavaScript has a "number" type for holding a number, and does not
+ * differentiate between floating point and integer numbers. The
+ * JavaScript operations will try to optimize operations by using
+ * integers when possible, but could end up with doubles. Therefore,
+ * you can't assume a numeric PP_Var will be the type you expect.
+ * Your code should be capable of handling either int32_t or double for numeric
+ * PP_Vars sent from JavaScript.
*/
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;
« no previous file with comments | « no previous file | ppapi/c/ppp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698