1/* Copyright 2013 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/* From ppb_var_array.idl modified Sun Jun 16 15:37:27 2013. */
7
8#ifndef PPAPI_C_PPB_VAR_ARRAY_H_
9#define PPAPI_C_PPB_VAR_ARRAY_H_
10
11#include "ppapi/c/pp_bool.h"
12#include "ppapi/c/pp_macros.h"
13#include "ppapi/c/pp_stdint.h"
14#include "ppapi/c/pp_var.h"
15
16#define PPB_VAR_ARRAY_INTERFACE_1_0 "PPB_VarArray;1.0"
17#define PPB_VAR_ARRAY_INTERFACE PPB_VAR_ARRAY_INTERFACE_1_0
18
19/**
20 * @file
21 * This file defines the <code>PPB_VarArray</code> struct providing
22 * a way to interact with array vars.
23 */
24
25
26/**
27 * @addtogroup Interfaces
28 * @{
29 */
30struct PPB_VarArray_1_0 {
31  /**
32   * Creates an array var, i.e., a <code>PP_Var</code> with type set to
33   * <code>PP_VARTYPE_ARRAY</code>. The array length is set to 0.
34   *
35   * @return An empty array var, whose reference count is set to 1 on behalf of
36   * the caller.
37   */
38  struct PP_Var (*Create)(void);
39  /**
40   * Gets an element from the array.
41   *
42   * @param[in] array An array var.
43   * @param[in] index An index indicating which element to return.
44   *
45   * @return The element at the specified position. The reference count of the
46   * element returned is incremented on behalf of the caller. If
47   * <code>index</code> is larger than or equal to the array length, an
48   * undefined var is returned.
49   */
50  struct PP_Var (*Get)(struct PP_Var array, uint32_t index);
51  /**
52   * Sets the value of an element in the array.
53   *
54   * @param[in] array An array var.
55   * @param[in] index An index indicating which element to modify. If
56   * <code>index</code> is larger than or equal to the array length, the length
57   * is updated to be <code>index</code> + 1. Any position in the array that
58   * hasn't been set before is set to undefined, i.e., <code>PP_Var</code> of
59   * type <code>PP_VARTYPE_UNDEFINED</code>.
60   * @param[in] value The value to set. The array holds a reference to it on
61   * success.
62   *
63   * @return A <code>PP_Bool</code> indicating whether the operation succeeds.
64   */
65  PP_Bool (*Set)(struct PP_Var array, uint32_t index, struct PP_Var value);
66  /**
67   * Gets the array length.
68   *
69   * @param[in] array An array var.
70   *
71   * @return The array length.
72   */
73  uint32_t (*GetLength)(struct PP_Var array);
74  /**
75   * Sets the array length.
76   *
77   * @param[in] array An array var.
78   * @param[in] length The new array length. If <code>length</code> is smaller
79   * than its current value, the array is truncated to the new length; any
80   * elements that no longer fit are removed and the references to them will be
81   * released. If <code>length</code> is larger than its current value,
82   * undefined vars are appended to increase the array to the specified length.
83   *
84   * @return A <code>PP_Bool</code> indicating whether the operation succeeds.
85   */
86  PP_Bool (*SetLength)(struct PP_Var array, uint32_t length);
87};
88
89typedef struct PPB_VarArray_1_0 PPB_VarArray;
90/**
91 * @}
92 */
93
94#endif  /* PPAPI_C_PPB_VAR_ARRAY_H_ */
95
96