| 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 |
| 6 /* From ppb_var.idl modified Sat Jul 16 16:50:26 2011. */ |
| 7 |
| 5 #ifndef PPAPI_C_PPB_VAR_H_ | 8 #ifndef PPAPI_C_PPB_VAR_H_ |
| 6 #define PPAPI_C_PPB_VAR_H_ | 9 #define PPAPI_C_PPB_VAR_H_ |
| 7 | 10 |
| 8 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_macros.h" | 12 #include "ppapi/c/pp_macros.h" |
| 10 #include "ppapi/c/pp_module.h" | 13 #include "ppapi/c/pp_module.h" |
| 11 #include "ppapi/c/pp_stdint.h" | 14 #include "ppapi/c/pp_stdint.h" |
| 12 #include "ppapi/c/pp_var.h" | 15 #include "ppapi/c/pp_var.h" |
| 13 | 16 |
| 14 #define PPB_VAR_INTERFACE_0_5 "PPB_Var;0.5" | |
| 15 #define PPB_VAR_INTERFACE_1_0 "PPB_Var;1.0" | |
| 16 #define PPB_VAR_INTERFACE PPB_VAR_INTERFACE_1_0 | |
| 17 | |
| 18 /** | 17 /** |
| 19 * @file | 18 * @file |
| 20 * This file defines the <code>PPB_Var</code> struct. | 19 * This file defines the <code>PPB_Var</code> struct. |
| 21 */ | 20 */ |
| 22 | 21 |
| 22 |
| 23 /** | 23 /** |
| 24 * @addtogroup Interfaces | 24 * @addtogroup Interfaces |
| 25 * @{ | 25 * @{ |
| 26 */ | 26 */ |
| 27 | |
| 28 /** | 27 /** |
| 29 * PPB_Var API | 28 * PPB_Var API |
| 30 */ | 29 */ |
| 30 #define PPB_VAR_INTERFACE_0_5 "PPB_Var;0.5" |
| 31 #define PPB_VAR_INTERFACE_1_0 "PPB_Var;1.0" |
| 32 #define PPB_VAR_INTERFACE PPB_VAR_INTERFACE_1_0 |
| 33 |
| 31 struct PPB_Var { | 34 struct PPB_Var { |
| 32 /** | 35 /** |
| 33 * AddRef() adds a reference to the given var. If this is not a refcounted | 36 * AddRef() adds a reference to the given var. If this is not a refcounted |
| 34 * object, this function will do nothing so you can always call it no matter | 37 * object, this function will do nothing so you can always call it no matter |
| 35 * what the type. | 38 * what the type. |
| 36 * | 39 * |
| 37 * @param[in] var A <code>PP_Var</code> that will have a reference added. | 40 * @param[in] var A <code>PP_Var</code> that will have a reference added. |
| 38 */ | 41 */ |
| 39 void (*AddRef)(struct PP_Var var); | 42 void (*AddRef)(struct PP_Var var); |
| 40 | |
| 41 /** | 43 /** |
| 42 * Release() removes a reference to given var, deleting it if the internal | 44 * Release() removes a reference to given var, deleting it if the internal |
| 43 * reference count becomes 0. If the given var is not a refcounted object, | 45 * reference count becomes 0. If the given var is not a refcounted object, |
| 44 * this function will do nothing so you can always call it no matter what | 46 * this function will do nothing so you can always call it no matter what |
| 45 * the type. | 47 * the type. |
| 46 * | 48 * |
| 47 * @param[in] var A <code>PP_Var</code> that will have a reference removed. | 49 * @param[in] var A <code>PP_Var</code> that will have a reference removed. |
| 48 */ | 50 */ |
| 49 void (*Release)(struct PP_Var var); | 51 void (*Release)(struct PP_Var var); |
| 50 | |
| 51 /** | 52 /** |
| 52 * VarFromUtf8() creates a string var from a string. The string must be | 53 * VarFromUtf8() creates a string var from a string. The string must be |
| 53 * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be | 54 * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be |
| 54 * specified in <code>len</code>. It is an error if the string is not | 55 * specified in <code>len</code>. It is an error if the string is not |
| 55 * valid UTF-8. | 56 * valid UTF-8. |
| 56 * | 57 * |
| 57 * If the length is 0, the <code>*data</code> pointer will not be dereferenced | 58 * If the length is 0, the <code>*data</code> pointer will not be dereferenced |
| 58 * and may be <code>NULL</code>. Note, however if length is 0, the | 59 * and may be <code>NULL</code>. Note, however if length is 0, the |
| 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] module A PP_Module uniquely identifying the module or .nexe. |
| 70 * @param[in] data A string | 71 * @param[in] data A string |
| 71 * @param[in] len The length of the string. | 72 * @param[in] len The length of the string. |
| 72 * | 73 * |
| 73 * @return A <code>PP_Var</code> structure containing a reference counted | 74 * @return A <code>PP_Var</code> structure containing a reference counted |
| 74 * string object. | 75 * string object. |
| 75 */ | 76 */ |
| 76 struct PP_Var (*VarFromUtf8)(PP_Module module, | 77 struct PP_Var (*VarFromUtf8)(PP_Module module, |
| 77 const char* data, | 78 const char* data, |
| 78 uint32_t len); | 79 uint32_t len); |
| 79 | |
| 80 /** | 80 /** |
| 81 * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This | 81 * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This |
| 82 * string is NOT NULL-terminated. The length will be placed in | 82 * string is NOT NULL-terminated. The length will be placed in |
| 83 * <code>*len</code>. If the string is valid but empty the return value will | 83 * <code>*len</code>. If the string is valid but empty the return value will |
| 84 * be non-NULL, but <code>*len</code> will still be 0. | 84 * be non-NULL, but <code>*len</code> will still be 0. |
| 85 * | 85 * |
| 86 * If the var is not a string, this function will return NULL and | 86 * If the var is not a string, this function will return NULL and |
| 87 * <code>*len</code> will be 0. | 87 * <code>*len</code> will be 0. |
| 88 * | 88 * |
| 89 * The returned buffer will be valid as long as the underlying var is alive. | 89 * The returned buffer will be valid as long as the underlying var is alive. |
| 90 * If the instance frees its reference, the string will be freed and the | 90 * If the instance frees its reference, the string will be freed and the |
| 91 * pointer will be to arbitrary memory. | 91 * pointer will be to arbitrary memory. |
| 92 * | 92 * |
| 93 * @param[in] var A PP_Var struct containing a string-type var. | 93 * @param[in] var A PP_Var struct containing a string-type var. |
| 94 * @param[in,out] len A pointer to the length of the string-type var. | 94 * @param[in,out] len A pointer to the length of the string-type var. |
| 95 * | 95 * |
| 96 * @return A char* encoded in UTF-8. | 96 * @return A char* encoded in UTF-8. |
| 97 */ | 97 */ |
| 98 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); | 98 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len); |
| 99 }; | 99 }; |
| 100 /** | 100 /** |
| 101 * @} | 101 * @} |
| 102 */ | 102 */ |
| 103 | 103 |
| 104 #endif /* PPAPI_C_PPB_VAR_H_ */ | 104 #endif /* PPAPI_C_PPB_VAR_H_ */ |
| 105 | 105 |
| OLD | NEW |