/* Copyright 2012 The Chromium Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* From pp_var.idl modified Thu Apr 10 14:52:30 2014. */ #ifndef PPAPI_C_PP_VAR_H_ #define PPAPI_C_PP_VAR_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" /** * @file * This file defines the API for handling the passing of data types between * your module and the page. */ /** * @addtogroup Enums * @{ */ /** * The <code>PP_VarType</code> is an enumeration of the different types that * can be contained within a <code>PP_Var</code> structure. */ PP_VarType; PP_COMPILE_ASSERT_SIZE_IN_BYTES(…); /** * @} */ /** * @addtogroup Structs * @{ */ /** * The PP_VarValue union stores the data for any one of the types listed * in the PP_VarType enum. */ PP_VarValue; /** * The <code>PP_VAR</code> struct is a variant data type and can contain any * value of one of the types named in the <code>PP_VarType</code> enum. This * structure is for passing data between native code which can be strongly * typed and the browser (JavaScript) which isn't strongly typed. * * 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 <code>PP_Var</code> 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_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(…); /** * @} */ /** * @addtogroup Functions * @{ */ /** * PP_MakeUndefined() is used to wrap an undefined value into a * <code>PP_Var</code> struct for passing to the browser. * * @return A <code>PP_Var</code> structure. */ PP_INLINE struct PP_Var PP_MakeUndefined(void) { … } /** * PP_MakeNull() is used to wrap a null value into a * <code>PP_Var</code> struct for passing to the browser. * * @return A <code>PP_Var</code> structure, */ PP_INLINE struct PP_Var PP_MakeNull(void) { … } /** * PP_MakeBool() is used to wrap a boolean value into a * <code>PP_Var</code> struct for passing to the browser. * * @param[in] value A <code>PP_Bool</code> enumeration to * wrap. * * @return A <code>PP_Var</code> structure. */ PP_INLINE struct PP_Var PP_MakeBool(PP_Bool value) { … } /** * PP_MakeInt32() is used to wrap a 32 bit integer value * into a <code>PP_Var</code> struct for passing to the browser. * * @param[in] value An int32 to wrap. * * @return A <code>PP_Var</code> structure. */ PP_INLINE struct PP_Var PP_MakeInt32(int32_t value) { … } /** * PP_MakeDouble() is used to wrap a double value into a * <code>PP_Var</code> struct for passing to the browser. * * @param[in] value A double to wrap. * * @return A <code>PP_Var</code> structure. */ PP_INLINE struct PP_Var PP_MakeDouble(double value) { … } /** * @} */ #endif /* PPAPI_C_PP_VAR_H_ */