PPAPI: make generator output a pointer to an array correctly.

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
parent 66909310
...@@ -53,11 +53,11 @@ interface PPB_CameraCapabilities_Private { ...@@ -53,11 +53,11 @@ interface PPB_CameraCapabilities_Private {
* @param[in] capabilities A <code>PP_Resource</code> corresponding to an * @param[in] capabilities A <code>PP_Resource</code> corresponding to an
* image capture capabilities resource. * image capture capabilities resource.
* @param[out] array_size The size of preview size array. * @param[out] array_size The size of preview size array.
* @param[out] An array of <code>PP_Size</code> corresponding to the * @param[out] preview_sizes An array of <code>PP_Size</code> corresponding
* supported preview sizes in pixels. The ownership of the array belongs to * to the supported preview sizes in pixels. The ownership of the array
* <code>PPB_CameraCapabilities_Private</code> and the caller should not * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* free it. When a PPB_CameraCapabilities_Private is deleted, the array * should not free it. When a PPB_CameraCapabilities_Private is deleted,
* returning from this is no longer valid. * the array returning from this is no longer valid.
*/ */
void GetSupportedPreviewSizes( void GetSupportedPreviewSizes(
[in] PP_Resource capabilities, [in] PP_Resource capabilities,
...@@ -72,11 +72,11 @@ interface PPB_CameraCapabilities_Private { ...@@ -72,11 +72,11 @@ interface PPB_CameraCapabilities_Private {
* image capture capabilities resource. * image capture capabilities resource.
* @param[out] array_size The size of JPEG size array. If the output of this * @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. * is 0, the camera has no support for generating JPEG images.
* @param[out] An array of <code>PP_Size</code> corresponding to the * @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to
* supported JPEG image sizes in pixels. The ownership of the array belongs * the supported JPEG image sizes in pixels. The ownership of the array
* to <code>PPB_CameraCapabilities_Private</code> and the caller should not * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* free it. When a PPB_CameraCapabilities_Private is deleted, the array * should not free it. When a PPB_CameraCapabilities_Private is deleted, the
* returning from this is no longer valid. * array returning from this is no longer valid.
*/ */
void GetSupportedJpegSizes( void GetSupportedJpegSizes(
[in] PP_Resource capabilities, [in] PP_Resource capabilities,
......
/* 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 * Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. * found in the LICENSE file.
*/ */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
*/ */
/* From private/ppb_camera_capabilities_private.idl, /* 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_ #ifndef PPAPI_C_PRIVATE_PPB_CAMERA_CAPABILITIES_PRIVATE_H_
...@@ -68,15 +68,15 @@ struct PPB_CameraCapabilities_Private_0_1 { ...@@ -68,15 +68,15 @@ struct PPB_CameraCapabilities_Private_0_1 {
* @param[in] capabilities A <code>PP_Resource</code> corresponding to an * @param[in] capabilities A <code>PP_Resource</code> corresponding to an
* image capture capabilities resource. * image capture capabilities resource.
* @param[out] array_size The size of preview size array. * @param[out] array_size The size of preview size array.
* @param[out] An array of <code>PP_Size</code> corresponding to the * @param[out] preview_sizes An array of <code>PP_Size</code> corresponding
* supported preview sizes in pixels. The ownership of the array belongs to * to the supported preview sizes in pixels. The ownership of the array
* <code>PPB_CameraCapabilities_Private</code> and the caller should not * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* free it. When a PPB_CameraCapabilities_Private is deleted, the array * should not free it. When a PPB_CameraCapabilities_Private is deleted,
* returning from this is no longer valid. * the array returning from this is no longer valid.
*/ */
void (*GetSupportedPreviewSizes)(PP_Resource capabilities, void (*GetSupportedPreviewSizes)(PP_Resource capabilities,
int32_t* array_size, int32_t* array_size,
struct PP_Size* preview_sizes[]); struct PP_Size** preview_sizes);
/** /**
* GetSupportedJpegSize() returns the supported JPEG sizes for the given * GetSupportedJpegSize() returns the supported JPEG sizes for the given
* <code>PPB_CameraCapabilities_Private</code>. * <code>PPB_CameraCapabilities_Private</code>.
...@@ -85,15 +85,15 @@ struct PPB_CameraCapabilities_Private_0_1 { ...@@ -85,15 +85,15 @@ struct PPB_CameraCapabilities_Private_0_1 {
* image capture capabilities resource. * image capture capabilities resource.
* @param[out] array_size The size of JPEG size array. If the output of this * @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. * is 0, the camera has no support for generating JPEG images.
* @param[out] An array of <code>PP_Size</code> corresponding to the * @param[out] jpeg_sizes An array of <code>PP_Size</code> corresponding to
* supported JPEG image sizes in pixels. The ownership of the array belongs * the supported JPEG image sizes in pixels. The ownership of the array
* to <code>PPB_CameraCapabilities_Private</code> and the caller should not * belongs to <code>PPB_CameraCapabilities_Private</code> and the caller
* free it. When a PPB_CameraCapabilities_Private is deleted, the array * should not free it. When a PPB_CameraCapabilities_Private is deleted, the
* returning from this is no longer valid. * array returning from this is no longer valid.
*/ */
void (*GetSupportedJpegSizes)(PP_Resource capabilities, void (*GetSupportedJpegSizes)(PP_Resource capabilities,
int32_t* array_size, int32_t* array_size,
struct PP_Size* jpeg_sizes[]); struct PP_Size** jpeg_sizes);
}; };
typedef struct PPB_CameraCapabilities_Private_0_1 typedef struct PPB_CameraCapabilities_Private_0_1
......
/* 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 * Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. * found in the LICENSE file.
*/ */
/* From private/ppp_flash_browser_operations.idl, /* 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_ #ifndef PPAPI_C_PRIVATE_PPP_FLASH_BROWSER_OPERATIONS_H_
...@@ -186,7 +186,7 @@ struct PPP_Flash_BrowserOperations_1_3 { ...@@ -186,7 +186,7 @@ struct PPP_Flash_BrowserOperations_1_3 {
* See also the NPP_GetSitesWithData function in NPAPI: * See also the NPP_GetSitesWithData function in NPAPI:
* https://wiki.mozilla.org/NPAPI:ClearSiteData * 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. * Frees the list of sites returned by GetSitesWithData.
* *
......
...@@ -384,6 +384,13 @@ class CGen(object): ...@@ -384,6 +384,13 @@ class CGen(object):
# Generate passing type by modifying root type # Generate passing type by modifying root type
rtype = self.GetTypeByMode(node, release, mode) 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'): if node.IsA('Enum', 'Interface', 'Struct'):
rname = node.GetName() rname = node.GetName()
else: else:
...@@ -394,7 +401,6 @@ class CGen(object): ...@@ -394,7 +401,6 @@ class CGen(object):
if '%' in rtype: if '%' in rtype:
rtype = rtype % rname rtype = rtype % rname
name = node.GetName() name = node.GetName()
arrayspec = [self.GetArraySpec(array) for array in node.GetListOf('Array')]
callnode = node.GetOneOf('Callspec') callnode = node.GetOneOf('Callspec')
if callnode: if callnode:
callspec = [] callspec = []
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// From private/ppb_camera_capabilities_private.idl, // 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/pp_errors.h"
#include "ppapi/c/private/ppb_camera_capabilities_private.h" #include "ppapi/c/private/ppb_camera_capabilities_private.h"
...@@ -33,7 +33,7 @@ PP_Bool IsCameraCapabilities(PP_Resource resource) { ...@@ -33,7 +33,7 @@ PP_Bool IsCameraCapabilities(PP_Resource resource) {
void GetSupportedPreviewSizes(PP_Resource capabilities, void GetSupportedPreviewSizes(PP_Resource capabilities,
int32_t* array_size, int32_t* array_size,
struct PP_Size* preview_sizes[]) { struct PP_Size** preview_sizes) {
VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedPreviewSizes()"; VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedPreviewSizes()";
EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true); EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true);
if (enter.failed()) if (enter.failed())
...@@ -43,7 +43,7 @@ void GetSupportedPreviewSizes(PP_Resource capabilities, ...@@ -43,7 +43,7 @@ void GetSupportedPreviewSizes(PP_Resource capabilities,
void GetSupportedJpegSizes(PP_Resource capabilities, void GetSupportedJpegSizes(PP_Resource capabilities,
int32_t* array_size, int32_t* array_size,
struct PP_Size* jpeg_sizes[]) { struct PP_Size** jpeg_sizes) {
VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedJpegSizes()"; VLOG(4) << "PPB_CameraCapabilities_Private::GetSupportedJpegSizes()";
EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true); EnterResource<PPB_CameraCapabilities_API> enter(capabilities, true);
if (enter.failed()) if (enter.failed())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment