1eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch/* Copyright 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/**
7eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch * This file defines the <code>PPB_VarArray</code> struct providing
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * a way to interact with array vars.
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)label Chrome {
12eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  M29 = 1.0
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
15eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch[macro="PPB_VAR_ARRAY_INTERFACE"]
16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdochinterface PPB_VarArray {
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Creates an array var, i.e., a <code>PP_Var</code> with type set to
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * <code>PP_VARTYPE_ARRAY</code>. The array length is set to 0.
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @return An empty array var, whose reference count is set to 1 on behalf of
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * the caller.
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  PP_Var Create();
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Gets an element from the array.
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] array An array var.
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] index An index indicating which element to return.
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
32eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * @return The element at the specified position. The reference count of the
33eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * element returned is incremented on behalf of the caller. If
34eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * <code>index</code> is larger than or equal to the array length, an
35eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * undefined var is returned.
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  PP_Var Get([in] PP_Var array, [in] uint32_t index);
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Sets the value of an element in the array.
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] array An array var.
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] index An index indicating which element to modify. If
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * <code>index</code> is larger than or equal to the array length, the length
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * is updated to be <code>index</code> + 1. Any position in the array that
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * hasn't been set before is set to undefined, i.e., <code>PP_Var</code> of
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * type <code>PP_VARTYPE_UNDEFINED</code>.
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] value The value to set. The array holds a reference to it on
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * success.
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @return A <code>PP_Bool</code> indicating whether the operation succeeds.
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  PP_Bool Set([in] PP_Var array, [in] uint32_t index, [in] PP_Var value);
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Gets the array length.
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] array An array var.
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @return The array length.
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  uint32_t GetLength([in] PP_Var array);
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Sets the array length.
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] array An array var.
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @param[in] length The new array length. If <code>length</code> is smaller
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * than its current value, the array is truncated to the new length; any
70eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * elements that no longer fit are removed and the references to them will be
71eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * released. If <code>length</code> is larger than its current value,
72eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch   * undefined vars are appended to increase the array to the specified length.
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   *
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * @return A <code>PP_Bool</code> indicating whether the operation succeeds.
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  PP_Bool SetLength([in] PP_Var array, [in] uint32_t length);
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
78