Skip to content

Commit 3872f2d

Browse files
committed
Fixed compiler warnings for the bool type.
Fixes to CookieManager: VisitUrlCookies() and VisitAllCookies() always returned false. Updated the README.txt file.
1 parent a797769 commit 3872f2d

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

cefpython/cef1/windows/binaries/README.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Chromium Embedded Framework (CEF) Standard Binary Distribution for Windows
22
-------------------------------------------------------------------------------
33

4-
Date: June 04, 2013
4+
Date: June 06, 2013
55

6-
CEF Version: 1.1453.1268
7-
CEF URL: http://chromiumembedded.googlecode.com/svn/branches/1453/cef1@1268
6+
CEF Version: 1.1453.1273
7+
CEF URL: http://chromiumembedded.googlecode.com/svn/branches/1453/cef1@1273
88

9-
Chromium Verison: 27.0.1453.93
10-
Chromium URL: http://src.chromium.org/svn/branches/1453_81/src@200836
9+
Chromium Verison: 27.0.1453.110
10+
Chromium URL: http://src.chromium.org/svn/branches/1453/src@202711
1111

1212
This distribution contains all components necessary to build and distribute an
1313
application using CEF on the Windows platform. Please see the LICENSING

cefpython/cefpython.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@
5252
# to the byte string buffer of the Python string itself. It is
5353
# tied to the life time of the Python string. When the Python
5454
# string is garbage collected, the pointer becomes invalid.
55+
#
56+
# - Do not define cpdef functions returning "cpp_bool":
57+
# | cpdef cpp_bool myfunc() except *:
58+
# This causes compiler warnings like this:
59+
# | cefpython.cpp(26533) : warning C4800: 'int' : forcing value
60+
# | to bool 'true' or 'false' (performance warning)
61+
# Do instead declare "py_bool" as return type:
62+
# | cpdef py_bool myufunc():
63+
# Lots of these warnings results in ignoring them, but sometimes
64+
# they are shown for a good reason, for example when you forget
65+
# to return a value in a function.
5566

5667
# Global variables.
5768

cefpython/cookie.pyx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,16 @@ cdef class Cookie:
132132
return CefToPyString(cefString)
133133

134134
cpdef py_void SetSecure(self, py_bool secure):
135-
self.cefCookie.secure = secure
135+
# Need to wrap it with bool() to get rid of the C++ compiler
136+
# warnings: "cefpython.cpp(24740) : warning C4800: 'int' :
137+
# forcing value to bool 'true' or 'false' (performance warning)".
138+
self.cefCookie.secure = bool(secure)
136139

137140
cpdef py_bool GetSecure(self):
138141
return self.cefCookie.secure
139142

140143
cpdef py_void SetHttpOnly(self, py_bool httpOnly):
141-
self.cefCookie.httponly = httpOnly
144+
self.cefCookie.httponly = bool(httpOnly)
142145

143146
cpdef py_bool GetHttpOnly(self):
144147
return self.cefCookie.httponly
@@ -156,7 +159,7 @@ cdef class Cookie:
156159
return CefTimeTToDatetime(self.cefCookie.last_access)
157160

158161
cpdef py_void SetHasExpires(self, py_bool hasExpires):
159-
self.cefCookie.has_expires = hasExpires
162+
self.cefCookie.has_expires = bool(hasExpires)
160163

161164
cpdef py_bool GetHasExpires(self):
162165
return self.cefCookie.has_expires
@@ -216,23 +219,25 @@ cdef class PyCookieManager:
216219
return True
217220
raise Exception("CookieVisitor object is missing Visit() method")
218221

219-
cpdef cpp_bool VisitAllCookies(self, object userCookieVisitor) except *:
222+
cpdef py_bool VisitAllCookies(self, object userCookieVisitor):
220223
self.ValidateUserCookieVisitor(userCookieVisitor)
221224
cdef int cookieVisitorId = StoreUserCookieVisitor(userCookieVisitor)
222225
cdef CefRefPtr[CefCookieVisitor] cefCookieVisitor = (
223226
<CefRefPtr[CefCookieVisitor]?>new CookieVisitor(
224227
cookieVisitorId))
225-
self.cefCookieManager.get().VisitAllCookies(cefCookieVisitor)
228+
return self.cefCookieManager.get().VisitAllCookies(
229+
cefCookieVisitor)
226230

227-
cpdef cpp_bool VisitUrlCookies(self, py_string url,
228-
py_bool includeHttpOnly, object userCookieVisitor) except *:
231+
cpdef py_bool VisitUrlCookies(self, py_string url,
232+
py_bool includeHttpOnly, object userCookieVisitor):
229233
self.ValidateUserCookieVisitor(userCookieVisitor)
230234
cdef int cookieVisitorId = StoreUserCookieVisitor(userCookieVisitor)
231235
cdef CefRefPtr[CefCookieVisitor] cefCookieVisitor = (
232236
<CefRefPtr[CefCookieVisitor]?>new CookieVisitor(
233237
cookieVisitorId))
234-
self.cefCookieManager.get().VisitUrlCookies(PyToCefStringValue(url),
235-
includeHttpOnly, cefCookieVisitor)
238+
return self.cefCookieManager.get().VisitUrlCookies(
239+
PyToCefStringValue(url), bool(includeHttpOnly),
240+
cefCookieVisitor)
236241

237242
cpdef py_void SetCookie(self, py_string url, PyCookie cookie):
238243
assert isinstance(cookie, Cookie), "cookie object is invalid"
@@ -245,7 +250,7 @@ cdef class PyCookieManager:
245250
&cef_cookie_manager_namespace.DeleteCookies,
246251
PyToCefStringValue(url), PyToCefStringValue(cookie_name)))
247252

248-
cpdef cpp_bool SetStoragePath(self, py_string path) except *:
253+
cpdef py_bool SetStoragePath(self, py_string path):
249254
return self.cefCookieManager.get().SetStoragePath(
250255
PyToCefStringValue(path))
251256

cefpython/drag_data.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ cdef PyDragData CreatePyDragData(CefRefPtr[CefDragData] cefDragData):
1010
cdef class PyDragData:
1111
cdef CefRefPtr[CefDragData] cefDragData
1212

13-
cpdef cpp_bool IsLink(self) except *:
13+
cpdef py_bool IsLink(self):
1414
return self.cefDragData.get().IsLink()
1515

16-
cpdef cpp_bool IsFragment(self) except *:
16+
cpdef py_bool IsFragment(self):
1717
return self.cefDragData.get().IsFragment()
1818

19-
cpdef cpp_bool IsFile(self) except *:
19+
cpdef py_bool IsFile(self):
2020
return self.cefDragData.get().IsFile()
2121

2222
cpdef str GetLinkUrl(self):

cefpython/request_handler.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ cdef public cpp_bool RequestHandler_GetAuthCredentials(
237237
PyToCefString(pyUsername[0], cefUsername)
238238
PyToCefString(pyPassword[0], cefPassword)
239239
return bool(ret)
240-
return False
240+
ELSE:
241+
return False
241242
except:
242243
(exc_type, exc_value, exc_trace) = sys.exc_info()
243244
sys.excepthook(exc_type, exc_value, exc_trace)

0 commit comments

Comments
 (0)