1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/* Copyright (c) 2011 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/* This file defines the PPB_Var API. */
/* Defines the PPB_Var struct. */
interface PPB_Var_0_5 {
/* Adds a reference to the given var. If this is not a refcounted object,
* this function will do nothing so you can always call it no matter what the
* type.
*/
void AddRef(
[in] PP_Var var);
/* Removes a reference to given var, deleting it if the internal refcount
* becomes 0. If the given var is not a refcounted object, this function will
* do nothing so you can always call it no matter what the type.
*/
void Release(
[in] PP_Var var);
/* Creates a string var from a string. The string must be encoded in valid
* UTF-8 and is NOT NULL-terminated, the length must be specified in |len|.
* It is an error if the string is not valid UTF-8.
*
* If the length is 0, the |data| pointer will not be dereferenced and may
* be NULL. Note, however, that if you do this, the "NULL-ness" will not be
* preserved, as VarToUtf8 will never return NULL on success, even for empty
* strings.
*
* The resulting object will be a refcounted string object. It will be
* AddRef()ed for the caller. When the caller is done with it, it should be
* Release()d.
*
* On error (basically out of memory to allocate the string, or input that
* is not valid UTF-8), this function will return a Null var.
*/
PP_Var VarFromUtf8(
[in] PP_Module module,
[in] str_t data,
[in] uint32_t len);
/* Converts a string-type var to a char* encoded in UTF-8. This string is NOT
* NULL-terminated. The length will be placed in |*len|. If the string is
* valid but empty the return value will be non-NULL, but |*len| will still
* be 0.
*
* If the var is not a string, this function will return NULL and |*len| will
* be 0.
*
* The returned buffer will be valid as long as the underlying var is alive.
* If the plugin frees its reference, the string will be freed and the pointer
* will be to random memory.
*/
str_t VarToUtf8(
[in] PP_Var var,
[out] uint32_t len);
};
|