Make BObjectList<> publically available:

* cleaned up ObjectList.h
* switched several uses of new() to new(std::nothrow)
* moved ugly AsBList() hack into BObjectList<>::Private class and
  adjusted all callers accordingly


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40252 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2011-01-20 12:09:16 +00:00
parent 260f2d0994
commit 915a7b8c24
10 changed files with 373 additions and 257 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,38 @@
/*
* Copyright 2011, Oliver Tappe <[email protected]>
* Distributed under the terms of the MIT License.
*/
#ifndef _OBJECT_LIST_PRIVATE_H
#define _OBJECT_LIST_PRIVATE_H
#include <ObjectList.h>
template<class T>
class BObjectList<T>::Private {
public:
Private(BObjectList<T>* objectList)
:
fObjectList(objectList)
{
}
BList*
AsBList()
{
return fObjectList;
}
const BList*
AsBList() const
{
return fObjectList;
}
private:
BObjectList<T>* fObjectList;
};
#endif // _OBJECT_LIST_PRIVATE_H
+4 -1
View File
@@ -64,6 +64,8 @@ All rights reserved.
#include <String.h> #include <String.h>
#include <Window.h> #include <Window.h>
#include <ObjectListPrivate.h>
#include "ColorTools.h" #include "ColorTools.h"
#include "ObjectList.h" #include "ObjectList.h"
@@ -4520,7 +4522,8 @@ OutlineView::SortList(BRowContainer* list, bool isVisible)
{ {
if (list) { if (list) {
// Shellsort // Shellsort
BRow** items = (BRow**) list->AsBList()->Items(); BRow** items
= (BRow**) BObjectList<BRow>::Private(list).AsBList()->Items();
int32 numItems = list->CountItems(); int32 numItems = list->CountItems();
int h; int h;
for (h = 1; h < numItems / 9; h = 3 * h + 1) for (h = 1; h < numItems / 9; h = 3 * h + 1)
+1 -1
View File
@@ -25,7 +25,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
SetSubDirSupportedPlatforms haiku libbe_test ; SetSubDirSupportedPlatforms haiku libbe_test ;
UseLibraryHeaders agg icon ; UseLibraryHeaders agg icon ;
UsePrivateHeaders app input print interface libbe shared tracker ; UsePrivateHeaders app input print interface libbe shared support tracker ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
+1 -1
View File
@@ -3,7 +3,7 @@ SubDir HAIKU_TOP src kits tracker ;
SetSubDirSupportedPlatformsBeOSCompatible ; SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ; AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders interface mount shared storage tracker ; UsePrivateHeaders interface mount shared storage support tracker ;
UseLibraryHeaders icon ; UseLibraryHeaders icon ;
+9 -5
View File
@@ -68,6 +68,8 @@ All rights reserved.
#include <Volume.h> #include <Volume.h>
#include <Window.h> #include <Window.h>
#include <ObjectListPrivate.h>
#include "Attributes.h" #include "Attributes.h"
#include "AttributeStream.h" #include "AttributeStream.h"
#include "AutoLock.h" #include "AutoLock.h"
@@ -8743,7 +8745,7 @@ PoseCompareAddWidgetBinder(const BPose *p1, const BPose *p2, void *castToPoseVie
} }
struct PoseComparator : public std::binary_function<const BPose *, struct PoseComparator : public std::binary_function<const BPose *,
const BPose *, bool> const BPose *, bool>
{ {
PoseComparator(BPoseView *poseView): fPoseView(poseView) { } PoseComparator(BPoseView *poseView): fPoseView(poseView) { }
@@ -8752,7 +8754,7 @@ struct PoseComparator : public std::binary_function<const BPose *,
return PoseCompareAddWidget(p1, p2, fPoseView) < 0; return PoseCompareAddWidget(p1, p2, fPoseView) < 0;
} }
BPoseView * fPoseView; BPoseView * fPoseView;
}; };
@@ -8776,11 +8778,13 @@ BPoseView::SortPoses()
PRINT(("===================\n")); PRINT(("===================\n"));
#endif #endif
BPose **poses = reinterpret_cast<BPose **>(fPoseList->AsBList()->Items()); BPose **poses = reinterpret_cast<BPose **>(
PoseList::Private(fPoseList).AsBList()->Items());
std::stable_sort(poses, &poses[fPoseList->CountItems()], PoseComparator(this)); std::stable_sort(poses, &poses[fPoseList->CountItems()], PoseComparator(this));
if (fFiltering) { if (fFiltering) {
poses = reinterpret_cast<BPose **>(fFilteredPoseList->AsBList()->Items()); poses = reinterpret_cast<BPose **>(
std::stable_sort(poses, &poses[fPoseList->CountItems()], PoseList::Private(fFilteredPoseList).AsBList()->Items());
std::stable_sort(poses, &poses[fPoseList->CountItems()],
PoseComparator(this)); PoseComparator(this));
} }
} }
+1 -1
View File
@@ -1,7 +1,7 @@
SubDir HAIKU_TOP src servers app ; SubDir HAIKU_TOP src servers app ;
UseLibraryHeaders agg ; UseLibraryHeaders agg ;
UsePrivateHeaders app graphics input interface kernel shared storage ; UsePrivateHeaders app graphics input interface kernel shared storage support ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ; UseHeaders [ FDirName $(HAIKU_TOP) src servers app drawing Painter ] ;
+2 -1
View File
@@ -25,6 +25,7 @@
#include <LinkReceiver.h> #include <LinkReceiver.h>
#include <OffsetFile.h> #include <OffsetFile.h>
#include <ObjectListPrivate.h>
#include <PicturePlayer.h> #include <PicturePlayer.h>
#include <PictureProtocol.h> #include <PictureProtocol.h>
#include <PortLink.h> #include <PortLink.h>
@@ -1071,7 +1072,7 @@ ServerPicture::Play(View* view)
return; return;
BPrivate::PicturePlayer player(mallocIO->Buffer(), BPrivate::PicturePlayer player(mallocIO->Buffer(),
mallocIO->BufferLength(), fPictures->AsBList()); mallocIO->BufferLength(), PictureList::Private(fPictures).AsBList());
player.Play(const_cast<void**>(kTableEntries), player.Play(const_cast<void**>(kTableEntries),
sizeof(kTableEntries) / sizeof(void*), view); sizeof(kTableEntries) / sizeof(void*), view);
} }
+2 -1
View File
@@ -14,6 +14,7 @@
#include <AppServerLink.h> #include <AppServerLink.h>
#include <MessagePrivate.h> #include <MessagePrivate.h>
#include <ObjectListPrivate.h>
#include <Autolock.h> #include <Autolock.h>
#include <Deskbar.h> #include <Deskbar.h>
@@ -1729,7 +1730,7 @@ InputServer::_FilterEvent(BInputServerFilter* filter, EventList& events,
if (result == B_DISPATCH_MESSAGE) { if (result == B_DISPATCH_MESSAGE) {
EventList addedEvents; EventList addedEvents;
addedEvents.AsBList()->AddList(&newEvents); EventList::Private(&addedEvents).AsBList()->AddList(&newEvents);
_SanitizeEvents(addedEvents); _SanitizeEvents(addedEvents);
// add the new events - but don't methodize them again // add the new events - but don't methodize them again
events.AddList(&addedEvents, index); events.AddList(&addedEvents, index);
+1 -1
View File
@@ -25,7 +25,7 @@ SEARCH on US-International.keymap += [ FDirName $(HAIKU_TOP) src data keymaps ]
AddResources input_server : input_server.rdef ; AddResources input_server : input_server.rdef ;
UsePrivateHeaders app input interface shared storage ; UsePrivateHeaders app input interface shared storage support ;
UsePrivateSystemHeaders ; UsePrivateSystemHeaders ;
if $(TARGET_PLATFORM) != haiku { if $(TARGET_PLATFORM) != haiku {