summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydatapointer.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-291-4/+0
| | | | | | | | | | | The macro was made empty in ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: Id2bb2e2cabde059305d4af5f12593344ba30f001 Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Don't manipulate immutable dataJoão Abecasis2012-09-111-1/+2
| | | | | | | | | | QArrayData can point to data it does not own (cf. fromRawData()), which shouldn't be modified. Not even upon destruction, as this data can live in Read-Only memory or be otherwise shared outside the QArrayData realm. Change-Id: I8bdf3050a17802fb003b77d5f543fe31769a7710 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andreas Hartmetz <ahartmetz@gmail.com>
* Introduce QArrayDataPointer::needsDetachJoão Abecasis2012-04-021-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | While QArrayDataPointer offers generic detach() functionality, this is only useful for operations that may modify data, but don't otherwise affect the container itself, such as non-const iteration, front() and back(). For other modifying operations, users of the API typically need to decide whether a detach is needed based on QArrayData's requirements (is data mutable? is it currently shared?) and its own (do we have spare capacity for growth?). Now that data may be shared, static or otherwise immutable (e.g., fromRawData) it no longer suffices to check the ref-count for isShared(). This commit adds needsDetach() which, from the point-of-view of QArrayData(Pointer), answers the question: 'Can contained data and associated metadata be changed?'. This fixes QArrayDataPointer::setSharable for static data (e.g., Q_ARRAY_LITERAL), previously it only catered to shared_null. SimpleVector is also fixed since it wasn't checking Mutability and it needs to because it supports fromRawData(). Change-Id: I3c7f9c85c83dfd02333762852fa456208e96d5ad Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introduce QArrayData::detachCapacityJoão Abecasis2012-04-021-1/+1
| | | | | | | | | | | | | | | This follows QArrayData::detachFlags's lead. Given the (known) size for a detached container, the function helps determine capacity, ensuring the capacityReserved flag is respected. This further helps aggregating behaviour on detach in QArrayData itself. SimpleVector was previously using qMax(capacity(), newSize), but there's no reason to pin the previous capacity value if reserve() wasn't requested. It now uses detachCapacity(). Change-Id: Ide2d99ea7ecd2cd98ae4c1aa397b4475d09c8485 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add support for rvalue-references in QArrayDataPointerJoão Abecasis2012-02-131-0/+14
| | | | | | | I love how this magically makes SimpleVector move-aware :-) Change-Id: I5cb75954d70cf256863c33e684ebc4551ac94f87 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Remove use of QT_MODULE from QArrayData stackJoão Abecasis2012-02-061-2/+0
| | | | | | | | The macro was made empty in 4ecf82795de54fba530ac9c386f3afff2174edbd, and is no longer necessary or used. Change-Id: If000ff51729e41bdcd1b0409961cf94d50e5f172 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update license headersJoão Abecasis2012-02-061-3/+3
| | | | | | | | | | | - Updated copyright year, per 1fdfc2abfe1fa26b86028934d4853432e25b4655 - Updated contact information, 629d6eda5cf67122776981de9073857bbc3dcba2 - Drop "All rights reserved", 5635823e17db3395d9b0fa8cfcc72f82fea583f4 (Empty line added to maintain license header line count) Change-Id: Ie401e2b6e40a4b79f4191377dd50dc60be801e1f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make clear() use the shared null inlineJoão Abecasis2012-02-011-1/+1
| | | | | | | | | There isn't a good reason to impose the additional library call and using the shared null here matches existing behavior in QByteArray, QString and QVector. Change-Id: Idd0bb9c7411db52630402534a11d87cbf2b1e7ba Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Enable use of QArrayDataPointer as a return typeJoão Abecasis2012-01-251-0/+5
| | | | | | | | | | | | | | | This is done through a (POD) wrapper around a raw QTypedArrayData pointer. The wrapper forces conscious decisions on the use of that pointer, while implying it is internal API. The pointed-to header is assumed to referenced, as if already owned by the receiving QArrayDataPointer. This wrapper is placed in the generic qarraydata.h header as its definition doesn't depend on QArrayDataPointer by itself. Change-Id: I9b2b6bb7dd9ab073dc7d882ccf999b32d793ed3f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move Q_CHECK_PTR to inline codeJoão Abecasis2012-01-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | The behavior of Q_CHECK_PTR is user-configurable. It may throw and exception, output a warning or be a no-op. As such, its best used in inline code that gets compiled into the user application. Moving it out of the QArrayData API also enables this to be used in code that must handle out-of-memory errors without crashing or otherwise issuing warnings. Putting in QArrayDataPointer gives good convenience coverage for those who are implementing containers on top of the QArrayData stack, and covers its use in the SimpleVector test case. It intentionally leaves out the use of allocate to access the (hidden) shared-empties which don't really allocate, anyway (in QArrayDataPointer::clear and setSharable). The autotest is not updated and will have to make do without the Q_CHECK_PTR "protection". I think that is ok. Change-Id: Idcad909903a9807866bf23ace89f1bf1edc53c3b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename QArrayData::AllocateOption to AllocationOptionJoão Abecasis2012-01-161-1/+1
| | | | | Change-Id: Id3e7c748b4b40d703ad1785c903c96bdd968390e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Enable QArrayData to reference external array dataJoão Abecasis2012-01-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | By default, QTypedArrayData::fromRawData provides the same semantics as already exist in QByteArray and QString (immutable, sharable data), but more combinations are possible. In particular, immutable-unsharable leaves the data owner in control of its lifetime by forcing deep copies. As part of this, a new isMutable property is introduced in QArrayData. This could be taken to be implicit in statics that are initialized with a proper size but with alloc set to 0. QStringLiteral and QByteLiteral already did this, forcing re-allocations on resize even before the (static, thus shared) ref-count is considered. The isMutable property detaches data mutability and shared status, which are orthogonal concepts (at least in the unshared state). For the time being, there is no API to explicitly (re)set mutability, but statics and RawData mark data immutable. Change-Id: I33a995a35e1c3d7a12391b1d7c36095aa28e221a Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add AllocateOptions to QArrayDataJoão Abecasis2012-01-091-5/+7
| | | | | | | | | | This approach is better for future ABI evolution than using individual bool parameters. QArrayData now also offers to calculate allocate options for typical detach and clone operations: the CapacityReserved flag is preserved, while cloning resets the Unsharable state. Change-Id: I256e135adcf27a52a5c7d6130069c35c8b946bc3 Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
* Remove shared_empty and unsharable_empty from APIJoão Abecasis2012-01-061-7/+2
| | | | | | | | | | | | | | They still exist and help avoid allocation of "empty" array headers, but they're no longer part of the public API, thus reducing relocatable symbols and relocations in inline code. This means an extra non-inline call on QArrayDataPointer::clear and setSharable operations, which are (expensive) detaching operations, anyway. Change-Id: Iea804e5ddc8af55ebc0951ca17a7a4e8401abc55 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add setSharable support in QArrayData stackJoão Abecasis2012-01-061-1/+19
| | | | | | | | | | | | | | | Making use of the same feature added in RefCount. To keep with the intention of avoiding the allocation of "empty" array headers, this introduces an unsharable_empty, which allows users to maintain the "unsharable bit" on empty containers, without imposing any actual allocations. (Before anyone asks, there is no point to a zero-sized capacity-reserved container so no other combinations are needed for now.) Change-Id: Icaa40ac3100ad954fdc20dee0c991861136a5b19 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Adding detach to QArrayDataPointerJoão Abecasis2012-01-061-0/+24
| | | | | | | | Detaching operations added to SimpleVector Change-Id: I5f549582cf579569f08cb8d53a6d12fe32b862e6 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introducing QArrayDataPointerJoão Abecasis2011-12-141-0/+161
This class provides RAII functionality for handling QArrayData pointers. Together with QArrayDataHeader and QArrayDataOps, this offers common boilerplate code for implementing a container which, itself, defines its own interface. Change-Id: If38eba22fbe8f69038a06fff4acb50af434d229e Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>