libutils: hide SharedBuffer by moving SharedBuffer.h to the implementation directory

Some methods in header files of classes using SharedBuffer need
to be moved to the implementation files accordingly

Change-Id: I891f3ace2b940ab219e4e449040bfed71c0547db
This commit is contained in:
Sergio Giro 2015-09-23 16:22:59 +01:00
parent 1d758c9095
commit d2529f2830
9 changed files with 43 additions and 38 deletions

View File

@ -19,7 +19,6 @@
#include <stdint.h>
#include <sys/types.h>
#include <utils/SharedBuffer.h>
#include <utils/TypeHelpers.h>
namespace android {
@ -55,13 +54,7 @@ protected:
virtual ~BasicHashtableImpl();
void dispose();
inline void edit() {
if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) {
clone();
}
}
void edit();
void setTo(const BasicHashtableImpl& other);
void clear();

View File

@ -18,7 +18,6 @@
#define ANDROID_STRING16_H
#include <utils/Errors.h>
#include <utils/SharedBuffer.h>
#include <utils/Unicode.h>
#include <utils/TypeHelpers.h>
@ -34,6 +33,7 @@ namespace android {
// ---------------------------------------------------------------------------
class SharedBuffer;
class String8;
class TextOutput;
@ -64,10 +64,10 @@ public:
~String16();
inline const char16_t* string() const;
inline size_t size() const;
inline const SharedBuffer* sharedBuffer() const;
const SharedBuffer* sharedBuffer() const;
size_t size() const;
void setTo(const String16& other);
status_t setTo(const char16_t* other);
status_t setTo(const char16_t* other, size_t len);
@ -144,16 +144,6 @@ inline const char16_t* String16::string() const
return mString;
}
inline size_t String16::size() const
{
return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
}
inline const SharedBuffer* String16::sharedBuffer() const
{
return SharedBuffer::bufferFromData(mString);
}
inline String16& String16::operator=(const String16& other)
{
setTo(other);

View File

@ -18,7 +18,6 @@
#define ANDROID_STRING8_H
#include <utils/Errors.h>
#include <utils/SharedBuffer.h>
#include <utils/Unicode.h>
#include <utils/TypeHelpers.h>
@ -29,6 +28,7 @@
namespace android {
class SharedBuffer;
class String16;
class TextOutput;
@ -65,11 +65,11 @@ public:
inline const char* string() const;
inline size_t size() const;
inline size_t length() const;
inline size_t bytes() const;
inline bool isEmpty() const;
inline const SharedBuffer* sharedBuffer() const;
size_t length() const;
const SharedBuffer* sharedBuffer() const;
void clear();
@ -263,11 +263,6 @@ inline const char* String8::string() const
return mString;
}
inline size_t String8::length() const
{
return SharedBuffer::sizeFromData(mString)-1;
}
inline size_t String8::size() const
{
return length();
@ -280,12 +275,7 @@ inline bool String8::isEmpty() const
inline size_t String8::bytes() const
{
return SharedBuffer::sizeFromData(mString)-1;
}
inline const SharedBuffer* String8::sharedBuffer() const
{
return SharedBuffer::bufferFromData(mString);
return length();
}
inline bool String8::contains(const char* other) const

View File

@ -22,6 +22,8 @@
#include <utils/BasicHashtable.h>
#include <utils/misc.h>
#include "SharedBuffer.h"
namespace android {
BasicHashtableImpl::BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor,
@ -46,6 +48,12 @@ BasicHashtableImpl::~BasicHashtableImpl()
{
}
void BasicHashtableImpl::edit() {
if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) {
clone();
}
}
void BasicHashtableImpl::dispose() {
if (mBuckets) {
releaseBuckets(mBuckets, mBucketCount);

View File

@ -17,9 +17,10 @@
#include <stdlib.h>
#include <string.h>
#include <utils/SharedBuffer.h>
#include <utils/Atomic.h>
#include "SharedBuffer.h"
// ---------------------------------------------------------------------------
namespace android {

View File

@ -25,6 +25,7 @@
#include <stdio.h>
#include <ctype.h>
#include "SharedBuffer.h"
namespace android {
@ -165,6 +166,16 @@ String16::~String16()
SharedBuffer::bufferFromData(mString)->release();
}
size_t String16::size() const
{
return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1;
}
const SharedBuffer* String16::sharedBuffer() const
{
return SharedBuffer::bufferFromData(mString);
}
void String16::setTo(const String16& other)
{
SharedBuffer::bufferFromData(other.mString)->acquire();

View File

@ -19,12 +19,13 @@
#include <utils/Compat.h>
#include <utils/Log.h>
#include <utils/Unicode.h>
#include <utils/SharedBuffer.h>
#include <utils/String16.h>
#include <utils/threads.h>
#include <ctype.h>
#include "SharedBuffer.h"
/*
* Functions outside android is below the namespace android, since they use
* functions and constants in android namespace.
@ -211,6 +212,16 @@ String8::~String8()
SharedBuffer::bufferFromData(mString)->release();
}
size_t String8::length() const
{
return SharedBuffer::sizeFromData(mString)-1;
}
const SharedBuffer* String8::sharedBuffer() const
{
return SharedBuffer::bufferFromData(mString);
}
String8 String8::format(const char* fmt, ...)
{
va_list args;

View File

@ -23,9 +23,10 @@
#include <cutils/log.h>
#include <utils/Errors.h>
#include <utils/SharedBuffer.h>
#include <utils/VectorImpl.h>
#include "SharedBuffer.h"
/*****************************************************************************/