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/c | |
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/c')
46 files changed, 498 insertions, 330 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 |