diff options
author | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 14:45:44 +0000 |
---|---|---|
committer | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 14:45:44 +0000 |
commit | 6f2e3919c4709404d8d7b6742f9cd9989b799c98 (patch) | |
tree | 55a933f7e2988625f0f3ded5a562203c7e3921c9 | |
parent | 79ba2d8a26fe6c9b343c57fef57896a90baa3878 (diff) | |
download | chromium_src-6f2e3919c4709404d8d7b6742f9cd9989b799c98.zip chromium_src-6f2e3919c4709404d8d7b6742f9cd9989b799c98.tar.gz chromium_src-6f2e3919c4709404d8d7b6742f9cd9989b799c98.tar.bz2 |
Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on Windows). This includes changing bool to PP_Bool and adding a PP_INLINE macro.
TEST=tests/test_c_includes.c
BUG=59791,53451
The first patch set is a straight copy of http://codereview.chromium.org/4019010/show which got LGTMed when PPAPI was in its own repo, but had to be rolled back in order to include chrome changes.
IMPORTANT: This change will break plugin implementations that use the C interface, and might break others as well.
Review URL: http://codereview.chromium.org/4310002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65200 0039d316-1c4b-4281-b951-d872f2087c98
100 files changed, 1150 insertions, 735 deletions
diff --git a/ppapi/c/dev/deprecated_bool.h b/ppapi/c/dev/deprecated_bool.h new file mode 100644 index 0000000..327700f --- /dev/null +++ b/ppapi/c/dev/deprecated_bool.h @@ -0,0 +1,43 @@ +// Copyright (c) 2010 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. + +#ifndef PPAPI_C_DEV_DEPRECATED_BOOL_H_ +#define PPAPI_C_DEV_DEPRECATED_BOOL_H_ + +/** + * @file + * Defines the API ... + * + * @addtogroup PP + * @{ + */ +// TODO(ppapi authors): Remove ppp_class_deprecated.h and ppb_var_deprecated.h +// and remove this file. This is only here to ease the transition from +// deprecated interfaces to the new ones. Add a usable definition of bool for +// C code. +#if !defined(__cplusplus) +# if defined(_MSC_VER) || !defined(__STDC_VERSION__) || \ + (__STDC_VERSION__ < 199901L) +// The Visual Studio C compiler and older versions of GCC do not support C99 +// and thus have no bool or stdbool.h. Make a simple definition of bool, +// true, and false to make this deprecated interface compile in C. Force it +// to 1 byte to have some chance of ABI compatibility between C and C++, in +// case we don't remove this. +typedef char bool; +# define false 0 +# define true 1 +# else +// In C99-compliant compilers, we can include stdbool.h to get a bool +// definition. +# include <stdbool.h> +# endif +#endif + +/** + * @} + * End addtogroup PP + */ + +#endif // PPAPI_C_DEV_DEPRECATED_BOOL_H_ + diff --git a/ppapi/c/dev/pp_video_dev.h b/ppapi/c/dev/pp_video_dev.h index 92b9f37..c141a85 100644 --- a/ppapi/c/dev/pp_video_dev.h +++ b/ppapi/c/dev/pp_video_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PP_VIDEO_DEV_H_ #define PPAPI_C_DEV_PP_VIDEO_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -245,9 +246,9 @@ struct PP_VideoUncompressedDataBuffer_Dev { // Output from decoder, indicating the decoded frame has error pixels. This // could be resulted from corrupted input bit stream and error concealment - // in decoding. + // in decoding. PP_TRUE indicates error. // TODO(wjia): add more info about error pixels, such as error MB map, etc. - bool has_error; + PP_Bool error; }; // Plugin callback for decoder to deliver decoded frame buffers. @@ -274,7 +275,7 @@ typedef void (*PP_VideoDecodeInputCallback_Func_Dev)( // data1 is type of PP_Rect*, data2 is ignored; typedef void (*PP_VideoDecodeEventHandler_Func_Dev)( PP_Instance instance, - PP_VideoDecoderEvent_Dev event, + enum PP_VideoDecoderEvent_Dev event, PP_VideoDecodeData_Dev data1, PP_VideoDecodeData_Dev data2); diff --git a/ppapi/c/dev/ppb_audio_config_dev.h b/ppapi/c/dev/ppb_audio_config_dev.h index 01079a9..780d768 100644 --- a/ppapi/c/dev/ppb_audio_config_dev.h +++ b/ppapi/c/dev/ppb_audio_config_dev.h @@ -5,11 +5,12 @@ #ifndef PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_ #define PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" -#define PPB_AUDIO_CONFIG_DEV_INTERFACE "PPB_AudioConfig(Dev);0.2" +#define PPB_AUDIO_CONFIG_DEV_INTERFACE "PPB_AudioConfig(Dev);0.3" enum { PP_AUDIOMINSAMPLEFRAMECOUNT = 64, @@ -74,7 +75,7 @@ struct PPB_AudioConfig_Dev { /** * Returns true if the given resource is an AudioConfig object. */ - bool (*IsAudioConfig)(PP_Resource resource); + PP_Bool (*IsAudioConfig)(PP_Resource resource); /** * Returns the sample rate for the given AudioConfig resource. If the @@ -91,4 +92,3 @@ struct PPB_AudioConfig_Dev { }; #endif // PPAPI_C_DEV_PPB_AUDIO_CONFIG_DEV_H_ - diff --git a/ppapi/c/dev/ppb_audio_dev.h b/ppapi/c/dev/ppb_audio_dev.h index cc567414..667371c 100644 --- a/ppapi/c/dev/ppb_audio_dev.h +++ b/ppapi/c/dev/ppb_audio_dev.h @@ -5,12 +5,13 @@ #ifndef PPAPI_C_DEV_PPB_AUDIO_DEV_H_ #define PPAPI_C_DEV_PPB_AUDIO_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" -#define PPB_AUDIO_DEV_INTERFACE "PPB_Audio(Dev);0.2" +#define PPB_AUDIO_DEV_INTERFACE "PPB_Audio(Dev);0.3" // Callback function type for SetCallback. typedef void (*PPB_Audio_Callback)(void* sample_buffer, @@ -49,23 +50,23 @@ struct PPB_Audio_Dev { PPB_Audio_Callback audio_callback, void* user_data); /** - * Returns true if the given resource is an Audio resource. + * Returns PP_TRUE if the given resource is an Audio resource, PP_FALSE + * otherwise. */ - bool (*IsAudio)(PP_Resource resource); + PP_Bool (*IsAudio)(PP_Resource resource); // Get the current configuration. PP_Resource (*GetCurrentConfig)(PP_Resource audio); // Start the playback. Begin periodically calling the callback. If called - // while playback is already in progress, will return true and be a no-op. - // On error, return false. - bool (*StartPlayback)(PP_Resource audio); + // while playback is already in progress, will return PP_TRUE and be a no-op. + // On error, return PP_FALSE. + PP_Bool (*StartPlayback)(PP_Resource audio); // Stop the playback. If playback is already stopped, this is a no-op and - // returns true. On error, returns false. If a callback is in progress, + // returns PP_TRUE. On error, returns PP_FALSE. If a callback is in progress, // StopPlayback will block until callback completes. - bool (*StopPlayback)(PP_Resource audio); + PP_Bool (*StopPlayback)(PP_Resource audio); }; #endif // PPAPI_C_DEV_PPB_DEVICE_CONTEXT_AUDIO_DEV_H_ - diff --git a/ppapi/c/dev/ppb_buffer_dev.h b/ppapi/c/dev/ppb_buffer_dev.h index 416ab0b..cf43aa6 100644 --- a/ppapi/c/dev/ppb_buffer_dev.h +++ b/ppapi/c/dev/ppb_buffer_dev.h @@ -5,11 +5,12 @@ #ifndef PPAPI_C_DEV_PPB_BUFFER_DEV_H_ #define PPAPI_C_DEV_PPB_BUFFER_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" -#define PPB_BUFFER_DEV_INTERFACE "PPB_Buffer(Dev);0.1" +#define PPB_BUFFER_DEV_INTERFACE "PPB_Buffer(Dev);0.2" struct PPB_Buffer_Dev { // Allocates a buffer of the given size in bytes. The return value will have @@ -17,13 +18,13 @@ struct PPB_Buffer_Dev { // handle was invalid. The buffer will be initialized to contain zeroes. PP_Resource (*Create)(PP_Module module, int32_t size_in_bytes); - // Returns true if the given resource is a Buffer. Returns false if the + // Returns PP_TRUE if the given resource is a Buffer. Returns PP_FALSE if the // resource is invalid or some type other than a Buffer. - bool (*IsBuffer)(PP_Resource resource); + PP_Bool (*IsBuffer)(PP_Resource resource); - // Gets the size of the buffer. Returns true on success, false + // Gets the size of the buffer. Returns PP_TRUE on success, PP_FALSE // if the resource is not a buffer. On failure, |*size_in_bytes| is not set. - bool (*Describe)(PP_Resource resource, int32_t* size_in_bytes); + PP_Bool (*Describe)(PP_Resource resource, int32_t* size_in_bytes); // Maps this buffer into the plugin address space and returns a pointer to the // beginning of the data. @@ -33,4 +34,3 @@ struct PPB_Buffer_Dev { }; #endif // PPAPI_C_DEV_PPB_BUFFER_DEV_H_ - diff --git a/ppapi/c/dev/ppb_char_set_dev.h b/ppapi/c/dev/ppb_char_set_dev.h index 382e1a8..9b9d8e5 100644 --- a/ppapi/c/dev/ppb_char_set_dev.h +++ b/ppapi/c/dev/ppb_char_set_dev.h @@ -9,7 +9,7 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_CHAR_SET_DEV_INTERFACE "PPB_CharSet(Dev);0.1" +#define PPB_CHAR_SET_DEV_INTERFACE "PPB_CharSet(Dev);0.2" // Specifies the error behavior for the character set conversion functions. // This will affect two cases: where the input is not encoded correctly, and @@ -50,7 +50,7 @@ struct PPB_CharSet_Dev { // set was unknown. char* (*UTF16ToCharSet)(const uint16_t* utf16, uint32_t utf16_len, const char* output_char_set, - PP_CharSet_ConversionError on_error, + enum PP_CharSet_ConversionError on_error, uint32_t* output_length); // Same as UTF16ToCharSet except converts in the other direction. The input @@ -63,7 +63,7 @@ struct PPB_CharSet_Dev { // is incorrect. uint16_t* (*CharSetToUTF16)(const char* input, uint32_t input_len, const char* input_char_set, - PP_CharSet_ConversionError on_error, + enum PP_CharSet_ConversionError on_error, uint32_t* output_length); // Returns a string var representing the current multi-byte character set of @@ -72,7 +72,7 @@ struct PPB_CharSet_Dev { // WARNING: You really shouldn't be using this function unless you're dealing // with legacy data. You should be using UTF-8 or UTF-16 and you don't have // to worry about the character sets. - PP_Var (*GetDefaultCharSet)(PP_Module module); + struct PP_Var (*GetDefaultCharSet)(PP_Module module); }; #endif // PPAPI_C_DEV_PPB_CHAR_SET_DEV_H_ diff --git a/ppapi/c/dev/ppb_cursor_control_dev.h b/ppapi/c/dev/ppb_cursor_control_dev.h index 7a38767..45b37e2 100644 --- a/ppapi/c/dev/ppb_cursor_control_dev.h +++ b/ppapi/c/dev/ppb_cursor_control_dev.h @@ -5,21 +5,22 @@ #ifndef PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_ #define PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/dev/pp_cursor_type_dev.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_resource.h" -#define PPB_CURSOR_CONTROL_DEV_INTERFACE "PPB_CursorControl(Dev);0.1" +#define PPB_CURSOR_CONTROL_DEV_INTERFACE "PPB_CursorControl(Dev);0.2" struct PPB_CursorControl_Dev { // Set a cursor. If "type" is PP_CURSOR_TYPE_CUSTOM, then "custom_image" // must be an ImageData resource containing the cursor and "hot_spot" must // contain the offset within that image that refers to the cursor's position. - bool (*SetCursor)(PP_Instance instance, - enum PP_CursorType_Dev type, - PP_Resource custom_image, - const struct PP_Point* hot_spot); + PP_Bool (*SetCursor)(PP_Instance instance, + enum PP_CursorType_Dev type, + PP_Resource custom_image, + const struct PP_Point* hot_spot); // This method causes the cursor to be moved to the center of the // instance and be locked, preventing the user from moving it. @@ -38,19 +39,18 @@ struct PPB_CursorControl_Dev { // another program via a reserved keystroke (e.g., ALT+TAB), or // some other system event. // - // Returns true if the cursor could be locked. - bool (*LockCursor)(PP_Instance); + // Returns PP_TRUE if the cursor could be locked, PP_FALSE otherwise. + PP_Bool (*LockCursor)(PP_Instance); // Causes the cursor to be unlocked, allowing it to track user // movement again. - bool (*UnlockCursor)(PP_Instance); + PP_Bool (*UnlockCursor)(PP_Instance); - // Returns true if the cursor is locked. - bool (*HasCursorLock)(PP_Instance); + // Returns PP_TRUE if the cursor is locked, PP_FALSE otherwise. + PP_Bool (*HasCursorLock)(PP_Instance); - // Returns true if the cursor can be locked. - bool (*CanLockCursor)(PP_Instance); + // Returns PP_TRUE if the cursor can be locked, PP_FALSE otherwise. + PP_Bool (*CanLockCursor)(PP_Instance); }; #endif // PPAPI_C_DEV_PPB_CURSOR_CONTROL_DEV_H_ - diff --git a/ppapi/c/dev/ppb_directory_reader_dev.h b/ppapi/c/dev/ppb_directory_reader_dev.h index 84983f5..2b86b9b 100644 --- a/ppapi/c/dev/ppb_directory_reader_dev.h +++ b/ppapi/c/dev/ppb_directory_reader_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_ #define PPAPI_C_DEV_PPB_DIRECTORY_READER_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/dev/pp_file_info_dev.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" @@ -16,7 +17,7 @@ struct PP_DirectoryEntry_Dev { PP_FileType_Dev file_type; }; -#define PPB_DIRECTORYREADER_DEV_INTERFACE "PPB_DirectoryReader(Dev);0.1" +#define PPB_DIRECTORYREADER_DEV_INTERFACE "PPB_DirectoryReader(Dev);0.2" struct PPB_DirectoryReader_Dev { // Creates a DirectoryReader for the given directory. Upon success, the @@ -25,9 +26,10 @@ struct PPB_DirectoryReader_Dev { // destroyed. PP_Resource (*Create)(PP_Resource directory_ref); - // Returns true if the given resource is a DirectoryReader. Returns false if - // the resource is invalid or some type other than a DirectoryReader. - bool (*IsDirectoryReader)(PP_Resource resource); + // Returns PP_TRUE if the given resource is a DirectoryReader. Returns + // PP_FALSE if the resource is invalid or some type other than a + // DirectoryReader. + PP_Bool (*IsDirectoryReader)(PP_Resource resource); // Reads the next entry in the directory. Return PP_OK and sets // entry->file_ref to 0 to indicate reaching the end of the directory. If diff --git a/ppapi/c/dev/ppb_file_chooser_dev.h b/ppapi/c/dev/ppb_file_chooser_dev.h index d5b06faa..c1cef4e 100644 --- a/ppapi/c/dev/ppb_file_chooser_dev.h +++ b/ppapi/c/dev/ppb_file_chooser_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ #define PPAPI_C_DEV_PPB_FILE_CHOOSER_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -27,7 +28,7 @@ struct PP_FileChooserOptions_Dev { const char* accept_mime_types; }; -#define PPB_FILECHOOSER_DEV_INTERFACE "PPB_FileChooser(Dev);0.1" +#define PPB_FILECHOOSER_DEV_INTERFACE "PPB_FileChooser(Dev);0.2" struct PPB_FileChooser_Dev { // Creates a file chooser dialog with the specified options. The chooser is @@ -37,9 +38,9 @@ struct PPB_FileChooser_Dev { PP_Resource (*Create)(PP_Instance instance, const struct PP_FileChooserOptions_Dev* options); - // Returns true if the given resource is a FileChooser. Returns false if the - // resource is invalid or some type other than a FileChooser. - bool (*IsFileChooser)(PP_Resource resource); + // Returns PP_TRUE if the given resource is a FileChooser. Returns PP_FALSE + // if the resource is invalid or some type other than a FileChooser. + PP_Bool (*IsFileChooser)(PP_Resource resource); // Prompts the user to choose a file or files. int32_t (*Show)(PP_Resource chooser, struct PP_CompletionCallback callback); diff --git a/ppapi/c/dev/ppb_file_io_dev.h b/ppapi/c/dev/ppb_file_io_dev.h index 1dfefd1..b69e005 100644 --- a/ppapi/c/dev/ppb_file_io_dev.h +++ b/ppapi/c/dev/ppb_file_io_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ #define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -36,16 +37,16 @@ typedef enum { PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4 } PP_FileOpenFlags_Dev; -#define PPB_FILEIO_DEV_INTERFACE "PPB_FileIO(Dev);0.1" +#define PPB_FILEIO_DEV_INTERFACE "PPB_FileIO(Dev);0.2" // Use this interface to operate on a regular file (PP_FileType_Regular). struct PPB_FileIO_Dev { // Creates a new FileIO object. Returns 0 if the module is invalid. PP_Resource (*Create)(PP_Module module); - // Returns true if the given resource is a FileIO. Returns false if the + // Returns PP_TRUE if the given resource is a FileIO. Returns PP_FALSE if the // resource is invalid or some type other than a FileIO. - bool (*IsFileIO)(PP_Resource resource); + PP_Bool (*IsFileIO)(PP_Resource resource); // Open the specified regular file for I/O according to the given open flags, // which is a bit-mask of the PP_FileOpenFlags values. Upon success, the @@ -59,7 +60,7 @@ struct PPB_FileIO_Dev { // Queries info about the file opened by this FileIO object. Fails if the // FileIO object has not been opened. int32_t (*Query)(PP_Resource file_io, - PP_FileInfo_Dev* info, + struct PP_FileInfo_Dev* info, struct PP_CompletionCallback callback); // Updates timestamps for the file opened by this FileIO object. Fails if diff --git a/ppapi/c/dev/ppb_file_ref_dev.h b/ppapi/c/dev/ppb_file_ref_dev.h index fd3a602..d1ffca6 100644 --- a/ppapi/c/dev/ppb_file_ref_dev.h +++ b/ppapi/c/dev/ppb_file_ref_dev.h @@ -5,12 +5,13 @@ #ifndef PPAPI_C_DEV_PPB_FILE_REF_DEV_H_ #define PPAPI_C_DEV_PPB_FILE_REF_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/dev/pp_file_info_dev.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" -#define PPB_FILEREF_DEV_INTERFACE "PPB_FileRef(Dev);0.2" +#define PPB_FILEREF_DEV_INTERFACE "PPB_FileRef(Dev);0.3" // A FileRef is a "weak pointer" to a file in a file system. It contains a // PP_FileSystemType identifier and a file path string. @@ -19,9 +20,9 @@ struct PPB_FileRef_Dev { // POSIX style. Returns 0 if the path is malformed. PP_Resource (*Create)(PP_Resource file_system, const char* path); - // Returns true if the given resource is a FileRef. Returns false if the + // Returns PP_TRUE if the given resource is a FileRef. Returns PP_FALSE if the // resource is invalid or some type other than a FileRef. - bool (*IsFileRef)(PP_Resource resource); + PP_Bool (*IsFileRef)(PP_Resource resource); // Returns the file system identifier of this file. PP_FileSystemType_Dev (*GetFileSystemType)(PP_Resource file_ref); @@ -39,12 +40,12 @@ struct PPB_FileRef_Dev { PP_Resource (*GetParent)(PP_Resource file_ref); // Makes a new directory in the filesystem as well as any parent directories - // if the make_ancestors parameter is true. It is not valid to make a + // if the make_ancestors parameter is PP_TRUE. It is not valid to make a // directory in the external filesystem. Fails if the directory already // exists or if ancestor directories do not exist and make_ancestors was not - // passed as true. + // passed as PP_TRUE. int32_t (*MakeDirectory)(PP_Resource directory_ref, - bool make_ancestors, + PP_Bool make_ancestors, struct PP_CompletionCallback callback); // Queries info about the file. You must have read access to this file if it diff --git a/ppapi/c/dev/ppb_find_dev.h b/ppapi/c/dev/ppb_find_dev.h index ffd7ca8..b74416e 100644 --- a/ppapi/c/dev/ppb_find_dev.h +++ b/ppapi/c/dev/ppb_find_dev.h @@ -5,19 +5,20 @@ #ifndef PPAPI_C_DEV_PPB_FIND_DEV_H_ #define PPAPI_C_DEV_PPB_FIND_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" -#define PPB_FIND_DEV_INTERFACE "PPB_Find(Dev);0.1" +#define PPB_FIND_DEV_INTERFACE "PPB_Find(Dev);0.2" struct PPB_Find_Dev { // Updates the number of find results for the current search term. If // there are no matches 0 should be passed in. Only when the plugin has // finished searching should it pass in the final count with finalResult set - // to true. + // to PP_TRUE. void (*NumberOfFindResultsChanged)(PP_Instance instance, int32_t total, - bool final_result); + PP_Bool final_result); // Updates the index of the currently selected search item. void (*SelectedFindResultChanged)(PP_Instance instance, diff --git a/ppapi/c/dev/ppb_font_dev.h b/ppapi/c/dev/ppb_font_dev.h index 48dc91f..9b5902f 100644 --- a/ppapi/c/dev/ppb_font_dev.h +++ b/ppapi/c/dev/ppb_font_dev.h @@ -5,12 +5,13 @@ #ifndef PPAPI_C_DEV_PPB_FONT_DEV_H_ #define PPAPI_C_DEV_PPB_FONT_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.1" +#define PPB_FONT_DEV_INTERFACE "PPB_Font(Dev);0.2" struct PP_Point; struct PP_Rect; @@ -55,8 +56,8 @@ struct PP_FontDescription_Dev { // Normally you will use either PP_FONTWEIGHT_NORMAL or PP_FONTWEIGHT_BOLD. PP_FontWeight_Dev weight; - bool italic; - bool small_caps; + PP_Bool italic; + PP_Bool small_caps; // Adjustment to apply to letter and word spacing, respectively. Initialize // to 0 to get normal spacing. Negative values bring letters/words closer @@ -78,11 +79,12 @@ struct PP_TextRun_Dev { // a 0-length string). struct PP_Var text; - // Set to true if the text is right-to-left. - bool rtl; + // Set to PP_TRUE if the text is right-to-left. + PP_Bool rtl; - // Set to true to force the directionality of the text regardless of content - bool override_direction; + // Set to PP_TRUE to force the directionality of the text regardless of + // content + PP_Bool override_direction; }; struct PPB_Font_Dev { @@ -91,9 +93,9 @@ struct PPB_Font_Dev { PP_Resource (*Create)(PP_Module module, const struct PP_FontDescription_Dev* description); - // Returns true if the given resource is a Font. Returns false if the + // Returns PP_TRUE if the given resource is a Font. Returns PP_FALSE if the // resource is invalid or some type other than a Font. - bool (*IsFont)(PP_Resource resource); + PP_Bool (*IsFont)(PP_Resource resource); // Loads the description and metrics of the font into the given structures. // The description will be different than the description the font was @@ -104,11 +106,11 @@ struct PPB_Font_Dev { // this will contain the string and will have a reference count of 1. The // plugin is responsible for calling Release on this var. // - // Returns true on success, false if the font is invalid or if the Var in - // the description isn't Null (to prevent leaks). - bool (*Describe)(PP_Resource font, - struct PP_FontDescription_Dev* description, - struct PP_FontMetrics_Dev* metrics); + // Returns PP_TRUE on success, PP_FALSE if the font is invalid or if the Var + // in the description isn't Null (to prevent leaks). + PP_Bool (*Describe)(PP_Resource font, + struct PP_FontDescription_Dev* description, + struct PP_FontMetrics_Dev* metrics); // Draws the text to the image buffer. // @@ -121,18 +123,18 @@ struct PPB_Font_Dev { // // The image_data_is_opaque flag indicates whether subpixel antialiasing can // be performend, if it is supported. When the image below the text is - // opaque, subpixel antialiasing is supported and you should set this to true - // to pick up the user's default preferences. If your plugin is partially - // transparent, then subpixel antialiasing is not possible and grayscale - // antialiasing will be used instead (assuming the user has antialiasing - // enabled at all). - bool (*DrawTextAt)(PP_Resource font, - PP_Resource image_data, - const struct PP_TextRun_Dev* text, - const struct PP_Point* position, - uint32_t color, - const struct PP_Rect* clip, - bool image_data_is_opaque); + // opaque, subpixel antialiasing is supported and you should set this to + // PP_TRUE to pick up the user's default preferences. If your plugin is + // partially transparent, then subpixel antialiasing is not possible and + // grayscale antialiasing will be used instead (assuming the user has + // antialiasing enabled at all). + PP_Bool (*DrawTextAt)(PP_Resource font, + PP_Resource image_data, + const struct PP_TextRun_Dev* text, + const struct PP_Point* position, + uint32_t color, + const struct PP_Rect* clip, + PP_Bool image_data_is_opaque); // Returns the width of the given string. If the font is invalid or the var // isn't a valid string, this will return -1. diff --git a/ppapi/c/dev/ppb_fullscreen_dev.h b/ppapi/c/dev/ppb_fullscreen_dev.h index 9730b3e..3166eb9 100644 --- a/ppapi/c/dev/ppb_fullscreen_dev.h +++ b/ppapi/c/dev/ppb_fullscreen_dev.h @@ -5,23 +5,24 @@ #ifndef PPAPI_C_DEV_PPB_FULLSCREEN_DEV_H_ #define PPAPI_C_DEV_PPB_FULLSCREEN_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" -#define PPB_FULLSCREEN_DEV_INTERFACE "PPB_Fullscreen(Dev);0.1" +#define PPB_FULLSCREEN_DEV_INTERFACE "PPB_Fullscreen(Dev);0.2" // Use this interface to change a plugin instance to fullscreen mode. struct PPB_Fullscreen_Dev { // Checks whether the plugin instance is currently in fullscreen mode. - bool (*IsFullscreen)(PP_Instance instance); + PP_Bool (*IsFullscreen)(PP_Instance instance); - // Switches the plugin instance to/from fullscreen mode. Returns true on - // success, false on failure. + // Switches the plugin instance to/from fullscreen mode. Returns PP_TRUE on + // success, PP_FALSE on failure. // When in fullscreen mode, the plugin will be transparently scaled to the // size of the screen. It will not receive a ViewChanged event, and doesn't // need to rebind the graphics context. The pending flushes will execute // normally, to the new fullscreen window. - bool (*SetFullscreen)(PP_Instance instance, bool fullscreen); + PP_Bool (*SetFullscreen)(PP_Instance instance, PP_Bool fullscreen); }; #endif // PPAPI_C_DEV_PPB_FULLSCREEN_DEV_H_ diff --git a/ppapi/c/dev/ppb_graphics_3d_dev.h b/ppapi/c/dev/ppb_graphics_3d_dev.h index 142c2f2..27793c1 100644 --- a/ppapi/c/dev/ppb_graphics_3d_dev.h +++ b/ppapi/c/dev/ppb_graphics_3d_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ #define PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" @@ -24,7 +25,7 @@ // // Shutdown. // core->ReleaseResource(context); -#define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.1" +#define PPB_GRAPHICS_3D_DEV_INTERFACE "PPB_Graphics3D(Dev);0.2" // These are the same error codes as used by EGL. enum { @@ -44,21 +45,21 @@ enum { }; struct PPB_Graphics3D_Dev { - bool (*IsGraphics3D)(PP_Resource resource); + PP_Bool (*IsGraphics3D)(PP_Resource resource); // EGL-like configuration ---------------------------------------------------- - bool (*GetConfigs)(int32_t* configs, - int32_t config_size, - int32_t* num_config); + PP_Bool (*GetConfigs)(int32_t* configs, + int32_t config_size, + int32_t* num_config); - bool (*ChooseConfig)(const int32_t* attrib_list, - int32_t* configs, - int32_t config_size, - int32_t* num_config); + PP_Bool (*ChooseConfig)(const int32_t* attrib_list, + int32_t* configs, + int32_t config_size, + int32_t* num_config); // TODO(apatrick): What to do if the browser window is moved to // another display? Do the configs potentially change? - bool (*GetConfigAttrib)(int32_t config, int32_t attribute, int32_t* value); + PP_Bool (*GetConfigAttrib)(int32_t config, int32_t attribute, int32_t* value); const char* (*QueryString)(int32_t name); // --------------------------------------------------------------------------- @@ -77,8 +78,9 @@ struct PPB_Graphics3D_Dev { // Any thread. void* (*GetProcAddress)(const char* name); - // Make a particular context current of the calling thread. - bool (*MakeCurent)(PP_Resource context); + // Make a particular context current of the calling thread. Returns PP_TRUE + // on success, PP_FALSE on failure. + PP_Bool (*MakeCurent)(PP_Resource context); // Returns the calling thread's current context or NULL if no context is // current. @@ -91,7 +93,7 @@ struct PPB_Graphics3D_Dev { // better for correct alpha blending effect. Most existing OpenGL code assumes // linear. I could convert from linear to premultiplied during the copy from // back-buffer to offscreen "front-buffer". - bool (*SwapBuffers)(PP_Resource context); + PP_Bool (*SwapBuffers)(PP_Resource context); // Returns the current error for this thread. This is not associated with a // particular context. It is distinct from the GL error returned by @@ -100,4 +102,3 @@ struct PPB_Graphics3D_Dev { }; #endif // PPAPI_C_DEV_PPB_GRAPHICS_3D_DEV_H_ - diff --git a/ppapi/c/dev/ppb_scrollbar_dev.h b/ppapi/c/dev/ppb_scrollbar_dev.h index 4b365bb..1252673 100644 --- a/ppapi/c/dev/ppb_scrollbar_dev.h +++ b/ppapi/c/dev/ppb_scrollbar_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPB_SCROLLBAR_DEV_H_ #define PPAPI_C_DEV_PPB_SCROLLBAR_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -18,18 +19,18 @@ typedef enum { PP_SCROLLBY_DOCUMENT = 3 } PP_ScrollBy_Dev; -#define PPB_SCROLLBAR_DEV_INTERFACE "PPB_Scrollbar(Dev);0.1" +#define PPB_SCROLLBAR_DEV_INTERFACE "PPB_Scrollbar(Dev);0.2" // The interface for a scrollbar. A scrollbar is a widget, so the functions // in PPB_Widget can also be used with scrollbar objects. struct PPB_Scrollbar_Dev { // Create a new scrollbar. Returns 0 if the instance is invalid. PP_Resource (*Create)(PP_Instance instance, - bool vertical); + PP_Bool vertical); - // Returns true if the given resource is a Scrollbar. Returns false if the - // resource is invalid or some type other than a scrollbar. - bool (*IsScrollbar)(PP_Resource resource); + // Returns PP_TRUE if the given resource is a Scrollbar. Returns PP_FALSE if + // the resource is invalid or some type other than a scrollbar. + PP_Bool (*IsScrollbar)(PP_Resource resource); // Gets the thickness of a scrollbar. uint32_t (*GetThickness)(); diff --git a/ppapi/c/dev/ppb_testing_dev.h b/ppapi/c/dev/ppb_testing_dev.h index 16c2bd4..5606ca6 100644 --- a/ppapi/c/dev/ppb_testing_dev.h +++ b/ppapi/c/dev/ppb_testing_dev.h @@ -5,13 +5,14 @@ #ifndef PPAPI_C_DEV_PPB_TESTING_DEV_H_ #define PPAPI_C_DEV_PPB_TESTING_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" struct PP_Point; -#define PPB_TESTING_DEV_INTERFACE "PPB_Testing(Dev);0.2" +#define PPB_TESTING_DEV_INTERFACE "PPB_Testing(Dev);0.3" // This interface contains functions used for unit testing. Do not use in // production code. They are not guaranteed to be available in normal plugin @@ -19,7 +20,7 @@ struct PP_Point; struct PPB_Testing_Dev { // Reads the bitmap data out of the backing store for the given // DeviceContext2D and into the given image. If the data was successfully - // read, it will return true. + // read, it will return PP_TRUE. // // This function should not generally be necessary for normal plugin // operation. If you want to update portions of a device, the expectation is @@ -33,20 +34,20 @@ struct PPB_Testing_Dev { // context, and proceeding down and to the right for as many pixels as the // image is large. If any part of the image bound would fall outside of the // backing store of the device if positioned at |top_left|, this function - // will fail and return false. + // will fail and return PP_FALSE. // // The image format must be of the format // PPB_ImageData.GetNativeImageDataFormat() or this function will fail and - // return false. + // return PP_FALSE. // // The returned image data will represent the current status of the backing // store. This will not include any paint, scroll, or replace operations // that have not yet been flushed; these operations are only reflected in // the backing store (and hence ReadImageData) until after a Flush() // operation has completed. - bool (*ReadImageData)(PP_Resource device_context_2d, - PP_Resource image, - const struct PP_Point* top_left); + PP_Bool (*ReadImageData)(PP_Resource device_context_2d, + PP_Resource image, + const struct PP_Point* top_left); // Runs a nested message loop. The plugin will be reentered from this call. // This function is used for unit testing the API. The normal pattern is to diff --git a/ppapi/c/dev/ppb_transport_dev.h b/ppapi/c/dev/ppb_transport_dev.h index 821557d..fd96a22 100644 --- a/ppapi/c/dev/ppb_transport_dev.h +++ b/ppapi/c/dev/ppb_transport_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PPB_TRANSPORT_DEV_H_ #define PPAPI_C_PPB_TRANSPORT_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_instance.h" @@ -12,7 +13,7 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_TRANSPORT_DEV_INTERFACE "PPB_Transport;0.1" +#define PPB_TRANSPORT_DEV_INTERFACE "PPB_Transport;0.2" struct PPB_Transport_Dev { // Creates a new transport object with the specified name @@ -21,12 +22,12 @@ struct PPB_Transport_Dev { const char* name, const char* proto); - // Returns whether or not resource is a Transport - bool (*IsTransport)(PP_Resource resource); + // Returns PP_TRUE if resource is a Transport, PP_FALSE otherwise. + PP_Bool (*IsTransport)(PP_Resource resource); - // Returns whether the transport is currently writable - // (i.e. can send data to the remote peer) - bool (*IsWritable)(PP_Resource transport); + // Returns PP_TRUE if the transport is currently writable + // (i.e. can send data to the remote peer), PP_FALSE otherwise. + PP_Bool (*IsWritable)(PP_Resource transport); // TODO(juberti): other getters/setters // connect state // connect type, protocol @@ -36,35 +37,34 @@ struct PPB_Transport_Dev { // Returns PP_ERROR_WOULDBLOCK and notifies on |cb| // when connectivity is established (or timeout occurs). int32_t (*Connect)(PP_Resource transport, - PP_CompletionCallback cb); + struct PP_CompletionCallback cb); // Obtains another ICE candidate address to be provided // to the remote peer. Returns PP_ERROR_WOULDBLOCK // if there are no more addresses to be sent. int32_t (*GetNextAddress)(PP_Resource transport, - PP_Var* address, - PP_CompletionCallback cb); + struct PP_Var* address, + struct PP_CompletionCallback cb); // Provides an ICE candidate address that was received // from the remote peer. int32_t (*ReceiveRemoteAddress)(PP_Resource transport, - PP_Var address); + struct PP_Var address); // Like recv(), receives data. Returns PP_ERROR_WOULDBLOCK // if there is currently no data to receive. int32_t (*Recv)(PP_Resource transport, void* data, uint32_t len, - PP_CompletionCallback cb); + struct PP_CompletionCallback cb); // Like send(), sends data. Returns PP_ERROR_WOULDBLOCK // if the socket is currently flow-controlled. int32_t (*Send)(PP_Resource transport, const void* data, uint32_t len, - PP_CompletionCallback cb); + struct PP_CompletionCallback cb); // Disconnects from the remote peer. int32_t (*Close)(PP_Resource transport); }; #endif // PPAPI_C_PPB_TRANSPORT_DEV_H_ - diff --git a/ppapi/c/dev/ppb_url_loader_dev.h b/ppapi/c/dev/ppb_url_loader_dev.h index 9d63b31..c0c5fff 100644 --- a/ppapi/c/dev/ppb_url_loader_dev.h +++ b/ppapi/c/dev/ppb_url_loader_dev.h @@ -5,13 +5,14 @@ #ifndef PPAPI_C_DEV_PPB_URL_LOADER_DEV_H_ #define PPAPI_C_DEV_PPB_URL_LOADER_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" struct PP_CompletionCallback; -#define PPB_URLLOADER_DEV_INTERFACE "PPB_URLLoader(Dev);0.1" +#define PPB_URLLOADER_DEV_INTERFACE "PPB_URLLoader(Dev);0.2" // The interface for loading URLs. // @@ -35,9 +36,9 @@ struct PPB_URLLoader_Dev { // know the origin of the URL request. PP_Resource (*Create)(PP_Instance instance); - // Returns true if the given resource is an URLLoader. Returns false if the - // resource is invalid or some type other than an URLLoader. - bool (*IsURLLoader)(PP_Resource resource); + // Returns PP_TRUE if the given resource is an URLLoader. Returns PP_FALSE if + // the resource is invalid or some type other than an URLLoader. + PP_Bool (*IsURLLoader)(PP_Resource resource); // Begins loading the URLRequestInfo. Completes when response headers are // received or when an error occurs. Use the GetResponseInfo method to @@ -56,26 +57,26 @@ struct PPB_URLLoader_Dev { // the headers. // // This data is only available if the URLRequestInfo passed to Open() had the - // PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS flag set to true. + // PP_URLREQUESTPROPERTY_REPORTUPLOADPROGRESS flag set to PP_TRUE. // - // This method returns false if upload progress is not available. - bool (*GetUploadProgress)(PP_Resource loader, - int64_t* bytes_sent, - int64_t* total_bytes_to_be_sent); + // This method returns PP_FALSE if upload progress is not available. + PP_Bool (*GetUploadProgress)(PP_Resource loader, + int64_t* bytes_sent, + int64_t* total_bytes_to_be_sent); // Returns the current download progress, which is meaningful after Open has // been called. Progress only refers to the response body and does not // include the headers. // // This data is only available if the URLRequestInfo passed to Open() had the - // PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS flag set to true. + // PP_URLREQUESTPROPERTY_REPORTDOWNLOADPROGRESS flag set to PP_TRUE. // // The total bytes to be received may be unknown, in which case - // total_bytes_to_be_received will be set to -1. This method returns false if - // download progress is not available. - bool (*GetDownloadProgress)(PP_Resource loader, - int64_t* bytes_received, - int64_t* total_bytes_to_be_received); + // total_bytes_to_be_received will be set to -1. This method returns PP_FALSE + // if download progress is not available. + PP_Bool (*GetDownloadProgress)(PP_Resource loader, + int64_t* bytes_received, + int64_t* total_bytes_to_be_received); // Returns the current URLResponseInfo object. PP_Resource (*GetResponseInfo)(PP_Resource loader); diff --git a/ppapi/c/dev/ppb_url_request_info_dev.h b/ppapi/c/dev/ppb_url_request_info_dev.h index 9916804..26c6b2e 100644 --- a/ppapi/c/dev/ppb_url_request_info_dev.h +++ b/ppapi/c/dev/ppb_url_request_info_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPB_URL_REQUEST_INFO_DEV_H_ #define PPAPI_C_DEV_PPB_URL_REQUEST_INFO_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -16,47 +17,50 @@ typedef enum { PP_URLREQUESTPROPERTY_URL, // string PP_URLREQUESTPROPERTY_METHOD, // string PP_URLREQUESTPROPERTY_HEADERS, // string, \n-delim - PP_URLREQUESTPROPERTY_STREAMTOFILE, // bool (default=false) - PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, // bool (default=true) + PP_URLREQUESTPROPERTY_STREAMTOFILE, // PP_Bool (default=PP_FALSE) + PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, // PP_Bool (default=PP_TRUE) // Set to true if you want to be able to poll the download progress via the // URLLoader.GetDownloadProgress function. // - // Boolean (default = false). + // Boolean (default = PP_FALSE). PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, // Set to true if you want to be able to pull the upload progress via the // URLLoader.GetUploadProgress function. // - // Boolean (default = false). + // Boolean (default = PP_FALSE). PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS // TODO(darin): Add security/privacy options? } PP_URLRequestProperty_Dev; -#define PPB_URLREQUESTINFO_DEV_INTERFACE "PPB_URLRequestInfo(Dev);0.1" +#define PPB_URLREQUESTINFO_DEV_INTERFACE "PPB_URLRequestInfo(Dev);0.2" struct PPB_URLRequestInfo_Dev { // Create a new URLRequestInfo object. Returns 0 if the module is invalid. PP_Resource (*Create)(PP_Module module); - // Returns true if the given resource is an URLRequestInfo. Returns false if - // the resource is invalid or some type other than an URLRequestInfo. - bool (*IsURLRequestInfo)(PP_Resource resource); + // Returns PP_TRUE if the given resource is an URLRequestInfo. Returns + // PP_FALSE if the resource is invalid or some type other than an + // URLRequestInfo. + PP_Bool (*IsURLRequestInfo)(PP_Resource resource); - // Sets a request property. Returns false if any of the parameters are - // invalid. The value property must be the correct type according to the - // property being set. - bool (*SetProperty)(PP_Resource request, - PP_URLRequestProperty_Dev property, - struct PP_Var value); + // Sets a request property. Returns PP_FALSE if any of the parameters are + // invalid, PP_TRUE on success. The value property must be the correct type + // according to the property being set. + PP_Bool (*SetProperty)(PP_Resource request, + PP_URLRequestProperty_Dev property, + struct PP_Var value); // Append data to the request body. // // A Content-Length request header will be automatically generated. // - // Returns false if any of the parameters are invalid. - bool (*AppendDataToBody)(PP_Resource request, const char* data, uint32_t len); + // Returns PP_FALSE if any of the parameters are invalid, PP_TRUE on success. + PP_Bool (*AppendDataToBody)(PP_Resource request, + const char* data, + uint32_t len); // Append a file reference to be uploaded. // @@ -72,12 +76,12 @@ struct PPB_URLRequestInfo_Dev { // // A Content-Length request header will be automatically generated. // - // Returns false if any of the parameters are invalid. - bool (*AppendFileToBody)(PP_Resource request, - PP_Resource file_ref, - int64_t start_offset, - int64_t number_of_bytes, - PP_Time expected_last_modified_time); + // Returns PP_FALSE if any of the parameters are invalid, PP_TRUE on success. + PP_Bool (*AppendFileToBody)(PP_Resource request, + PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time); }; #endif // PPAPI_C_DEV_PPB_URL_REQUEST_INFO_DEV_H_ diff --git a/ppapi/c/dev/ppb_url_response_info_dev.h b/ppapi/c/dev/ppb_url_response_info_dev.h index 8e3a9e4..e1307f5 100644 --- a/ppapi/c/dev/ppb_url_response_info_dev.h +++ b/ppapi/c/dev/ppb_url_response_info_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPB_URL_RESPONSE_INFO_DEV_H_ #define PPAPI_C_DEV_PPB_URL_RESPONSE_INFO_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" @@ -17,17 +18,18 @@ typedef enum { PP_URLRESPONSEPROPERTY_HEADERS // string, \n-delim } PP_URLResponseProperty_Dev; -#define PPB_URLRESPONSEINFO_DEV_INTERFACE "PPB_URLResponseInfo(Dev);0.1" +#define PPB_URLRESPONSEINFO_DEV_INTERFACE "PPB_URLResponseInfo(Dev);0.2" struct PPB_URLResponseInfo_Dev { - // Returns true if the given resource is an URLResponseInfo. Returns false if - // the resource is invalid or some type other than an URLResponseInfo. - bool (*IsURLResponseInfo)(PP_Resource resource); + // Returns PP_TRUE if the given resource is an URLResponseInfo. Returns + // PP_FALSE if the resource is invalid or some type other than an + // URLResponseInfo. + PP_Bool (*IsURLResponseInfo)(PP_Resource resource); // Gets a response property. Return PP_VarType_Void if an input parameter is // invalid. - PP_Var (*GetProperty)(PP_Resource response, - PP_URLResponseProperty_Dev property); + struct PP_Var (*GetProperty)(PP_Resource response, + PP_URLResponseProperty_Dev property); // Returns a FileRef pointing to the file containing the response body. This // is only valid if PP_URLREQUESTPROPERTY_STREAMTOFILE was set on the diff --git a/ppapi/c/dev/ppb_url_util_dev.h b/ppapi/c/dev/ppb_url_util_dev.h index c16e59d..d557b88 100644 --- a/ppapi/c/dev/ppb_url_util_dev.h +++ b/ppapi/c/dev/ppb_url_util_dev.h @@ -5,11 +5,12 @@ #ifndef PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ #define PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_URLUTIL_DEV_INTERFACE "PPB_UrlUtil(Dev);0.1" +#define PPB_URLUTIL_DEV_INTERFACE "PPB_UrlUtil(Dev);0.2" // A component specifies the range of the part of the URL. The begin specifies // the index into the string of the first character of that component. The len @@ -33,14 +34,14 @@ struct PP_UrlComponent_Dev { }; struct PP_UrlComponents_Dev { - PP_UrlComponent_Dev scheme; - PP_UrlComponent_Dev username; - PP_UrlComponent_Dev password; - PP_UrlComponent_Dev host; - PP_UrlComponent_Dev port; - PP_UrlComponent_Dev path; - PP_UrlComponent_Dev query; - PP_UrlComponent_Dev ref; + struct PP_UrlComponent_Dev scheme; + struct PP_UrlComponent_Dev username; + struct PP_UrlComponent_Dev password; + struct PP_UrlComponent_Dev host; + struct PP_UrlComponent_Dev port; + struct PP_UrlComponent_Dev path; + struct PP_UrlComponent_Dev query; + struct PP_UrlComponent_Dev ref; }; // URL encoding: URLs are supplied to this interface as NULL-terminated 8-bit @@ -91,21 +92,20 @@ struct PPB_UrlUtil_Dev { struct PP_UrlComponents_Dev* components); // Checks whether the given two URLs are in the same security origin. Returns - // false if either of the URLs are invalid. - bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b); + // FALSE if either of the URLs are invalid. + PP_Bool (*IsSameSecurityOrigin)(struct PP_Var url_a, struct PP_Var url_b); // Checks whether the document hosting the given plugin instance can access // the given URL according to the same origin policy of the browser. Returns - // false if the instance or the URL is invalid. - bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url); + // PP_FALSE if the instance or the URL is invalid. + PP_Bool (*DocumentCanRequest)(PP_Instance instance, struct PP_Var url); // Checks whether the document containing the |active| plugin instance can // access the document containing the |target| plugin instance according to // the security policy of the browser. This includes the same origin policy // and any cross-origin capabilities enabled by the document. If either of - // the plugin instances are invalid, returns false. - bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target); + // the plugin instances are invalid, returns PP_FALSE. + PP_Bool (*DocumentCanAccessDocument)(PP_Instance active, PP_Instance target); }; #endif // PPAPI_C_DEV_PPB_URL_UTIL_DEV_H_ - diff --git a/ppapi/c/dev/ppb_var_deprecated.h b/ppapi/c/dev/ppb_var_deprecated.h index 51194b2..e71ba9f 100644 --- a/ppapi/c/dev/ppb_var_deprecated.h +++ b/ppapi/c/dev/ppb_var_deprecated.h @@ -5,13 +5,14 @@ #ifndef PPAPI_C_PPB_VAR_DEPRECATED_H_ #define PPAPI_C_PPB_VAR_DEPRECATED_H_ +#include "ppapi/c/dev/deprecated_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" struct PPP_Class_Deprecated; -#define PPB_VAR_DEPRECATED_INTERFACE "PPB_Var(Deprecated);0.1" +#define PPB_VAR_DEPRECATED_INTERFACE "PPB_Var(Deprecated);0.2" /** * @file @@ -240,4 +241,3 @@ struct PPB_Var_Deprecated { * End addtogroup PPB */ #endif // PPAPI_C_PPB_VAR_DEPRECATED_H_ - diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h index 33274de..842d7ff 100644 --- a/ppapi/c/dev/ppb_video_decoder_dev.h +++ b/ppapi/c/dev/ppb_video_decoder_dev.h @@ -5,13 +5,14 @@ #ifndef PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ #define PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/dev/pp_video_dev.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_completion_callback.h" -#define PPB_VIDEODECODER_DEV_INTERFACE "PPB_VideoDecoder(Dev);0.1" +#define PPB_VIDEODECODER_DEV_INTERFACE "PPB_VideoDecoder(Dev);0.2" struct PPB_VideoDecoder_Dev { // Queries capability of the decoder for |codec|. @@ -25,13 +26,13 @@ struct PPB_VideoDecoder_Dev { // are returned, but the total number of configurations available will be // returned in |num_config|. // - // Returns true on success, false otherwise. + // Returns PP_TRUE on success, PP_FALSE otherwise. // NOTE: browser owns the memory of all PP_VideoConfig's. - bool (*GetConfig)(PP_Instance instance, - PP_VideoCodecId_Dev codec, - PP_VideoConfig_Dev* configs, - int32_t config_size, - int32_t* num_config); + PP_Bool (*GetConfig)(PP_Instance instance, + enum PP_VideoCodecId_Dev codec, + PP_VideoConfig_Dev* configs, + int32_t config_size, + int32_t* num_config); // Creates a video decoder with requested |decoder_config|. // |input_format| in |decoder_config| specifies the format of input access @@ -66,20 +67,20 @@ struct PPB_VideoDecoder_Dev { // provided by plugin during creation of decoder. // The input data buffer is returned to plugin by decoder only when plugin // provides |input_callback|. - // Returns true on decoder successfully accepting buffer, false otherwise. + // Returns PP_TRUE on decoder successfully accepting buffer, PP_FALSE + // otherwise. // - bool (*Decode)(PP_Resource decoder, - struct PP_VideoCompressedDataBuffer_Dev* input_buffer); + PP_Bool (*Decode)(PP_Resource decoder, + struct PP_VideoCompressedDataBuffer_Dev* input_buffer); // Requests the decoder to flush its input and output buffers. Once done with // flushing, the decode will call the |callback|. - int32_t (*Flush)(PP_Resource decoder, - PP_CompletionCallback callback); + int32_t (*Flush)(PP_Resource decoder, struct PP_CompletionCallback callback); // Plugin sends uncompressed data buffers to the decoder. - // Returns true on decoder successfully accepting the buffer, false otherwise. - bool (*ReturnUncompressedDataBuffer)( - PP_Resource decoder, + // Returns PP_TRUE on decoder successfully accepting the buffer, PP_FALSE + // otherwise. + PP_Bool (*ReturnUncompressedDataBuffer)(PP_Resource decoder, struct PP_VideoUncompressedDataBuffer_Dev* buffer); }; diff --git a/ppapi/c/dev/ppb_widget_dev.h b/ppapi/c/dev/ppb_widget_dev.h index 0319b22..3d23e0e 100644 --- a/ppapi/c/dev/ppb_widget_dev.h +++ b/ppapi/c/dev/ppb_widget_dev.h @@ -5,32 +5,34 @@ #ifndef PPAPI_C_DEV_PPB_WIDGET_DEV_H_ #define PPAPI_C_DEV_PPB_WIDGET_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_resource.h" struct PP_Rect; struct PP_InputEvent; -#define PPB_WIDGET_DEV_INTERFACE "PPB_Widget(Dev);0.1" +#define PPB_WIDGET_DEV_INTERFACE "PPB_Widget(Dev);0.2" // The interface for reusing browser widgets. struct PPB_Widget_Dev { - // Returns true if the given resource is a Widget. Returns false if the + // Returns PP_TRUE if the given resource is a Widget. Returns PP_FALSE if the // resource is invalid or some type other than an Widget. - bool (*IsWidget)(PP_Resource resource); + PP_Bool (*IsWidget)(PP_Resource resource); // Paint the given rectangle of the widget into the given image. - // Returns true on success, false on failure - bool (*Paint)(PP_Resource widget, - const struct PP_Rect* rect, - PP_Resource image); + // Returns PP_TRUE on success, PP_FALSE on failure + PP_Bool (*Paint)(PP_Resource widget, + const struct PP_Rect* rect, + PP_Resource image); - // Pass in an event to a widget. It'll return true if the event was consumed. - bool (*HandleEvent)(PP_Resource widget, - const struct PP_InputEvent* event); + // Pass in an event to a widget. It'll return PP_TRUE if the event was + // consumed. + PP_Bool (*HandleEvent)(PP_Resource widget, + const struct PP_InputEvent* event); // Get/set the location of the widget. - bool (*GetLocation)(PP_Resource widget, - struct PP_Rect* location); + PP_Bool (*GetLocation)(PP_Resource widget, + struct PP_Rect* location); void (*SetLocation)(PP_Resource widget, const struct PP_Rect* location); diff --git a/ppapi/c/dev/ppp_class_deprecated.h b/ppapi/c/dev/ppp_class_deprecated.h index d8a1349..2f82348 100644 --- a/ppapi/c/dev/ppp_class_deprecated.h +++ b/ppapi/c/dev/ppp_class_deprecated.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PPP_CLASS_DEPRECATED_H_ #define PPAPI_C_PPP_CLASS_DEPRECATED_H_ +#include "ppapi/c/dev/deprecated_bool.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" @@ -131,4 +132,3 @@ struct PPP_Class_Deprecated { * End addtogroup PPP */ #endif // PPAPI_C_PPP_CLASS_DEPRECATED_H_ - diff --git a/ppapi/c/dev/ppp_find_dev.h b/ppapi/c/dev/ppp_find_dev.h index 98586a3..c20f699 100644 --- a/ppapi/c/dev/ppp_find_dev.h +++ b/ppapi/c/dev/ppp_find_dev.h @@ -5,9 +5,10 @@ #ifndef PPAPI_C_DEV_PPP_FIND_DEV_H_ #define PPAPI_C_DEV_PPP_FIND_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" -#define PPP_FIND_DEV_INTERFACE "PPP_Find(Dev);0.1" +#define PPP_FIND_DEV_INTERFACE "PPP_Find(Dev);0.2" struct PPP_Find_Dev { // Finds the given UTF-8 text starting at the current selection. The number of @@ -15,15 +16,15 @@ struct PPP_Find_Dev { // PPB_Find. Note that multiple StartFind calls can happen before StopFind is // called in the case of the search term changing. // - // Return false if plugin doesn't support find in page. Consequently, it won't - // call any callbacks. - bool (*StartFind)(PP_Instance instance, - const char* text, - bool case_sensitive); + // Return PP_FALSE if the plugin doesn't support find in page. Consequently, + // it won't call any callbacks. + PP_Bool (*StartFind)(PP_Instance instance, + const char* text, + PP_Bool case_sensitive); // Go to the next/previous result. void (*SelectFindResult)(PP_Instance instance, - bool forward); + PP_Bool forward); // Tells the plugin that the find operation has stopped, so it should clear // any highlighting. diff --git a/ppapi/c/dev/ppp_printing_dev.h b/ppapi/c/dev/ppp_printing_dev.h index 0a4316e..affecc8 100644 --- a/ppapi/c/dev/ppp_printing_dev.h +++ b/ppapi/c/dev/ppp_printing_dev.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_DEV_PPP_PRINTING_DEV_H_ #define PPAPI_C_DEV_PPP_PRINTING_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" @@ -28,7 +29,7 @@ struct PP_PrintSettings_Dev { struct PP_Rect printable_area; int32_t dpi; PP_PrintOrientation_Dev orientation; - bool grayscale; + PP_Bool grayscale; PP_PrintOutputFormat_Dev format; }; @@ -40,7 +41,7 @@ struct PP_PrintPageNumberRange_Dev { }; // Interface for the plugin to implement printing. -#define PPP_PRINTING_DEV_INTERFACE "PPP_Printing(Dev);0.1" +#define PPP_PRINTING_DEV_INTERFACE "PPP_Printing(Dev);0.2" struct PPP_Printing_Dev { // Returns array of supported print output formats. The array is allocated @@ -71,4 +72,3 @@ struct PPP_Printing_Dev { }; #endif // PPAPI_C_DEV_PPP_PRINTING_DEV_H_ - diff --git a/ppapi/c/dev/ppp_scrollbar_dev.h b/ppapi/c/dev/ppp_scrollbar_dev.h index 73688f42..b032a2a 100644 --- a/ppapi/c/dev/ppp_scrollbar_dev.h +++ b/ppapi/c/dev/ppp_scrollbar_dev.h @@ -3,7 +3,7 @@ // found in the LICENSE file. #ifndef PPAPI_C_DEV_PPP_SCROLLBAR_DEV_H_ -#define PPAPI_C_DEv_PPP_SCROLLBAR_DEV_H_ +#define PPAPI_C_DEV_PPP_SCROLLBAR_DEV_H_ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" diff --git a/ppapi/c/dev/ppp_selection_dev.h b/ppapi/c/dev/ppp_selection_dev.h index bcdc97d..834b4ed 100644 --- a/ppapi/c/dev/ppp_selection_dev.h +++ b/ppapi/c/dev/ppp_selection_dev.h @@ -5,10 +5,11 @@ #ifndef PPAPI_C_DEV_PPP_SELECTION_DEV_H_ #define PPAPI_C_DEV_PPP_SELECTION_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_var.h" -#define PPP_SELECTION_DEV_INTERFACE "PPP_Selection(Dev);0.1" +#define PPP_SELECTION_DEV_INTERFACE "PPP_Selection(Dev);0.2" struct PPP_Selection_Dev { /** @@ -17,7 +18,7 @@ struct PPP_Selection_Dev { * void string. */ struct PP_Var (*GetSelectedText)(PP_Instance instance, - bool html); + PP_Bool html); }; #endif // PPAPI_C_DEV_PPP_SELECTION_DEV_H_ diff --git a/ppapi/c/dev/ppp_zoom_dev.h b/ppapi/c/dev/ppp_zoom_dev.h index 725ff69..90c8be9 100644 --- a/ppapi/c/dev/ppp_zoom_dev.h +++ b/ppapi/c/dev/ppp_zoom_dev.h @@ -5,10 +5,11 @@ #ifndef PPAPI_C_DEV_PPP_ZOOM_DEV_H_ #define PPAPI_C_DEV_PPP_ZOOM_DEV_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" // Zoom interface should only apply to those full-page "plugin-document". -#define PPP_ZOOM_DEV_INTERFACE "PPP_Zoom(Dev);0.1" +#define PPP_ZOOM_DEV_INTERFACE "PPP_Zoom(Dev);0.2" struct PPP_Zoom_Dev { // Instruct plug-in to zoom according to the given factor and whether the zoom @@ -16,7 +17,7 @@ struct PPP_Zoom_Dev { // 100, i.e. 150% zoom is 1.5. void (*Zoom)(PP_Instance instance, double factor, - bool text_only); + PP_Bool text_only); }; #endif // PPAPI_C_DEV_PPP_ZOOM_DEV_H_ diff --git a/ppapi/c/pp_bool.h b/ppapi/c/pp_bool.h new file mode 100644 index 0000000..44c360e --- /dev/null +++ b/ppapi/c/pp_bool.h @@ -0,0 +1,32 @@ +// Copyright (c) 2010 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. + +#ifndef PPAPI_C_PP_BOOL_H_ +#define PPAPI_C_PP_BOOL_H_ + +/** + * @file + * Defines the API ... + * + * @addtogroup PP + * @{ + */ + +/** + * A boolean value for use in PPAPI C headers. The standard bool type is not + * available to pre-C99 compilers, and is not guaranteed to be compatible + * between C and C++, whereas the PPAPI C headers can be included from C or C++ + * code. + */ +typedef enum { + PP_FALSE = 0, + PP_TRUE = 1 +} PP_Bool; +/** + * @} + * End addtogroup PP + */ + +#endif // PPAPI_C_PP_BOOL_H_ + diff --git a/ppapi/c/pp_completion_callback.h b/ppapi/c/pp_completion_callback.h index 3944a815..8e148bc 100644 --- a/ppapi/c/pp_completion_callback.h +++ b/ppapi/c/pp_completion_callback.h @@ -15,6 +15,7 @@ #include <stdlib.h> +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" typedef void (*PP_CompletionCallback_Func)(void* user_data, int32_t result); @@ -36,15 +37,15 @@ struct PP_CompletionCallback { void* user_data; }; -inline struct PP_CompletionCallback PP_MakeCompletionCallback( +PP_INLINE struct PP_CompletionCallback PP_MakeCompletionCallback( PP_CompletionCallback_Func func, void* user_data) { struct PP_CompletionCallback cc = { func, user_data }; return cc; } -inline void PP_RunCompletionCallback(struct PP_CompletionCallback* cc, - int32_t res) { +PP_INLINE void PP_RunCompletionCallback(struct PP_CompletionCallback* cc, + int32_t res) { cc->func(cc->user_data, res); } @@ -53,7 +54,7 @@ inline void PP_RunCompletionCallback(struct PP_CompletionCallback* cc, * behavior. If specified, the calling thread will block until a method * completes. This is only usable from background threads. */ -inline struct PP_CompletionCallback PP_BlockUntilComplete() { +PP_INLINE struct PP_CompletionCallback PP_BlockUntilComplete() { return PP_MakeCompletionCallback(NULL, NULL); } diff --git a/ppapi/c/pp_input_event.h b/ppapi/c/pp_input_event.h index eddfb2d..715c016 100644 --- a/ppapi/c/pp_input_event.h +++ b/ppapi/c/pp_input_event.h @@ -13,6 +13,7 @@ * @{ */ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" @@ -145,7 +146,7 @@ struct PP_InputEvent_Wheel { float wheel_ticks_x; float wheel_ticks_y; - bool scroll_by_page; + PP_Bool scroll_by_page; }; struct PP_InputEvent { diff --git a/ppapi/c/pp_macros.h b/ppapi/c/pp_macros.h new file mode 100644 index 0000000..e864cc1 --- /dev/null +++ b/ppapi/c/pp_macros.h @@ -0,0 +1,46 @@ +// Copyright (c) 2010 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. + +#ifndef PPAPI_C_PP_MACROS_H_ +#define PPAPI_C_PP_MACROS_H_ + +/** + * @file + * Defines the API ... + * + * @addtogroup PP + * @{ + */ + +/* Use PP_INLINE to tell the compiler to inline functions. The main purpose of + * inline functions in ppapi is to allow us to define convenience functions in + * the ppapi header files, without requiring clients or implementers to link a + * PPAPI C library. The "inline" keyword is not supported by pre-C99 C + * compilers (such as MS Visual Studio 2008 and older versions of GCC). MSVS + * supports __forceinline and GCC supports __inline__. Use of the static + * keyword ensures (in C) that the function is not compiled on its own, which + * could cause multiple definition errors. + * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx + * http://gcc.gnu.org/onlinedocs/gcc/Inline.html + */ +#if defined(__cplusplus) +/* The inline keyword is part of C++ and guarantees we won't get multiple + * definition errors. + */ +# define PP_INLINE inline +#else +# if defined(_MSC_VER) +# define PP_INLINE static __forceinline +# else +# define PP_INLINE static __inline__ +# endif +#endif + +/** + * @} + * End of addtogroup PP + */ + +#endif // PPAPI_C_PP_MACROS_H_ + diff --git a/ppapi/c/pp_point.h b/ppapi/c/pp_point.h index 24bb775..0ff8562 100644 --- a/ppapi/c/pp_point.h +++ b/ppapi/c/pp_point.h @@ -13,6 +13,7 @@ * @{ */ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" struct PP_Point { @@ -20,7 +21,7 @@ struct PP_Point { int32_t y; }; -inline struct PP_Point PP_MakePoint(int32_t x, int32_t y) { +PP_INLINE struct PP_Point PP_MakePoint(int32_t x, int32_t y) { struct PP_Point ret; ret.x = x; ret.y = y; diff --git a/ppapi/c/pp_rect.h b/ppapi/c/pp_rect.h index 8b76ebd..39808e2 100644 --- a/ppapi/c/pp_rect.h +++ b/ppapi/c/pp_rect.h @@ -13,6 +13,7 @@ * @{ */ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_size.h" #include "ppapi/c/pp_stdint.h" @@ -22,8 +23,8 @@ struct PP_Rect { struct PP_Size size; }; -inline struct PP_Rect PP_MakeRectFromXYWH(int32_t x, int32_t y, - int32_t w, int32_t h) { +PP_INLINE struct PP_Rect PP_MakeRectFromXYWH(int32_t x, int32_t y, + int32_t w, int32_t h) { struct PP_Rect ret; ret.point.x = x; ret.point.y = y; diff --git a/ppapi/c/pp_size.h b/ppapi/c/pp_size.h index 3ad2084..1f77f7f 100644 --- a/ppapi/c/pp_size.h +++ b/ppapi/c/pp_size.h @@ -13,6 +13,7 @@ * @{ */ +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" struct PP_Size { @@ -20,7 +21,7 @@ struct PP_Size { int32_t height; }; -inline struct PP_Size PP_MakeSize(int32_t w, int32_t h) { +PP_INLINE struct PP_Size PP_MakeSize(int32_t w, int32_t h) { struct PP_Size ret; ret.width = w; ret.height = h; diff --git a/ppapi/c/pp_var.h b/ppapi/c/pp_var.h index 75a9492..81596d6 100644 --- a/ppapi/c/pp_var.h +++ b/ppapi/c/pp_var.h @@ -13,6 +13,8 @@ * @{ */ +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" typedef enum { @@ -40,7 +42,7 @@ typedef enum { struct PP_Var { PP_VarType type; union { - bool as_bool; + PP_Bool as_bool; int32_t as_int; double as_double; @@ -53,30 +55,30 @@ struct PP_Var { } value; }; -inline struct PP_Var PP_MakeUndefined() { - struct PP_Var result = { PP_VARTYPE_UNDEFINED, {0} }; +PP_INLINE struct PP_Var PP_MakeUndefined() { + struct PP_Var result = { PP_VARTYPE_UNDEFINED, {PP_FALSE} }; return result; } -inline struct PP_Var PP_MakeNull() { - struct PP_Var result = { PP_VARTYPE_NULL, {0} }; +PP_INLINE struct PP_Var PP_MakeNull() { + struct PP_Var result = { PP_VARTYPE_NULL, {PP_FALSE} }; return result; } -inline struct PP_Var PP_MakeBool(bool value) { - struct PP_Var result = { PP_VARTYPE_BOOL, {0} }; +PP_INLINE struct PP_Var PP_MakeBool(PP_Bool value) { + struct PP_Var result = { PP_VARTYPE_BOOL, {PP_FALSE} }; result.value.as_bool = value; return result; } -inline struct PP_Var PP_MakeInt32(int32_t value) { - PP_Var result = { PP_VARTYPE_INT32, {0} }; +PP_INLINE struct PP_Var PP_MakeInt32(int32_t value) { + struct PP_Var result = { PP_VARTYPE_INT32, {PP_FALSE} }; result.value.as_int = value; return result; } -inline struct PP_Var PP_MakeDouble(double value) { - PP_Var result = { PP_VARTYPE_DOUBLE, {0} }; +PP_INLINE struct PP_Var PP_MakeDouble(double value) { + struct PP_Var result = { PP_VARTYPE_DOUBLE, {PP_FALSE} }; result.value.as_double = value; return result; } diff --git a/ppapi/c/ppb_class.h b/ppapi/c/ppb_class.h index c4718dd..5b027f9 100644 --- a/ppapi/c/ppb_class.h +++ b/ppapi/c/ppb_class.h @@ -8,9 +8,10 @@ #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_var.h" -#define PPB_CLASS_INTERFACE "PPB_Class;0.1" +#define PPB_CLASS_INTERFACE "PPB_Class;0.2" /** * @file @@ -29,9 +30,11 @@ * different native_ptr information, make sure you can handle the case of * JS calling one object's function with another object set as this. */ -typedef PP_Var (*PP_ClassFunction)(void* native_ptr, PP_Var this_object, - PP_Var* args, uint32_t argc, - PP_Var* exception); +typedef struct PP_Var (*PP_ClassFunction)(void* native_ptr, + struct PP_Var this_object, /*NOLINT*/ + struct PP_Var* args, + uint32_t argc, + struct PP_Var* exception); typedef void (*PP_ClassDestructor)(void* native_ptr); @@ -101,7 +104,7 @@ struct PPB_Class { PP_Resource (*Create)(PP_Module module, PP_ClassDestructor destruct, PP_ClassFunction invoke, - PP_ClassProperty* properties); + struct PP_ClassProperty* properties); /** * Creates an instance of the given class, and attaches given native pointer @@ -109,8 +112,9 @@ struct PPB_Class { * * If the class_object is invalid, throws an exception. */ - PP_Var (*Instantiate)(PP_Resource class_object, - void* native_ptr, PP_Var* exception); + struct PP_Var (*Instantiate)(PP_Resource class_object, + void* native_ptr, + struct PP_Var* exception); }; /** @@ -118,4 +122,3 @@ struct PPB_Class { * End addtogroup PPP */ #endif // PPAPI_C_PPP_CLASS_H_ - diff --git a/ppapi/c/ppb_core.h b/ppapi/c/ppb_core.h index 2e1b30c..471322a 100644 --- a/ppapi/c/ppb_core.h +++ b/ppapi/c/ppb_core.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PPB_CORE_H_ #define PPAPI_C_PPB_CORE_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_time.h" @@ -12,7 +13,7 @@ struct PP_CompletionCallback; -#define PPB_CORE_INTERFACE "PPB_Core;0.1" +#define PPB_CORE_INTERFACE "PPB_Core;0.2" /** * @file @@ -82,7 +83,7 @@ struct PPB_Core { * This is useful for implementing sanity checks, and deciding if dispatching * via CallOnMainThread() is required. */ - bool (*IsMainThread)(); + PP_Bool (*IsMainThread)(); }; /** diff --git a/ppapi/c/ppb_graphics_2d.h b/ppapi/c/ppb_graphics_2d.h index 6a15b14..06557bf 100644 --- a/ppapi/c/ppb_graphics_2d.h +++ b/ppapi/c/ppb_graphics_2d.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PPB_GRAPHICS_2D_H_ #define PPAPI_C_PPB_GRAPHICS_2D_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" @@ -14,7 +15,7 @@ struct PP_Point; struct PP_Rect; struct PP_Size; -#define PPB_GRAPHICS_2D_INTERFACE "PPB_Graphics2D;0.1" +#define PPB_GRAPHICS_2D_INTERFACE "PPB_Graphics2D;0.2" /** * @file @@ -46,23 +47,23 @@ struct PPB_Graphics2D { */ PP_Resource (*Create)(PP_Module module, const struct PP_Size* size, - bool is_always_opaque); + PP_Bool is_always_opaque); /** - * Returns true if the given resource is a valid Graphics2D, false if it + * Returns PP_TRUE if the given resource is a valid Graphics2D, PP_FALSE if it * is an invalid resource or is a resource of another type. */ - bool (*IsGraphics2D)(PP_Resource resource); + PP_Bool (*IsGraphics2D)(PP_Resource resource); /** * Retrieves the configuration for the given graphics context, filling the - * given values (which must not be NULL). On success, returns true. If the + * given values (which must not be NULL). On success, returns PP_TRUE. If the * resource is invalid, the output parameters will be set to 0 and it will - * return false. + * return PP_FALSE. */ - bool (*Describe)(PP_Resource graphics_2d, - struct PP_Size* size, - bool* is_always_opqaue); + PP_Bool (*Describe)(PP_Resource graphics_2d, + struct PP_Size* size, + PP_Bool* is_always_opqaue); /** * Enqueues a paint of the given image into the context. THIS HAS NO EFFECT diff --git a/ppapi/c/ppb_image_data.h b/ppapi/c/ppb_image_data.h index 905e694..6387941 100644 --- a/ppapi/c/ppb_image_data.h +++ b/ppapi/c/ppb_image_data.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PPB_IMAGE_DATA_H_ #define PPAPI_C_PPB_IMAGE_DATA_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_size.h" @@ -19,14 +20,14 @@ struct PP_ImageDataDesc { PP_ImageDataFormat format; // Size of the bitmap in pixels. - PP_Size size; + struct PP_Size size; // The row width in bytes. This may be different than width * 4 since there // may be padding at the end of the lines. int32_t stride; }; -#define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.1" +#define PPB_IMAGEDATA_INTERFACE "PPB_ImageData;0.2" /** * @file @@ -46,9 +47,9 @@ struct PPB_ImageData { PP_ImageDataFormat (*GetNativeImageDataFormat)(); /** - * Returns true if the given image data format is supported by the browser. + * Returns PP_TRUE if the given image data format is supported by the browser. */ - bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); + PP_Bool (*IsImageDataFormatSupported)(PP_ImageDataFormat format); /** * Allocates an image data resource with the given format and size. The @@ -67,21 +68,21 @@ struct PPB_ImageData { PP_Resource (*Create)(PP_Module module, PP_ImageDataFormat format, const struct PP_Size* size, - bool init_to_zero); + PP_Bool init_to_zero); /** - * Returns true if the given resource is an image data. Returns false if the - * resource is invalid or some type other than an image data. + * Returns PP_TRUE if the given resource is an image data. Returns PP_FALSE if + * the resource is invalid or some type other than an image data. */ - bool (*IsImageData)(PP_Resource image_data); + PP_Bool (*IsImageData)(PP_Resource image_data); /** - * Computes the description of the image data. Returns true on success, false - * if the resource is not an image data. On false, the |desc| structure will - * be filled with 0. + * Computes the description of the image data. Returns PP_TRUE on success, + * PP_FALSE if the resource is not an image data. On PP_FALSE, the |desc| + * structure will be filled with 0. */ - bool (*Describe)(PP_Resource image_data, - struct PP_ImageDataDesc* desc); + PP_Bool (*Describe)(PP_Resource image_data, + struct PP_ImageDataDesc* desc); /** * Maps this bitmap into the plugin address space and returns a pointer to the diff --git a/ppapi/c/ppb_instance.h b/ppapi/c/ppb_instance.h index 3815650..2cb9d78 100644 --- a/ppapi/c/ppb_instance.h +++ b/ppapi/c/ppb_instance.h @@ -5,11 +5,12 @@ #ifndef PPAPI_C_PPB_INSTANCE_H_ #define PPAPI_C_PPB_INSTANCE_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_var.h" -#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.1" +#define PPB_INSTANCE_INTERFACE "PPB_Instance;0.2" /** * @file @@ -33,7 +34,7 @@ struct PPB_Instance { * * You can pass a NULL resource as the device parameter to unbind all * devices from the given instance. The instance will then appear - * transparent. Re-binding the same device will return true and will do + * transparent. Re-binding the same device will return PP_TRUE and will do * nothing. Unbinding a device will drop any pending flush callbacks. * * Any previously-bound device will be Release()d. It is an error to bind @@ -41,7 +42,7 @@ struct PPB_Instance { * to move a device between instances, first unbind it from the old one, and * then rebind it to the new one. * - * Returns true if the bind was successful. False means the device was not + * Returns PP_TRUE if the bind was successful. False means the device was not * the correct type. On success, a reference to the device will be held by * the plugin instance, so the caller can release its reference if it * chooses. @@ -49,15 +50,15 @@ struct PPB_Instance { * Binding a device will invalidate that portion of the web page to flush the * contents of the new device to the screen. */ - bool (*BindGraphics)(PP_Instance instance, PP_Resource device); + PP_Bool (*BindGraphics)(PP_Instance instance, PP_Resource device); /** - * Returns true if the instance is full-frame. Such a plugin represents the - * entire document in a frame rather than an embedded resource. This can + * Returns PP_TRUE if the instance is full-frame. Such a plugin represents + * the entire document in a frame rather than an embedded resource. This can * happen if the user does a top level navigation or the page specifies an * iframe to a resource with a MIME type registered by the plugin. */ - bool (*IsFullFrame)(PP_Instance instance); + PP_Bool (*IsFullFrame)(PP_Instance instance); /** * Executes the given script in the context of the frame containing the @@ -78,8 +79,9 @@ struct PPB_Instance { * @return The result of the script execution, * or a "void" var if execution failed. */ - PP_Var (*ExecuteScript)(PP_Instance instance, PP_Var script, - PP_Var* exception); + struct PP_Var (*ExecuteScript)(PP_Instance instance, + struct PP_Var script, + struct PP_Var* exception); }; /** diff --git a/ppapi/c/ppb_var.h b/ppapi/c/ppb_var.h index 9de1121..fe4c1ef 100644 --- a/ppapi/c/ppb_var.h +++ b/ppapi/c/ppb_var.h @@ -5,13 +5,15 @@ #ifndef PPAPI_C_PPB_VAR_H_ #define PPAPI_C_PPB_VAR_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" #include "ppapi/c/pp_var.h" -#define PPB_VAR_INTERFACE "PPB_Var;0.1" +#define PPB_VAR_INTERFACE "PPB_Var;0.2" /** * @file @@ -33,10 +35,10 @@ enum PP_ObjectProperty_Modifier { }; struct PP_ObjectProperty { - PP_Var name; - PP_Var value; - PP_Var getter; - PP_Var setter; + struct PP_Var name; + struct PP_Var value; + struct PP_Var getter; + struct PP_Var setter; uint32_t modifiers; }; @@ -127,10 +129,10 @@ struct PPB_Var { * For conversions from/to PP_VARTYPE_OBJECT, the instance must be specified, * or an exception of type PP_VARTYPE_STRING will be thrown. */ - PP_Var (*ConvertType)(PP_Instance instance, - struct PP_Var var, - PP_VarType new_type, - PP_Var* exception); + struct PP_Var (*ConvertType)(PP_Instance instance, + struct PP_Var var, + PP_VarType new_type, + struct PP_Var* exception); /** * Sets a property on the object, similar to Object.prototype.defineProperty. @@ -148,7 +150,7 @@ struct PPB_Var { */ void (*DefineProperty)(struct PP_Var object, struct PP_ObjectProperty property, - PP_Var* exception); + struct PP_Var* exception); /** * Tests whether an object has a property with a given name. @@ -159,9 +161,9 @@ struct PPB_Var { * Then, convert 'property' to string using ConvertType (ToString [9.8]). * Then return true if the given property exists on the object [8.12.6]. */ - bool (*HasProperty)(struct PP_Var object, - struct PP_Var property, - struct PP_Var* exception); + PP_Bool (*HasProperty)(struct PP_Var object, + struct PP_Var property, + struct PP_Var* exception); /** * Returns a given property of the object. @@ -172,9 +174,9 @@ struct PPB_Var { * Then, convert 'property' to string using ConvertType (ToString [9.8]). * Then return the given property of the object [8.12.2]. */ - PP_Var (*GetProperty)(struct PP_Var object, - struct PP_Var property, - struct PP_Var* exception); + struct PP_Var (*GetProperty)(struct PP_Var object, + struct PP_Var property, + struct PP_Var* exception); /** * Delete a property from the object, return true if succeeded. @@ -187,9 +189,9 @@ struct PPB_Var { * Then, convert 'property' to string using ConvertType (ToString [9.8]). * Then delete the given property of the object [8.12.7]. */ - bool (*DeleteProperty)(struct PP_Var object, - struct PP_Var property, - struct PP_Var* exception); + PP_Bool (*DeleteProperty)(struct PP_Var object, + struct PP_Var property, + struct PP_Var* exception); /** * Retrieves all property names on the given object. Property names include @@ -232,7 +234,7 @@ struct PPB_Var { /** * Check if an object is a JS Function [9.11]. */ - bool (*IsCallable)(struct PP_Var object); + PP_Bool (*IsCallable)(struct PP_Var object); /** * Call the functions. @@ -279,11 +281,14 @@ struct PPB_Var { struct PP_Var* exception); }; -inline struct PP_ObjectProperty PP_MakeSimpleProperty(PP_Var name, - PP_Var value) { - struct PP_ObjectProperty result = { - name, value, PP_MakeUndefined(), PP_MakeUndefined(), - PP_OBJECTPROPERTY_MODIFIER_HASVALUE }; +PP_INLINE struct PP_ObjectProperty PP_MakeSimpleProperty(struct PP_Var name, + struct PP_Var value) { + struct PP_ObjectProperty result; + result.name = name; + result.value = value; + result.getter = PP_MakeUndefined(); + result.setter = PP_MakeUndefined(); + result.modifiers = PP_OBJECTPROPERTY_MODIFIER_HASVALUE; return result; } @@ -292,4 +297,3 @@ inline struct PP_ObjectProperty PP_MakeSimpleProperty(PP_Var name, * End addtogroup PPB */ #endif // PPAPI_C_PPB_VAR_H_ - diff --git a/ppapi/c/ppp_instance.h b/ppapi/c/ppp_instance.h index a7b72e7..cb7988d 100644 --- a/ppapi/c/ppp_instance.h +++ b/ppapi/c/ppp_instance.h @@ -5,6 +5,7 @@ #ifndef PPAPI_C_PPP_INSTANCE_H_ #define PPAPI_C_PPP_INSTANCE_H_ +#include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_rect.h" #include "ppapi/c/pp_resource.h" @@ -12,7 +13,7 @@ struct PP_InputEvent; struct PP_Var; -#define PPP_INSTANCE_INTERFACE "PPP_Instance;0.1" +#define PPP_INSTANCE_INTERFACE "PPP_Instance;0.2" /** * @file @@ -35,10 +36,10 @@ struct PPP_Instance { * If the plugin reports failure from this function, the plugin will be * deleted and OnDestroy will be called. */ - bool (*DidCreate)(PP_Instance instance, - uint32_t argc, - const char* argn[], - const char* argv[]); + PP_Bool (*DidCreate)(PP_Instance instance, + uint32_t argc, + const char* argn[], + const char* argv[]); /** * Called when the plugin instance is destroyed. This will always be called, @@ -74,7 +75,7 @@ struct PPP_Instance { * If you're not getting focus, check to make sure you're returning true from * the mouse click in HandleInputEvent. */ - void (*DidChangeFocus)(PP_Instance instance, bool has_focus); + void (*DidChangeFocus)(PP_Instance instance, PP_Bool has_focus); /** * General handler for input events. Returns true if the event was handled or @@ -92,8 +93,8 @@ struct PPP_Instance { * where clicks on the transparent areas will behave like clicks to the * underlying page. */ - bool (*HandleInputEvent)(PP_Instance instance, - const struct PP_InputEvent* event); + PP_Bool (*HandleInputEvent)(PP_Instance instance, + const struct PP_InputEvent* event); /** * Called after Initialize for a full-frame plugin that was instantiated @@ -107,11 +108,11 @@ struct PPP_Instance { * of the plugin, if you're going to keep a reference to it, you need to * addref it yourself. * - * This method returns false if the plugin cannot handle the data. In + * This method returns PP_FALSE if the plugin cannot handle the data. In * response to this method, the plugin should call ReadResponseBody to read * the incoming data. */ - bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); + PP_Bool (*HandleDocumentLoad)(PP_Instance instance, PP_Resource url_loader); /** * Returns a Var representing the instance object to the web page. Normally diff --git a/ppapi/cpp/common.h b/ppapi/cpp/common.h new file mode 100644 index 0000000..8f1c5ee --- /dev/null +++ b/ppapi/cpp/common.h @@ -0,0 +1,38 @@ +// Copyright (c) 2010 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. + +#ifndef PPAPI_CPP_COMMON_H_ +#define PPAPI_CPP_COMMON_H_ + +/** + * @file + * Defines the API ... + * + * @addtogroup CPP + * @{ + */ + +#include "ppapi/c/pp_bool.h" + +namespace pp { + +/** Convert a C++ bool to the appropriate PP_Bool value. */ +inline PP_Bool BoolToPPBool(bool value) { + return value ? PP_TRUE : PP_FALSE; +} + +/** Convert a PP_Bool to a C++ bool value. */ +inline bool PPBoolToBool(PP_Bool value) { + return !!value; +} + +} // namespace pp + +/** + * @} + * End addtogroup CPP + */ + +#endif // PPAPI_CPP_COMMON_H_ + diff --git a/ppapi/cpp/core.cc b/ppapi/cpp/core.cc index 5a24ecb..146a362 100644 --- a/ppapi/cpp/core.cc +++ b/ppapi/cpp/core.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/core.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/completion_callback.h" namespace pp { @@ -19,7 +20,7 @@ void Core::CallOnMainThread(int32_t delay_in_milliseconds, } bool Core::IsMainThread() { - return interface_->IsMainThread(); + return PPBoolToBool(interface_->IsMainThread()); } } // namespace pp diff --git a/ppapi/cpp/dev/file_ref_dev.cc b/ppapi/cpp/dev/file_ref_dev.cc index c65c07f..d5c5ec0 100644 --- a/ppapi/cpp/dev/file_ref_dev.cc +++ b/ppapi/cpp/dev/file_ref_dev.cc @@ -73,7 +73,7 @@ int32_t FileRef_Dev::MakeDirectory(const CompletionCallback& cc) { if (!file_ref_f) return PP_ERROR_NOINTERFACE; return file_ref_f->MakeDirectory(pp_resource(), - false, // make_ancestors + PP_FALSE, // make_ancestors cc.pp_completion_callback()); } @@ -82,7 +82,7 @@ int32_t FileRef_Dev::MakeDirectoryIncludingAncestors( if (!file_ref_f) return PP_ERROR_NOINTERFACE; return file_ref_f->MakeDirectory(pp_resource(), - true, // make_ancestors + PP_TRUE, // make_ancestors cc.pp_completion_callback()); } diff --git a/ppapi/cpp/dev/find_dev.cc b/ppapi/cpp/dev/find_dev.cc index 8cbde54..74e5915 100644 --- a/ppapi/cpp/dev/find_dev.cc +++ b/ppapi/cpp/dev/find_dev.cc @@ -5,6 +5,7 @@ #include "ppapi/cpp/dev/find_dev.h" #include "ppapi/c/dev/ppb_find_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -15,21 +16,23 @@ namespace { static const char kPPPFindInterface[] = PPP_FIND_DEV_INTERFACE; -bool StartFind(PP_Instance instance, - const char* text, - bool case_sensitive) { +PP_Bool StartFind(PP_Instance instance, + const char* text, + PP_Bool case_sensitive) { void* object = pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); if (!object) - return false; - return static_cast<Find_Dev*>(object)->StartFind(text, case_sensitive); + return PP_FALSE; + bool return_value = static_cast<Find_Dev*>(object)->StartFind( + text, PPBoolToBool(case_sensitive)); + return BoolToPPBool(return_value); } -void SelectFindResult(PP_Instance instance, bool forward) { +void SelectFindResult(PP_Instance instance, PP_Bool forward) { void* object = pp::Instance::GetPerInstanceObject(instance, kPPPFindInterface); if (object) - static_cast<Find_Dev*>(object)->SelectFindResult(forward); + static_cast<Find_Dev*>(object)->SelectFindResult(PPBoolToBool(forward)); } void StopFind(PP_Instance instance) { @@ -61,7 +64,8 @@ Find_Dev::~Find_Dev() { void Find_Dev::NumberOfFindResultsChanged(int32_t total, bool final_result) { if (ppb_find_f) { ppb_find_f->NumberOfFindResultsChanged(associated_instance_->pp_instance(), - total, final_result); + total, + BoolToPPBool(final_result)); } } diff --git a/ppapi/cpp/dev/font_dev.cc b/ppapi/cpp/dev/font_dev.cc index 9e294fb..185c63f 100644 --- a/ppapi/cpp/dev/font_dev.cc +++ b/ppapi/cpp/dev/font_dev.cc @@ -6,6 +6,7 @@ #include <algorithm> +#include "ppapi/cpp/common.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/point.h" @@ -77,8 +78,8 @@ void FontDescription_Dev::swap(FontDescription_Dev& other) { TextRun_Dev::TextRun_Dev() { pp_text_run_.text = text_.pp_var(); - pp_text_run_.rtl = false; - pp_text_run_.override_direction = false; + pp_text_run_.rtl = PP_FALSE; + pp_text_run_.override_direction = PP_FALSE; } TextRun_Dev::TextRun_Dev(const std::string& text, @@ -86,8 +87,8 @@ TextRun_Dev::TextRun_Dev(const std::string& text, bool override_direction) : text_(text) { pp_text_run_.text = text_.pp_var(); - pp_text_run_.rtl = rtl; - pp_text_run_.override_direction = override_direction; + pp_text_run_.rtl = BoolToPPBool(rtl); + pp_text_run_.override_direction = BoolToPPBool(override_direction); } TextRun_Dev::TextRun_Dev(const TextRun_Dev& other) : text_(other.text_) { @@ -166,9 +167,13 @@ bool Font_Dev::DrawTextAt(ImageData* dest, bool image_data_is_opaque) const { if (!font_f) return false; - return font_f->DrawTextAt(pp_resource(), dest->pp_resource(), - &text.pp_text_run(), &position.pp_point(), - color, &clip.pp_rect(), image_data_is_opaque); + return PPBoolToBool(font_f->DrawTextAt(pp_resource(), + dest->pp_resource(), + &text.pp_text_run(), + &position.pp_point(), + color, + &clip.pp_rect(), + BoolToPPBool(image_data_is_opaque))); } int32_t Font_Dev::MeasureText(const TextRun_Dev& text) const { diff --git a/ppapi/cpp/dev/font_dev.h b/ppapi/cpp/dev/font_dev.h index bac8bb9..99bfe69 100644 --- a/ppapi/cpp/dev/font_dev.h +++ b/ppapi/cpp/dev/font_dev.h @@ -8,6 +8,7 @@ #include <string> #include "ppapi/c/dev/ppb_font_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/resource.h" #include "ppapi/cpp/var.h" @@ -51,11 +52,15 @@ class FontDescription_Dev { PP_FontWeight_Dev weight() const { return pp_font_description_.weight; } void set_weight(PP_FontWeight_Dev w) { pp_font_description_.weight = w; } - bool italic() const { return pp_font_description_.italic; } - void set_italic(bool i) { pp_font_description_.italic = i; } + bool italic() const { return PPBoolToBool(pp_font_description_.italic); } + void set_italic(bool i) { pp_font_description_.italic = BoolToPPBool(i); } - bool small_caps() const { return pp_font_description_.small_caps; } - void set_small_caps(bool s) { pp_font_description_.small_caps = s; } + bool small_caps() const { + return PPBoolToBool(pp_font_description_.small_caps); + } + void set_small_caps(bool s) { + pp_font_description_.small_caps = BoolToPPBool(s); + } int letter_spacing() const { return pp_font_description_.letter_spacing; } void set_letter_spacing(int s) { pp_font_description_.letter_spacing = s; } @@ -70,7 +75,7 @@ class FontDescription_Dev { PP_FontDescription_Dev pp_font_description_; }; -// TextRun_Dev --------------------------------------------------------------------- +// TextRun_Dev ----------------------------------------------------------------- class TextRun_Dev { public: diff --git a/ppapi/cpp/dev/fullscreen_dev.cc b/ppapi/cpp/dev/fullscreen_dev.cc index fd04ec9..b398b49 100644 --- a/ppapi/cpp/dev/fullscreen_dev.cc +++ b/ppapi/cpp/dev/fullscreen_dev.cc @@ -5,6 +5,7 @@ #include "ppapi/cpp/dev/fullscreen_dev.h" #include "ppapi/c/dev/ppb_fullscreen_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -32,8 +33,9 @@ bool Fullscreen_Dev::IsFullscreen() { bool Fullscreen_Dev::SetFullscreen(bool fullscreen) { if (!ppb_fullscreen_f) return false; - return ppb_fullscreen_f->SetFullscreen(associated_instance_->pp_instance(), - fullscreen); + return PPBoolToBool( + ppb_fullscreen_f->SetFullscreen(associated_instance_->pp_instance(), + BoolToPPBool(fullscreen))); } } // namespace pp diff --git a/ppapi/cpp/dev/graphics_3d_dev.cc b/ppapi/cpp/dev/graphics_3d_dev.cc index 766b70c..a15417c 100644 --- a/ppapi/cpp/dev/graphics_3d_dev.cc +++ b/ppapi/cpp/dev/graphics_3d_dev.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/dev/graphics_3d_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/resource.h" #include "ppapi/cpp/module.h" @@ -30,25 +31,34 @@ namespace pp { // static bool Graphics3D_Dev::GetConfigs(int32_t *configs, int32_t config_size, int32_t *num_config) { - if (graphics_3d_f) - return graphics_3d_f->GetConfigs(configs, config_size, num_config); + if (graphics_3d_f) { + return PPBoolToBool(graphics_3d_f->GetConfigs(configs, + config_size, + num_config)); + } return false; } // static bool Graphics3D_Dev::ChooseConfig(const int32_t *attrib_list, int32_t *configs, int32_t config_size, int32_t *num_config) { - if (graphics_3d_f) - return graphics_3d_f->ChooseConfig(attrib_list, configs, config_size, - num_config); + if (graphics_3d_f) { + return PPBoolToBool(graphics_3d_f->ChooseConfig(attrib_list, + configs, + config_size, + num_config)); + } return false; } // static bool Graphics3D_Dev::GetConfigAttrib(int32_t config, int32_t attribute, int32_t *value) { - if (graphics_3d_f) - return graphics_3d_f->GetConfigAttrib(config, attribute, value); + if (graphics_3d_f) { + return PPBoolToBool(graphics_3d_f->GetConfigAttrib(config, + attribute, + value)); + } return false; } @@ -114,4 +124,3 @@ bool Graphics3D_Dev::SwapBuffers() const { } } // namespace pp - diff --git a/ppapi/cpp/dev/scrollbar_dev.cc b/ppapi/cpp/dev/scrollbar_dev.cc index 23395ef..d24d769 100644 --- a/ppapi/cpp/dev/scrollbar_dev.cc +++ b/ppapi/cpp/dev/scrollbar_dev.cc @@ -6,6 +6,7 @@ #include "ppapi/cpp/dev/scrollbar_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -25,7 +26,8 @@ Scrollbar_Dev::Scrollbar_Dev(PP_Resource resource) : Widget_Dev(resource) { Scrollbar_Dev::Scrollbar_Dev(const Instance& instance, bool vertical) { if (!scrollbar_f) return; - PassRefFromConstructor(scrollbar_f->Create(instance.pp_instance(), vertical)); + PassRefFromConstructor(scrollbar_f->Create(instance.pp_instance(), + BoolToPPBool(vertical))); } Scrollbar_Dev::Scrollbar_Dev(const Scrollbar_Dev& other) diff --git a/ppapi/cpp/dev/selection_dev.cc b/ppapi/cpp/dev/selection_dev.cc index 6f1fcb7..f5c8cad 100644 --- a/ppapi/cpp/dev/selection_dev.cc +++ b/ppapi/cpp/dev/selection_dev.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/dev/selection_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/var.h" @@ -14,12 +15,13 @@ namespace { static const char kPPPSelectionInterface[] = PPP_SELECTION_DEV_INTERFACE; -PP_Var GetSelectedText(PP_Instance instance, bool html) { +PP_Var GetSelectedText(PP_Instance instance, PP_Bool html) { void* object = pp::Instance::GetPerInstanceObject(instance, kPPPSelectionInterface); if (!object) return Var().Detach(); - return static_cast<Selection_Dev*>(object)->GetSelectedText(html).Detach(); + return static_cast<Selection_Dev*>(object)-> + GetSelectedText(PPBoolToBool(html)).Detach(); } const PPP_Selection_Dev ppp_selection = { diff --git a/ppapi/cpp/dev/url_loader_dev.cc b/ppapi/cpp/dev/url_loader_dev.cc index 5c63f3d..b7fdc03 100644 --- a/ppapi/cpp/dev/url_loader_dev.cc +++ b/ppapi/cpp/dev/url_loader_dev.cc @@ -6,6 +6,7 @@ #include "ppapi/c/dev/ppb_url_loader_dev.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/dev/file_ref_dev.h" #include "ppapi/cpp/dev/url_request_info_dev.h" @@ -64,10 +65,9 @@ bool URLLoader_Dev::GetUploadProgress(int64_t* bytes_sent, int64_t* total_bytes_to_be_sent) const { if (!url_loader_f) return false; - return url_loader_f->GetUploadProgress( - pp_resource(), - bytes_sent, - total_bytes_to_be_sent); + return PPBoolToBool(url_loader_f->GetUploadProgress(pp_resource(), + bytes_sent, + total_bytes_to_be_sent)); } bool URLLoader_Dev::GetDownloadProgress( @@ -75,10 +75,10 @@ bool URLLoader_Dev::GetDownloadProgress( int64_t* total_bytes_to_be_received) const { if (!url_loader_f) return false; - return url_loader_f->GetDownloadProgress( - pp_resource(), - bytes_received, - total_bytes_to_be_received); + return PPBoolToBool( + url_loader_f->GetDownloadProgress(pp_resource(), + bytes_received, + total_bytes_to_be_received)); } URLResponseInfo_Dev URLLoader_Dev::GetResponseInfo() const { diff --git a/ppapi/cpp/dev/url_request_info_dev.cc b/ppapi/cpp/dev/url_request_info_dev.cc index faf975c5..5b4a135 100644 --- a/ppapi/cpp/dev/url_request_info_dev.cc +++ b/ppapi/cpp/dev/url_request_info_dev.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/dev/url_request_info_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/dev/file_ref_dev.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -43,15 +44,17 @@ bool URLRequestInfo_Dev::SetProperty(PP_URLRequestProperty_Dev property, const Var& value) { if (!url_request_info_f) return false; - return url_request_info_f->SetProperty(pp_resource(), - property, - value.pp_var()); + return PPBoolToBool(url_request_info_f->SetProperty(pp_resource(), + property, + value.pp_var())); } bool URLRequestInfo_Dev::AppendDataToBody(const char* data, uint32_t len) { if (!url_request_info_f) return false; - return url_request_info_f->AppendDataToBody(pp_resource(), data, len); + return PPBoolToBool(url_request_info_f->AppendDataToBody(pp_resource(), + data, + len)); } bool URLRequestInfo_Dev::AppendFileToBody( @@ -59,11 +62,12 @@ bool URLRequestInfo_Dev::AppendFileToBody( PP_Time expected_last_modified_time) { if (!url_request_info_f) return false; - return url_request_info_f->AppendFileToBody(pp_resource(), - file_ref.pp_resource(), - 0, - -1, - expected_last_modified_time); + return PPBoolToBool( + url_request_info_f->AppendFileToBody(pp_resource(), + file_ref.pp_resource(), + 0, + -1, + expected_last_modified_time)); } bool URLRequestInfo_Dev::AppendFileRangeToBody( @@ -71,11 +75,12 @@ bool URLRequestInfo_Dev::AppendFileRangeToBody( int64_t start_offset, int64_t length, PP_Time expected_last_modified_time) { - return url_request_info_f->AppendFileToBody(pp_resource(), - file_ref.pp_resource(), - start_offset, - length, - expected_last_modified_time); + return PPBoolToBool( + url_request_info_f->AppendFileToBody(pp_resource(), + file_ref.pp_resource(), + start_offset, + length, + expected_last_modified_time)); } } // namespace pp diff --git a/ppapi/cpp/dev/url_util_dev.cc b/ppapi/cpp/dev/url_util_dev.cc index 82e1974..ec08856 100644 --- a/ppapi/cpp/dev/url_util_dev.cc +++ b/ppapi/cpp/dev/url_util_dev.cc @@ -4,6 +4,7 @@ #include "ppapi/cpp/dev/url_util_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" @@ -52,19 +53,21 @@ Var UrlUtil_Dev::ResoveRelativeToDocument( bool UrlUtil_Dev::IsSameSecurityOrigin(const Var& url_a, const Var& url_b) const { - return interface_->IsSameSecurityOrigin(url_a.pp_var(), url_b.pp_var()); + return PPBoolToBool(interface_->IsSameSecurityOrigin(url_a.pp_var(), + url_b.pp_var())); } bool UrlUtil_Dev::DocumentCanRequest(const Instance& instance, const Var& url) const { - return interface_->DocumentCanRequest(instance.pp_instance(), url.pp_var()); + return PPBoolToBool(interface_->DocumentCanRequest(instance.pp_instance(), + url.pp_var())); } bool UrlUtil_Dev::DocumentCanAccessDocument(const Instance& active, const Instance& target) const { - return interface_->DocumentCanAccessDocument(active.pp_instance(), - target.pp_instance()); + return PPBoolToBool( + interface_->DocumentCanAccessDocument(active.pp_instance(), + target.pp_instance())); } } // namespace pp - diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc index 298bad4..9868293 100644 --- a/ppapi/cpp/dev/video_decoder_dev.cc +++ b/ppapi/cpp/dev/video_decoder_dev.cc @@ -5,6 +5,7 @@ #include "ppapi/cpp/dev/video_decoder_dev.h" #include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -53,18 +54,17 @@ bool VideoDecoder_Dev::GetConfig(const Instance& instance, int32_t* num_config) { if (!video_decoder_f) return false; - return video_decoder_f->GetConfig(instance.pp_instance(), - codec, - configs, - config_size, - num_config); + return PPBoolToBool(video_decoder_f->GetConfig(instance.pp_instance(), + codec, + configs, + config_size, + num_config)); } bool VideoDecoder_Dev::Decode(PP_VideoCompressedDataBuffer_Dev& input_buffer) { if (!video_decoder_f || !pp_resource()) return false; - return video_decoder_f->Decode(pp_resource(), - &input_buffer); + return PPBoolToBool(video_decoder_f->Decode(pp_resource(), &input_buffer)); } int32_t VideoDecoder_Dev::Flush(PP_CompletionCallback callback) { @@ -77,8 +77,9 @@ bool VideoDecoder_Dev::ReturnUncompressedDataBuffer( PP_VideoUncompressedDataBuffer_Dev& buffer) { if (!video_decoder_f || !pp_resource()) return false; - return video_decoder_f->ReturnUncompressedDataBuffer(pp_resource(), - &buffer); + return PPBoolToBool( + video_decoder_f->ReturnUncompressedDataBuffer(pp_resource(), + &buffer)); } } // namespace pp diff --git a/ppapi/cpp/dev/widget_dev.cc b/ppapi/cpp/dev/widget_dev.cc index e3c94ee..00756e5 100644 --- a/ppapi/cpp/dev/widget_dev.cc +++ b/ppapi/cpp/dev/widget_dev.cc @@ -5,6 +5,7 @@ #include "ppapi/cpp/dev/widget_dev.h" #include "ppapi/c/dev/ppb_widget_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" @@ -38,20 +39,22 @@ void Widget_Dev::swap(Widget_Dev& other) { bool Widget_Dev::Paint(const Rect& rect, ImageData* image) { if (!widget_f) return false; - return widget_f->Paint( - pp_resource(), &rect.pp_rect(), image->pp_resource()); + return PPBoolToBool(widget_f->Paint(pp_resource(), + &rect.pp_rect(), + image->pp_resource())); } bool Widget_Dev::HandleEvent(const PP_InputEvent& event) { if (!widget_f) return false; - return widget_f->HandleEvent(pp_resource(), &event); + return PPBoolToBool(widget_f->HandleEvent(pp_resource(), &event)); } bool Widget_Dev::GetLocation(Rect* location) { if (!widget_f) return false; - return widget_f->GetLocation(pp_resource(), &location->pp_rect()); + return PPBoolToBool(widget_f->GetLocation(pp_resource(), + &location->pp_rect())); } void Widget_Dev::SetLocation(const Rect& location) { diff --git a/ppapi/cpp/dev/zoom_dev.cc b/ppapi/cpp/dev/zoom_dev.cc index 43966b3..3d20676 100644 --- a/ppapi/cpp/dev/zoom_dev.cc +++ b/ppapi/cpp/dev/zoom_dev.cc @@ -5,6 +5,7 @@ #include "ppapi/cpp/dev/zoom_dev.h" #include "ppapi/c/dev/ppb_zoom_dev.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -17,12 +18,13 @@ static const char kPPPZoomInterface[] = PPP_ZOOM_DEV_INTERFACE; void Zoom(PP_Instance instance, double factor, - bool text_only) { + PP_Bool text_only) { void* object = pp::Instance::GetPerInstanceObject(instance, kPPPZoomInterface); if (!object) return; - static_cast<Zoom_Dev*>(object)->Zoom(factor, text_only); + static_cast<Zoom_Dev*>(object)->Zoom(factor, + PPBoolToBool(text_only)); } const PPP_Zoom_Dev ppp_zoom = { diff --git a/ppapi/cpp/graphics_2d.cc b/ppapi/cpp/graphics_2d.cc index aaccff7..37008cf 100644 --- a/ppapi/cpp/graphics_2d.cc +++ b/ppapi/cpp/graphics_2d.cc @@ -6,6 +6,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_graphics_2d.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/image_data.h" #include "ppapi/cpp/module.h" @@ -35,7 +36,7 @@ Graphics2D::Graphics2D(const Size& size, bool is_always_opaque) return; PassRefFromConstructor(graphics_2d_f->Create(Module::Get()->pp_module(), &size.pp_size(), - is_always_opaque)); + BoolToPPBool(is_always_opaque))); if (!is_null()) { // Only save the size if allocation succeeded. size_ = size; diff --git a/ppapi/cpp/image_data.cc b/ppapi/cpp/image_data.cc index 6f4bf69..d4b15e0 100644 --- a/ppapi/cpp/image_data.cc +++ b/ppapi/cpp/image_data.cc @@ -8,6 +8,7 @@ #include <algorithm> +#include "ppapi/cpp/common.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -51,7 +52,7 @@ ImageData::ImageData(PP_ImageDataFormat format, PassRefAndInitData(image_data_f->Create(Module::Get()->pp_module(), format, &size.pp_size(), - init_to_zero)); + BoolToPPBool(init_to_zero))); } ImageData::~ImageData() { diff --git a/ppapi/cpp/instance.cc b/ppapi/cpp/instance.cc index 16d7f76..d900c8a 100644 --- a/ppapi/cpp/instance.cc +++ b/ppapi/cpp/instance.cc @@ -6,6 +6,7 @@ #include "ppapi/c/dev/ppp_printing_dev.h" #include "ppapi/c/ppb_instance.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/dev/scrollbar_dev.h" #include "ppapi/cpp/dev/widget_dev.h" #include "ppapi/cpp/graphics_2d.h" @@ -83,13 +84,14 @@ Var Instance::GetOwnerElementObject() { bool Instance::BindGraphics(const Graphics2D& graphics) { if (!ppb_instance_f) return false; - return ppb_instance_f->BindGraphics(pp_instance(), graphics.pp_resource()); + return PPBoolToBool(ppb_instance_f->BindGraphics(pp_instance(), + graphics.pp_resource())); } bool Instance::IsFullFrame() { if (!ppb_instance_f) return false; - return ppb_instance_f->IsFullFrame(pp_instance()); + return PPBoolToBool(ppb_instance_f->IsFullFrame(pp_instance())); } Var Instance::ExecuteScript(const Var& script, Var* exception) { diff --git a/ppapi/cpp/module.cc b/ppapi/cpp/module.cc index fe32569..1aa5ea8 100644 --- a/ppapi/cpp/module.cc +++ b/ppapi/cpp/module.cc @@ -28,6 +28,7 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/ppp_instance.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/dev/url_loader_dev.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/rect.h" @@ -38,19 +39,19 @@ namespace pp { // PPP_Instance implementation ------------------------------------------------- -bool Instance_DidCreate(PP_Instance pp_instance, - uint32_t argc, - const char* argn[], - const char* argv[]) { +PP_Bool Instance_DidCreate(PP_Instance pp_instance, + uint32_t argc, + const char* argn[], + const char* argv[]) { Module* module_singleton = Module::Get(); if (!module_singleton) - return false; + return PP_FALSE; Instance* instance = module_singleton->CreateInstance(pp_instance); if (!instance) - return false; + return PP_FALSE; module_singleton->current_instances_[pp_instance] = instance; - return instance->Init(argc, argn, argv); + return BoolToPPBool(instance->Init(argc, argn, argv)); } void Instance_DidDestroy(PP_Instance instance) { @@ -80,36 +81,37 @@ void Instance_DidChangeView(PP_Instance pp_instance, instance->DidChangeView(*position, *clip); } -void Instance_DidChangeFocus(PP_Instance pp_instance, bool has_focus) { +void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { Module* module_singleton = Module::Get(); if (!module_singleton) return; Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); if (!instance) return; - instance->DidChangeFocus(has_focus); + instance->DidChangeFocus(PPBoolToBool(has_focus)); } -bool Instance_HandleInputEvent(PP_Instance pp_instance, - const PP_InputEvent* event) { +PP_Bool Instance_HandleInputEvent(PP_Instance pp_instance, + const PP_InputEvent* event) { Module* module_singleton = Module::Get(); if (!module_singleton) - return false; + return PP_FALSE; Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); if (!instance) - return false; - return instance->HandleInputEvent(*event); + return PP_FALSE; + return BoolToPPBool(instance->HandleInputEvent(*event)); } -bool Instance_HandleDocumentLoad(PP_Instance pp_instance, - PP_Resource pp_url_loader) { +PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, + PP_Resource pp_url_loader) { Module* module_singleton = Module::Get(); if (!module_singleton) - return false; + return PP_FALSE; Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); if (!instance) - return false; - return instance->HandleDocumentLoad(URLLoader_Dev(pp_url_loader)); + return PP_FALSE; + return BoolToPPBool( + instance->HandleDocumentLoad(URLLoader_Dev(pp_url_loader))); } PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { diff --git a/ppapi/cpp/module.h b/ppapi/cpp/module.h index 362eedf..308d3ce 100644 --- a/ppapi/cpp/module.h +++ b/ppapi/cpp/module.h @@ -13,6 +13,7 @@ #include "ppapi/c/pp_stdint.h" #include "ppapi/c/ppb.h" #include "ppapi/c/ppb_core.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/core.h" namespace pp { @@ -93,10 +94,10 @@ class Module { virtual Instance* CreateInstance(PP_Instance instance) = 0; private: - friend bool Instance_DidCreate(PP_Instance pp_instance, - uint32_t argc, - const char* argn[], - const char* argv[]); + friend PP_Bool Instance_DidCreate(PP_Instance pp_instance, + uint32_t argc, + const char* argn[], + const char* argv[]); friend void Instance_DidDestroy(PP_Instance instance); // Unimplemented (disallow copy and assign). diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc index d48253a..5ade9b0 100644 --- a/ppapi/cpp/var.cc +++ b/ppapi/cpp/var.cc @@ -10,6 +10,7 @@ #include "ppapi/c/pp_var.h" #include "ppapi/c/dev/ppb_var_deprecated.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/logging.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/module_impl.h" @@ -50,7 +51,7 @@ Var::Var(Null) { Var::Var(bool b) { var_.type = PP_VARTYPE_BOOL; - var_.value.as_bool = b; + var_.value.as_bool = BoolToPPBool(b); needs_release_ = false; } @@ -166,7 +167,7 @@ bool Var::AsBool() const { PP_NOTREACHED(); return false; } - return var_.value.as_bool; + return PPBoolToBool(var_.value.as_bool); } int32_t Var::AsInt() const { diff --git a/ppapi/examples/2d/graphics_2d_example.c b/ppapi/examples/2d/graphics_2d_example.c index eadfb31..01dd4fb 100644 --- a/ppapi/examples/2d/graphics_2d_example.c +++ b/ppapi/examples/2d/graphics_2d_example.c @@ -31,20 +31,20 @@ const struct PPB_Instance* g_instance_interface; struct InstanceInfo { PP_Instance pp_instance; - PP_Size last_size; + struct PP_Size last_size; - InstanceInfo* next; + struct InstanceInfo* next; }; // Linked list of all live instances. -InstanceInfo* all_instances = NULL; +struct InstanceInfo* all_instances = NULL; // Returns a refed resource corresponding to the created device context. PP_Resource MakeAndBindDeviceContext(PP_Instance instance, const struct PP_Size* size) { PP_Resource device_context; - device_context = g_graphics_2d_interface->Create(g_module_id, size, false); + device_context = g_graphics_2d_interface->Create(g_module_id, size, PP_FALSE); if (!device_context) return 0; @@ -59,15 +59,15 @@ void FlushCompletionCallback(void* user_data, int32_t result) { // Don't need to do anything here. } -void Repaint(InstanceInfo* instance, const struct PP_Size* size) { +void Repaint(struct InstanceInfo* instance, const struct PP_Size* size) { PP_Resource image, device_context; - PP_ImageDataDesc image_desc; + struct PP_ImageDataDesc image_desc; uint32_t* image_data; int num_words, i; // Create image data to paint into. image = g_image_data_interface->Create( - g_module_id, PP_IMAGEDATAFORMAT_BGRA_PREMUL, size, true); + g_module_id, PP_IMAGEDATAFORMAT_BGRA_PREMUL, size, PP_TRUE); if (!image) return; g_image_data_interface->Describe(image, &image_desc); @@ -98,8 +98,8 @@ void Repaint(InstanceInfo* instance, const struct PP_Size* size) { } // Returns the info for the given instance, or NULL if it's not found. -InstanceInfo* FindInstance(PP_Instance instance) { - InstanceInfo* cur = all_instances; +struct InstanceInfo* FindInstance(PP_Instance instance) { + struct InstanceInfo* cur = all_instances; while (cur) { if (cur->pp_instance == instance) return cur; @@ -107,8 +107,12 @@ InstanceInfo* FindInstance(PP_Instance instance) { return NULL; } -bool Instance_New(PP_Instance instance) { - InstanceInfo* info = (InstanceInfo*)malloc(sizeof(InstanceInfo)); +PP_Bool Instance_DidCreate(PP_Instance instance, + uint32_t argc, + const char* argn[], + const char* argv[]) { + struct InstanceInfo* info = + (struct InstanceInfo*)malloc(sizeof(struct InstanceInfo)); info->pp_instance = instance; info->last_size.width = 0; info->last_size.height = 0; @@ -116,13 +120,13 @@ bool Instance_New(PP_Instance instance) { // Insert into linked list of live instances. info->next = all_instances; all_instances = info; - return true; + return PP_TRUE; } -void Instance_Delete(PP_Instance instance) { +void Instance_DidDestroy(PP_Instance instance) { // Find the matching item in the linked list, delete it, and patch the links. - InstanceInfo** prev_ptr = &all_instances; - InstanceInfo* cur = all_instances; + struct InstanceInfo** prev_ptr = &all_instances; + struct InstanceInfo* cur = all_instances; while (cur) { if (instance == cur->pp_instance) { *prev_ptr = cur->next; @@ -133,35 +137,10 @@ void Instance_Delete(PP_Instance instance) { } } -bool Instance_Initialize(PP_Instance pp_instance, - uint32_t argc, - const char* argn[], - const char* argv[]) { - return true; -} - -bool Instance_HandleDocumentLoad(PP_Instance pp_instance, - PP_Resource pp_url_loader) { - return false; -} - -bool Instance_HandleInputEvent(PP_Instance pp_instance, - const struct PP_InputEvent* event) { - // We don't handle any events. - return false; -} - -void Instance_HandleFocusChanged(bool /*has_focus*/) { -} - -PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { - return PP_MakeNull(); -} - -void Instance_ViewChanged(PP_Instance pp_instance, - const struct PP_Rect* position, - const struct PP_Rect* clip) { - InstanceInfo* info = FindInstance(pp_instance); +void Instance_DidChangeView(PP_Instance pp_instance, + const struct PP_Rect* position, + const struct PP_Rect* clip) { + struct InstanceInfo* info = FindInstance(pp_instance); if (!info) return; @@ -174,21 +153,32 @@ void Instance_ViewChanged(PP_Instance pp_instance, } } -PP_Var Instance_GetSelectedText(PP_Instance pp_instance, - bool html) { +void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { +} + +PP_Bool Instance_HandleInputEvent(PP_Instance pp_instance, + const struct PP_InputEvent* event) { + // We don't handle any events. + return PP_FALSE; +} + +PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, + PP_Resource pp_url_loader) { + return PP_FALSE; +} + +struct PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { return PP_MakeNull(); } -static PPP_Instance instance_interface = { - &Instance_New, - &Instance_Delete, - &Instance_Initialize, - &Instance_HandleDocumentLoad, +static struct PPP_Instance instance_interface = { + &Instance_DidCreate, + &Instance_DidDestroy, + &Instance_DidChangeView, + &Instance_DidChangeFocus, &Instance_HandleInputEvent, - &Instance_HandleFocusChanged, + &Instance_HandleDocumentLoad, &Instance_GetInstanceObject, - &Instance_ViewChanged, - &Instance_GetSelectedText, }; diff --git a/ppapi/ppapi.gyp b/ppapi/ppapi.gyp index 3a747d7..d968ddf 100644 --- a/ppapi/ppapi.gyp +++ b/ppapi/ppapi.gyp @@ -38,10 +38,12 @@ ], }, 'sources': [ + 'c/pp_bool.h', 'c/pp_completion_callback.h', 'c/pp_errors.h', 'c/pp_input_event.h', 'c/pp_instance.h', + 'c/pp_macros.h', 'c/pp_module.h', 'c/pp_point.h', 'c/pp_rect.h', @@ -101,6 +103,7 @@ 'c/dev/ppp_zoom_dev.h', # Deprecated interfaces. + 'c/dev/deprecated_bool.h', 'c/dev/ppb_var_deprecated.h', 'c/dev/ppp_class_deprecated.h', ], @@ -115,6 +118,7 @@ '..', ], 'sources': [ + 'cpp/common.h', 'cpp/completion_callback.h', 'cpp/core.cc', 'cpp/core.h', @@ -367,9 +371,7 @@ # 'examples/file_chooser/file_chooser.cc', # ], # }, - -#TODO(ppapi authors): Fix the C headers so that they are C compatible. -# { +# { # 'target_name': 'ppapi_example_graphics_2d', # 'dependencies': [ # 'ppapi_example_skeleton', @@ -378,7 +380,6 @@ # 'examples/2d/graphics_2d_example.c', # ], # }, - # { # 'target_name': 'ppapi_example_paint_manager', # 'dependencies': [ @@ -419,6 +420,7 @@ # Test cases. 'tests/test_buffer.cc', 'tests/test_buffer.h', + 'tests/test_c_includes.c', 'tests/test_char_set.cc', 'tests/test_char_set.h', 'tests/test_directory_reader.cc', diff --git a/ppapi/tests/test_c_includes.c b/ppapi/tests/test_c_includes.c new file mode 100644 index 0000000..e17671f --- /dev/null +++ b/ppapi/tests/test_c_includes.c @@ -0,0 +1,74 @@ +/* Copyright (c) 2010 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. + + * This test simply includes all the C headers to ensure they compile with a C + compiler. If it compiles, it passes. + */ +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/pp_input_event.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_module.h" +#include "ppapi/c/pp_point.h" +#include "ppapi/c/pp_rect.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_time.h" +#include "ppapi/c/pp_var.h" +#include "ppapi/c/ppb.h" +#include "ppapi/c/ppb_class.h" +#include "ppapi/c/ppb_core.h" +#include "ppapi/c/ppb_graphics_2d.h" +#include "ppapi/c/ppb_image_data.h" +#include "ppapi/c/ppb_instance.h" +#include "ppapi/c/ppb_var.h" +#include "ppapi/c/ppp.h" +#include "ppapi/c/ppp_instance.h" +#include "ppapi/c/dev/deprecated_bool.h" +#include "ppapi/c/dev/pp_cursor_type_dev.h" +#include "ppapi/c/dev/pp_file_info_dev.h" +#include "ppapi/c/dev/pp_video_dev.h" +#include "ppapi/c/dev/ppb_audio_config_dev.h" +#include "ppapi/c/dev/ppb_audio_dev.h" +#include "ppapi/c/dev/ppb_audio_trusted_dev.h" +#include "ppapi/c/dev/ppb_buffer_dev.h" +#include "ppapi/c/dev/ppb_char_set_dev.h" +#include "ppapi/c/dev/ppb_cursor_control_dev.h" +#include "ppapi/c/dev/ppb_directory_reader_dev.h" +#include "ppapi/c/dev/ppb_file_chooser_dev.h" +#include "ppapi/c/dev/ppb_file_io_dev.h" +#include "ppapi/c/dev/ppb_file_io_trusted_dev.h" +#include "ppapi/c/dev/ppb_file_ref_dev.h" +#include "ppapi/c/dev/ppb_file_system_dev.h" +#include "ppapi/c/dev/ppb_find_dev.h" +#include "ppapi/c/dev/ppb_font_dev.h" +#include "ppapi/c/dev/ppb_fullscreen_dev.h" +#include "ppapi/c/dev/ppb_graphics_3d_dev.h" +#include "ppapi/c/dev/ppb_opengles_dev.h" +#include "ppapi/c/dev/ppb_scrollbar_dev.h" +#include "ppapi/c/dev/ppb_testing_dev.h" +#include "ppapi/c/dev/ppb_transport_dev.h" +#include "ppapi/c/dev/ppb_url_loader_dev.h" +#include "ppapi/c/dev/ppb_url_loader_trusted_dev.h" +#include "ppapi/c/dev/ppb_url_request_info_dev.h" +#include "ppapi/c/dev/ppb_url_response_info_dev.h" +#include "ppapi/c/dev/ppb_url_util_dev.h" +#include "ppapi/c/dev/ppb_var_deprecated.h" +#include "ppapi/c/dev/ppb_video_decoder_dev.h" +#include "ppapi/c/dev/ppb_widget_dev.h" +#include "ppapi/c/dev/ppb_zoom_dev.h" +#include "ppapi/c/dev/ppp_class_deprecated.h" +#include "ppapi/c/dev/ppp_cursor_control_dev.h" +#include "ppapi/c/dev/ppp_find_dev.h" +#include "ppapi/c/dev/ppp_graphics_3d_dev.h" +#include "ppapi/c/dev/ppp_printing_dev.h" +#include "ppapi/c/dev/ppp_scrollbar_dev.h" +#include "ppapi/c/dev/ppp_selection_dev.h" +#include "ppapi/c/dev/ppp_widget_dev.h" +#include "ppapi/c/dev/ppp_zoom_dev.h" +#include "ppapi/c/trusted/ppb_image_data_trusted.h" + diff --git a/ppapi/tests/test_graphics_2d.cc b/ppapi/tests/test_graphics_2d.cc index 34b9945..1ba8f7f 100644 --- a/ppapi/tests/test_graphics_2d.cc +++ b/ppapi/tests/test_graphics_2d.cc @@ -9,6 +9,7 @@ #include "ppapi/c/dev/ppb_testing_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/ppb_graphics_2d.h" +#include "ppapi/cpp/common.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/graphics_2d.h" #include "ppapi/cpp/image_data.h" @@ -68,9 +69,10 @@ void TestGraphics2D::QuitMessageLoop() { bool TestGraphics2D::ReadImageData(const pp::Graphics2D& dc, pp::ImageData* image, const pp::Point& top_left) const { - return testing_interface_->ReadImageData(dc.pp_resource(), - image->pp_resource(), - &top_left.pp_point()); + return pp::PPBoolToBool(testing_interface_->ReadImageData( + dc.pp_resource(), + image->pp_resource(), + &top_left.pp_point())); } bool TestGraphics2D::IsDCUniformColor(const pp::Graphics2D& dc, @@ -181,7 +183,7 @@ std::string TestGraphics2D::TestInvalidResource() { // Describe. PP_Size size; - bool opaque; + PP_Bool opaque; graphics_2d_interface_->Describe(image.pp_resource(), &size, &opaque); graphics_2d_interface_->Describe(null_context.pp_resource(), &size, &opaque); @@ -248,12 +250,12 @@ std::string TestGraphics2D::TestInvalidSize() { size.width = 16; size.height = -16; ASSERT_FALSE(!!graphics_2d_interface_->Create( - pp::Module::Get()->pp_module(), &size, false)); + pp::Module::Get()->pp_module(), &size, PP_FALSE)); size.width = -16; size.height = 16; ASSERT_FALSE(!!graphics_2d_interface_->Create( - pp::Module::Get()->pp_module(), &size, false)); + pp::Module::Get()->pp_module(), &size, PP_FALSE)); return ""; } @@ -296,11 +298,11 @@ std::string TestGraphics2D::TestDescribe() { PP_Size size; size.width = -1; size.height = -1; - bool is_always_opaque = true; + PP_Bool is_always_opaque = PP_TRUE; if (!graphics_2d_interface_->Describe(dc.pp_resource(), &size, &is_always_opaque)) return "Describe failed"; - if (size.width != w || size.height != h || is_always_opaque != false) + if (size.width != w || size.height != h || is_always_opaque != PP_FALSE) return "Mismatch of data."; return ""; diff --git a/ppapi/tests/test_image_data.cc b/ppapi/tests/test_image_data.cc index 6b918f4..6300264 100644 --- a/ppapi/tests/test_image_data.cc +++ b/ppapi/tests/test_image_data.cc @@ -61,7 +61,7 @@ std::string TestImageData::TestInvalidSize() { PP_Resource rsrc = image_data_interface_->Create( pp::Module::Get()->pp_module(), PP_IMAGEDATAFORMAT_BGRA_PREMUL, - &negative_height, true); + &negative_height, PP_TRUE); if (rsrc) return "Negative height accepted"; @@ -71,7 +71,7 @@ std::string TestImageData::TestInvalidSize() { rsrc = image_data_interface_->Create( pp::Module::Get()->pp_module(), PP_IMAGEDATAFORMAT_BGRA_PREMUL, - &negative_width, true); + &negative_width, PP_TRUE); if (rsrc) return "Negative width accepted"; @@ -137,4 +137,3 @@ std::string TestImageData::TestIsImageData() { return ""; } - diff --git a/ppapi/tests/test_var_deprecated.cc b/ppapi/tests/test_var_deprecated.cc index 084afaf..b4bdee9 100644 --- a/ppapi/tests/test_var_deprecated.cc +++ b/ppapi/tests/test_var_deprecated.cc @@ -219,7 +219,7 @@ std::string TestVarDeprecated::TestVarToUtf8ForWrongType() { length = kInvalidLength; result = NULL; - result = var_interface_->VarToUtf8(PP_MakeBool(true), &length); + result = var_interface_->VarToUtf8(PP_MakeBool(PP_TRUE), &length); if (length != 0) { return "Expected 0 on string conversion from Bool var."; } diff --git a/webkit/glue/plugins/pepper_audio.cc b/webkit/glue/plugins/pepper_audio.cc index e5babec..d98ef1b 100644 --- a/webkit/glue/plugins/pepper_audio.cc +++ b/webkit/glue/plugins/pepper_audio.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "ppapi/c/dev/ppb_audio_dev.h" #include "ppapi/c/dev/ppb_audio_trusted_dev.h" +#include "webkit/glue/plugins/pepper_common.h" namespace pepper { @@ -50,9 +51,9 @@ uint32_t RecommendSampleFrameCount(uint32_t requested_sample_frame_count) { return requested_sample_frame_count; } -bool IsAudioConfig(PP_Resource resource) { +PP_Bool IsAudioConfig(PP_Resource resource) { scoped_refptr<AudioConfig> config = Resource::GetAs<AudioConfig>(resource); - return !!config; + return BoolToPPBool(!!config); } PP_AudioSampleRate_Dev GetSampleRate(PP_Resource config_id) { @@ -87,9 +88,9 @@ PP_Resource Create(PP_Instance instance_id, PP_Resource config_id, return audio->GetReference(); } -bool IsAudio(PP_Resource resource) { +PP_Bool IsAudio(PP_Resource resource) { scoped_refptr<Audio> audio = Resource::GetAs<Audio>(resource); - return !!audio; + return BoolToPPBool(!!audio); } PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { @@ -97,14 +98,14 @@ PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { return audio ? audio->GetCurrentConfiguration() : 0; } -bool StartPlayback(PP_Resource audio_id) { +PP_Bool StartPlayback(PP_Resource audio_id) { scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id); - return audio ? audio->StartPlayback() : false; + return audio ? BoolToPPBool(audio->StartPlayback()) : PP_FALSE; } -bool StopPlayback(PP_Resource audio_id) { +PP_Bool StopPlayback(PP_Resource audio_id) { scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id); - return audio ? audio->StopPlayback() : false; + return audio ? BoolToPPBool(audio->StopPlayback()) : PP_FALSE; } const PPB_Audio_Dev ppb_audio = { diff --git a/webkit/glue/plugins/pepper_audio.h b/webkit/glue/plugins/pepper_audio.h index 705192c..ccba021 100644 --- a/webkit/glue/plugins/pepper_audio.h +++ b/webkit/glue/plugins/pepper_audio.h @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ +#define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ + #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/shared_memory.h" @@ -15,9 +18,6 @@ #include "webkit/glue/plugins/pepper_plugin_module.h" #include "webkit/glue/plugins/pepper_resource.h" -#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ -#define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ - namespace pepper { class PluginInstance; diff --git a/webkit/glue/plugins/pepper_buffer.cc b/webkit/glue/plugins/pepper_buffer.cc index 7b52e69..cee10c9 100644 --- a/webkit/glue/plugins/pepper_buffer.cc +++ b/webkit/glue/plugins/pepper_buffer.cc @@ -12,6 +12,7 @@ #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_module.h" #include "ppapi/c/pp_resource.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" @@ -31,16 +32,16 @@ PP_Resource Create(PP_Module module_id, int32_t size) { return buffer->GetReference(); } -bool IsBuffer(PP_Resource resource) { - return !!Resource::GetAs<Buffer>(resource); +PP_Bool IsBuffer(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Buffer>(resource)); } -bool Describe(PP_Resource resource, int32_t* size_in_bytes) { +PP_Bool Describe(PP_Resource resource, int32_t* size_in_bytes) { scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(resource)); if (!buffer) - return false; + return PP_FALSE; buffer->Describe(size_in_bytes); - return true; + return PP_TRUE; } void* Map(PP_Resource resource) { diff --git a/webkit/glue/plugins/pepper_common.h b/webkit/glue/plugins/pepper_common.h new file mode 100644 index 0000000..be9fe3d --- /dev/null +++ b/webkit/glue/plugins/pepper_common.h @@ -0,0 +1,24 @@ +// Copyright (c) 2010 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. + +#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_ +#define WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_var.h" + +namespace pepper { + +inline PP_Bool BoolToPPBool(bool value) { + return value ? PP_TRUE : PP_FALSE; +} + +inline bool PPBoolToBool(PP_Bool value) { + return (PP_TRUE == value); +} + +} // namespace pepper + +#endif // WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_ + diff --git a/webkit/glue/plugins/pepper_cursor_control.cc b/webkit/glue/plugins/pepper_cursor_control.cc index f515deb..62b4e2f 100644 --- a/webkit/glue/plugins/pepper_cursor_control.cc +++ b/webkit/glue/plugins/pepper_cursor_control.cc @@ -10,6 +10,7 @@ #include "ppapi/c/dev/ppb_cursor_control_dev.h" #include "ppapi/c/pp_point.h" #include "ppapi/c/pp_resource.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_image_data.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_resource.h" @@ -18,59 +19,59 @@ namespace pepper { namespace { -bool SetCursor(PP_Instance instance_id, +PP_Bool SetCursor(PP_Instance instance_id, PP_CursorType_Dev type, PP_Resource custom_image_id, const PP_Point* hot_spot) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; scoped_refptr<ImageData> custom_image( Resource::GetAs<ImageData>(custom_image_id)); if (custom_image.get()) { // TODO(neb): implement custom cursors. NOTIMPLEMENTED(); - return false; + return PP_FALSE; } - return instance->SetCursor(type); + return BoolToPPBool(instance->SetCursor(type)); } -bool LockCursor(PP_Instance instance_id) { +PP_Bool LockCursor(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } -bool UnlockCursor(PP_Instance instance_id) { +PP_Bool UnlockCursor(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } -bool HasCursorLock(PP_Instance instance_id) { +PP_Bool HasCursorLock(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } -bool CanLockCursor(PP_Instance instance_id) { +PP_Bool CanLockCursor(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } const PPB_CursorControl_Dev cursor_control_interface = { diff --git a/webkit/glue/plugins/pepper_directory_reader.cc b/webkit/glue/plugins/pepper_directory_reader.cc index 558560e..c476b76 100644 --- a/webkit/glue/plugins/pepper_directory_reader.cc +++ b/webkit/glue/plugins/pepper_directory_reader.cc @@ -10,6 +10,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/dev/ppb_directory_reader_dev.h" #include "webkit/glue/plugins/pepper_file_callbacks.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_file_ref.h" #include "webkit/glue/plugins/pepper_file_system.h" #include "webkit/glue/plugins/pepper_plugin_delegate.h" @@ -51,8 +52,8 @@ PP_Resource Create(PP_Resource directory_ref_id) { return reader->GetReference(); } -bool IsDirectoryReader(PP_Resource resource) { - return !!Resource::GetAs<DirectoryReader>(resource); +PP_Bool IsDirectoryReader(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<DirectoryReader>(resource)); } int32_t GetNextEntry(PP_Resource reader_id, diff --git a/webkit/glue/plugins/pepper_event_conversion.cc b/webkit/glue/plugins/pepper_event_conversion.cc index bc60af2..300592f 100644 --- a/webkit/glue/plugins/pepper_event_conversion.cc +++ b/webkit/glue/plugins/pepper_event_conversion.cc @@ -12,6 +12,7 @@ #include "base/utf_string_conversion_utils.h" #include "ppapi/c/pp_input_event.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" +#include "webkit/glue/plugins/pepper_common.h" using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; @@ -142,7 +143,8 @@ void AppendMouseWheelEvent(const WebInputEvent& event, result.u.wheel.delta_y = mouse_wheel_event.deltaY; result.u.wheel.wheel_ticks_x = mouse_wheel_event.wheelTicksX; result.u.wheel.wheel_ticks_y = mouse_wheel_event.wheelTicksY; - result.u.wheel.scroll_by_page = !!mouse_wheel_event.scrollByPage; + result.u.wheel.scroll_by_page = + pepper::BoolToPPBool(!!mouse_wheel_event.scrollByPage); pp_events->push_back(result); } diff --git a/webkit/glue/plugins/pepper_file_chooser.cc b/webkit/glue/plugins/pepper_file_chooser.cc index 576e205..fd3ade1 100644 --- a/webkit/glue/plugins/pepper_file_chooser.cc +++ b/webkit/glue/plugins/pepper_file_chooser.cc @@ -15,6 +15,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_file_ref.h" #include "webkit/glue/plugins/pepper_plugin_delegate.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" @@ -41,8 +42,8 @@ PP_Resource Create(PP_Instance instance_id, return chooser->GetReference(); } -bool IsFileChooser(PP_Resource resource) { - return !!Resource::GetAs<FileChooser>(resource); +PP_Bool IsFileChooser(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<FileChooser>(resource)); } int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) { diff --git a/webkit/glue/plugins/pepper_file_io.cc b/webkit/glue/plugins/pepper_file_io.cc index 41ce5b6..1d3d66e 100644 --- a/webkit/glue/plugins/pepper_file_io.cc +++ b/webkit/glue/plugins/pepper_file_io.cc @@ -15,6 +15,7 @@ #include "ppapi/c/dev/ppb_file_io_trusted_dev.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_file_ref.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" @@ -33,8 +34,8 @@ PP_Resource Create(PP_Module module_id) { return file_io->GetReference(); } -bool IsFileIO(PP_Resource resource) { - return !!Resource::GetAs<FileIO>(resource); +PP_Bool IsFileIO(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<FileIO>(resource)); } int32_t Open(PP_Resource file_io_id, diff --git a/webkit/glue/plugins/pepper_file_ref.cc b/webkit/glue/plugins/pepper_file_ref.cc index a135cf6..67e39e3 100644 --- a/webkit/glue/plugins/pepper_file_ref.cc +++ b/webkit/glue/plugins/pepper_file_ref.cc @@ -7,6 +7,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "ppapi/c/pp_errors.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_directory_reader.h" #include "webkit/glue/plugins/pepper_file_callbacks.h" #include "webkit/glue/plugins/pepper_file_system.h" @@ -58,8 +59,8 @@ PP_Resource Create(PP_Resource file_system_id, const char* path) { return file_ref->GetReference(); } -bool IsFileRef(PP_Resource resource) { - return !!Resource::GetAs<FileRef>(resource); +PP_Bool IsFileRef(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<FileRef>(resource)); } PP_FileSystemType_Dev GetFileSystemType(PP_Resource file_ref_id) { @@ -103,7 +104,7 @@ PP_Resource GetParent(PP_Resource file_ref_id) { } int32_t MakeDirectory(PP_Resource directory_ref_id, - bool make_ancestors, + PP_Bool make_ancestors, PP_CompletionCallback callback) { scoped_refptr<FileRef> directory_ref( Resource::GetAs<FileRef>(directory_ref_id)); @@ -117,7 +118,7 @@ int32_t MakeDirectory(PP_Resource directory_ref_id, PluginInstance* instance = file_system->instance(); if (!instance->delegate()->MakeDirectory( - directory_ref->GetSystemPath(), make_ancestors, + directory_ref->GetSystemPath(), PPBoolToBool(make_ancestors), new FileCallbacks(instance->module()->AsWeakPtr(), callback, NULL, NULL, NULL))) return PP_ERROR_FAILED; diff --git a/webkit/glue/plugins/pepper_font.cc b/webkit/glue/plugins/pepper_font.cc index 340e076..553c8ed 100644 --- a/webkit/glue/plugins/pepper_font.cc +++ b/webkit/glue/plugins/pepper_font.cc @@ -14,6 +14,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebFloatPoint.h" #include "third_party/WebKit/WebKit/chromium/public/WebFloatRect.h" #include "third_party/WebKit/WebKit/chromium/public/WebTextRun.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_image_data.h" #include "webkit/glue/plugins/pepper_plugin_module.h" #include "webkit/glue/plugins/pepper_string.h" @@ -87,8 +88,8 @@ WebFontDescription PPFontDescToWebFontDesc(const PP_FontDescription_Dev& font) { result.family = UTF8ToUTF16(face_name->value()); result.genericFamily = PP_FONTFAMILY_TO_WEB_FONTFAMILY(font.family); result.size = static_cast<float>(font.size); - result.italic = font.italic; - result.smallCaps = font.small_caps; + result.italic = PPBoolToBool(font.italic); + result.smallCaps = PPBoolToBool(font.small_caps); result.weight = static_cast<WebFontDescription::Weight>(font.weight); result.letterSpacing = static_cast<short>(font.letter_spacing); result.wordSpacing = static_cast<short>(font.word_spacing); @@ -102,7 +103,8 @@ bool PPTextRunToWebTextRun(const PP_TextRun_Dev* run, WebTextRun* output) { if (!text_string) return false; *output = WebTextRun(UTF8ToUTF16(text_string->value()), - run->rtl, run->override_direction); + PPBoolToBool(run->rtl), + PPBoolToBool(run->override_direction)); return true; } @@ -119,31 +121,31 @@ PP_Resource Create(PP_Module module_id, return font->GetReference(); } -bool IsFont(PP_Resource resource) { - return !!Resource::GetAs<Font>(resource).get(); +PP_Bool IsFont(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Font>(resource).get()); } -bool Describe(PP_Resource font_id, +PP_Bool Describe(PP_Resource font_id, PP_FontDescription_Dev* description, PP_FontMetrics_Dev* metrics) { scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); if (!font.get()) - return false; - return font->Describe(description, metrics); + return PP_FALSE; + return BoolToPPBool(font->Describe(description, metrics)); } -bool DrawTextAt(PP_Resource font_id, +PP_Bool DrawTextAt(PP_Resource font_id, PP_Resource image_data, const PP_TextRun_Dev* text, const PP_Point* position, uint32_t color, const PP_Rect* clip, - bool image_data_is_opaque) { + PP_Bool image_data_is_opaque) { scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); if (!font.get()) - return false; - return font->DrawTextAt(image_data, text, position, color, clip, - image_data_is_opaque); + return PP_FALSE; + return BoolToPPBool(font->DrawTextAt(image_data, text, position, color, clip, + PPBoolToBool(image_data_is_opaque))); } int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) { @@ -211,8 +213,8 @@ bool Font::Describe(PP_FontDescription_Dev* description, description->family = static_cast<PP_FontFamily_Dev>(web_desc.genericFamily); description->size = static_cast<uint32_t>(web_desc.size); description->weight = static_cast<PP_FontWeight_Dev>(web_desc.weight); - description->italic = web_desc.italic; - description->small_caps = web_desc.smallCaps; + description->italic = BoolToPPBool(web_desc.italic); + description->small_caps = BoolToPPBool(web_desc.smallCaps); metrics->height = font_->height(); metrics->ascent = font_->ascent(); diff --git a/webkit/glue/plugins/pepper_graphics_2d.cc b/webkit/glue/plugins/pepper_graphics_2d.cc index 720d1d8..a8d5091 100644 --- a/webkit/glue/plugins/pepper_graphics_2d.cc +++ b/webkit/glue/plugins/pepper_graphics_2d.cc @@ -19,6 +19,7 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/ppb_graphics_2d.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_image_data.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" @@ -112,28 +113,28 @@ void ConvertImageData(ImageData* src_image, const SkIRect& src_rect, PP_Resource Create(PP_Module module_id, const PP_Size* size, - bool is_always_opaque) { + PP_Bool is_always_opaque) { PluginModule* module = ResourceTracker::Get()->GetModule(module_id); if (!module) return 0; scoped_refptr<Graphics2D> context(new Graphics2D(module)); - if (!context->Init(size->width, size->height, is_always_opaque)) + if (!context->Init(size->width, size->height, PPBoolToBool(is_always_opaque))) return 0; return context->GetReference(); } -bool IsGraphics2D(PP_Resource resource) { - return !!Resource::GetAs<Graphics2D>(resource); +PP_Bool IsGraphics2D(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Graphics2D>(resource)); } -bool Describe(PP_Resource graphics_2d, +PP_Bool Describe(PP_Resource graphics_2d, PP_Size* size, - bool* is_always_opaque) { + PP_Bool* is_always_opaque) { scoped_refptr<Graphics2D> context( Resource::GetAs<Graphics2D>(graphics_2d)); if (!context) - return false; + return PP_FALSE; return context->Describe(size, is_always_opaque); } @@ -242,11 +243,11 @@ bool Graphics2D::Init(int width, int height, bool is_always_opaque) { return true; } -bool Graphics2D::Describe(PP_Size* size, bool* is_always_opaque) { +PP_Bool Graphics2D::Describe(PP_Size* size, PP_Bool* is_always_opaque) { size->width = image_data_->width(); size->height = image_data_->height(); - *is_always_opaque = false; // TODO(brettw) implement this. - return true; + *is_always_opaque = PP_FALSE; // TODO(brettw) implement this. + return PP_TRUE; } void Graphics2D::PaintImageData(PP_Resource image_data, diff --git a/webkit/glue/plugins/pepper_graphics_2d.h b/webkit/glue/plugins/pepper_graphics_2d.h index 6caac83..78170ab 100644 --- a/webkit/glue/plugins/pepper_graphics_2d.h +++ b/webkit/glue/plugins/pepper_graphics_2d.h @@ -42,7 +42,7 @@ class Graphics2D : public Resource { virtual Graphics2D* AsGraphics2D() { return this; } // PPB_Graphics2D functions. - bool Describe(PP_Size* size, bool* is_always_opaque); + PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque); void PaintImageData(PP_Resource image_data, const PP_Point* top_left, const PP_Rect* src_rect); diff --git a/webkit/glue/plugins/pepper_graphics_3d.cc b/webkit/glue/plugins/pepper_graphics_3d.cc index 47b587e..fa9c2ec1c 100644 --- a/webkit/glue/plugins/pepper_graphics_3d.cc +++ b/webkit/glue/plugins/pepper_graphics_3d.cc @@ -8,6 +8,7 @@ #include "base/singleton.h" #include "base/thread_local.h" #include "ppapi/c/dev/ppb_graphics_3d_dev.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" namespace pepper { @@ -22,24 +23,24 @@ typedef Singleton<base::ThreadLocalPointer<Graphics3D>, // Size of the transfer buffer. enum { kTransferBufferSize = 512 * 1024 }; -bool IsGraphics3D(PP_Resource resource) { - return !!Resource::GetAs<Graphics3D>(resource); +PP_Bool IsGraphics3D(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Graphics3D>(resource)); } -bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) { +PP_Bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) { // TODO(neb): Implement me! - return false; + return PP_FALSE; } -bool ChooseConfig(const int32_t* attrib_list, int32_t* configs, - int32_t config_size, int32_t* num_config) { +PP_Bool ChooseConfig(const int32_t* attrib_list, int32_t* configs, + int32_t config_size, int32_t* num_config) { // TODO(neb): Implement me! - return false; + return PP_FALSE; } -bool GetConfigAttrib(int32_t config, int32_t attribute, int32_t* value) { +PP_Bool GetConfigAttrib(int32_t config, int32_t attribute, int32_t* value) { // TODO(neb): Implement me! - return false; + return PP_FALSE; } const char* QueryString(int32_t name) { @@ -80,13 +81,13 @@ void* GetProcAddress(const char* name) { return NULL; } -bool MakeCurrent(PP_Resource graphics3d) { +PP_Bool MakeCurrent(PP_Resource graphics3d) { if (!graphics3d) { Graphics3D::ResetCurrent(); - return true; + return PP_TRUE; } else { scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); - return context.get() && context->MakeCurrent(); + return BoolToPPBool(context.get() && context->MakeCurrent()); } } @@ -95,9 +96,9 @@ PP_Resource GetCurrentContext() { return currentContext ? currentContext->GetReference() : 0; } -bool SwapBuffers(PP_Resource graphics3d) { +PP_Bool SwapBuffers(PP_Resource graphics3d) { scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); - return context && context->SwapBuffers(); + return BoolToPPBool(context && context->SwapBuffers()); } uint32_t GetError() { diff --git a/webkit/glue/plugins/pepper_image_data.cc b/webkit/glue/plugins/pepper_image_data.cc index 6dc9be5..702abee 100644 --- a/webkit/glue/plugins/pepper_image_data.cc +++ b/webkit/glue/plugins/pepper_image_data.cc @@ -16,6 +16,7 @@ #include "ppapi/c/ppb_image_data.h" #include "ppapi/c/trusted/ppb_image_data_trusted.h" #include "third_party/skia/include/core/SkColorPriv.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" @@ -27,38 +28,42 @@ PP_ImageDataFormat GetNativeImageDataFormat() { return ImageData::GetNativeImageDataFormat(); } -bool IsImageDataFormatSupported(PP_ImageDataFormat format) { - return ImageData::IsImageDataFormatSupported(format); +PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) { + return BoolToPPBool(ImageData::IsImageDataFormatSupported(format)); } PP_Resource Create(PP_Module module_id, PP_ImageDataFormat format, const PP_Size* size, - bool init_to_zero) { + PP_Bool init_to_zero) { PluginModule* module = ResourceTracker::Get()->GetModule(module_id); if (!module) return 0; scoped_refptr<ImageData> data(new ImageData(module)); - if (!data->Init(format, size->width, size->height, init_to_zero)) + if (!data->Init(format, + size->width, + size->height, + PPBoolToBool(init_to_zero))) { return 0; + } return data->GetReference(); } -bool IsImageData(PP_Resource resource) { - return !!Resource::GetAs<ImageData>(resource); +PP_Bool IsImageData(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<ImageData>(resource)); } -bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) { +PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) { // Give predictable values on failure. memset(desc, 0, sizeof(PP_ImageDataDesc)); scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource)); if (!image_data) - return false; + return PP_FALSE; image_data->Describe(desc); - return true; + return PP_TRUE; } void* Map(PP_Resource resource) { diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index f735591..b40874a 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -48,6 +48,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/plugins/pepper_buffer.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_graphics_2d.h" #include "webkit/glue/plugins/pepper_event_conversion.h" #include "webkit/glue/plugins/pepper_fullscreen_container.h" @@ -160,18 +161,18 @@ PP_Var GetOwnerElementObject(PP_Instance instance_id) { return instance->GetOwnerElementObject(); } -bool BindGraphics(PP_Instance instance_id, PP_Resource device_id) { +PP_Bool BindGraphics(PP_Instance instance_id, PP_Resource device_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->BindGraphics(device_id); + return PP_FALSE; + return BoolToPPBool(instance->BindGraphics(device_id)); } -bool IsFullFrame(PP_Instance instance_id) { +PP_Bool IsFullFrame(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->full_frame(); + return PP_FALSE; + return BoolToPPBool(instance->full_frame()); } PP_Var ExecuteScript(PP_Instance instance_id, @@ -193,14 +194,14 @@ const PPB_Instance ppb_instance = { void NumberOfFindResultsChanged(PP_Instance instance_id, int32_t total, - bool final_result) { + PP_Bool final_result) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) return; DCHECK_NE(instance->find_identifier(), -1); instance->delegate()->NumberOfFindResultsChanged( - instance->find_identifier(), total, final_result); + instance->find_identifier(), total, PPBoolToBool(final_result)); } void SelectedFindResultChanged(PP_Instance instance_id, @@ -219,18 +220,18 @@ const PPB_Find_Dev ppb_find = { &SelectedFindResultChanged, }; -bool IsFullscreen(PP_Instance instance_id) { +PP_Bool IsFullscreen(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->IsFullscreen(); + return PP_FALSE; + return BoolToPPBool(instance->IsFullscreen()); } -bool SetFullscreen(PP_Instance instance_id, bool fullscreen) { +PP_Bool SetFullscreen(PP_Instance instance_id, PP_Bool fullscreen) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->SetFullscreen(fullscreen); + return PP_FALSE; + return BoolToPPBool(instance->SetFullscreen(PPBoolToBool(fullscreen))); } const PPB_Fullscreen_Dev ppb_fullscreen = { @@ -502,13 +503,16 @@ bool PluginInstance::Initialize(WebPluginContainer* container, argc++; } - return instance_interface_->DidCreate(pp_instance(), - argc, argn.get(), argv.get()); + return PPBoolToBool(instance_interface_->DidCreate(pp_instance(), + argc, + argn.get(), + argv.get())); } bool PluginInstance::HandleDocumentLoad(URLLoader* loader) { Resource::ScopedResourceId resource(loader); - return instance_interface_->HandleDocumentLoad(pp_instance(), resource.id); + return PPBoolToBool(instance_interface_->HandleDocumentLoad(pp_instance(), + resource.id)); } bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, @@ -518,8 +522,10 @@ bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, // Each input event may generate more than one PP_InputEvent. bool rv = false; - for (size_t i = 0; i < pp_events.size(); i++) - rv |= instance_interface_->HandleInputEvent(pp_instance(), &pp_events[i]); + for (size_t i = 0; i < pp_events.size(); i++) { + rv |= PPBoolToBool(instance_interface_->HandleInputEvent(pp_instance(), + &pp_events[i])); + } if (cursor_.get()) *cursor_info = *cursor_; @@ -555,8 +561,10 @@ void PluginInstance::SetWebKitFocus(bool has_focus) { bool old_plugin_focus = PluginHasFocus(); has_webkit_focus_ = has_focus; - if (PluginHasFocus() != old_plugin_focus) - instance_interface_->DidChangeFocus(pp_instance(), PluginHasFocus()); + if (PluginHasFocus() != old_plugin_focus) { + instance_interface_->DidChangeFocus(pp_instance(), + BoolToPPBool(PluginHasFocus())); + } } void PluginInstance::SetContentAreaFocus(bool has_focus) { @@ -565,8 +573,10 @@ void PluginInstance::SetContentAreaFocus(bool has_focus) { bool old_plugin_focus = PluginHasFocus(); has_content_area_focus_ = has_focus; - if (PluginHasFocus() != old_plugin_focus) - instance_interface_->DidChangeFocus(pp_instance(), PluginHasFocus()); + if (PluginHasFocus() != old_plugin_focus) { + instance_interface_->DidChangeFocus(pp_instance(), + BoolToPPBool(PluginHasFocus())); + } } void PluginInstance::ViewInitiatedPaint() { @@ -610,7 +620,8 @@ string16 PluginInstance::GetSelectedText(bool html) { if (!LoadSelectionInterface()) return string16(); - PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), html); + PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), + BoolToPPBool(html)); scoped_refptr<StringVar> string(StringVar::FromPPVar(rv)); Var::PluginReleasePPVar(rv); // Release the ref the plugin transfered to us. if (!string) @@ -636,7 +647,7 @@ string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { void PluginInstance::Zoom(double factor, bool text_only) { if (!LoadZoomInterface()) return; - plugin_zoom_interface_->Zoom(pp_instance(), factor, text_only); + plugin_zoom_interface_->Zoom(pp_instance(), factor, BoolToPPBool(text_only)); } bool PluginInstance::StartFind(const string16& search_text, @@ -645,15 +656,17 @@ bool PluginInstance::StartFind(const string16& search_text, if (!LoadFindInterface()) return false; find_identifier_ = identifier; - return plugin_find_interface_->StartFind( - pp_instance(), - UTF16ToUTF8(search_text.c_str()).c_str(), - case_sensitive); + return PPBoolToBool( + plugin_find_interface_->StartFind( + pp_instance(), + UTF16ToUTF8(search_text.c_str()).c_str(), + BoolToPPBool(case_sensitive))); } void PluginInstance::SelectFindResult(bool forward) { if (LoadFindInterface()) - plugin_find_interface_->SelectFindResult(pp_instance(), forward); + plugin_find_interface_->SelectFindResult(pp_instance(), + BoolToPPBool(forward)); } void PluginInstance::StopFind() { @@ -759,7 +772,7 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, RectToPPRect(printable_area, &print_settings.printable_area); print_settings.dpi = printer_dpi; print_settings.orientation = PP_PRINTORIENTATION_NORMAL; - print_settings.grayscale = false; + print_settings.grayscale = PP_FALSE; print_settings.format = format; int num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc index a639f71..09e5369 100644 --- a/webkit/glue/plugins/pepper_plugin_module.cc +++ b/webkit/glue/plugins/pepper_plugin_module.cc @@ -49,6 +49,7 @@ #include "ppapi/c/ppp_instance.h" #include "webkit/glue/plugins/pepper_audio.h" #include "webkit/glue/plugins/pepper_buffer.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_char_set.h" #include "webkit/glue/plugins/pepper_cursor_control.h" #include "webkit/glue/plugins/pepper_directory_reader.h" @@ -141,8 +142,8 @@ void CallOnMainThread(int delay_in_msec, delay_in_msec); } -bool IsMainThread() { - return GetMainThreadMessageLoop()->BelongsToCurrentThread(); +PP_Bool IsMainThread() { + return BoolToPPBool(GetMainThreadMessageLoop()->BelongsToCurrentThread()); } const PPB_Core core_interface = { @@ -158,14 +159,14 @@ const PPB_Core core_interface = { // PPB_Testing ----------------------------------------------------------------- -bool ReadImageData(PP_Resource device_context_2d, +PP_Bool ReadImageData(PP_Resource device_context_2d, PP_Resource image, const PP_Point* top_left) { scoped_refptr<Graphics2D> context( Resource::GetAs<Graphics2D>(device_context_2d)); if (!context.get()) - return false; - return context->ReadImageData(image, top_left); + return PP_FALSE; + return BoolToPPBool(context->ReadImageData(image, top_left)); } void RunMessageLoop() { diff --git a/webkit/glue/plugins/pepper_scrollbar.cc b/webkit/glue/plugins/pepper_scrollbar.cc index 624f114..2b96259 100644 --- a/webkit/glue/plugins/pepper_scrollbar.cc +++ b/webkit/glue/plugins/pepper_scrollbar.cc @@ -12,6 +12,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/WebKit/chromium/public/WebScrollbar.h" #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_event_conversion.h" #include "webkit/glue/plugins/pepper_image_data.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" @@ -30,17 +31,18 @@ namespace pepper { namespace { -PP_Resource Create(PP_Instance instance_id, bool vertical) { +PP_Resource Create(PP_Instance instance_id, PP_Bool vertical) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) return 0; - scoped_refptr<Scrollbar> scrollbar(new Scrollbar(instance, vertical)); + scoped_refptr<Scrollbar> scrollbar(new Scrollbar(instance, + PPBoolToBool(vertical))); return scrollbar->GetReference(); } -bool IsScrollbar(PP_Resource resource) { - return !!Resource::GetAs<Scrollbar>(resource); +PP_Bool IsScrollbar(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Scrollbar>(resource)); } uint32_t GetThickness() { diff --git a/webkit/glue/plugins/pepper_transport.cc b/webkit/glue/plugins/pepper_transport.cc index 3e60a2c..29a4495 100644 --- a/webkit/glue/plugins/pepper_transport.cc +++ b/webkit/glue/plugins/pepper_transport.cc @@ -7,6 +7,7 @@ #include "base/singleton.h" #include "base/thread_local.h" #include "ppapi/c/dev/ppb_transport_dev.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" @@ -25,15 +26,15 @@ PP_Resource CreateTransport(PP_Module module, } // Returns whether or not resource is Transport -bool IsTransport(PP_Resource resource) { - return !!Resource::GetAs<Transport>(resource); +PP_Bool IsTransport(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Transport>(resource)); } // Returns whether the transport is currently writable // (i.e. can send data to the remote peer) -bool IsWritable(PP_Resource transport) { +PP_Bool IsWritable(PP_Resource transport) { // TODO(juberti): impelement me - return false; + return PP_FALSE; } diff --git a/webkit/glue/plugins/pepper_url_loader.cc b/webkit/glue/plugins/pepper_url_loader.cc index 2e68adb..9c3b03a 100644 --- a/webkit/glue/plugins/pepper_url_loader.cc +++ b/webkit/glue/plugins/pepper_url_loader.cc @@ -19,6 +19,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" #include "webkit/appcache/web_application_cache_host_impl.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_url_request_info.h" #include "webkit/glue/plugins/pepper_url_response_info.h" @@ -50,8 +51,8 @@ PP_Resource Create(PP_Instance instance_id) { return loader->GetReference(); } -bool IsURLLoader(PP_Resource resource) { - return !!Resource::GetAs<URLLoader>(resource); +PP_Bool IsURLLoader(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<URLLoader>(resource)); } int32_t Open(PP_Resource loader_id, @@ -78,24 +79,26 @@ int32_t FollowRedirect(PP_Resource loader_id, return loader->FollowRedirect(callback); } -bool GetUploadProgress(PP_Resource loader_id, +PP_Bool GetUploadProgress(PP_Resource loader_id, int64_t* bytes_sent, int64_t* total_bytes_to_be_sent) { scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); if (!loader) - return false; - return loader->GetUploadProgress(bytes_sent, total_bytes_to_be_sent); - return true; + return PP_FALSE; + + return BoolToPPBool(loader->GetUploadProgress(bytes_sent, + total_bytes_to_be_sent)); } -bool GetDownloadProgress(PP_Resource loader_id, - int64_t* bytes_received, - int64_t* total_bytes_to_be_received) { +PP_Bool GetDownloadProgress(PP_Resource loader_id, + int64_t* bytes_received, + int64_t* total_bytes_to_be_received) { scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id)); if (!loader) - return false; - return loader->GetDownloadProgress(bytes_received, - total_bytes_to_be_received); + return PP_FALSE; + + return BoolToPPBool(loader->GetDownloadProgress(bytes_received, + total_bytes_to_be_received)); } PP_Resource GetResponseInfo(PP_Resource loader_id) { diff --git a/webkit/glue/plugins/pepper_url_request_info.cc b/webkit/glue/plugins/pepper_url_request_info.cc index 723b327..a7a6589 100644 --- a/webkit/glue/plugins/pepper_url_request_info.cc +++ b/webkit/glue/plugins/pepper_url_request_info.cc @@ -15,6 +15,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_file_ref.h" #include "webkit/glue/plugins/pepper_plugin_module.h" #include "webkit/glue/plugins/pepper_string.h" @@ -38,12 +39,12 @@ const char* const kIgnoredRequestHeaders[] = { "content-length" }; -bool IsIgnoredRequestHeader(const std::string& name) { +PP_Bool IsIgnoredRequestHeader(const std::string& name) { for (size_t i = 0; i < arraysize(kIgnoredRequestHeaders); ++i) { if (LowerCaseEqualsASCII(name, kIgnoredRequestHeaders[i])) - return true; + return PP_TRUE; } - return false; + return PP_FALSE; } PP_Resource Create(PP_Module module_id) { @@ -56,40 +57,47 @@ PP_Resource Create(PP_Module module_id) { return request->GetReference(); } -bool IsURLRequestInfo(PP_Resource resource) { - return !!Resource::GetAs<URLRequestInfo>(resource); +PP_Bool IsURLRequestInfo(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<URLRequestInfo>(resource)); } -bool SetProperty(PP_Resource request_id, - PP_URLRequestProperty_Dev property, - PP_Var var) { +PP_Bool SetProperty(PP_Resource request_id, + PP_URLRequestProperty_Dev property, + PP_Var var) { scoped_refptr<URLRequestInfo> request( Resource::GetAs<URLRequestInfo>(request_id)); if (!request) - return false; + return PP_FALSE; - if (var.type == PP_VARTYPE_BOOL) - return request->SetBooleanProperty(property, var.value.as_bool); + if (var.type == PP_VARTYPE_BOOL) { + return BoolToPPBool( + request->SetBooleanProperty(property, + PPBoolToBool(var.value.as_bool))); + } if (var.type == PP_VARTYPE_STRING) { scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); - if (string) - return request->SetStringProperty(property, string->value()); + if (string) { + return BoolToPPBool(request->SetStringProperty(property, + string->value())); + } } - return false; + return PP_FALSE; } -bool AppendDataToBody(PP_Resource request_id, const char* data, uint32_t len) { +PP_Bool AppendDataToBody(PP_Resource request_id, + const char* data, + uint32_t len) { scoped_refptr<URLRequestInfo> request( Resource::GetAs<URLRequestInfo>(request_id)); if (!request) - return false; + return PP_FALSE; - return request->AppendDataToBody(std::string(data, len)); + return BoolToPPBool(request->AppendDataToBody(std::string(data, len))); } -bool AppendFileToBody(PP_Resource request_id, +PP_Bool AppendFileToBody(PP_Resource request_id, PP_Resource file_ref_id, int64_t start_offset, int64_t number_of_bytes, @@ -97,16 +105,16 @@ bool AppendFileToBody(PP_Resource request_id, scoped_refptr<URLRequestInfo> request( Resource::GetAs<URLRequestInfo>(request_id)); if (!request) - return false; + return PP_FALSE; scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); if (!file_ref) - return false; + return PP_FALSE; - return request->AppendFileToBody(file_ref, - start_offset, - number_of_bytes, - expected_last_modified_time); + return BoolToPPBool(request->AppendFileToBody(file_ref, + start_offset, + number_of_bytes, + expected_last_modified_time)); } const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { diff --git a/webkit/glue/plugins/pepper_url_response_info.cc b/webkit/glue/plugins/pepper_url_response_info.cc index bcb54ef..ee27003 100644 --- a/webkit/glue/plugins/pepper_url_response_info.cc +++ b/webkit/glue/plugins/pepper_url_response_info.cc @@ -10,6 +10,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_file_ref.h" #include "webkit/glue/plugins/pepper_var.h" #include "webkit/glue/webkit_glue.h" @@ -38,8 +39,8 @@ class HeaderFlattener : public WebHTTPHeaderVisitor { std::string buffer_; }; -bool IsURLResponseInfo(PP_Resource resource) { - return !!Resource::GetAs<URLResponseInfo>(resource); +PP_Bool IsURLResponseInfo(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<URLResponseInfo>(resource)); } PP_Var GetProperty(PP_Resource response_id, diff --git a/webkit/glue/plugins/pepper_url_util.cc b/webkit/glue/plugins/pepper_url_util.cc index c6ea5f8..2f97e6c 100644 --- a/webkit/glue/plugins/pepper_url_util.cc +++ b/webkit/glue/plugins/pepper_url_util.cc @@ -13,6 +13,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_string.h" #include "webkit/glue/plugins/pepper_var.h" @@ -115,46 +116,46 @@ PP_Var ResolveRelativeToDocument(PP_Instance instance_id, components); } -bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { +PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { scoped_refptr<StringVar> url_a_string(StringVar::FromPPVar(url_a)); scoped_refptr<StringVar> url_b_string(StringVar::FromPPVar(url_b)); if (!url_a_string || !url_b_string) - return false; + return PP_FALSE; GURL gurl_a(url_a_string->value()); GURL gurl_b(url_b_string->value()); if (!gurl_a.is_valid() || !gurl_b.is_valid()) - return false; + return PP_FALSE; - return gurl_a.GetOrigin() == gurl_b.GetOrigin(); + return BoolToPPBool(gurl_a.GetOrigin() == gurl_b.GetOrigin()); } -bool DocumentCanRequest(PP_Instance instance, PP_Var url) { +PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) { scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url)); if (!url_string) - return false; + return PP_FALSE; WebKit::WebSecurityOrigin security_origin; if (!SecurityOriginForInstance(instance, &security_origin)) - return false; + return PP_FALSE; GURL gurl(url_string->value()); if (!gurl.is_valid()) - return false; + return PP_FALSE; - return security_origin.canRequest(gurl); + return BoolToPPBool(security_origin.canRequest(gurl)); } -bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { +PP_Bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { WebKit::WebSecurityOrigin active_origin; if (!SecurityOriginForInstance(active, &active_origin)) - return false; + return PP_FALSE; WebKit::WebSecurityOrigin target_origin; if (!SecurityOriginForInstance(active, &target_origin)) - return false; + return PP_FALSE; - return active_origin.canAccess(target_origin); + return BoolToPPBool(active_origin.canAccess(target_origin)); } } // namespace diff --git a/webkit/glue/plugins/pepper_var.cc b/webkit/glue/plugins/pepper_var.cc index 9a1f6cb..db83229 100644 --- a/webkit/glue/plugins/pepper_var.cc +++ b/webkit/glue/plugins/pepper_var.cc @@ -13,6 +13,7 @@ #include "ppapi/c/ppb_var.h" #include "ppapi/c/pp_var.h" #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" #include "webkit/glue/plugins/pepper_plugin_object.h" @@ -297,20 +298,24 @@ PP_Var ConvertType(PP_Instance instance, return result; } +PP_Var BoolToPPVar(bool value) { + return PP_MakeBool(BoolToPPBool(value)); +} + void DefineProperty(struct PP_Var object, struct PP_ObjectProperty property, PP_Var* exception) { PP_Var params[] = { object, property.name, - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_HASVALUE)), + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_HASVALUE)), property.value, - PP_MakeBool(property.getter.type == PP_VARTYPE_OBJECT), + BoolToPPVar(property.getter.type == PP_VARTYPE_OBJECT), property.getter, - PP_MakeBool(property.setter.type == PP_VARTYPE_OBJECT), + BoolToPPVar(property.setter.type == PP_VARTYPE_OBJECT), property.setter, - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_READONLY)), - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTDELETE)), - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTENUM)) + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_READONLY)), + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTDELETE)), + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTENUM)) }; RunJSFunction(object, @@ -329,14 +334,21 @@ void DefineProperty(struct PP_Var object, params, sizeof(params) / sizeof(PP_Var), exception); } -bool HasProperty(PP_Var var, - PP_Var name, - PP_Var* exception) { +PP_Bool HasProperty(PP_Var var, + PP_Var name, + PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) - return false; - return WebBindings::hasProperty(NULL, accessor.object()->np_object(), - accessor.identifier()); + return PP_FALSE; + return BoolToPPBool(WebBindings::hasProperty(NULL, + accessor.object()->np_object(), + accessor.identifier())); +} + +bool HasPropertyDeprecated(PP_Var var, + PP_Var name, + PP_Var* exception) { + return PPBoolToBool(HasProperty(var, name, exception)); } bool HasMethodDeprecated(PP_Var var, @@ -418,15 +430,17 @@ void SetPropertyDeprecated(PP_Var var, accessor.SetException(kUnableToSetPropertyException); } -bool DeleteProperty(PP_Var var, - PP_Var name, - PP_Var* exception) { +PP_Bool DeleteProperty(PP_Var var, + PP_Var name, + PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) - return false; + return PP_FALSE; - return WebBindings::removeProperty(NULL, accessor.object()->np_object(), - accessor.identifier()); + return BoolToPPBool( + WebBindings::removeProperty(NULL, + accessor.object()->np_object(), + accessor.identifier())); } void DeletePropertyDeprecated(PP_Var var, @@ -441,10 +455,12 @@ void DeletePropertyDeprecated(PP_Var var, accessor.SetException(kUnableToRemovePropertyException); } -bool IsCallable(struct PP_Var object) { +PP_Bool IsCallable(struct PP_Var object) { PP_Var result = RunJSFunction(object, "(function() { return typeof(this) == 'function' })", NULL, 0, NULL); - return result.type == PP_VARTYPE_BOOL && result.value.as_bool; + if (result.type == PP_VARTYPE_BOOL) + return result.value.as_bool; + return PP_FALSE; } struct PP_Var Call(struct PP_Var object, @@ -597,7 +613,7 @@ const PPB_Var_Deprecated var_deprecated_interface = { &Var::PluginReleasePPVar, &VarFromUtf8, &VarToUtf8, - &HasProperty, + &HasPropertyDeprecated, &HasMethodDeprecated, &GetProperty, &EnumerateProperties, @@ -644,7 +660,7 @@ PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) { case NPVariantType_Null: return PP_MakeNull(); case NPVariantType_Bool: - return PP_MakeBool(NPVARIANT_TO_BOOLEAN(*variant)); + return BoolToPPVar(NPVARIANT_TO_BOOLEAN(*variant)); case NPVariantType_Int32: return PP_MakeInt32(NPVARIANT_TO_INT32(*variant)); case NPVariantType_Double: diff --git a/webkit/glue/plugins/pepper_video_decoder.cc b/webkit/glue/plugins/pepper_video_decoder.cc index b0c1135..cd4d3b5 100644 --- a/webkit/glue/plugins/pepper_video_decoder.cc +++ b/webkit/glue/plugins/pepper_video_decoder.cc @@ -9,6 +9,7 @@ #include "ppapi/c/dev/ppb_video_decoder_dev.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_file_ref.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_resource_tracker.h" @@ -17,7 +18,7 @@ namespace pepper { namespace { -bool GetConfig(PP_Instance instance_id, +PP_Bool GetConfig(PP_Instance instance_id, PP_VideoCodecId_Dev codec, PP_VideoConfig_Dev* configs, int32_t config_size, @@ -25,7 +26,7 @@ bool GetConfig(PP_Instance instance_id, PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); *num_config = 0; if (!instance) - return false; + return PP_FALSE; // Get configs based on codec. @@ -35,7 +36,7 @@ bool GetConfig(PP_Instance instance_id, // Update *num_config. - return true; + return PP_TRUE; } PP_Resource Create(PP_Instance instance_id, @@ -52,15 +53,15 @@ PP_Resource Create(PP_Instance instance_id, return decoder->GetReference(); } -bool Decode(PP_Resource decoder_id, +PP_Bool Decode(PP_Resource decoder_id, PP_VideoCompressedDataBuffer_Dev* input_buffer) { scoped_refptr<VideoDecoder> decoder( Resource::GetAs<VideoDecoder>(decoder_id)); if (!decoder) - return false; + return PP_FALSE; decoder->Decode(*input_buffer); - return true; + return PP_TRUE; } int32_t Flush(PP_Resource decoder_id, PP_CompletionCallback callback) { @@ -72,14 +73,14 @@ int32_t Flush(PP_Resource decoder_id, PP_CompletionCallback callback) { return decoder->Flush(callback); } -bool ReturnUncompressedDataBuffer(PP_Resource decoder_id, +PP_Bool ReturnUncompressedDataBuffer(PP_Resource decoder_id, PP_VideoUncompressedDataBuffer_Dev* buffer) { scoped_refptr<VideoDecoder> decoder( Resource::GetAs<VideoDecoder>(decoder_id)); if (!decoder) - return false; + return PP_FALSE; - return decoder->ReturnUncompressedDataBuffer(*buffer); + return BoolToPPBool(decoder->ReturnUncompressedDataBuffer(*buffer)); } const PPB_VideoDecoder_Dev ppb_videodecoder = { diff --git a/webkit/glue/plugins/pepper_widget.cc b/webkit/glue/plugins/pepper_widget.cc index 2418220..e704e8c 100644 --- a/webkit/glue/plugins/pepper_widget.cc +++ b/webkit/glue/plugins/pepper_widget.cc @@ -9,6 +9,7 @@ #include "ppapi/c/dev/ppp_widget_dev.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" +#include "webkit/glue/plugins/pepper_common.h" #include "webkit/glue/plugins/pepper_image_data.h" #include "webkit/glue/plugins/pepper_plugin_instance.h" #include "webkit/glue/plugins/pepper_plugin_module.h" @@ -17,30 +18,30 @@ namespace pepper { namespace { -bool IsWidget(PP_Resource resource) { - return !!Resource::GetAs<Widget>(resource); +PP_Bool IsWidget(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Widget>(resource)); } -bool Paint(PP_Resource resource, const PP_Rect* rect, PP_Resource image_id) { +PP_Bool Paint(PP_Resource resource, const PP_Rect* rect, PP_Resource image_id) { scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); if (!widget) - return false; + return PP_FALSE; scoped_refptr<ImageData> image(Resource::GetAs<ImageData>(image_id)); if (!image) - return false; + return PP_FALSE; - return widget->Paint(rect, image); + return BoolToPPBool(widget->Paint(rect, image)); } -bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) { +PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) { scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); - return widget && widget->HandleEvent(event); + return BoolToPPBool(widget && widget->HandleEvent(event)); } -bool GetLocation(PP_Resource resource, PP_Rect* location) { +PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) { scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); - return widget && widget->GetLocation(location); + return BoolToPPBool(widget && widget->GetLocation(location)); } void SetLocation(PP_Resource resource, const PP_Rect* location) { |