Kaydet (Commit) a843c457 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Remove RegistryTypeReader_Api indirection

Change-Id: I43710d057043a258ec9ab94bca0703434098e6c9
üst cfde943f
...@@ -1741,31 +1741,90 @@ void TYPEREG_CALLTYPE typereg_reader_getSuperTypeName( ...@@ -1741,31 +1741,90 @@ void TYPEREG_CALLTYPE typereg_reader_getSuperTypeName(
rtl_uString_new(pSuperTypeName); rtl_uString_new(pSuperTypeName);
} }
RegistryTypeReader_Api* TYPEREG_CALLTYPE initRegistryTypeReader_Api() RegistryTypeReader::RegistryTypeReader(const sal_uInt8* buffer,
{ sal_uInt32 bufferLen,
static RegistryTypeReader_Api aApi= {0,0,0,0,0,0,0,0,0,0,0,0,0}; bool copyData)
if (!aApi.acquire) : m_hImpl(NULL)
{ {
aApi.createEntry = &createEntry; m_hImpl = createEntry(buffer, bufferLen, copyData);
aApi.acquire = &typereg_reader_acquire; }
aApi.release = &typereg_reader_release;
aApi.getTypeClass = &typereg_reader_getTypeClass; RegistryTypeReader::RegistryTypeReader(const RegistryTypeReader& toCopy)
aApi.getTypeName = &typereg_reader_getTypeName; : m_hImpl(toCopy.m_hImpl)
aApi.getSuperTypeName = &getSuperTypeName; { typereg_reader_acquire(m_hImpl); }
aApi.getFieldCount = &getFieldCount;
aApi.getFieldName = &typereg_reader_getFieldName;
aApi.getFieldType = &typereg_reader_getFieldTypeName; RegistryTypeReader::~RegistryTypeReader()
aApi.getFieldAccess = &typereg_reader_getFieldFlags; { typereg_reader_release(m_hImpl); }
aApi.getFieldConstValue = &getFieldConstValue;
aApi.getFieldDoku = &typereg_reader_getFieldDocumentation; RegistryTypeReader& RegistryTypeReader::operator == (const RegistryTypeReader& toAssign)
aApi.getFieldFileName = &typereg_reader_getFieldFileName; {
if (m_hImpl != toAssign.m_hImpl)
return (&aApi);
}
else
{ {
return (&aApi); typereg_reader_release(m_hImpl);
m_hImpl = toAssign.m_hImpl;
typereg_reader_acquire(m_hImpl);
} }
return *this;
}
RTTypeClass RegistryTypeReader::getTypeClass() const
{ return typereg_reader_getTypeClass(m_hImpl); }
rtl::OUString RegistryTypeReader::getTypeName() const
{
rtl::OUString sRet;
typereg_reader_getTypeName(m_hImpl, &sRet.pData);
return sRet;
}
rtl::OUString RegistryTypeReader::getSuperTypeName() const
{
rtl::OUString sRet;
::getSuperTypeName(m_hImpl, &sRet.pData);
return sRet;
}
sal_uInt32 RegistryTypeReader::getFieldCount() const
{ return ::getFieldCount(m_hImpl); }
rtl::OUString RegistryTypeReader::getFieldName( sal_uInt16 index ) const
{
rtl::OUString sRet;
typereg_reader_getFieldName(m_hImpl, &sRet.pData, index);
return sRet;
}
rtl::OUString RegistryTypeReader::getFieldType( sal_uInt16 index ) const
{
rtl::OUString sRet;
typereg_reader_getFieldTypeName(m_hImpl, &sRet.pData, index);
return sRet;
}
RTFieldAccess RegistryTypeReader::getFieldAccess( sal_uInt16 index ) const
{ return typereg_reader_getFieldFlags(m_hImpl, index); }
RTConstValue RegistryTypeReader::getFieldConstValue( sal_uInt16 index ) const
{
RTConstValue ret;
ret.m_type = ::getFieldConstValue(m_hImpl, index, &ret.m_value);
return ret;
}
rtl::OUString RegistryTypeReader::getFieldDoku( sal_uInt16 index ) const
{
rtl::OUString sRet;
typereg_reader_getFieldDocumentation(m_hImpl, &sRet.pData, index);
return sRet;
}
rtl::OUString RegistryTypeReader::getFieldFileName( sal_uInt16 index ) const
{
rtl::OUString sRet;
typereg_reader_getFieldFileName(m_hImpl, &sRet.pData, index);
return sRet;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -27,50 +27,10 @@ ...@@ -27,50 +27,10 @@
/// Implememetation handle /// Implememetation handle
typedef void* TypeReaderImpl; typedef void* TypeReaderImpl;
/****************************************************************************
C-Api
*****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/** specifies a collection of function pointers which represents the complete registry type reader C-API.
This funtions pointers are used by the C++ wrapper to call the C-API.
*/
struct RegistryTypeReader_Api
{
TypeReaderImpl (TYPEREG_CALLTYPE *createEntry) (const sal_uInt8*, sal_uInt32, bool);
void (TYPEREG_CALLTYPE *acquire) (TypeReaderImpl);
void (TYPEREG_CALLTYPE *release) (TypeReaderImpl);
RTTypeClass (TYPEREG_CALLTYPE *getTypeClass) (TypeReaderImpl);
void (TYPEREG_CALLTYPE *getTypeName) (TypeReaderImpl, rtl_uString**);
void (TYPEREG_CALLTYPE *getSuperTypeName) (TypeReaderImpl, rtl_uString**);
sal_uInt32 (TYPEREG_CALLTYPE *getFieldCount) (TypeReaderImpl);
void (TYPEREG_CALLTYPE *getFieldName) (TypeReaderImpl, rtl_uString**, sal_uInt16);
void (TYPEREG_CALLTYPE *getFieldType) (TypeReaderImpl, rtl_uString**, sal_uInt16);
RTFieldAccess (TYPEREG_CALLTYPE *getFieldAccess) (TypeReaderImpl, sal_uInt16);
RTValueType (TYPEREG_CALLTYPE *getFieldConstValue) (TypeReaderImpl, sal_uInt16, RTConstValueUnion*);
void (TYPEREG_CALLTYPE *getFieldDoku) (TypeReaderImpl, rtl_uString**, sal_uInt16);
void (TYPEREG_CALLTYPE *getFieldFileName) (TypeReaderImpl, rtl_uString**, sal_uInt16);
};
/** the API initialization function.
*/
RegistryTypeReader_Api* TYPEREG_CALLTYPE initRegistryTypeReader_Api();
#ifdef __cplusplus
}
#endif
/** RegistryTypeReades reads a binary type blob. /** RegistryTypeReades reads a binary type blob.
This class provides the necessary functions to read type information This class provides the necessary functions to read type information
for all kinds of types of a type blob. for all kinds of types of a type blob.
The class is inline and use a C-Api.
@deprecated @deprecated
use typereg::Reader instead use typereg::Reader instead
...@@ -87,18 +47,18 @@ public: ...@@ -87,18 +47,18 @@ public:
The block can be copied to ensure that the data The block can be copied to ensure that the data
is valid for the lifetime of this instance. is valid for the lifetime of this instance.
*/ */
inline RegistryTypeReader(const sal_uInt8* buffer, RegistryTypeReader(const sal_uInt8* buffer,
sal_uInt32 bufferLen, sal_uInt32 bufferLen,
bool copyData); bool copyData);
/// Copy constructcor /// Copy constructcor
inline RegistryTypeReader(const RegistryTypeReader& toCopy); RegistryTypeReader(const RegistryTypeReader& toCopy);
/// Destructor. The Destructor frees the data block if the copyData flag was TRUE. /// Destructor. The Destructor frees the data block if the copyData flag was TRUE.
inline ~RegistryTypeReader(); ~RegistryTypeReader();
/// Assign operator /// Assign operator
inline RegistryTypeReader& operator == (const RegistryTypeReader& toAssign); RegistryTypeReader& operator == (const RegistryTypeReader& toAssign);
/** returns the typeclass of the type represented by this blob. /** returns the typeclass of the type represented by this blob.
...@@ -106,158 +66,59 @@ public: ...@@ -106,158 +66,59 @@ public:
This function will always return the type class without the internal This function will always return the type class without the internal
RT_TYPE_PUBLISHED flag set. RT_TYPE_PUBLISHED flag set.
*/ */
inline RTTypeClass getTypeClass() const; RTTypeClass getTypeClass() const;
/** returns the full qualified name of the type. /** returns the full qualified name of the type.
*/ */
inline rtl::OUString getTypeName() const; rtl::OUString getTypeName() const;
/** returns the full qualified name of the supertype. /** returns the full qualified name of the supertype.
*/ */
inline rtl::OUString getSuperTypeName() const; rtl::OUString getSuperTypeName() const;
/** returns the number of fields (attributes/properties, enum values or number /** returns the number of fields (attributes/properties, enum values or number
of constants in a module). of constants in a module).
*/ */
inline sal_uInt32 getFieldCount() const; sal_uInt32 getFieldCount() const;
/** returns the name of the field specified by index. /** returns the name of the field specified by index.
*/ */
inline rtl::OUString getFieldName( sal_uInt16 index ) const; rtl::OUString getFieldName( sal_uInt16 index ) const;
/** returns the full qualified name of the field specified by index. /** returns the full qualified name of the field specified by index.
*/ */
inline rtl::OUString getFieldType( sal_uInt16 index ) const; rtl::OUString getFieldType( sal_uInt16 index ) const;
/** returns the access mode of the field specified by index. /** returns the access mode of the field specified by index.
*/ */
inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const; RTFieldAccess getFieldAccess( sal_uInt16 index ) const;
/** returns the value of the field specified by index. /** returns the value of the field specified by index.
This function returns the value of an enum value or of a constant. This function returns the value of an enum value or of a constant.
*/ */
inline RTConstValue getFieldConstValue( sal_uInt16 index ) const; RTConstValue getFieldConstValue( sal_uInt16 index ) const;
/** returns the documentation string for the field specified by index. /** returns the documentation string for the field specified by index.
Each field of a type can have their own documentation. Each field of a type can have their own documentation.
*/ */
inline rtl::OUString getFieldDoku( sal_uInt16 index ) const; rtl::OUString getFieldDoku( sal_uInt16 index ) const;
/** returns the IDL filename of the field specified by index. /** returns the IDL filename of the field specified by index.
The IDL filename of a field can differ from the filename of the ype itself The IDL filename of a field can differ from the filename of the ype itself
because modules and also constants can be defined in different IDL files. because modules and also constants can be defined in different IDL files.
*/ */
inline rtl::OUString getFieldFileName( sal_uInt16 index ) const; rtl::OUString getFieldFileName( sal_uInt16 index ) const;
protected: protected:
/// stores the registry type reader Api.
const RegistryTypeReader_Api* m_pApi;
/// stores the handle of an implementation class /// stores the handle of an implementation class
TypeReaderImpl m_hImpl; TypeReaderImpl m_hImpl;
}; };
inline RegistryTypeReader::RegistryTypeReader(const sal_uInt8* buffer,
sal_uInt32 bufferLen,
bool copyData)
: m_pApi(initRegistryTypeReader_Api())
, m_hImpl(NULL)
{
m_hImpl = m_pApi->createEntry(buffer, bufferLen, copyData);
}
inline RegistryTypeReader::RegistryTypeReader(const RegistryTypeReader& toCopy)
: m_pApi(toCopy.m_pApi)
, m_hImpl(toCopy.m_hImpl)
{ m_pApi->acquire(m_hImpl); }
inline RegistryTypeReader::~RegistryTypeReader()
{ m_pApi->release(m_hImpl); }
inline RegistryTypeReader& RegistryTypeReader::operator == (const RegistryTypeReader& toAssign)
{
if (m_hImpl != toAssign.m_hImpl)
{
m_pApi->release(m_hImpl);
m_hImpl = toAssign.m_hImpl;
m_pApi->acquire(m_hImpl);
}
return *this;
}
inline RTTypeClass RegistryTypeReader::getTypeClass() const
{ return m_pApi->getTypeClass(m_hImpl); }
inline rtl::OUString RegistryTypeReader::getTypeName() const
{
rtl::OUString sRet;
m_pApi->getTypeName(m_hImpl, &sRet.pData);
return sRet;
}
inline rtl::OUString RegistryTypeReader::getSuperTypeName() const
{
rtl::OUString sRet;
m_pApi->getSuperTypeName(m_hImpl, &sRet.pData);
return sRet;
}
inline sal_uInt32 RegistryTypeReader::getFieldCount() const
{ return m_pApi->getFieldCount(m_hImpl); }
inline rtl::OUString RegistryTypeReader::getFieldName( sal_uInt16 index ) const
{
rtl::OUString sRet;
m_pApi->getFieldName(m_hImpl, &sRet.pData, index);
return sRet;
}
inline rtl::OUString RegistryTypeReader::getFieldType( sal_uInt16 index ) const
{
rtl::OUString sRet;
m_pApi->getFieldType(m_hImpl, &sRet.pData, index);
return sRet;
}
inline RTFieldAccess RegistryTypeReader::getFieldAccess( sal_uInt16 index ) const
{ return m_pApi->getFieldAccess(m_hImpl, index); }
inline RTConstValue RegistryTypeReader::getFieldConstValue( sal_uInt16 index ) const
{
RTConstValue ret;
ret.m_type = m_pApi->getFieldConstValue(m_hImpl, index, &ret.m_value);
return ret;
}
inline rtl::OUString RegistryTypeReader::getFieldDoku( sal_uInt16 index ) const
{
rtl::OUString sRet;
m_pApi->getFieldDoku(m_hImpl, &sRet.pData, index);
return sRet;
}
inline rtl::OUString RegistryTypeReader::getFieldFileName( sal_uInt16 index ) const
{
rtl::OUString sRet;
m_pApi->getFieldFileName(m_hImpl, &sRet.pData, index);
return sRet;
}
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment