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 /** | 6 /** |
7 * This file defines the <code>PPB_Var</code> struct. | 7 * This file defines the <code>PPB_Var</code> struct. |
8 */ | 8 */ |
9 | 9 |
10 label Chrome { | 10 label Chrome { |
11 M14 = 1.0 | 11 M14 = 1.0, |
| 12 M18 = 1.1 |
12 }; | 13 }; |
13 | 14 |
14 /** | 15 /** |
15 * PPB_Var API | 16 * PPB_Var API |
16 */ | 17 */ |
17 interface PPB_Var { | 18 interface PPB_Var { |
18 /** | 19 /** |
19 * AddRef() adds a reference to the given var. If this is not a refcounted | 20 * AddRef() adds a reference to the given var. If this is not a refcounted |
20 * object, this function will do nothing so you can always call it no matter | 21 * object, this function will do nothing so you can always call it no matter |
21 * what the type. | 22 * what the type. |
22 * | 23 * |
23 * @param[in] var A <code>PP_Var</code> that will have a reference added. | 24 * @param[in] var A <code>PP_Var</code> that will have a reference added. |
24 */ | 25 */ |
25 void AddRef( | 26 [version=1.0] |
26 [in] PP_Var var); | 27 void AddRef([in] PP_Var var); |
27 | 28 |
28 /** | 29 /** |
29 * Release() removes a reference to given var, deleting it if the internal | 30 * Release() removes a reference to given var, deleting it if the internal |
30 * reference count becomes 0. If the given var is not a refcounted object, | 31 * reference count becomes 0. If the given var is not a refcounted object, |
31 * this function will do nothing so you can always call it no matter what | 32 * this function will do nothing so you can always call it no matter what |
32 * the type. | 33 * the type. |
33 * | 34 * |
34 * @param[in] var A <code>PP_Var</code> that will have a reference removed. | 35 * @param[in] var A <code>PP_Var</code> that will have a reference removed. |
35 */ | 36 */ |
36 void Release( | 37 [version=1.0] |
37 [in] PP_Var var); | 38 void Release([in] PP_Var var); |
38 | 39 |
39 /** | 40 /** |
40 * VarFromUtf8() creates a string var from a string. The string must be | 41 * VarFromUtf8() creates a string var from a string. The string must be |
41 * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be | 42 * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be |
42 * specified in <code>len</code>. It is an error if the string is not | 43 * specified in <code>len</code>. It is an error if the string is not |
43 * valid UTF-8. | 44 * valid UTF-8. |
44 * | 45 * |
45 * If the length is 0, the <code>*data</code> pointer will not be dereferenced | 46 * If the length is 0, the <code>*data</code> pointer will not be dereferenced |
46 * and may be <code>NULL</code>. Note, however if length is 0, the | 47 * and may be <code>NULL</code>. Note, however if length is 0, the |
47 * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never | 48 * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never |
48 * return <code>NULL</code> on success, even for empty strings. | 49 * return <code>NULL</code> on success, even for empty strings. |
49 * | 50 * |
50 * The resulting object will be a refcounted string object. It will be | 51 * The resulting object will be a refcounted string object. It will be |
51 * AddRef'ed for the caller. When the caller is done with it, it should be | 52 * AddRef'ed for the caller. When the caller is done with it, it should be |
52 * Released. | 53 * Released. |
53 * | 54 * |
54 * On error (basically out of memory to allocate the string, or input that | 55 * On error (basically out of memory to allocate the string, or input that |
55 * is not valid UTF-8), this function will return a Null var. | 56 * is not valid UTF-8), this function will return a Null var. |
56 * | 57 * |
57 * @param[in] module A PP_Module uniquely identifying the module or .nexe. | 58 * @param[in] module A PP_Module uniquely identifying the module or .nexe. |
58 * @param[in] data A string | 59 * @param[in] data A string |
59 * @param[in] len The length of the string. | 60 * @param[in] len The length of the string. |
60 * | 61 * |
61 * @return A <code>PP_Var</code> structure containing a reference counted | 62 * @return A <code>PP_Var</code> structure containing a reference counted |
62 * string object. | 63 * string object. |
63 */ | 64 */ |
64 PP_Var VarFromUtf8( | 65 [version=1.0] |
65 [in] PP_Module module, | 66 PP_Var VarFromUtf8([in] PP_Module module, [in] str_t data, [in] uint32_t len); |
66 [in] str_t data, | 67 |
67 [in] uint32_t len); | 68 /** |
| 69 * VarFromUtf8() creates a string var from a string. The string must be |
| 70 * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be |
| 71 * specified in <code>len</code>. It is an error if the string is not |
| 72 * valid UTF-8. |
| 73 * |
| 74 * If the length is 0, the <code>*data</code> pointer will not be dereferenced |
| 75 * and may be <code>NULL</code>. Note, however if length is 0, the |
| 76 * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never |
| 77 * return <code>NULL</code> on success, even for empty strings. |
| 78 * |
| 79 * The resulting object will be a refcounted string object. It will be |
| 80 * AddRef'ed for the caller. When the caller is done with it, it should be |
| 81 * Released. |
| 82 * |
| 83 * On error (basically out of memory to allocate the string, or input that |
| 84 * is not valid UTF-8), this function will return a Null var. |
| 85 * |
| 86 * @param[in] data A string |
| 87 * @param[in] len The length of the string. |
| 88 * |
| 89 * @return A <code>PP_Var</code> structure containing a reference counted |
| 90 * string object. |
| 91 */ |
| 92 [version=1.1] |
| 93 PP_Var VarFromUtf8([in] str_t data, [in] uint32_t len); |
68 | 94 |
69 /** | 95 /** |
70 * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This | 96 * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This |
71 * string is NOT NULL-terminated. The length will be placed in | 97 * string is NOT NULL-terminated. The length will be placed in |
72 * <code>*len</code>. If the string is valid but empty the return value will | 98 * <code>*len</code>. If the string is valid but empty the return value will |
73 * be non-NULL, but <code>*len</code> will still be 0. | 99 * be non-NULL, but <code>*len</code> will still be 0. |
74 * | 100 * |
75 * If the var is not a string, this function will return NULL and | 101 * If the var is not a string, this function will return NULL and |
76 * <code>*len</code> will be 0. | 102 * <code>*len</code> will be 0. |
77 * | 103 * |
78 * The returned buffer will be valid as long as the underlying var is alive. | 104 * The returned buffer will be valid as long as the underlying var is alive. |
79 * If the instance frees its reference, the string will be freed and the | 105 * If the instance frees its reference, the string will be freed and the |
80 * pointer will be to arbitrary memory. | 106 * pointer will be to arbitrary memory. |
81 * | 107 * |
82 * @param[in] var A PP_Var struct containing a string-type var. | 108 * @param[in] var A PP_Var struct containing a string-type var. |
83 * @param[in,out] len A pointer to the length of the string-type var. | 109 * @param[in,out] len A pointer to the length of the string-type var. |
84 * | 110 * |
85 * @return A char* encoded in UTF-8. | 111 * @return A char* encoded in UTF-8. |
86 */ | 112 */ |
87 str_t VarToUtf8( | 113 [version=1.0] |
88 [in] PP_Var var, | 114 str_t VarToUtf8([in] PP_Var var, [out] uint32_t len); |
89 [out] uint32_t len); | |
90 }; | 115 }; |
91 | 116 |
OLD | NEW |