summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 01:24:13 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 01:24:13 +0000
commit56c49bb6435e6cbecae9504f23dc8189b49ad955 (patch)
tree37fc8cf187c355b6cb2d43efc1d5fcaf304373ab /ppapi
parent210257b2f908030f3924d6878b0ba1cedfc5615b (diff)
downloadchromium_src-56c49bb6435e6cbecae9504f23dc8189b49ad955.zip
chromium_src-56c49bb6435e6cbecae9504f23dc8189b49ad955.tar.gz
chromium_src-56c49bb6435e6cbecae9504f23dc8189b49ad955.tar.bz2
Autogenerate thunk for PPB_ImageData.
This changes idl_thunk.py to use functions from ppapi/shared_impl when the first argument to a function is not PP_Instance or PP_Resource. This pattern seems to be used in multiple IDL files. I also needed to clean up the APIs a bit so the function signatures matched up with what idl_thunk.py emits. Tested: Built chrome and browser_tests. BUG= Review URL: https://chromiumcodereview.appspot.com/14060022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/ppb_image_data.idl9
-rwxr-xr-xppapi/generators/idl_thunk.py46
-rw-r--r--ppapi/proxy/ppb_image_data_proxy.cc4
-rw-r--r--ppapi/proxy/resource_creation_proxy.cc6
-rw-r--r--ppapi/proxy/resource_creation_proxy.h4
-rw-r--r--ppapi/shared_impl/ppb_image_data_shared.cc6
-rw-r--r--ppapi/shared_impl/ppb_image_data_shared.h2
-rw-r--r--ppapi/thunk/ppb_image_data_thunk.cc59
-rw-r--r--ppapi/thunk/resource_creation_api.h4
9 files changed, 88 insertions, 52 deletions
diff --git a/ppapi/api/ppb_image_data.idl b/ppapi/api/ppb_image_data.idl
index 4934f79..8e1d09d 100644
--- a/ppapi/api/ppb_image_data.idl
+++ b/ppapi/api/ppb_image_data.idl
@@ -8,9 +8,11 @@
* a browser handles image data.
*/
- label Chrome {
- M14 = 1.0
- };
+[generate_thunk]
+
+label Chrome {
+ M14 = 1.0
+};
/**
* <code>PP_ImageDataFormat</code> is an enumeration of the different types of
@@ -157,6 +159,7 @@ interface PPB_ImageData {
* <code>PP_FALSE</code>, the <code>desc</code> structure will be filled
* with 0.
*/
+ [always_set_output_parameters]
PP_Bool Describe(
[in] PP_Resource image_data,
[out] PP_ImageDataDesc desc);
diff --git a/ppapi/generators/idl_thunk.py b/ppapi/generators/idl_thunk.py
index 11fa736..6c28c9a2 100755
--- a/ppapi/generators/idl_thunk.py
+++ b/ppapi/generators/idl_thunk.py
@@ -90,9 +90,8 @@ def _GetThunkFileName(filenode, relpath):
return name
-def _AddApiHeader(filenode, meta):
- """Adds an API header for the given file to the ThunkBodyMetadata."""
- # The API header matches the file name, not the interface name.
+def _StripFileName(filenode):
+ """Strips path and dev, trusted, and private suffixes from the file name."""
api_basename = _GetBaseFileName(filenode)
if api_basename.endswith('_dev'):
api_basename = api_basename[:-len('_dev')]
@@ -100,20 +99,24 @@ def _AddApiHeader(filenode, meta):
api_basename = api_basename[:-len('_trusted')]
if api_basename.endswith('_private'):
api_basename = api_basename[:-len('_private')]
- meta.AddApi(api_basename + '_api')
+ return api_basename
-def _MakeEnterLine(filenode, interface, member, arg, handle_errors, callback,
- meta):
- """Returns an EnterInstance/EnterResource string for a function."""
- api_name = interface.GetName()
+def _StripApiName(api_name):
+ """Strips Dev, Private, and Trusted suffixes from the API name."""
if api_name.endswith('Trusted'):
api_name = api_name[:-len('Trusted')]
if api_name.endswith('_Dev'):
api_name = api_name[:-len('_Dev')]
if api_name.endswith('_Private'):
api_name = api_name[:-len('_Private')]
- api_name += '_API'
+ return api_name
+
+
+def _MakeEnterLine(filenode, interface, member, arg, handle_errors, callback,
+ meta):
+ """Returns an EnterInstance/EnterResource string for a function."""
+ api_name = _StripApiName(interface.GetName()) + '_API'
if member.GetProperty('api'): # Override API name.
manually_provided_api = True
# TODO(teravest): Automatically guess the API header file.
@@ -128,14 +131,14 @@ def _MakeEnterLine(filenode, interface, member, arg, handle_errors, callback,
arg_string = '%s, %s' % (arg[1], callback)
if interface.GetProperty('singleton') or member.GetProperty('singleton'):
if not manually_provided_api:
- _AddApiHeader(filenode, meta)
+ meta.AddApi('ppapi/thunk/%s_api.h' % _StripFileName(filenode))
return 'EnterInstanceAPI<%s> enter(%s);' % (api_name, arg_string)
else:
return 'EnterInstance enter(%s);' % arg_string
elif arg[0] == 'PP_Resource':
enter_type = 'EnterResource<%s>' % api_name
if not manually_provided_api:
- _AddApiHeader(filenode, meta)
+ meta.AddApi('ppapi/thunk/%s_api.h' % _StripFileName(filenode))
if callback is None:
return '%s enter(%s, %s);' % (enter_type, arg[1],
str(handle_errors).lower())
@@ -180,6 +183,7 @@ def _GetDefaultFailureValue(t):
'uint16_t': '0',
'uint32_t': '0',
'uint64_t': '0',
+ 'void*': 'NULL'
}
if t in values:
return values[t]
@@ -256,6 +260,14 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args,
include_version - whether to include the version in the invocation
meta - ThunkBodyMetadata for header hints
"""
+ if len(args) == 0:
+ # Calling into the "Shared" code for the interface seems like a reasonable
+ # heuristic when we don't have any arguments; some thunk code follows this
+ # convention today.
+ meta.AddApi('ppapi/shared_impl/%s_shared.h' % _StripFileName(filenode))
+ return 'return %s::%s();' % (_StripApiName(node.GetName()) + '_Shared',
+ member.GetName())
+
is_callback_func = args[len(args) - 1][0] == 'struct PP_CompletionCallback'
if is_callback_func:
@@ -267,9 +279,17 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args,
if args[0][0] == 'PP_Instance':
call_arglist = ', '.join(a[1] for a in call_args)
function_container = 'functions'
- else:
+ elif args[0][0] == 'PP_Resource':
call_arglist = ', '.join(a[1] for a in call_args[1:])
function_container = 'object'
+ else:
+ # Calling into the "Shared" code for the interface seems like a reasonable
+ # heuristic when the first argument isn't a PP_Instance or a PP_Resource;
+ # some thunk code follows this convention today.
+ meta.AddApi('ppapi/shared_impl/%s_shared.h' % _StripFileName(filenode))
+ return 'return %s::%s(%s);' % (_StripApiName(node.GetName()) + '_Shared',
+ member.GetName(),
+ ', '.join(a[1] for a in args))
function_name = member.GetName()
if include_version:
@@ -443,7 +463,7 @@ class TGen(GeneratorByFile):
'ppapi/thunk/thunk.h']
includes.append(_GetHeaderFileName(filenode))
for api in meta.Apis():
- includes.append('ppapi/thunk/%s.h' % api.lower())
+ includes.append('%s' % api.lower())
for i in meta.Includes():
includes.append(i)
for include in sorted(includes):
diff --git a/ppapi/proxy/ppb_image_data_proxy.cc b/ppapi/proxy/ppb_image_data_proxy.cc
index 0262855..bd9c756 100644
--- a/ppapi/proxy/ppb_image_data_proxy.cc
+++ b/ppapi/proxy/ppb_image_data_proxy.cc
@@ -533,7 +533,7 @@ void PPB_ImageData_Proxy::OnHostMsgCreate(PP_Instance instance,
return;
PP_Resource resource = enter.functions()->CreateImageData(
- instance, static_cast<PP_ImageDataFormat>(format), size, init_to_zero);
+ instance, static_cast<PP_ImageDataFormat>(format), &size, init_to_zero);
if (!resource)
return;
result->SetHostResource(instance, resource);
@@ -577,7 +577,7 @@ void PPB_ImageData_Proxy::OnHostMsgCreateNaCl(
return;
PP_Resource resource = enter.functions()->CreateImageDataNaCl(
- instance, static_cast<PP_ImageDataFormat>(format), size, init_to_zero);
+ instance, static_cast<PP_ImageDataFormat>(format), &size, init_to_zero);
if (!resource)
return;
result->SetHostResource(instance, resource);
diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc
index 2aaed07..74f907c 100644
--- a/ppapi/proxy/resource_creation_proxy.cc
+++ b/ppapi/proxy/resource_creation_proxy.cc
@@ -256,16 +256,16 @@ PP_Resource ResourceCreationProxy::CreateHostResolverPrivate(
PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance,
PP_ImageDataFormat format,
- const PP_Size& size,
+ const PP_Size* size,
PP_Bool init_to_zero) {
- return PPB_ImageData_Proxy::CreateProxyResource(instance, format, size,
+ return PPB_ImageData_Proxy::CreateProxyResource(instance, format, *size,
init_to_zero);
}
PP_Resource ResourceCreationProxy::CreateImageDataNaCl(
PP_Instance instance,
PP_ImageDataFormat format,
- const PP_Size& size,
+ const PP_Size* size,
PP_Bool init_to_zero) {
// These really only are different on the host side. On the plugin side, we
// always request a "platform" ImageData if we're trusted, or a "NaCl" one
diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h
index fa7fe5a..85f2ddd 100644
--- a/ppapi/proxy/resource_creation_proxy.h
+++ b/ppapi/proxy/resource_creation_proxy.h
@@ -120,11 +120,11 @@ class ResourceCreationProxy : public InterfaceProxy,
virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) OVERRIDE;
virtual PP_Resource CreateImageData(PP_Instance instance,
PP_ImageDataFormat format,
- const PP_Size& size,
+ const PP_Size* size,
PP_Bool init_to_zero) OVERRIDE;
virtual PP_Resource CreateImageDataNaCl(PP_Instance instance,
PP_ImageDataFormat format,
- const PP_Size& size,
+ const PP_Size* size,
PP_Bool init_to_zero) OVERRIDE;
virtual PP_Resource CreateNetworkMonitor(
PP_Instance instance,
diff --git a/ppapi/shared_impl/ppb_image_data_shared.cc b/ppapi/shared_impl/ppb_image_data_shared.cc
index abdea60..4201a1e 100644
--- a/ppapi/shared_impl/ppb_image_data_shared.cc
+++ b/ppapi/shared_impl/ppb_image_data_shared.cc
@@ -36,10 +36,10 @@ PP_ImageDataFormat PPB_ImageData_Shared::GetNativeImageDataFormat() {
}
// static
-bool PPB_ImageData_Shared::IsImageDataFormatSupported(
+PP_Bool PPB_ImageData_Shared::IsImageDataFormatSupported(
PP_ImageDataFormat format) {
- return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL ||
- format == PP_IMAGEDATAFORMAT_RGBA_PREMUL;
+ return PP_FromBool(format == PP_IMAGEDATAFORMAT_BGRA_PREMUL ||
+ format == PP_IMAGEDATAFORMAT_RGBA_PREMUL);
}
} // namespace ppapi
diff --git a/ppapi/shared_impl/ppb_image_data_shared.h b/ppapi/shared_impl/ppb_image_data_shared.h
index 4f9a4d5..0f1f4bb 100644
--- a/ppapi/shared_impl/ppb_image_data_shared.h
+++ b/ppapi/shared_impl/ppb_image_data_shared.h
@@ -23,7 +23,7 @@ namespace ppapi {
class PPAPI_SHARED_EXPORT PPB_ImageData_Shared {
public:
static PP_ImageDataFormat GetNativeImageDataFormat();
- static bool IsImageDataFormatSupported(PP_ImageDataFormat format);
+ static PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format);
};
} // namespace ppapi
diff --git a/ppapi/thunk/ppb_image_data_thunk.cc b/ppapi/thunk/ppb_image_data_thunk.cc
index f50842e..d26904a 100644
--- a/ppapi/thunk/ppb_image_data_thunk.cc
+++ b/ppapi/thunk/ppb_image_data_thunk.cc
@@ -2,11 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+// From ppb_image_data.idl modified Thu Apr 25 14:42:27 2013.
+
+#include <string.h>
+
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/shared_impl/ppb_image_data_shared.h"
+#include "ppapi/shared_impl/tracked_callback.h"
#include "ppapi/thunk/enter.h"
#include "ppapi/thunk/ppb_image_data_api.h"
+#include "ppapi/thunk/ppb_instance_api.h"
#include "ppapi/thunk/resource_creation_api.h"
#include "ppapi/thunk/thunk.h"
@@ -15,69 +21,76 @@ namespace thunk {
namespace {
-PP_ImageDataFormat GetNativeImageDataFormat() {
- return ppapi::PPB_ImageData_Shared::GetNativeImageDataFormat();
+PP_ImageDataFormat GetNativeImageDataFormat(void) {
+ VLOG(4) << "PPB_ImageData::GetNativeImageDataFormat()";
+ return PPB_ImageData_Shared::GetNativeImageDataFormat();
}
PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) {
- return ppapi::PPB_ImageData_Shared::IsImageDataFormatSupported(format)
- ? PP_TRUE : PP_FALSE;
+ VLOG(4) << "PPB_ImageData::IsImageDataFormatSupported()";
+ return PPB_ImageData_Shared::IsImageDataFormatSupported(format);
}
PP_Resource Create(PP_Instance instance,
PP_ImageDataFormat format,
- const PP_Size* size,
+ const struct PP_Size* size,
PP_Bool init_to_zero) {
+ VLOG(4) << "PPB_ImageData::Create()";
EnterResourceCreation enter(instance);
if (enter.failed())
return 0;
- return enter.functions()->CreateImageData(instance, format,
- *size, init_to_zero);
+ return enter.functions()->CreateImageData(instance,
+ format,
+ size,
+ init_to_zero);
}
-PP_Bool IsImageData(PP_Resource resource) {
- EnterResource<PPB_ImageData_API> enter(resource, false);
- return enter.succeeded() ? PP_TRUE : PP_FALSE;
+PP_Bool IsImageData(PP_Resource image_data) {
+ VLOG(4) << "PPB_ImageData::IsImageData()";
+ EnterResource<PPB_ImageData_API> enter(image_data, false);
+ return PP_FromBool(enter.succeeded());
}
-PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) {
- // Give predictable values on failure.
- memset(desc, 0, sizeof(PP_ImageDataDesc));
-
- EnterResource<PPB_ImageData_API> enter(resource, true);
- if (enter.failed())
+PP_Bool Describe(PP_Resource image_data, struct PP_ImageDataDesc* desc) {
+ VLOG(4) << "PPB_ImageData::Describe()";
+ EnterResource<PPB_ImageData_API> enter(image_data, true);
+ if (enter.failed()) {
+ memset(desc, 0, sizeof(*desc));
return PP_FALSE;
+ }
return enter.object()->Describe(desc);
}
-void* Map(PP_Resource resource) {
- EnterResource<PPB_ImageData_API> enter(resource, true);
+void* Map(PP_Resource image_data) {
+ VLOG(4) << "PPB_ImageData::Map()";
+ EnterResource<PPB_ImageData_API> enter(image_data, true);
if (enter.failed())
return NULL;
return enter.object()->Map();
}
-void Unmap(PP_Resource resource) {
- EnterResource<PPB_ImageData_API> enter(resource, true);
+void Unmap(PP_Resource image_data) {
+ VLOG(4) << "PPB_ImageData::Unmap()";
+ EnterResource<PPB_ImageData_API> enter(image_data, true);
if (enter.failed())
return;
enter.object()->Unmap();
}
-const PPB_ImageData g_ppb_image_data_thunk = {
+const PPB_ImageData_1_0 g_ppb_imagedata_thunk_1_0 = {
&GetNativeImageDataFormat,
&IsImageDataFormatSupported,
&Create,
&IsImageData,
&Describe,
&Map,
- &Unmap,
+ &Unmap
};
} // namespace
const PPB_ImageData_1_0* GetPPB_ImageData_1_0_Thunk() {
- return &g_ppb_image_data_thunk;
+ return &g_ppb_imagedata_thunk_1_0;
}
} // namespace thunk
diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h
index cd9a8ff..1a4713e 100644
--- a/ppapi/thunk/resource_creation_api.h
+++ b/ppapi/thunk/resource_creation_api.h
@@ -130,11 +130,11 @@ class ResourceCreationAPI {
virtual PP_Resource CreateHostResolverPrivate(PP_Instance instance) = 0;
virtual PP_Resource CreateImageData(PP_Instance instance,
PP_ImageDataFormat format,
- const PP_Size& size,
+ const PP_Size* size,
PP_Bool init_to_zero) = 0;
virtual PP_Resource CreateImageDataNaCl(PP_Instance instance,
PP_ImageDataFormat format,
- const PP_Size& size,
+ const PP_Size* size,
PP_Bool init_to_zero) = 0;
virtual PP_Resource CreateNetworkMonitor(
PP_Instance instance,