summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp
diff options
context:
space:
mode:
authordmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 14:45:44 +0000
committerdmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-05 14:45:44 +0000
commit6f2e3919c4709404d8d7b6742f9cd9989b799c98 (patch)
tree55a933f7e2988625f0f3ded5a562203c7e3921c9 /ppapi/cpp
parent79ba2d8a26fe6c9b343c57fef57896a90baa3878 (diff)
downloadchromium_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/cpp')
-rw-r--r--ppapi/cpp/common.h38
-rw-r--r--ppapi/cpp/core.cc3
-rw-r--r--ppapi/cpp/dev/file_ref_dev.cc4
-rw-r--r--ppapi/cpp/dev/find_dev.cc20
-rw-r--r--ppapi/cpp/dev/font_dev.cc19
-rw-r--r--ppapi/cpp/dev/font_dev.h15
-rw-r--r--ppapi/cpp/dev/fullscreen_dev.cc6
-rw-r--r--ppapi/cpp/dev/graphics_3d_dev.cc25
-rw-r--r--ppapi/cpp/dev/scrollbar_dev.cc4
-rw-r--r--ppapi/cpp/dev/selection_dev.cc6
-rw-r--r--ppapi/cpp/dev/url_loader_dev.cc16
-rw-r--r--ppapi/cpp/dev/url_request_info_dev.cc33
-rw-r--r--ppapi/cpp/dev/url_util_dev.cc13
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc19
-rw-r--r--ppapi/cpp/dev/widget_dev.cc11
-rw-r--r--ppapi/cpp/dev/zoom_dev.cc6
-rw-r--r--ppapi/cpp/graphics_2d.cc3
-rw-r--r--ppapi/cpp/image_data.cc3
-rw-r--r--ppapi/cpp/instance.cc6
-rw-r--r--ppapi/cpp/module.cc40
-rw-r--r--ppapi/cpp/module.h9
-rw-r--r--ppapi/cpp/var.cc5
22 files changed, 197 insertions, 107 deletions
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 {