Skip to content

Commit

Permalink
PPAPI: make generator output a pointer to an array correctly.
Browse files Browse the repository at this point in the history
Originally an IDL argument like "[out] int[] foo" will generate
int* foo[]. It means an array of pointers to integers and what we
want is a pointer to an array of integers. Change the output to
int** foo to be not confusing.

BUG=387547
TEST=Run generator and build chrome.

Review URL: https://codereview.chromium.org/490433002

Cr-Commit-Position: refs/heads/master@{#291349}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291349 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
wuchengli@chromium.org committed Aug 22, 2014
1 parent 6690931 commit ab8bcef
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 31 deletions.
20 changes: 10 additions & 10 deletions ppapi/api/private/ppb_camera_capabilities_private.idl
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ interface PPB_CameraCapabilities_Private {
* @param[in] capabilities A <code>PP_Resource</code> corresponding to an
* image capture capabilities resource.
* @param[out] array_size The size of preview size array.
* @param[out] An array of <code>PP_Size</code> corresponding to the
* supported preview sizes in pixels. The ownership of the array belongs to
* <code>PPB_CameraCapabilities_Private</code> and the caller should not
* free it. When a PPB_CameraCapabilities_Private is deleted, the array
* returning from this is no longer valid.
* @param[out] preview_sizes An array of <code>PP_Size</code> corresponding
* to the supported preview sizes in pixels. The ownership of the array
* belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* should not free it. When a PPB_CameraCapabilities_Private is deleted,
* the array returning from this is no longer valid.
*/
void GetSupportedPreviewSizes(
[in] PP_Resource capabilities,
Expand All @@ -72,11 +72,11 @@ interface PPB_CameraCapabilities_Private {
* image capture capabilities resource.
* @param[out] array_size The size of JPEG size array. If the output of this
* is 0, the camera has no support for generating JPEG images.
* @param[out] An array of <code>PP_Size</code> corresponding to the
* supported JPEG image sizes in pixels. The ownership of the array belongs
* to <code>PPB_CameraCapabilities_Private</code> and the caller should not
* free it. When a PPB_CameraCapabilities_Private is deleted, the array
* returning from this is no longer valid.
* @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to
* the supported JPEG image sizes in pixels. The ownership of the array
* belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* should not free it. When a PPB_CameraCapabilities_Private is deleted, the
* array returning from this is no longer valid.
*/
void GetSupportedJpegSizes(
[in] PP_Resource capabilities,
Expand Down
2 changes: 1 addition & 1 deletion ppapi/api/private/ppp_flash_browser_operations.idl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
/* Copyright 2012 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.
*/
Expand Down
26 changes: 13 additions & 13 deletions ppapi/c/private/ppb_camera_capabilities_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/* From private/ppb_camera_capabilities_private.idl,
* modified Thu Aug 14 11:40:27 2014.
* modified Fri Aug 22 11:08:14 2014.
*/

#ifndef PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_
Expand Down Expand Up @@ -68,15 +68,15 @@ struct PPB_CameraCapabilities_Private_0_1 {
* @param[in] capabilities A <code>PP_Resource</code> corresponding to an
* image capture capabilities resource.
* @param[out] array_size The size of preview size array.
* @param[out] An array of <code>PP_Size</code> corresponding to the
* supported preview sizes in pixels. The ownership of the array belongs to
* <code>PPB_CameraCapabilities_Private</code> and the caller should not
* free it. When a PPB_CameraCapabilities_Private is deleted, the array
* returning from this is no longer valid.
* @param[out] preview_sizes An array of <code>PP_Size</code> corresponding
* to the supported preview sizes in pixels. The ownership of the array
* belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* should not free it. When a PPB_CameraCapabilities_Private is deleted,
* the array returning from this is no longer valid.
*/
void (*GetSupportedPreviewSizes)(PP_Resource capabilities,
int32_t* array_size,
struct PP_Size* preview_sizes[]);
struct PP_Size** preview_sizes);
/**
* GetSupportedJpegSize() returns the supported JPEG sizes for the given
* <code>PPB_CameraCapabilities_Private</code>.
Expand All @@ -85,15 +85,15 @@ struct PPB_CameraCapabilities_Private_0_1 {
* image capture capabilities resource.
* @param[out] array_size The size of JPEG size array. If the output of this
* is 0, the camera has no support for generating JPEG images.
* @param[out] An array of <code>PP_Size</code> corresponding to the
* supported JPEG image sizes in pixels. The ownership of the array belongs
* to <code>PPB_CameraCapabilities_Private</code> and the caller should not
* free it. When a PPB_CameraCapabilities_Private is deleted, the array
* returning from this is no longer valid.
* @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to
* the supported JPEG image sizes in pixels. The ownership of the array
* belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* should not free it. When a PPB_CameraCapabilities_Private is deleted, the
* array returning from this is no longer valid.
*/
void (*GetSupportedJpegSizes)(PP_Resource capabilities,
int32_t* array_size,
struct PP_Size* jpeg_sizes[]);
struct PP_Size** jpeg_sizes);
};

typedef struct PPB_CameraCapabilities_Private_0_1
Expand Down
6 changes: 3 additions & 3 deletions ppapi/c/private/ppp_flash_browser_operations.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
/* Copyright 2012 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.
*/

/* From private/ppp_flash_browser_operations.idl,
* modified Thu Mar 28 10:23:11 2013.
* modified Fri Aug 22 11:10:06 2014.
*/

#ifndef PPAPI_C_PRIVATE_PPP_FLASH_BROWSER_OPERATIONS_H_
Expand Down Expand Up @@ -186,7 +186,7 @@ struct PPP_Flash_BrowserOperations_1_3 {
* See also the NPP_GetSitesWithData function in NPAPI:
* https://wiki.mozilla.org/NPAPI:ClearSiteData
*/
void (*GetSitesWithData)(const char* plugin_data_path, char** sites[]);
void (*GetSitesWithData)(const char* plugin_data_path, char*** sites);
/**
* Frees the list of sites returned by GetSitesWithData.
*
Expand Down
8 changes: 7 additions & 1 deletion ppapi/generators/idl_c_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,13 @@ def GetComponents(self, node, release, mode):

# Generate passing type by modifying root type
rtype = self.GetTypeByMode(node, release, mode)
# If this is an array output, change it from type* foo[] to type** foo.
# type* foo[] means an array of pointers to type, which is confusing.
arrayspec = [self.GetArraySpec(array) for array in node.GetListOf('Array')]
if mode == 'out' and len(arrayspec) == 1 and arrayspec[0] == '[]':
rtype += '*'
del arrayspec[0]

if node.IsA('Enum', 'Interface', 'Struct'):
rname = node.GetName()
else:
Expand All @@ -394,7 +401,6 @@ def GetComponents(self, node, release, mode):
if '%' in rtype:
rtype = rtype % rname
name = node.GetName()
arrayspec = [self.GetArraySpec(array) for array in node.GetListOf('Array')]
callnode = node.GetOneOf('Callspec')
if callnode:
callspec = []
Expand Down
6 changes: 3 additions & 3 deletions ppapi/thunk/ppb_camera_capabilities_private_thunk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

// From private/ppb_camera_capabilities_private.idl,
// modified Wed Aug 13 14:08:24 2014.
// modified Tue Aug 19 14:43:34 2014.

#include "ppapi/c/pp_errors.h"
#include "ppapi/c/private/ppb_camera_capabilities_private.h"
Expand Down Expand Up @@ -33,7 +33,7 @@ PP_Bool IsCameraCapabilities(PP_Resource resource) {

void GetSupportedPreviewSizes(PP_Resource capabilities,
int32_t* array_size,
struct PP_Size* preview_sizes[]) {
struct PP_Size** preview_sizes) {
VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedPreviewSizes()";
EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true);
if (enter.failed())
Expand All @@ -43,7 +43,7 @@ void GetSupportedPreviewSizes(PP_Resource capabilities,

void GetSupportedJpegSizes(PP_Resource capabilities,
int32_t* array_size,
struct PP_Size* jpeg_sizes[]) {
struct PP_Size** jpeg_sizes) {
VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedJpegSizes()";
EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true);
if (enter.failed())
Expand Down

0 comments on commit ab8bcef

Please sign in to comment.