* Added KMessage to libroot_build.
* libbe_build: Where possible we directly use the actual Haiku headers and sources, now. In the headers/build headers we just include the respective Haiku headers as needed. That still allows overrides where necessary. The intention is to make it easier to keep the build stuff in sync. * Fixed a few printf() format and signed/unsigned comparison warnings. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42179 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,220 +1 @@
|
||||
/*
|
||||
* Copyright 2001-2007, Ingo Weinhold, [email protected]. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _AUTO_DELETER_H
|
||||
#define _AUTO_DELETER_H
|
||||
|
||||
/*! Scope-based automatic deletion of objects/arrays.
|
||||
ObjectDeleter - deletes an object
|
||||
ArrayDeleter - deletes an array
|
||||
MemoryDeleter - free()s malloc()ed memory
|
||||
CObjectDeleter - calls an arbitrary specified destructor function
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
// AutoDeleter
|
||||
|
||||
template<typename C, typename DeleteFunc>
|
||||
class AutoDeleter {
|
||||
public:
|
||||
inline AutoDeleter()
|
||||
: fObject(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
inline AutoDeleter(C *object)
|
||||
: fObject(object)
|
||||
{
|
||||
}
|
||||
|
||||
inline ~AutoDeleter()
|
||||
{
|
||||
fDelete(fObject);
|
||||
}
|
||||
|
||||
inline void SetTo(C *object)
|
||||
{
|
||||
if (object != fObject) {
|
||||
fDelete(fObject);
|
||||
fObject = object;
|
||||
}
|
||||
}
|
||||
|
||||
inline void Unset()
|
||||
{
|
||||
SetTo(NULL);
|
||||
}
|
||||
|
||||
inline void Delete()
|
||||
{
|
||||
SetTo(NULL);
|
||||
}
|
||||
|
||||
inline C *Get() const
|
||||
{
|
||||
return fObject;
|
||||
}
|
||||
|
||||
inline C *Detach()
|
||||
{
|
||||
C *object = fObject;
|
||||
fObject = NULL;
|
||||
return object;
|
||||
}
|
||||
|
||||
protected:
|
||||
C *fObject;
|
||||
DeleteFunc fDelete;
|
||||
};
|
||||
|
||||
|
||||
// ObjectDeleter
|
||||
|
||||
template<typename C>
|
||||
struct ObjectDelete
|
||||
{
|
||||
inline void operator()(C *object)
|
||||
{
|
||||
delete object;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct ObjectDeleter : AutoDeleter<C, ObjectDelete<C> >
|
||||
{
|
||||
ObjectDeleter() : AutoDeleter<C, ObjectDelete<C> >() {}
|
||||
ObjectDeleter(C *object) : AutoDeleter<C, ObjectDelete<C> >(object) {}
|
||||
};
|
||||
|
||||
|
||||
// ArrayDeleter
|
||||
|
||||
template<typename C>
|
||||
struct ArrayDelete
|
||||
{
|
||||
inline void operator()(C *array)
|
||||
{
|
||||
delete[] array;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
struct ArrayDeleter : AutoDeleter<C, ArrayDelete<C> >
|
||||
{
|
||||
ArrayDeleter() : AutoDeleter<C, ArrayDelete<C> >() {}
|
||||
ArrayDeleter(C *array) : AutoDeleter<C, ArrayDelete<C> >(array) {}
|
||||
};
|
||||
|
||||
|
||||
// MemoryDeleter
|
||||
|
||||
struct MemoryDelete
|
||||
{
|
||||
inline void operator()(void *memory)
|
||||
{
|
||||
free(memory);
|
||||
}
|
||||
};
|
||||
|
||||
struct MemoryDeleter : AutoDeleter<void, MemoryDelete >
|
||||
{
|
||||
MemoryDeleter() : AutoDeleter<void, MemoryDelete >() {}
|
||||
MemoryDeleter(void *memory) : AutoDeleter<void, MemoryDelete >(memory) {}
|
||||
};
|
||||
|
||||
|
||||
// CObjectDeleter
|
||||
|
||||
template<typename Type, typename DestructorReturnType>
|
||||
struct CObjectDelete
|
||||
{
|
||||
inline void operator()(Type *object)
|
||||
{
|
||||
if (fDestructor != NULL && object != NULL)
|
||||
fDestructor(object);
|
||||
}
|
||||
|
||||
template<typename Destructor>
|
||||
inline void operator=(Destructor destructor)
|
||||
{
|
||||
fDestructor = destructor;
|
||||
}
|
||||
|
||||
private:
|
||||
DestructorReturnType (*fDestructor)(Type*);
|
||||
};
|
||||
|
||||
template<typename Type, typename DestructorReturnType = void>
|
||||
struct CObjectDeleter
|
||||
: AutoDeleter<Type, CObjectDelete<Type, DestructorReturnType> >
|
||||
{
|
||||
typedef AutoDeleter<Type, CObjectDelete<Type, DestructorReturnType> > Base;
|
||||
|
||||
template<typename Destructor>
|
||||
CObjectDeleter(Destructor destructor) : Base()
|
||||
{
|
||||
Base::fDelete = destructor;
|
||||
}
|
||||
|
||||
template<typename Destructor>
|
||||
CObjectDeleter(Type *object, Destructor destructor) : Base(object)
|
||||
{
|
||||
Base::fDelete = destructor;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// MethodDeleter
|
||||
|
||||
template<typename Type, typename DestructorReturnType>
|
||||
struct MethodDelete
|
||||
{
|
||||
inline void operator()(Type *object)
|
||||
{
|
||||
if (fDestructor && object != NULL)
|
||||
(object->*fDestructor)();
|
||||
}
|
||||
|
||||
template<typename Destructor>
|
||||
inline void operator=(Destructor destructor)
|
||||
{
|
||||
fDestructor = destructor;
|
||||
}
|
||||
|
||||
private:
|
||||
DestructorReturnType (Type::*fDestructor)();
|
||||
};
|
||||
|
||||
|
||||
template<typename Type, typename DestructorReturnType = void>
|
||||
struct MethodDeleter
|
||||
: AutoDeleter<Type, MethodDelete<Type, DestructorReturnType> >
|
||||
{
|
||||
typedef AutoDeleter<Type, MethodDelete<Type, DestructorReturnType> > Base;
|
||||
|
||||
template<typename Destructor>
|
||||
MethodDeleter(Destructor destructor) : Base()
|
||||
{
|
||||
Base::fDelete = destructor;
|
||||
}
|
||||
|
||||
template<typename Destructor>
|
||||
MethodDeleter(Type *object, Destructor destructor) : Base(object)
|
||||
{
|
||||
Base::fDelete = destructor;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using BPrivate::ObjectDeleter;
|
||||
using BPrivate::ArrayDeleter;
|
||||
using BPrivate::MemoryDeleter;
|
||||
using BPrivate::CObjectDeleter;
|
||||
using BPrivate::MethodDeleter;
|
||||
|
||||
#endif // _AUTO_DELETER_H
|
||||
#include <../private/shared/AutoDeleter.h>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include <../private/shared/AutoLocker.h>
|
||||
@@ -1,61 +1 @@
|
||||
/*
|
||||
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Jérôme Duval
|
||||
* Axel Dörfler, [email protected].
|
||||
*/
|
||||
#ifndef _KEYMAP_H
|
||||
#define _KEYMAP_H
|
||||
|
||||
|
||||
#include <DataIO.h>
|
||||
#include <InterfaceDefs.h>
|
||||
|
||||
|
||||
class BKeymap {
|
||||
public:
|
||||
BKeymap();
|
||||
virtual ~BKeymap();
|
||||
|
||||
status_t SetTo(const char* path);
|
||||
status_t SetTo(BDataIO& stream);
|
||||
status_t SetToCurrent();
|
||||
status_t SetToDefault();
|
||||
void Unset();
|
||||
|
||||
bool IsModifierKey(uint32 keyCode) const;
|
||||
uint32 Modifier(uint32 keyCode) const;
|
||||
uint32 KeyForModifier(uint32 modifier) const;
|
||||
uint8 ActiveDeadKey(uint32 keyCode,
|
||||
uint32 modifiers) const;
|
||||
uint8 DeadKey(uint32 keyCode, uint32 modifiers,
|
||||
bool* _isEnabled) const;
|
||||
bool IsDeadSecondKey(uint32 keyCode,
|
||||
uint32 modifiers,
|
||||
uint8 activeDeadKey) const;
|
||||
void GetChars(uint32 keyCode, uint32 modifiers,
|
||||
uint8 activeDeadKey, char** chars,
|
||||
int32* numBytes) const;
|
||||
|
||||
const key_map& Map() const { return fKeys; }
|
||||
|
||||
bool operator==(const BKeymap& other) const;
|
||||
bool operator!=(const BKeymap& other) const;
|
||||
|
||||
BKeymap& operator=(const BKeymap& other);
|
||||
|
||||
protected:
|
||||
int32 Offset(uint32 keyCode, uint32 modifiers,
|
||||
uint32* _table = NULL) const;
|
||||
uint8 DeadKeyIndex(int32 offset) const;
|
||||
|
||||
protected:
|
||||
char* fChars;
|
||||
key_map fKeys;
|
||||
uint32 fCharsSize;
|
||||
};
|
||||
|
||||
|
||||
#endif // KEYMAP_H
|
||||
#include <../private/shared/Keymap.h>
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: ObjectLocker.h
|
||||
// Author(s): Erik Jaesler ([email protected])
|
||||
// Description: A templatized version of BAutolock. Client class needs to
|
||||
// supply:
|
||||
// bool Lock() -- returns whether lock succeeded
|
||||
// void Unlock() -- unlocks the class
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifndef OBJECTLOCKER_H
|
||||
#define OBJECTLOCKER_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
template<class T>
|
||||
class BObjectLocker
|
||||
{
|
||||
public:
|
||||
inline BObjectLocker(T* looper);
|
||||
inline BObjectLocker(T& locker);
|
||||
|
||||
inline ~BObjectLocker();
|
||||
|
||||
inline bool IsLocked(void);
|
||||
|
||||
private:
|
||||
T* fLockClient;
|
||||
bool fIsLocked;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
BObjectLocker<T>::BObjectLocker(T* client)
|
||||
: fLockClient(client), fIsLocked(client->Lock())
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BObjectLocker<T>::BObjectLocker(T& client)
|
||||
: fLockClient(&client), fIsLocked(client.Lock())
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
BObjectLocker<T>::~BObjectLocker()
|
||||
{
|
||||
if (fIsLocked)
|
||||
{
|
||||
fLockClient->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool BObjectLocker<T>::IsLocked(void)
|
||||
{
|
||||
return fIsLocked;
|
||||
}
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif //OBJECTLOCKER_H
|
||||
|
||||
/*
|
||||
* $Log $
|
||||
*
|
||||
* $Id $
|
||||
*
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user