blob: 2351536576b44ecfb564968db07f7a8ecfbc602d [file] [log] [blame]
[email protected]b5746262011-03-23 17:06:311/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]6ea69542010-12-20 18:15:592 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
[email protected]9b37f4802011-07-19 00:09:285
6/* From ppb_var.idl modified Sat Jul 16 16:50:26 2011. */
7
[email protected]1758e882010-11-01 16:16:508#ifndef PPAPI_C_PPB_VAR_H_
9#define PPAPI_C_PPB_VAR_H_
10
[email protected]6f2e3912010-11-05 14:45:4411#include "ppapi/c/pp_bool.h"
[email protected]6f2e3912010-11-05 14:45:4412#include "ppapi/c/pp_macros.h"
[email protected]1758e882010-11-01 16:16:5013#include "ppapi/c/pp_module.h"
[email protected]1758e882010-11-01 16:16:5014#include "ppapi/c/pp_stdint.h"
15#include "ppapi/c/pp_var.h"
16
[email protected]1758e882010-11-01 16:16:5017/**
[email protected]f98c6a12011-01-28 22:28:4318 * @file
[email protected]8dd1f5772011-07-06 15:37:2819 * This file defines the <code>PPB_Var</code> struct.
[email protected]f98c6a12011-01-28 22:28:4320 */
21
[email protected]9b37f4802011-07-19 00:09:2822
[email protected]f98c6a12011-01-28 22:28:4323/**
[email protected]040d5e82011-01-28 15:38:3824 * @addtogroup Interfaces
25 * @{
26 */
[email protected]1758e882010-11-01 16:16:5027/**
28 * PPB_Var API
[email protected]1758e882010-11-01 16:16:5029 */
[email protected]9b37f4802011-07-19 00:09:2830#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
[email protected]1758e882010-11-01 16:16:5034struct PPB_Var {
35 /**
[email protected]8dd1f5772011-07-06 15:37:2836 * AddRef() adds a reference to the given var. If this is not a refcounted
37 * object, this function will do nothing so you can always call it no matter
38 * what the type.
39 *
40 * @param[in] var A <code>PP_Var</code> that will have a reference added.
[email protected]1758e882010-11-01 16:16:5041 */
42 void (*AddRef)(struct PP_Var var);
[email protected]1758e882010-11-01 16:16:5043 /**
[email protected]8dd1f5772011-07-06 15:37:2844 * Release() removes a reference to given var, deleting it if the internal
45 * reference count becomes 0. If the given var is not a refcounted object,
46 * this function will do nothing so you can always call it no matter what
47 * the type.
48 *
49 * @param[in] var A <code>PP_Var</code> that will have a reference removed.
[email protected]1758e882010-11-01 16:16:5050 */
51 void (*Release)(struct PP_Var var);
[email protected]1758e882010-11-01 16:16:5052 /**
[email protected]8dd1f5772011-07-06 15:37:2853 * VarFromUtf8() creates a string var from a string. The string must be
54 * encoded in valid UTF-8 and is NOT NULL-terminated, the length must be
55 * specified in <code>len</code>. It is an error if the string is not
56 * valid UTF-8.
[email protected]1758e882010-11-01 16:16:5057 *
[email protected]8dd1f5772011-07-06 15:37:2858 * If the length is 0, the <code>*data</code> pointer will not be dereferenced
59 * and may be <code>NULL</code>. Note, however if length is 0, the
60 * "NULL-ness" will not be preserved, as <code>VarToUtf8</code> will never
61 * return <code>NULL</code> on success, even for empty strings.
[email protected]1758e882010-11-01 16:16:5062 *
63 * The resulting object will be a refcounted string object. It will be
[email protected]8dd1f5772011-07-06 15:37:2864 * AddRef'ed for the caller. When the caller is done with it, it should be
65 * Released.
[email protected]1758e882010-11-01 16:16:5066 *
67 * On error (basically out of memory to allocate the string, or input that
68 * is not valid UTF-8), this function will return a Null var.
[email protected]8dd1f5772011-07-06 15:37:2869 *
70 * @param[in] module A PP_Module uniquely identifying the module or .nexe.
71 * @param[in] data A string
72 * @param[in] len The length of the string.
73 *
74 * @return A <code>PP_Var</code> structure containing a reference counted
75 * string object.
[email protected]1758e882010-11-01 16:16:5076 */
77 struct PP_Var (*VarFromUtf8)(PP_Module module,
[email protected]b2b420d72011-07-12 00:59:3178 const char* data,
79 uint32_t len);
[email protected]1758e882010-11-01 16:16:5080 /**
[email protected]8dd1f5772011-07-06 15:37:2881 * 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
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.
[email protected]1758e882010-11-01 16:16:5085 *
[email protected]8dd1f5772011-07-06 15:37:2886 * If the var is not a string, this function will return NULL and
87 * <code>*len</code> will be 0.
[email protected]1758e882010-11-01 16:16:5088 *
89 * The returned buffer will be valid as long as the underlying var is alive.
[email protected]8dd1f5772011-07-06 15:37:2890 * If the instance frees its reference, the string will be freed and the
91 * pointer will be to arbitrary memory.
92 *
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.
95 *
96 * @return A char* encoded in UTF-8.
[email protected]1758e882010-11-01 16:16:5097 */
98 const char* (*VarToUtf8)(struct PP_Var var, uint32_t* len);
[email protected]1758e882010-11-01 16:16:5099};
[email protected]040d5e82011-01-28 15:38:38100/**
101 * @}
102 */
[email protected]1758e882010-11-01 16:16:50103
[email protected]6ea69542010-12-20 18:15:59104#endif /* PPAPI_C_PPB_VAR_H_ */
105