1*976fe0bfSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*976fe0bfSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*976fe0bfSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*976fe0bfSAndrew Rist * distributed with this work for additional information 6*976fe0bfSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*976fe0bfSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*976fe0bfSAndrew Rist * "License"); you may not use this file except in compliance 9*976fe0bfSAndrew Rist * with the License. You may obtain a copy of the License at 10*976fe0bfSAndrew Rist * 11*976fe0bfSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*976fe0bfSAndrew Rist * 13*976fe0bfSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*976fe0bfSAndrew Rist * software distributed under the License is distributed on an 15*976fe0bfSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*976fe0bfSAndrew Rist * KIND, either express or implied. See the License for the 17*976fe0bfSAndrew Rist * specific language governing permissions and limitations 18*976fe0bfSAndrew Rist * under the License. 19*976fe0bfSAndrew Rist * 20*976fe0bfSAndrew Rist *************************************************************/ 21*976fe0bfSAndrew Rist 22*976fe0bfSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _CODEMAKER_REGISTRY_HXX_ 25cdf0e10cSrcweir #define _CODEMAKER_REGISTRY_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <rtl/alloc.h> 28cdf0e10cSrcweir #include <osl/interlck.h> 29cdf0e10cSrcweir #include <registry/registry.hxx> 30cdf0e10cSrcweir #include "registry/reader.hxx" 31cdf0e10cSrcweir #include "registry/version.h" 32cdf0e10cSrcweir #include <codemaker/options.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir struct TypeReader_Impl 35cdf0e10cSrcweir { TypeReader_ImplTypeReader_Impl36cdf0e10cSrcweir TypeReader_Impl(const sal_uInt8* buffer, 37cdf0e10cSrcweir sal_uInt32 bufferLen, 38cdf0e10cSrcweir sal_Bool copyData) 39cdf0e10cSrcweir : m_refCount(0) 40cdf0e10cSrcweir , m_copyData(copyData) 41cdf0e10cSrcweir , m_blopSize(bufferLen) 42cdf0e10cSrcweir , m_pBlop(buffer) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir if (copyData) 45cdf0e10cSrcweir { 46cdf0e10cSrcweir m_pBlop = (sal_uInt8*)rtl_allocateMemory(bufferLen); 47cdf0e10cSrcweir rtl_copyMemory((void*)m_pBlop, buffer, bufferLen); 48cdf0e10cSrcweir } else 49cdf0e10cSrcweir { 50cdf0e10cSrcweir m_blopSize = bufferLen; 51cdf0e10cSrcweir m_pBlop = buffer; 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir m_pReader = new typereg::Reader( 55cdf0e10cSrcweir m_pBlop, m_blopSize, false, TYPEREG_VERSION_1); 56cdf0e10cSrcweir } 57cdf0e10cSrcweir ~TypeReader_ImplTypeReader_Impl58cdf0e10cSrcweir ~TypeReader_Impl() 59cdf0e10cSrcweir { 60cdf0e10cSrcweir if (m_copyData && m_pReader) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir delete m_pReader; 63cdf0e10cSrcweir } 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir sal_Int32 m_refCount; 67cdf0e10cSrcweir sal_Bool m_copyData; 68cdf0e10cSrcweir sal_Int32 m_blopSize; 69cdf0e10cSrcweir const sal_uInt8* m_pBlop; 70cdf0e10cSrcweir typereg::Reader* m_pReader; 71cdf0e10cSrcweir }; 72cdf0e10cSrcweir 73cdf0e10cSrcweir class TypeReader 74cdf0e10cSrcweir { 75cdf0e10cSrcweir /* 76cdf0e10cSrcweir inline TypeReader(const RegistryTypeReader_Api* pApi, 77cdf0e10cSrcweir const sal_uInt8* buffer, 78cdf0e10cSrcweir sal_uInt32 bufferLen, 79cdf0e10cSrcweir sal_Bool copyData); 80cdf0e10cSrcweir */ 81cdf0e10cSrcweir public: TypeReader()82cdf0e10cSrcweir inline TypeReader() 83cdf0e10cSrcweir : m_pImpl(NULL) 84cdf0e10cSrcweir {} 85cdf0e10cSrcweir TypeReader(const sal_uInt8 * buffer,sal_uInt32 bufferLen,sal_Bool copyData)86cdf0e10cSrcweir inline TypeReader( const sal_uInt8* buffer, 87cdf0e10cSrcweir sal_uInt32 bufferLen, 88cdf0e10cSrcweir sal_Bool copyData) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir m_pImpl = new TypeReader_Impl(buffer, bufferLen, copyData); 91cdf0e10cSrcweir acquire(); 92cdf0e10cSrcweir } 93cdf0e10cSrcweir TypeReader(const TypeReader & toCopy)94cdf0e10cSrcweir inline TypeReader(const TypeReader& toCopy) 95cdf0e10cSrcweir : m_pImpl(toCopy.m_pImpl) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir acquire(); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir ~TypeReader()100cdf0e10cSrcweir inline ~TypeReader() 101cdf0e10cSrcweir { 102cdf0e10cSrcweir release(); 103cdf0e10cSrcweir } 104cdf0e10cSrcweir acquire()105cdf0e10cSrcweir inline void acquire() 106cdf0e10cSrcweir { 107cdf0e10cSrcweir if (m_pImpl) 108cdf0e10cSrcweir osl_incrementInterlockedCount(&m_pImpl->m_refCount); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir release()111cdf0e10cSrcweir inline void release() 112cdf0e10cSrcweir { 113cdf0e10cSrcweir if (m_pImpl && 0 == osl_decrementInterlockedCount(&m_pImpl->m_refCount)) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir delete m_pImpl; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir } 118cdf0e10cSrcweir operator =(const TypeReader & value)119cdf0e10cSrcweir inline TypeReader& operator = ( const TypeReader& value ) 120cdf0e10cSrcweir { 121cdf0e10cSrcweir release(); 122cdf0e10cSrcweir m_pImpl = value.m_pImpl; 123cdf0e10cSrcweir acquire(); 124cdf0e10cSrcweir return *this; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir isValid() const127cdf0e10cSrcweir inline sal_Bool isValid() const 128cdf0e10cSrcweir { 129cdf0e10cSrcweir if (m_pImpl) 130cdf0e10cSrcweir return m_pImpl->m_pReader->isValid(); 131cdf0e10cSrcweir else 132cdf0e10cSrcweir return sal_False; 133cdf0e10cSrcweir } 134cdf0e10cSrcweir getTypeClass() const135cdf0e10cSrcweir inline RTTypeClass getTypeClass() const 136cdf0e10cSrcweir { return m_pImpl->m_pReader->getTypeClass(); } getTypeName() const137cdf0e10cSrcweir inline const ::rtl::OString getTypeName() const 138cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getTypeName() ); } getSuperTypeCount() const139cdf0e10cSrcweir inline sal_uInt16 getSuperTypeCount() const 140cdf0e10cSrcweir { return m_pImpl->m_pReader->getSuperTypeCount(); } getSuperTypeName(sal_uInt16 index) const141cdf0e10cSrcweir inline const ::rtl::OString getSuperTypeName(sal_uInt16 index) const 142cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getSuperTypeName(index) ); } getDoku() const143cdf0e10cSrcweir inline const ::rtl::OString getDoku() const 144cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getDocumentation() ); } getFileName() const145cdf0e10cSrcweir inline const ::rtl::OString getFileName() const 146cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getFileName() ); } getFieldCount() const147cdf0e10cSrcweir inline sal_uInt32 getFieldCount() const 148cdf0e10cSrcweir { return m_pImpl->m_pReader->getFieldCount(); } getFieldName(sal_uInt16 index) const149cdf0e10cSrcweir inline const ::rtl::OString getFieldName( sal_uInt16 index ) const 150cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getFieldName(index) ); } getFieldType(sal_uInt16 index) const151cdf0e10cSrcweir inline const ::rtl::OString getFieldType( sal_uInt16 index ) const 152cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getFieldTypeName(index) ); } getFieldAccess(sal_uInt16 index) const153cdf0e10cSrcweir inline RTFieldAccess getFieldAccess( sal_uInt16 index ) const 154cdf0e10cSrcweir { return m_pImpl->m_pReader->getFieldFlags(index); } getFieldConstValue(sal_uInt16 index) const155cdf0e10cSrcweir inline RTConstValue getFieldConstValue( sal_uInt16 index ) const 156cdf0e10cSrcweir { return m_pImpl->m_pReader->getFieldValue(index); } getFieldDoku(sal_uInt16 index) const157cdf0e10cSrcweir inline const ::rtl::OString getFieldDoku( sal_uInt16 index ) const 158cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getFieldDocumentation(index) ); } getFieldFileName(sal_uInt16 index) const159cdf0e10cSrcweir inline const ::rtl::OString getFieldFileName( sal_uInt16 index ) const 160cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getFieldFileName(index) ); } getMethodCount() const161cdf0e10cSrcweir inline sal_uInt32 getMethodCount() const 162cdf0e10cSrcweir { return m_pImpl->m_pReader->getMethodCount(); } getMethodName(sal_uInt16 index) const163cdf0e10cSrcweir inline const ::rtl::OString getMethodName( sal_uInt16 index ) const 164cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getMethodName(index) ); } getMethodParamCount(sal_uInt16 index) const165cdf0e10cSrcweir inline sal_uInt32 getMethodParamCount( sal_uInt16 index ) const 166cdf0e10cSrcweir { return m_pImpl->m_pReader->getMethodParameterCount(index); } getMethodParamType(sal_uInt16 index,sal_uInt16 paramIndex) const167cdf0e10cSrcweir inline const ::rtl::OString getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const 168cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getMethodParameterTypeName(index,paramIndex) ); } getMethodParamName(sal_uInt16 index,sal_uInt16 paramIndex) const169cdf0e10cSrcweir inline const ::rtl::OString getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const 170cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getMethodParameterName(index,paramIndex) ); } getMethodParamMode(sal_uInt16 index,sal_uInt16 paramIndex) const171cdf0e10cSrcweir inline RTParamMode getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const 172cdf0e10cSrcweir { return m_pImpl->m_pReader->getMethodParameterFlags(index,paramIndex); } getMethodExcCount(sal_uInt16 index) const173cdf0e10cSrcweir inline sal_uInt32 getMethodExcCount( sal_uInt16 index ) const 174cdf0e10cSrcweir { return m_pImpl->m_pReader->getMethodExceptionCount(index); } getMethodExcType(sal_uInt16 index,sal_uInt16 excIndex) const175cdf0e10cSrcweir inline const ::rtl::OString getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const 176cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getMethodExceptionTypeName(index,excIndex) ); } getMethodReturnType(sal_uInt16 index) const177cdf0e10cSrcweir inline const ::rtl::OString getMethodReturnType( sal_uInt16 index ) const 178cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getMethodReturnTypeName(index) ); } getMethodMode(sal_uInt16 index) const179cdf0e10cSrcweir inline RTMethodMode getMethodMode( sal_uInt16 index ) const 180cdf0e10cSrcweir { return m_pImpl->m_pReader->getMethodFlags(index); } getMethodDoku(sal_uInt16 index) const181cdf0e10cSrcweir inline const ::rtl::OString getMethodDoku( sal_uInt16 index ) const 182cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getMethodDocumentation(index) ); } 183cdf0e10cSrcweir getReferenceCount() const184cdf0e10cSrcweir inline sal_uInt32 getReferenceCount() const 185cdf0e10cSrcweir { return m_pImpl->m_pReader->getReferenceCount(); } getReferenceName(sal_uInt16 index) const186cdf0e10cSrcweir inline const ::rtl::OString getReferenceName( sal_uInt16 index ) const 187cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getReferenceTypeName(index) ); } getReferenceType(sal_uInt16 index) const188cdf0e10cSrcweir inline RTReferenceType getReferenceType( sal_uInt16 index ) const 189cdf0e10cSrcweir { return m_pImpl->m_pReader->getReferenceSort(index); } getReferenceDoku(sal_uInt16 index) const190cdf0e10cSrcweir inline const ::rtl::OString getReferenceDoku( sal_uInt16 index ) const 191cdf0e10cSrcweir { return inGlobalSet( m_pImpl->m_pReader->getReferenceDocumentation(index) ); } 192cdf0e10cSrcweir getBlopSize() const193cdf0e10cSrcweir inline sal_uInt32 getBlopSize() const 194cdf0e10cSrcweir { return m_pImpl->m_blopSize; } 195cdf0e10cSrcweir getBlop() const196cdf0e10cSrcweir inline const sal_uInt8* getBlop() const 197cdf0e10cSrcweir { return m_pImpl->m_pBlop; } 198cdf0e10cSrcweir 199cdf0e10cSrcweir private: 200cdf0e10cSrcweir TypeReader_Impl* m_pImpl; 201cdf0e10cSrcweir }; 202cdf0e10cSrcweir 203cdf0e10cSrcweir 204cdf0e10cSrcweir #endif // _CODEMAKER_REGISTRY_HXX_ 205