| OLD | NEW |
| 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 | 5 |
| 6 /* From ppb_var.idl modified Wed Aug 24 20:49:04 2011. */ | 6 /* From ppb_var.idl modified Tue Dec 6 11:26:58 2011. */ |
| 7 | 7 |
| 8 #ifndef PPAPI_C_PPB_VAR_H_ | 8 #ifndef PPAPI_C_PPB_VAR_H_ |
| 9 #define PPAPI_C_PPB_VAR_H_ | 9 #define PPAPI_C_PPB_VAR_H_ |
| 10 | 10 |
| 11 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
| 12 #include "ppapi/c/pp_macros.h" | 12 #include "ppapi/c/pp_macros.h" |
| 13 #include "ppapi/c/pp_module.h" | 13 #include "ppapi/c/pp_module.h" |
| 14 #include "ppapi/c/pp_stdint.h" | 14 #include "ppapi/c/pp_stdint.h" |
| 15 #include "ppapi/c/pp_var.h" | 15 #include "ppapi/c/pp_var.h" |
| 16 | 16 |
| 17 #define PPB_VAR_INTERFACE_1_0 "PPB_Var;1.0" | 17 #define PPB_VAR_INTERFACE_1_0 "PPB_Var;1.0" |
| 18 #define PPB_VAR_INTERFACE PPB_VAR_INTERFACE_1_0 | 18 #define PPB_VAR_INTERFACE_1_1 "PPB_Var;1.1" |
| 19 #define PPB_VAR_INTERFACE PPB_VAR_INTERFACE_1_1 |
| 19 | 20 |
| 20 /** | 21 /** |
| 21 * @file | 22 * @file |
| 22 * This file defines the <code>PPB_Var</code> struct. | 23 * This file defines the <code>PPB_Var</code> struct. |
| 23 */ | 24 */ |
| 24 | 25 |
| 25 | 26 |
| 26 /** | 27 /** |
| 27 * @addtogroup Interfaces | 28 * @addtogroup Interfaces |
| 28 * @{ | 29 * @{ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 59 * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never | 60 * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never |
| 60 * return <code>NULL</code> on success, even for empty strings. | 61 * return <code>NULL</code> on success, even for empty strings. |
| 61 * | 62 * |
| 62 * The resulting object will be a refcounted string object. It will be | 63 * The resulting object will be a refcounted string object. It will be |
| 63 * AddRef'ed for the caller. When the caller is done with it, it should be | 64 * AddRef'ed for the caller. When the caller is done with it, it should be |
| 64 * Released. | 65 * Released. |
| 65 * | 66 * |
| 66 * On error (basically out of memory to allocate the string, or input that | 67 * On error (basically out of memory to allocate the string, or input that |
| 67 * is not valid UTF-8), this function will return a Null var. | 68 * is not valid UTF-8), this function will return a Null var. |
| 68 * | 69 * |
| 69 * @param[in] module A PP_Module uniquely identifying the module or .nexe. | |
| 70 * @param[in] data A string | 70 * @param[in] data A string |
| 71 * @param[in] len The length of the string. | 71 * @param[in] len The length of the string. |
| 72 * | 72 * |
| 73 * @return A <code>PP_Var</code> structure containing a reference counted | 73 * @return A <code>PP_Var</code> structure containing a reference counted |
| 74 * string object. | 74 * string object. |
| 75 */ | 75 */ |
| 76 struct PP_Var (*VarFromUtf8)(PP_Module module, | 76 struct PP_Var (*VarFromUtf8)(const char* data, uint32_t len); |
| 77 const char* data, | |
| 78 uint32_t len); | |
| 79 /** | 77 /** |
| 80 * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This | 78 * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This |
| 81 * string is NOT NULL-terminated. The length will be placed in | 79 * string is NOT NULL-terminated. The length will be placed in |
| 82 * <code>*len</code>. If the string is valid but empty the return value will | 80 * <code>*len</code>. If the string is valid but empty the return value will |
| 83 * be non-NULL, but <code>*len</code> will still be 0. | 81 * be non-NULL, but <code>*len</code> will still be 0. |
| 84 * | 82 * |
| 85 * If the var is not a string, this function will return NULL and | 83 * If the var is not a string, this function will return NULL and |
| 86 * <code>*len</code> will be 0. | 84 * <code>*len</code> will be 0. |
| 87 * | 85 * |
| 88 * The returned buffer will be valid as long as the underlying var is alive. | 86 * The returned buffer will be valid as long as the underlying var is alive. |
| 89 * If the instance frees its reference, the string will be freed and the | 87 * If the instance frees its reference, the string will be freed and the |
| 90 * pointer will be to arbitrary memory. | 88 * pointer will be to arbitrary memory. |
| 91 * | 89 * |
| 92 * @param[in] var A PP_Var struct containing a string-type var. | 90 * @param[in] var A PP_Var struct containing a string-type var. |
| 93 * @param[in,out] len A pointer to the length of the string-type var. | 91 * @param[in,out] len A pointer to the length of the string-type var. |
| 94 * | 92 * |
| 95 * @return A char* encoded in UTF-8. | 93 * @return A char* encoded in UTF-8. |
| 96 */ | 94 */ |
| 97 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); | 95 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); |
| 98 }; | 96 }; |
| 97 |
| 98 struct PPB_Var_1_0 { |
| 99 void (*AddRef)(struct PP_Var var); |
| 100 void (*Release)(struct PP_Var var); |
| 101 struct PP_Var (*VarFromUtf8)(PP_Module module, |
| 102 const char* data, |
| 103 uint32_t len); |
| 104 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); |
| 105 }; |
| 99 /** | 106 /** |
| 100 * @} | 107 * @} |
| 101 */ | 108 */ |
| 102 | 109 |
| 103 #endif /* PPAPI_C_PPB_VAR_H_ */ | 110 #endif /* PPAPI_C_PPB_VAR_H_ */ |
| 104 | 111 |
| OLD | NEW |