Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: core/include/fxcrt/fx_basic.h

Issue 889673003: Replace CFX_SmartPointer cast operator with Get() method. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _FX_BASIC_H_ 7 #ifndef _FX_BASIC_H_
8 #define _FX_BASIC_H_ 8 #define _FX_BASIC_H_
9 #ifndef _FX_SYSTEM_H_ 9 #ifndef _FX_SYSTEM_H_
10 #include "fx_system.h" 10 #include "fx_system.h"
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 m_Location = location; 1422 m_Location = location;
1423 m_OldValue = *location; 1423 m_OldValue = *location;
1424 } 1424 }
1425 ~CFX_AutoRestorer() { *m_Location = m_OldValue; } 1425 ~CFX_AutoRestorer() { *m_Location = m_OldValue; }
1426 1426
1427 private: 1427 private:
1428 T* m_Location; 1428 T* m_Location;
1429 T m_OldValue; 1429 T m_OldValue;
1430 }; 1430 };
1431 1431
1432 // For objects which support a Release() method as opposed to outright
1433 // explicit deletion.
1432 template <class T> 1434 template <class T>
1433 class CFX_SmartPointer 1435 class CFX_SmartPointer
1434 { 1436 {
1435 public: 1437 public:
1438 CFX_SmartPointer() : m_pObj(nullptr) {}
1436 CFX_SmartPointer(T *pObj) : m_pObj(pObj) {} 1439 CFX_SmartPointer(T *pObj) : m_pObj(pObj) {}
1440 CFX_SmartPointer(const CFX_SmartPointer<T>&) = delete;
1437 ~CFX_SmartPointer() 1441 ~CFX_SmartPointer()
1438 { 1442 {
1439 m_pObj->Release(); 1443 if (m_pObj)
1444 m_pObj->Release();
1440 } 1445 }
1441 operator T*(void) 1446 T* Get()
1442 { 1447 {
1443 return m_pObj; 1448 return m_pObj;
1444 } 1449 }
1445 T&» » operator *(void) 1450 T* TakeOwnership()
1451 {
1452 T* result = m_pObj;
1453 m_pObj = nullptr;
1454 return result;
1455 }
1456 T& operator* (void)
1446 { 1457 {
1447 return *m_pObj; 1458 return *m_pObj;
1448 } 1459 }
1449 T*» » operator ->(void) 1460 T* operator-> (void)
1450 { 1461 {
1451 return m_pObj; 1462 return m_pObj;
1452 } 1463 }
1464 T& operator= (const T* that)
1465 {
1466 if (m_pObj)
1467 m_pObj->Release();
1468 m_pObj = that;
dcheng 2015/01/31 01:41:30 I wonder if we need to worry about bizarre code li
1469 }
1470 T& operator= (const CFX_SmartPointer<T>&) = delete;
1453 protected: 1471 protected:
1454 T *m_pObj; 1472 T *m_pObj;
1455 }; 1473 };
1474
1456 #define FX_DATALIST_LENGTH 1024 1475 #define FX_DATALIST_LENGTH 1024
1457 template<size_t unit> 1476 template<size_t unit>
1458 class CFX_SortListArray : public CFX_Object 1477 class CFX_SortListArray : public CFX_Object
1459 { 1478 {
1460 protected: 1479 protected:
1461 1480
1462 struct DataList { 1481 struct DataList {
1463 1482
1464 FX_INT32 start; 1483 FX_INT32 start;
1465 1484
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 FX_FLOAT c; 1668 FX_FLOAT c;
1650 FX_FLOAT d; 1669 FX_FLOAT d;
1651 FX_FLOAT e; 1670 FX_FLOAT e;
1652 FX_FLOAT f; 1671 FX_FLOAT f;
1653 FX_FLOAT g; 1672 FX_FLOAT g;
1654 FX_FLOAT h; 1673 FX_FLOAT h;
1655 FX_FLOAT i; 1674 FX_FLOAT i;
1656 }; 1675 };
1657 1676
1658 #endif 1677 #endif
OLDNEW
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698