Skip to content

Commit 2845170

Browse files
committed
Sync to tfs
1 parent 6bf92cf commit 2845170

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+588
-470
lines changed

Release/collateral/Samples/FacebookDemo/MainPage.xaml.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ void MainPage::AlbumButton_Click_1(Platform::Object^ sender, Windows::UI::Xaml::
7575
.then([](web::json::value v){
7676
std::vector<FacebookAlbum^> albums;
7777

78-
for(const auto& it : v[L"data"]){
79-
auto& elem = it.second;
78+
for(const auto& elem : v[L"data"].as_array()){
8079

8180
albums.push_back(ref new FacebookAlbum(
8281
elem[L"name"].as_string(),

Release/collateral/Samples/WindowsLiveAuth/MainPage.xaml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::Route
7171
this->LogOutButton->Visibility = Windows::UI::Xaml::Visibility::Visible;
7272
this->LogInButton->Visibility = Windows::UI::Xaml::Visibility::Collapsed;
7373

74-
this->Block1->Text = ref new Platform::String((L"auth_token = \n" + lv_client.authentication_token()).c_str());
74+
this->Block1->Text = ref new Platform::String((L"access_token = \n" + lv_client.access_token()).c_str());
7575
}
7676
}, ui_ctx);
7777
}

Release/collateral/Samples/WindowsLiveAuth/live_connect.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ namespace web { namespace live {
160160
/// <returns><c>true</c> if logout succeeded, <c>false</c> otherwise.</returns>
161161
/// <remarks>
162162
/// Whether the logout attempt was successful or not, the application will
163-
/// be required to log in again, since the authentication token will be cleared.
163+
/// be required to log in again, since the access token will be cleared.
164164
/// </remarks>
165165
pplx::task<bool> logout()
166166
{
@@ -176,10 +176,10 @@ namespace web { namespace live {
176176
}
177177

178178
/// <summary>
179-
/// Retrieves the authentication token in use by this client instance.
179+
/// Retrieves the access token in use by this client instance.
180180
/// </summary>
181181
/// <returns>The current token: a string. An invalid token is indicated by an empty string.</returns>
182-
utility::string_t authentication_token() const
182+
const utility::string_t& access_token() const
183183
{
184184
return m_token;
185185
}
@@ -322,11 +322,15 @@ namespace web { namespace live {
322322
}
323323
return response.body().read_to_end(stream.streambuf());
324324
})
325-
.then([stream](pplx::task<size_t> response)
325+
.then([stream](pplx::task<size_t> ret_task)
326326
{
327-
stream.flush();
328-
stream.close();
329-
return response;
327+
return stream.flush().then([stream, ret_task]()
328+
{
329+
return stream.close();
330+
}).then([ret_task]()
331+
{
332+
return ret_task;
333+
});
330334
});
331335
});
332336
}
@@ -394,8 +398,10 @@ namespace web { namespace live {
394398
})
395399
.then([stream](pplx::task<web::http::http_response> response)
396400
{
397-
stream.close();
398-
return _json_extract(response.get());
401+
return stream.close().then([response]()
402+
{
403+
return _json_extract(response.get());
404+
});
399405
});
400406
});
401407
});

Release/include/compat/SafeInt3.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,13 @@ namespace SafeIntInternal
650650
static __declspec(noreturn) void __stdcall SafeIntOnOverflow()
651651
{
652652
SafeIntExceptionAssert();
653-
SafeIntWin32Exception( EXCEPTION_INT_OVERFLOW );
653+
SafeIntWin32Exception( (DWORD)EXCEPTION_INT_OVERFLOW );
654654
}
655655

656656
static __declspec(noreturn) void __stdcall SafeIntOnDivZero()
657657
{
658658
SafeIntExceptionAssert();
659-
SafeIntWin32Exception( EXCEPTION_INT_DIVIDE_BY_ZERO );
659+
SafeIntWin32Exception( (DWORD)EXCEPTION_INT_DIVIDE_BY_ZERO );
660660
}
661661
};
662662
#endif

Release/include/compat/windows_compat.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
****/
2727
#pragma once
2828

29-
#include <safeint.h>
29+
#include "compat\safeint3.hpp"
3030
#include <string>
3131

3232
#if _MSC_VER >= 1700
@@ -52,5 +52,4 @@ typedef std::wistringstream utf16istringstream;
5252
#define U(x) _XPLATSTR(x)
5353
#endif // !_TURN_OFF_PLATFORM_STRING
5454

