diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-16 21:02:16 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-16 21:02:16 +0000 |
commit | a388796bf49a8f8b87a6a8bdfb0c3a87fbe81e3a (patch) | |
tree | a6288cc2100ad8a569df7ef98805e22a830e0069 /ppapi | |
parent | b942f1de3e1dee7a766f375f256eb6bf1680880b (diff) | |
download | chromium_src-a388796bf49a8f8b87a6a8bdfb0c3a87fbe81e3a.zip chromium_src-a388796bf49a8f8b87a6a8bdfb0c3a87fbe81e3a.tar.gz chromium_src-a388796bf49a8f8b87a6a8bdfb0c3a87fbe81e3a.tar.bz2 |
Pepper: Autogenerate thunk for PPB_TrueTypeFont.
This makes a few changes to IDL annotations:
* 'singleton_resource' is now 'singleton' and can be per-function or per-interface.
* There is a new 'API' annotation that describes when a specific API should be used for a function.
* There is a 'thunk_include' annotation for when a header file must be included in the thunk output, but we can't guess it.
Review URL: https://codereview.chromium.org/13820003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194445 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/dev/ppb_truetype_font_dev.idl | 8 | ||||
-rw-r--r-- | ppapi/api/ppb_gamepad.idl | 4 | ||||
-rw-r--r-- | ppapi/c/dev/ppb_truetype_font_dev.h | 6 | ||||
-rw-r--r-- | ppapi/c/ppb_gamepad.h | 4 | ||||
-rwxr-xr-x | ppapi/generators/idl_thunk.py | 35 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 6 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 2 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.cc | 4 | ||||
-rw-r--r-- | ppapi/proxy/resource_creation_proxy.h | 2 | ||||
-rw-r--r-- | ppapi/tests/test_truetype_font.cc | 10 | ||||
-rw-r--r-- | ppapi/thunk/ppb_truetype_font_dev_thunk.cc (renamed from ppapi/thunk/ppb_truetype_font_thunk.cc) | 44 | ||||
-rw-r--r-- | ppapi/thunk/resource_creation_api.h | 2 |
12 files changed, 78 insertions, 49 deletions
diff --git a/ppapi/api/dev/ppb_truetype_font_dev.idl b/ppapi/api/dev/ppb_truetype_font_dev.idl index 9775d98..6460c17 100644 --- a/ppapi/api/dev/ppb_truetype_font_dev.idl +++ b/ppapi/api/dev/ppb_truetype_font_dev.idl @@ -8,6 +8,9 @@ * interface exposes font table data for 'sfnt' fonts on the host system. These * include TrueType and OpenType fonts. */ + +[generate_thunk,thunk_include="ppapi/thunk/ppb_truetype_font_singleton_api.h"] + label Chrome { M26 = 0.1 }; @@ -146,6 +149,7 @@ interface PPB_TrueTypeFont_Dev { * @return If >= 0, the number of family names returned, otherwise an error * code from <code>pp_errors.h</code>. */ + [singleton,api=PPB_TrueTypeFont_Singleton_API] int32_t GetFontFamilies([in] PP_Instance instance, [in] PP_ArrayOutput output, [in] PP_CompletionCallback callback); @@ -162,14 +166,14 @@ interface PPB_TrueTypeFont_Dev { [in] PP_TrueTypeFontDesc_Dev desc); /** - * Determines if the given resource is a font. + * Determines if the given resource is a TrueType font. * * @param[in] resource A <code>PP_Resource</code> corresponding to a font. * * @return <code>PP_TRUE</code> if the resource is a * <code>PPB_TrueTypeFont_Dev</code>, <code>PP_FALSE</code> otherwise. */ - PP_Bool IsFont([in] PP_Resource resource); + PP_Bool IsTrueTypeFont([in] PP_Resource resource); /** * Returns a description of the given font resource. This description may diff --git a/ppapi/api/ppb_gamepad.idl b/ppapi/api/ppb_gamepad.idl index 6403e34..c3d0652 100644 --- a/ppapi/api/ppb_gamepad.idl +++ b/ppapi/api/ppb_gamepad.idl @@ -85,10 +85,10 @@ struct PP_GamepadsSampleData { * The <code>PPB_Gamepad</code> interface allows retrieving data from * gamepad/joystick devices that are connected to the system. */ -[version=1.0, macro="PPB_GAMEPAD_INTERFACE", singleton_resource] +[version=1.0, macro="PPB_GAMEPAD_INTERFACE", singleton] interface PPB_Gamepad { /** - * Samples the current state of the connected gamepads. + * Samples the current state of the available gamepads. */ void Sample( [in] PP_Instance instance, diff --git a/ppapi/c/dev/ppb_truetype_font_dev.h b/ppapi/c/dev/ppb_truetype_font_dev.h index e0fc499..c8f3673 100644 --- a/ppapi/c/dev/ppb_truetype_font_dev.h +++ b/ppapi/c/dev/ppb_truetype_font_dev.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From dev/ppb_truetype_font_dev.idl modified Mon Mar 11 14:12:14 2013. */ +/* From dev/ppb_truetype_font_dev.idl modified Wed Apr 10 11:41:36 2013. */ #ifndef PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ #define PPAPI_C_DEV_PPB_TRUETYPE_FONT_DEV_H_ @@ -193,14 +193,14 @@ struct PPB_TrueTypeFont_Dev_0_1 { PP_Resource (*Create)(PP_Instance instance, const struct PP_TrueTypeFontDesc_Dev* desc); /** - * Determines if the given resource is a font. + * Determines if the given resource is a TrueType font. * * @param[in] resource A <code>PP_Resource</code> corresponding to a font. * * @return <code>PP_TRUE</code> if the resource is a * <code>PPB_TrueTypeFont_Dev</code>, <code>PP_FALSE</code> otherwise. */ - PP_Bool (*IsFont)(PP_Resource resource); + PP_Bool (*IsTrueTypeFont)(PP_Resource resource); /** * Returns a description of the given font resource. This description may * differ from the description passed to Create, reflecting the host's font diff --git a/ppapi/c/ppb_gamepad.h b/ppapi/c/ppb_gamepad.h index 6726568..4beb9b8 100644 --- a/ppapi/c/ppb_gamepad.h +++ b/ppapi/c/ppb_gamepad.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From ppb_gamepad.idl modified Thu Mar 1 11:41:21 2012. */ +/* From ppb_gamepad.idl modified Tue Apr 16 09:04:34 2013. */ #ifndef PPAPI_C_PPB_GAMEPAD_H_ #define PPAPI_C_PPB_GAMEPAD_H_ @@ -98,7 +98,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_GamepadsSampleData, 1896); */ struct PPB_Gamepad_1_0 { /** - * Samples the current state of the connected gamepads. + * Samples the current state of the available gamepads. */ void (*Sample)(PP_Instance instance, struct PP_GamepadsSampleData* data); }; diff --git a/ppapi/generators/idl_thunk.py b/ppapi/generators/idl_thunk.py index ad770fe..6018753 100755 --- a/ppapi/generators/idl_thunk.py +++ b/ppapi/generators/idl_thunk.py @@ -101,7 +101,8 @@ def _AddApiHeader(filenode, meta): meta.AddApi(api_basename + '_api') -def _MakeEnterLine(filenode, interface, arg, handle_errors, callback, meta): +def _MakeEnterLine(filenode, interface, member, arg, handle_errors, callback, + meta): """Returns an EnterInstance/EnterResource string for a function.""" api_name = interface.GetName() if api_name.endswith('Trusted'): @@ -109,20 +110,28 @@ def _MakeEnterLine(filenode, interface, arg, handle_errors, callback, meta): if api_name.endswith('_Dev'): api_name = api_name[:-len('_Dev')] api_name += '_API' + if member.GetProperty('api'): # Override API name. + manually_provided_api = True + # TODO(teravest): Automatically guess the API header file. + api_name = member.GetProperty('api') + else: + manually_provided_api = False if arg[0] == 'PP_Instance': if callback is None: arg_string = arg[1] else: arg_string = '%s, %s' % (arg[1], callback) - if interface.GetProperty('singleton_resource'): - _AddApiHeader(filenode, meta) + if interface.GetProperty('singleton') or member.GetProperty('singleton'): + if not manually_provided_api: + _AddApiHeader(filenode, meta) 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 - _AddApiHeader(filenode, meta) + if not manually_provided_api: + _AddApiHeader(filenode, meta) if callback is None: return '%s enter(%s, %s);' % (enter_type, arg[1], str(handle_errors).lower()) @@ -245,8 +254,8 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args, handle_errors = not (member.GetProperty('report_errors') == 'False') if is_callback_func: - body = '%s\n' % _MakeEnterLine(filenode, node, args[0], handle_errors, - args[len(args) - 1][1], meta) + body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0], + handle_errors, args[len(args) - 1][1], meta) body += 'if (enter.failed())\n' value = member.GetProperty('on_failure') if value is None: @@ -267,8 +276,8 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args, ptype, pname, _, _ = cgen.GetComponents(param, release, 'store') out_params.append((pname, ptype)) - body = '%s\n' % _MakeEnterLine(filenode, node, args[0], handle_errors, - None, meta) + body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0], + handle_errors, None, meta) if not out_params: body += 'if (enter.succeeded())\n' body += ' %s;' % invocation @@ -288,8 +297,8 @@ def _MakeNormalMemberBody(filenode, release, node, member, rtype, args, if value is None: raise TGenError('No default value for rtype %s' % rtype) - body = '%s\n' % _MakeEnterLine(filenode, node, args[0], handle_errors, - None, meta) + body = '%s\n' % _MakeEnterLine(filenode, node, member, args[0], + handle_errors, None, meta) body += 'if (enter.failed())\n' body += ' return %s;\n' % value body += 'return %s;' % invocation @@ -314,7 +323,8 @@ def DefineMember(filenode, node, member, release, include_version, meta): body = 'VLOG(4) << \"%s::%s()\";\n' % (node.GetName(), member.GetName()) if _IsTypeCheck(node, member): - body += '%s\n' % _MakeEnterLine(filenode, node, args[0], False, None, meta) + body += '%s\n' % _MakeEnterLine(filenode, node, member, args[0], False, + None, meta) body += 'return PP_FromBool(enter.succeeded());' elif member.GetName() == 'Create': body += _MakeCreateMemberBody(node, member, args) @@ -375,6 +385,9 @@ class TGen(GeneratorByFile): thunk_out = IDLOutFile(savename) body, meta = self.GenerateBody(thunk_out, filenode, releases, options) + # TODO(teravest): How do we handle repeated values? + if filenode.GetProperty('thunk_include'): + meta.AddInclude(filenode.GetProperty('thunk_include')) self.WriteHead(thunk_out, filenode, releases, options, meta) thunk_out.Write('\n\n'.join(body)) self.WriteTail(thunk_out, filenode, releases, options) diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 3ad8662..04b4d3e 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -2221,9 +2221,9 @@ PP_Resource Pnacl_M26_PPB_TrueTypeFont_Dev_Create(PP_Instance instance, const st } static __attribute__((pnaclcall)) -PP_Bool Pnacl_M26_PPB_TrueTypeFont_Dev_IsFont(PP_Resource resource) { +PP_Bool Pnacl_M26_PPB_TrueTypeFont_Dev_IsTrueTypeFont(PP_Resource resource) { const struct PPB_TrueTypeFont_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_TrueTypeFont_Dev_0_1.real_iface; - return iface->IsFont(resource); + return iface->IsTrueTypeFont(resource); } static __attribute__((pnaclcall)) @@ -4598,7 +4598,7 @@ struct PPB_Testing_Dev_0_91 Pnacl_Wrappers_PPB_Testing_Dev_0_91 = { struct PPB_TrueTypeFont_Dev_0_1 Pnacl_Wrappers_PPB_TrueTypeFont_Dev_0_1 = { .GetFontFamilies = (int32_t (*)(PP_Instance instance, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_GetFontFamilies, .Create = (PP_Resource (*)(PP_Instance instance, const struct PP_TrueTypeFontDesc_Dev* desc))&Pnacl_M26_PPB_TrueTypeFont_Dev_Create, - .IsFont = (PP_Bool (*)(PP_Resource resource))&Pnacl_M26_PPB_TrueTypeFont_Dev_IsFont, + .IsTrueTypeFont = (PP_Bool (*)(PP_Resource resource))&Pnacl_M26_PPB_TrueTypeFont_Dev_IsTrueTypeFont, .Describe = (int32_t (*)(PP_Resource font, struct PP_TrueTypeFontDesc_Dev* desc, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_Describe, .GetTableTags = (int32_t (*)(PP_Resource font, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_GetTableTags, .GetTable = (int32_t (*)(PP_Resource font, uint32_t table, int32_t offset, int32_t max_data_length, struct PP_ArrayOutput output, struct PP_CompletionCallback callback))&Pnacl_M26_PPB_TrueTypeFont_Dev_GetTable diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 352281a..6042294 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -230,7 +230,7 @@ 'thunk/ppb_text_input_thunk.cc', 'thunk/ppb_truetype_font_api.h', 'thunk/ppb_truetype_font_singleton_api.h', - 'thunk/ppb_truetype_font_thunk.cc', + 'thunk/ppb_truetype_font_dev_thunk.cc', 'thunk/ppb_udp_socket_private_api.h', 'thunk/ppb_udp_socket_private_thunk.cc', 'thunk/ppb_url_loader_api.h', diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 98b2ba0..2aaed07 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -155,9 +155,9 @@ PP_Resource ResourceCreationProxy::CreateResourceArray( PP_Resource ResourceCreationProxy::CreateTrueTypeFont( PP_Instance instance, - const PP_TrueTypeFontDesc_Dev& desc) { + const PP_TrueTypeFontDesc_Dev* desc) { return (new TrueTypeFontResource(GetConnection(), - instance, desc))->GetReference(); + instance, *desc))->GetReference(); } diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 476ea83..fa7fe5a 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -80,7 +80,7 @@ class ResourceCreationProxy : public InterfaceProxy, uint32_t size) OVERRIDE; virtual PP_Resource CreateTrueTypeFont( PP_Instance instance, - const PP_TrueTypeFontDesc_Dev& desc) OVERRIDE; + const PP_TrueTypeFontDesc_Dev* desc) OVERRIDE; virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance) OVERRIDE; diff --git a/ppapi/tests/test_truetype_font.cc b/ppapi/tests/test_truetype_font.cc index b09cb58..7644b95 100644 --- a/ppapi/tests/test_truetype_font.cc +++ b/ppapi/tests/test_truetype_font.cc @@ -6,6 +6,7 @@ #include "ppapi/tests/test_truetype_font.h" +#include <stdio.h> #include <string.h> #include <algorithm> #include <limits> @@ -114,7 +115,8 @@ std::string TestTrueTypeFont::TestGetFontFamilies() { kInvalidInstance, cc.GetCallback().output(), cc.GetCallback().pp_completion_callback())); - ASSERT_EQ(PP_ERROR_FAILED, cc.result()); + ASSERT_TRUE(cc.result() == PP_ERROR_FAILED || + cc.result() == PP_ERROR_BADARGUMENT); ASSERT_EQ(0, cc.output().size()); } @@ -134,16 +136,16 @@ std::string TestTrueTypeFont::TestCreate() { // Creating a font from an invalid instance returns an invalid resource. font = ppb_truetype_font_interface_->Create(kInvalidInstance, &desc); ASSERT_EQ(kInvalidResource, font); - ASSERT_NE(PP_TRUE, ppb_truetype_font_interface_->IsFont(font)); + ASSERT_NE(PP_TRUE, ppb_truetype_font_interface_->IsTrueTypeFont(font)); // Creating a font from a valid instance returns a font resource. font = ppb_truetype_font_interface_->Create(instance_->pp_instance(), &desc); ASSERT_NE(kInvalidResource, font); - ASSERT_EQ(PP_TRUE, ppb_truetype_font_interface_->IsFont(font)); + ASSERT_EQ(PP_TRUE, ppb_truetype_font_interface_->IsTrueTypeFont(font)); ppb_core_interface_->ReleaseResource(font); // Once released, the resource shouldn't be a font. - ASSERT_NE(PP_TRUE, ppb_truetype_font_interface_->IsFont(font)); + ASSERT_NE(PP_TRUE, ppb_truetype_font_interface_->IsTrueTypeFont(font)); PASS(); } diff --git a/ppapi/thunk/ppb_truetype_font_thunk.cc b/ppapi/thunk/ppb_truetype_font_dev_thunk.cc index 4b47afb..610914a 100644 --- a/ppapi/thunk/ppb_truetype_font_thunk.cc +++ b/ppapi/thunk/ppb_truetype_font_dev_thunk.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// From dev/ppb_truetype_font_dev.idl modified Wed Apr 10 11:59:27 2013. + #include "ppapi/c/dev/ppb_truetype_font_dev.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" @@ -19,31 +21,37 @@ namespace thunk { namespace { int32_t GetFontFamilies(PP_Instance instance, - PP_ArrayOutput output, - PP_CompletionCallback callback) { + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TrueTypeFont_Dev::GetFontFamilies()"; EnterInstanceAPI<PPB_TrueTypeFont_Singleton_API> enter(instance, callback); if (enter.failed()) - return PP_ERROR_FAILED; - return enter.SetResult( - enter.functions()->GetFontFamilies(instance, output, enter.callback())); + return enter.retval(); + return enter.SetResult(enter.functions()->GetFontFamilies( + instance, + output, + enter.callback())); } PP_Resource Create(PP_Instance instance, - const PP_TrueTypeFontDesc_Dev* desc) { + const struct PP_TrueTypeFontDesc_Dev* desc) { + VLOG(4) << "PPB_TrueTypeFont_Dev::Create()"; EnterResourceCreation enter(instance); if (enter.failed()) return 0; - return enter.functions()->CreateTrueTypeFont(instance, *desc); + return enter.functions()->CreateTrueTypeFont(instance, desc); } -PP_Bool IsFont(PP_Resource resource) { +PP_Bool IsTrueTypeFont(PP_Resource resource) { + VLOG(4) << "PPB_TrueTypeFont_Dev::IsTrueTypeFont()"; EnterResource<PPB_TrueTypeFont_API> enter(resource, false); return PP_FromBool(enter.succeeded()); } int32_t Describe(PP_Resource font, - PP_TrueTypeFontDesc_Dev* desc, - PP_CompletionCallback callback) { + struct PP_TrueTypeFontDesc_Dev* desc, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TrueTypeFont_Dev::Describe()"; EnterResource<PPB_TrueTypeFont_API> enter(font, callback, true); if (enter.failed()) return enter.retval(); @@ -51,8 +59,9 @@ int32_t Describe(PP_Resource font, } int32_t GetTableTags(PP_Resource font, - PP_ArrayOutput output, - PP_CompletionCallback callback) { + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TrueTypeFont_Dev::GetTableTags()"; EnterResource<PPB_TrueTypeFont_API> enter(font, callback, true); if (enter.failed()) return enter.retval(); @@ -64,8 +73,9 @@ int32_t GetTable(PP_Resource font, uint32_t table, int32_t offset, int32_t max_data_length, - PP_ArrayOutput output, - PP_CompletionCallback callback) { + struct PP_ArrayOutput output, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_TrueTypeFont_Dev::GetTable()"; EnterResource<PPB_TrueTypeFont_API> enter(font, callback, true); if (enter.failed()) return enter.retval(); @@ -76,10 +86,10 @@ int32_t GetTable(PP_Resource font, enter.callback())); } -const PPB_TrueTypeFont_Dev_0_1 g_ppb_truetypefont_thunk_0_1 = { +const PPB_TrueTypeFont_Dev_0_1 g_ppb_truetypefont_dev_thunk_0_1 = { &GetFontFamilies, &Create, - &IsFont, + &IsTrueTypeFont, &Describe, &GetTableTags, &GetTable @@ -88,7 +98,7 @@ const PPB_TrueTypeFont_Dev_0_1 g_ppb_truetypefont_thunk_0_1 = { } // namespace const PPB_TrueTypeFont_Dev_0_1* GetPPB_TrueTypeFont_Dev_0_1_Thunk() { - return &g_ppb_truetypefont_thunk_0_1; + return &g_ppb_truetypefont_dev_thunk_0_1; } } // namespace thunk diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 258ce7a..cd9a8ff 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -86,7 +86,7 @@ class ResourceCreationAPI { uint32_t size) = 0; virtual PP_Resource CreateTrueTypeFont( PP_Instance instance, - const PP_TrueTypeFontDesc_Dev& desc) = 0; + const PP_TrueTypeFontDesc_Dev* desc) = 0; virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; virtual PP_Resource CreateURLRequestInfo( PP_Instance instance) = 0; |