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 /ppapi | |
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
Diffstat (limited to 'ppapi')
74 files changed, 832 insertions, 507 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."; } |