55-
typedef msl::utilities::SafeInt<size_t> SafeSize;
56-
55+
typedef SafeInt<size_t> SafeSize;

Release/include/cpprest/containerstream.h

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/***
22
* ==++==
33
*
4-
* Copyright (c) Microsoft Corporation. All rights reserved.
4+
* Copyright (c) Microsoft Corporation. All rights reserved.
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -35,15 +35,12 @@
3535
#if defined(_MSC_VER) && (_MSC_VER >= 1800)
3636
#include <ppltasks.h>
3737
namespace pplx = Concurrency;
38-
#else
38+
#else
3939
#include "pplx/pplxtasks.h"
4040
#endif
4141

4242
#include "cpprest/astreambuf.h"
4343
#include "cpprest/streams.h"
44-
#ifdef _MS_WINDOWS
45-
#include <safeint.h>
46-
#endif
4744

4845
#ifndef _CONCRT_H
4946
#ifndef _LWRCASE_CNCRRNCY
@@ -96,7 +93,7 @@ namespace Concurrency { namespace streams {
9693
/// Destructor
9794
/// </summary>
9895
virtual ~basic_container_buffer()
99-
{
96+
{
10097
// Invoke the synchronous versions since we need to
10198
// purge the request queue before deleting the buffer
10299
this->_close_read();
@@ -140,7 +137,7 @@ namespace Concurrency { namespace streams {
140137
/// <param name="size">The size to use for internal buffering, 0 if no buffering should be done.</param>
141138
/// <param name="direction">The direction of buffering (in or out)</param>
142139
/// <remarks>An implementation that does not support buffering will silently ignore calls to this function and it will not have any effect on what is returned by subsequent calls to <see cref="::buffer_size method" />.</remarks>
143-
virtual void set_buffer_size(size_t , std::ios_base::openmode = std::ios_base::in)
140+
virtual void set_buffer_size(size_t , std::ios_base::openmode = std::ios_base::in)
144141
{
145142
return;
146143
}
@@ -152,16 +149,13 @@ namespace Concurrency { namespace streams {
152149
/// </summary>
153150
virtual size_t in_avail() const
154151
{
155-
// See the comment in seek around the restiction that we do not allow read head to
152+
// See the comment in seek around the restriction that we do not allow read head to
156153
// seek beyond the current write_end.
157154
_ASSERTE(m_current_position <= m_size);
158-
#ifdef _MS_WINDOWS
159-
msl::utilities::SafeInt<size_t> readhead(m_current_position);
160-
msl::utilities::SafeInt<size_t> writeend(m_size);
161-
return (size_t)(writeend - readhead);
162-
#else
163-
return m_size - m_current_position;
164-
#endif
155+
156+
SafeSize readhead(m_current_position);
157+
SafeSize writeend(m_size);
158+
return (size_t)(writeend - readhead);
165159
}
166160

167161
virtual pplx::task<bool> _sync()
@@ -207,7 +201,7 @@ namespace Concurrency { namespace streams {
207201
}
208202

209203
/// <summary>
210-
/// Gets a pointer to the next already allocated contiguous block of data.
204+
/// Gets a pointer to the next already allocated contiguous block of data.
211205
/// </summary>
212206
/// <param name="ptr">A reference to a pointer variable that will hold the address of the block on success.</param>
213207
/// <param name="count">The number of contiguous characters available at the address in 'ptr.'</param>
@@ -259,7 +253,7 @@ namespace Concurrency { namespace streams {
259253
}
260254

261255
size_t _sgetn(_Out_writes_ (count) _CharType *ptr, _In_ size_t count)
262-
{
256+
{
263257
return this->read(ptr, count);
264258
}
265259

@@ -272,7 +266,7 @@ namespace Concurrency { namespace streams {
272266
{
273267
return pplx::task_from_result(this->read_byte(true));
274268
}
275-
269+
276270
virtual int_type _sbumpc()
277271
{
278272
return this->read_byte(true);
@@ -282,7 +276,7 @@ namespace Concurrency { namespace streams {
282276
{
283277
return pplx::task_from_result(this->read_byte(false));
284278
}
285-
279+
286280
int_type _sgetc()
287281
{
288282
return this->read_byte(false);
@@ -293,7 +287,7 @@ namespace Concurrency { namespace streams {
293287
this->read_byte(true);
294288
return pplx::task_from_result(this->read_byte(false));
295289
}
296-
290+
297291
virtual pplx::task<int_type> _ungetc()
298292
{
299293
auto pos = seekoff(-1, std::ios_base::cur, std::ios_base::in);
@@ -307,7 +301,7 @@ namespace Concurrency { namespace streams {
307301
/// </summary>
308302
/// <param name="direction">The I/O direction to seek (see remarks)</param>
309303
/// <returns>The current position. EOF if the operation fails.</returns>
310-
/// <remarks>Some streams may have separate write and read cursors.
304+
/// <remarks>Some streams may have separate write and read cursors.
311305
/// For such streams, the direction parameter defines whether to move the read or the write cursor.</remarks>
312306
virtual pos_type getpos(std::ios_base::openmode mode) const
313307
{
@@ -332,7 +326,7 @@ namespace Concurrency { namespace streams {
332326
// Inorder to support relative seeking from the end postion we need to fix an end position.
333327
// Technically, there is no end for the stream buffer as new writes would just expand the buffer.
334328
// For now, we assume that the current write_end is the end of the buffer. We use this aritifical
335-
// end to restrict the read head from seeking beyond what is available.
329+
// end to restrict the read head from seeking beyond what is available.
336330

337331
pos_type end(m_size);
338332

@@ -341,7 +335,7 @@ namespace Concurrency { namespace streams {
341335
auto pos = static_cast<size_t>(position);
342336

343337
// Read head
344-
if ((mode & std::ios_base::in) && this->can_read())
338+
if ((mode & std::ios_base::in) && this->can_read())
345339
{
346340
if (position <= end)
347341
{
@@ -352,7 +346,7 @@ namespace Concurrency { namespace streams {
352346
}
353347

354348
// Write head
355-
if ((mode & std::ios_base::out) && this->can_write())
349+
if ((mode & std::ios_base::out) && this->can_write())
356350
{
357351
// Allocate space
358352
resize_for_write(pos);
@@ -368,17 +362,17 @@ namespace Concurrency { namespace streams {
368362

369363
return static_cast<pos_type>(traits::eof());
370364
}
371-
365+
372366
/// <summary>
373367
/// Seeks to a position given by a relative offset.
374368
/// </summary>
375369
/// <param name="offset">The relative position to seek to</param>
376370
/// <param name="way">The starting point (beginning, end, current) for the seek.</param>
377371
/// <param name="mode">The I/O direction to seek (see remarks)</param>
378372
/// <returns>The position. EOF if the operation fails.</returns>
379-
/// <remarks>Some streams may have separate write and read cursors.
373+
/// <remarks>Some streams may have separate write and read cursors.
380374
/// For such streams, the mode parameter defines whether to move the read or the write cursor.</remarks>
381-
virtual pos_type seekoff(off_type offset, std::ios_base::seekdir way, std::ios_base::openmode mode)
375+
virtual pos_type seekoff(off_type offset, std::ios_base::seekdir way, std::ios_base::openmode mode)
382376
{
383377
pos_type beg = 0;
384378
pos_type cur = static_cast<pos_type>(m_current_position);
@@ -406,7 +400,7 @@ namespace Concurrency { namespace streams {
406400
/// <summary>
407401
/// Constructor
408402
/// </summary>
409-
basic_container_buffer(std::ios_base::openmode mode)
403+
basic_container_buffer(std::ios_base::openmode mode)
410404
: streambuf_state_manager<typename _CollectionType::value_type>(mode),
411405
m_current_position(0),
412406
m_size(0)
@@ -417,7 +411,7 @@ namespace Concurrency { namespace streams {
417411
/// <summary>
418412
/// Constructor
419413
/// </summary>
420-
basic_container_buffer(_CollectionType data, std::ios_base::openmode mode)
414+
basic_container_buffer(_CollectionType data, std::ios_base::openmode mode)
421415
: streambuf_state_manager<typename _CollectionType::value_type>(mode),
422416
m_data(std::move(data)),
423417
m_current_position((mode & std::ios_base::in) ? 0 : m_data.size()),
@@ -471,7 +465,7 @@ namespace Concurrency { namespace streams {
471465

472466
auto readBegin = begin(m_data) + m_current_position;
473467
auto readEnd = begin(m_data) + newPos;
474-
468+
475469
#ifdef _MS_WINDOWS
476470
// Avoid warning C4996: Use checked iterators under SECURE_SCL
477471
std::copy(readBegin, readEnd, stdext::checked_array_iterator<_CharType *>(ptr, count));
@@ -495,7 +489,7 @@ namespace Concurrency { namespace streams {
495489
if (!this->can_write() || (count == 0)) return 0;
496490

497491
auto newSize = m_current_position + count;
498-
492+
499493
// Allocate space
500494
resize_for_write(newSize);
501495

@@ -557,7 +551,7 @@ namespace Concurrency { namespace streams {
557551
/// <typeparam name="_CollectionType">
558552
/// The type of the container.
559553
/// </typeparam>
560-
/// <remarks>
554+
/// <remarks>
561555
/// This is a reference-counted version of <c>basic_container_buffer</c>.
562556
/// </remarks>
563557
template<typename _CollectionType>
@@ -571,7 +565,7 @@ namespace Concurrency { namespace streams {
571565
/// </summary>
572566
/// <param name="data">The collection that is the starting point for the buffer</param>
573567
/// <param name="mode">The I/O mode that the buffer should use (in / out)</param>
574-
container_buffer(_CollectionType data, std::ios_base::openmode mode = std::ios_base::in)
568+
container_buffer(_CollectionType data, std::ios_base::openmode mode = std::ios_base::in)
575569
: streambuf<typename _CollectionType::value_type>(
576570
std::shared_ptr<details::basic_container_buffer<_CollectionType>>(new streams::details::basic_container_buffer<_CollectionType>(std::move(data), mode)))
577571
{
@@ -581,7 +575,7 @@ namespace Concurrency { namespace streams {
581575
/// Creates a container_buffer starting from an empty collection.
582576
/// </summary>
583577
/// <param name="mode">The I/O mode that the buffer should use (in / out)</param>
584-
container_buffer(std::ios_base::openmode mode = std::ios_base::out)
578+
container_buffer(std::ios_base::openmode mode = std::ios_base::out)
585579
: streambuf<typename _CollectionType::value_type>(
586580
std::shared_ptr<details::basic_container_buffer<_CollectionType>>(new details::basic_container_buffer<_CollectionType>(mode)))
587581
{
@@ -609,7 +603,7 @@ namespace Concurrency { namespace streams {
609603

610604
typedef typename _CollectionType::value_type char_type;
611605
typedef container_buffer<_CollectionType> buffer_type;
612-
606+
613607
static concurrency::streams::basic_istream<char_type> open_istream(_CollectionType data)
614608
{
615609
return concurrency::streams::basic_istream<char_type>(buffer_type(std::move(data), std::ios_base::in));
@@ -637,7 +631,7 @@ namespace Concurrency { namespace streams {
637631
class bytestream
638632
{
639633
public:
640-
634+
641635
template<typename _CollectionType>
642636
static concurrency::streams::istream open_istream(_CollectionType data)
643637
{
@@ -651,7 +645,7 @@ namespace Concurrency { namespace streams {
651645
}
652646
};
653647

654-
648+
655649
}} // namespaces
656650

657651
#pragma warning(pop) // 4100

Release/include/cpprest/fileio.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ namespace pplx = Concurrency;
4242

4343
#ifdef WIN32
4444
#include <cstdint>
45-
#include <safeint.h>
4645
#endif
4746

4847
#include "cpprest/basic_types.h"

Release/include/cpprest/filestream.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,10 @@ namespace details {
187187

188188
if ( m_info->m_buffer == nullptr || m_info->m_buffill == 0 ) return 0;
189189
if ( m_info->m_bufoff > m_info->m_rdpos || (m_info->m_bufoff+m_info->m_buffill) < m_info->m_rdpos ) return 0;
190-
#ifdef _MS_WINDOWS
191-
msl::utilities::SafeInt<size_t> rdpos(m_info->m_rdpos);
192-
msl::utilities::SafeInt<size_t> buffill(m_info->m_buffill);
193-
msl::utilities::SafeInt<size_t> bufpos = rdpos - m_info->m_bufoff;
194-
#else
195190

196-
size_t rdpos(m_info->m_rdpos);
197-
size_t buffill(m_info->m_buffill);
198-
size_t bufpos = rdpos - m_info->m_bufoff;
199-
#endif
191+
SafeInt<size_t> rdpos(m_info->m_rdpos);
192+
SafeInt<size_t> buffill(m_info->m_buffill);
193+
SafeInt<size_t> bufpos = rdpos - m_info->m_bufoff;
200194

201195
return buffill - bufpos;
202196
}

0 commit comments

Comments
 (0)