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