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

View File

@ -0,0 +1,38 @@
/*
* Copyright 2011, Oliver Tappe <zooey@hirschkaefer.de>
* 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

View File

@ -64,6 +64,8 @@ All rights reserved.
#include <String.h>
#include <Window.h>
#include <ObjectListPrivate.h>
#include "ColorTools.h"
#include "ObjectList.h"
@ -4520,7 +4522,8 @@ OutlineView::SortList(BRowContainer* list, bool isVisible)
{
if (list) {
// Shellsort
BRow** items = (BRow**) list->AsBList()->Items();
BRow** items
= (BRow**) BObjectList<BRow>::Private(list).AsBList()->Items();
int32 numItems = list->CountItems();
int h;
for (h = 1; h < numItems / 9; h = 3 * h + 1)

View File

@ -25,7 +25,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
SetSubDirSupportedPlatforms haiku libbe_test ;
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) layouter ] ;

View File

@ -3,7 +3,7 @@ SubDir HAIKU_TOP src kits tracker ;
SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders interface mount shared storage tracker ;
UsePrivateHeaders interface mount shared storage support tracker ;
UseLibraryHeaders icon ;

View File

@ -68,6 +68,8 @@ All rights reserved.
#include <Volume.h>
#include <Window.h>
#include <ObjectListPrivate.h>
#include "Attributes.h"
#include "AttributeStream.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>
{
PoseComparator(BPoseView *poseView): fPoseView(poseView) { }
@ -8752,7 +8754,7 @@ struct PoseComparator : public std::binary_function<const BPose *,
return PoseCompareAddWidget(p1, p2, fPoseView) < 0;
}
BPoseView * fPoseView;
BPoseView * fPoseView;
};
@ -8776,11 +8778,13 @@ BPoseView::SortPoses()
PRINT(("===================\n"));
#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));
if (fFiltering) {
poses = reinterpret_cast<BPose **>(fFilteredPoseList->AsBList()->Items());
std::stable_sort(poses, &poses[fPoseList->CountItems()],
poses = reinterpret_cast<BPose **>(
PoseList::Private(fFilteredPoseList).AsBList()->Items());
std::stable_sort(poses, &poses[fPoseList->CountItems()],
PoseComparator(this));
}
}

View File

@ -1,7 +1,7 @@
SubDir HAIKU_TOP src servers app ;
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 Painter ] ;

View File

@ -25,6 +25,7 @@
#include <LinkReceiver.h>
#include <OffsetFile.h>
#include <ObjectListPrivate.h>
#include <PicturePlayer.h>
#include <PictureProtocol.h>
#include <PortLink.h>
@ -1071,7 +1072,7 @@ ServerPicture::Play(View* view)
return;
BPrivate::PicturePlayer player(mallocIO->Buffer(),
mallocIO->BufferLength(), fPictures->AsBList());
mallocIO->BufferLength(), PictureList::Private(fPictures).AsBList());
player.Play(const_cast<void**>(kTableEntries),
sizeof(kTableEntries) / sizeof(void*), view);
}

View File

@ -14,6 +14,7 @@
#include <AppServerLink.h>
#include <MessagePrivate.h>
#include <ObjectListPrivate.h>
#include <Autolock.h>
#include <Deskbar.h>
@ -1729,7 +1730,7 @@ InputServer::_FilterEvent(BInputServerFilter* filter, EventList& events,
if (result == B_DISPATCH_MESSAGE) {
EventList addedEvents;
addedEvents.AsBList()->AddList(&newEvents);
EventList::Private(&addedEvents).AsBList()->AddList(&newEvents);
_SanitizeEvents(addedEvents);
// add the new events - but don't methodize them again
events.AddList(&addedEvents, index);

View File

@ -25,7 +25,7 @@ SEARCH on US-International.keymap += [ FDirName $(HAIKU_TOP) src data keymaps ]
AddResources input_server : input_server.rdef ;
UsePrivateHeaders app input interface shared storage ;
UsePrivateHeaders app input interface shared storage support ;
UsePrivateSystemHeaders ;
if $(TARGET_PLATFORM) != haiku {