1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
7 * This file defines the <code>PPB_Var</code> struct.
20 * AddRef() adds a reference to the given var. If this is not a refcounted
21 * object, this function will do nothing so you can always call it no matter
24 * @param[in] var A <code>PP_Var</code> that will have a reference added.
27 void AddRef
([in] PP_Var var
);
30 * Release() removes a reference to given var, deleting it if the internal
31 * reference count becomes 0. If the given var is not a refcounted object,
32 * this function will do nothing so you can always call it no matter what
35 * @param[in] var A <code>PP_Var</code> that will have a reference removed.
38 void Release
([in] PP_Var var
);
41 * VarFromUtf8() creates a string var from a string. The string must be
42 * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be
43 * specified in <code>len</code>. It is an error if the string is not
46 * If the length is 0, the <code>*data</code> pointer will not be dereferenced
47 * and may be <code>NULL</code>. Note, however if length is 0, the
48 * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never
49 * return <code>NULL</code> on success, even for empty strings.
51 * The resulting object will be a refcounted string object. It will be
52 * AddRef'ed for the caller. When the caller is done with it, it should be
55 * On error (basically out of memory to allocate the string, or input that
56 * is not valid UTF-8), this function will return a Null var.
58 * @param[in] module A PP_Module uniquely identifying the module or .nexe.
59 * @param[in] data A string
60 * @param[in] len The length of the string.
62 * @return A <code>PP_Var</code> structure containing a reference counted
66 PP_Var VarFromUtf8
([in] PP_Module
module, [in] str_t data
, [in] uint32_t len
);
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
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.
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
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.
86 * @param[in] data A string
87 * @param[in] len The length of the string.
89 * @return A <code>PP_Var</code> structure containing a reference counted
93 PP_Var VarFromUtf8
([in] str_t data
, [in] uint32_t len
);
96 * VarToUtf8() converts a string-type var to a char* encoded in UTF-8. This
97 * string is NOT NULL-terminated. The length will be placed in
98 * <code>*len</code>. If the string is valid but empty the return value will
99 * be non-NULL, but <code>*len</code> will still be 0.
101 * If the var is not a string, this function will return NULL and
102 * <code>*len</code> will be 0.
104 * The returned buffer will be valid as long as the underlying var is alive.
105 * If the instance frees its reference, the string will be freed and the
106 * pointer will be to arbitrary memory.
108 * @param[in] var A PP_Var struct containing a string-type var.
109 * @param[in,out] len A pointer to the length of the string-type var.
111 * @return A char* encoded in UTF-8.
114 str_t VarToUtf8
([in] PP_Var var
, [out] uint32_t len
);