From ee27dd72550ce8815e06e337d3682d5b8d9d7b11 Mon Sep 17 00:00:00 2001 From: Jens-Heiner Rechtien Date: Mon, 18 Sep 2000 15:33:13 +0000 Subject: initial import --- idl/inc/attrib.hxx | 113 ++ idl/inc/basobj.hxx | 338 +++++ idl/inc/bastype.hxx | 399 ++++++ idl/inc/char.hxx | 78 ++ idl/inc/command.hxx | 117 ++ idl/inc/database.hxx | 231 ++++ idl/inc/globals.hxx | 274 ++++ idl/inc/hash.hxx | 164 +++ idl/inc/lex.hxx | 315 +++++ idl/inc/module.hxx | 151 +++ idl/inc/object.hxx | 204 +++ idl/inc/slot.hxx | 308 +++++ idl/inc/types.hxx | 379 ++++++ idl/prj/d.lst | 2 + idl/source/cmptools/char.cxx | 247 ++++ idl/source/cmptools/hash.cxx | 367 +++++ idl/source/cmptools/lex.cxx | 677 ++++++++++ idl/source/cmptools/makefile.mk | 99 ++ idl/source/objects/basobj.cxx | 863 ++++++++++++ idl/source/objects/bastype.cxx | 1045 ++++++++++++++ idl/source/objects/makefile.mk | 103 ++ idl/source/objects/module.cxx | 732 ++++++++++ idl/source/objects/object.cxx | 1091 +++++++++++++++ idl/source/objects/slot.cxx | 2011 +++++++++++++++++++++++++++ idl/source/objects/types.cxx | 2840 +++++++++++++++++++++++++++++++++++++++ idl/source/prj/command.cxx | 472 +++++++ idl/source/prj/database.cxx | 1378 +++++++++++++++++++ idl/source/prj/globals.cxx | 233 ++++ idl/source/prj/idldll.cxx | 115 ++ idl/source/prj/makefile.mk | 101 ++ idl/source/prj/svidl.cxx | 463 +++++++ idl/source/svidl.dat | Bin 0 -> 204 bytes idl/util/idlpch.cxx | 85 ++ idl/util/makefile.mk | 151 +++ idl/util/svidl.hdb | 25 + 35 files changed, 16171 insertions(+) create mode 100644 idl/inc/attrib.hxx create mode 100644 idl/inc/basobj.hxx create mode 100644 idl/inc/bastype.hxx create mode 100644 idl/inc/char.hxx create mode 100644 idl/inc/command.hxx create mode 100644 idl/inc/database.hxx create mode 100644 idl/inc/globals.hxx create mode 100644 idl/inc/hash.hxx create mode 100644 idl/inc/lex.hxx create mode 100644 idl/inc/module.hxx create mode 100644 idl/inc/object.hxx create mode 100644 idl/inc/slot.hxx create mode 100644 idl/inc/types.hxx create mode 100644 idl/prj/d.lst create mode 100644 idl/source/cmptools/char.cxx create mode 100644 idl/source/cmptools/hash.cxx create mode 100644 idl/source/cmptools/lex.cxx create mode 100644 idl/source/cmptools/makefile.mk create mode 100644 idl/source/objects/basobj.cxx create mode 100644 idl/source/objects/bastype.cxx create mode 100644 idl/source/objects/makefile.mk create mode 100644 idl/source/objects/module.cxx create mode 100644 idl/source/objects/object.cxx create mode 100644 idl/source/objects/slot.cxx create mode 100644 idl/source/objects/types.cxx create mode 100644 idl/source/prj/command.cxx create mode 100644 idl/source/prj/database.cxx create mode 100644 idl/source/prj/globals.cxx create mode 100644 idl/source/prj/idldll.cxx create mode 100644 idl/source/prj/makefile.mk create mode 100644 idl/source/prj/svidl.cxx create mode 100644 idl/source/svidl.dat create mode 100644 idl/util/idlpch.cxx create mode 100644 idl/util/makefile.mk create mode 100644 idl/util/svidl.hdb (limited to 'idl') diff --git a/idl/inc/attrib.hxx b/idl/inc/attrib.hxx new file mode 100644 index 000000000000..f26ca2be8cc8 --- /dev/null +++ b/idl/inc/attrib.hxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * $RCSfile: attrib.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _ATTRIB_HXX +#define _ATTRIB_HXX + +#ifdef IDL_COMPILER +#include +#include + +/******************** class SvAttribute **********************************/ +class SvAttribute +{ + SvStringHashEntryRef aName; + CreateMetaObjectType pCreateMethod; + SvMetaObjectRef aTmpClass; +public: + SvAttribute( SvStringHashEntry * pAttribName, + CreateMetaObjectType pMethod ) + : aName( pAttribName ), + pCreateMethod( pMethod ) {} + + SvMetaObjectRef CreateClass() + { + if( aTmpClass.Is() ) + { + SvMetaObjectRef aTmp( aTmpClass ); + aTmpClass.Clear(); + return aTmp; + } + return pCreateMethod(); + } + void PutBackClass( SvMetaObject * pClass ) + { /* OptimierungaTmpClass = pClass*/; } +}; + +#define SV_ATTRIBUTE( AttributeName, PostfixClassName ) \ + SvAttribute( SvHash_##AttributeName(), \ + SvMeta##PostfixClassName::Create ) + +/******************** class SvAttributeList ******************************/ +DECLARE_LIST(SvAttributeListImpl,SvAttribute*) +class SvAttributeList : public SvAttributeListImpl +{ +public: + SvAttributeList() : SvAttributeListImpl() {} + + void Append( SvAttribute * pObj ) + { Insert( pObj, LIST_APPEND ); } +}; + + +#endif // IDL_COMPILER +#endif // _ATTRIB_HXX + diff --git a/idl/inc/basobj.hxx b/idl/inc/basobj.hxx new file mode 100644 index 000000000000..b6f04c47be94 --- /dev/null +++ b/idl/inc/basobj.hxx @@ -0,0 +1,338 @@ +/************************************************************************* + * + * $RCSfile: basobj.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _BASOBJ_HXX +#define _BASOBJ_HXX + +#include +#include + +#ifndef _PSTM_HXX //autogen +#include +#endif + +class SvTokenStream; +class SvMetaObject; +class SvAttributeList; +class SvIdlDataBase; + +typedef SvMetaObject * (*CreateMetaObjectType)(); +#define IDL_WRITE_COMPILER 0x8000 +#define IDL_WRITE_BROWSER 0x4000 +#define IDL_WRITE_CALLING 0x2000 +#define IDL_WRITE_MASK 0xE000 + +#define C_PREF "C_" + +enum WriteType +{ + WRITE_IDL, WRITE_ODL, WRITE_SLOTMAP, WRITE_C_HEADER, WRITE_C_SOURCE, + WRITE_CXX_HEADER, WRITE_CXX_SOURCE, WRITE_DOCU +}; + +enum +{ + WA_METHOD = 0x1, WA_VARIABLE = 0x2, WA_ARGUMENT = 0x4, + WA_STRUCT = 0x8, WA_READONLY = 0x10 +}; +typedef int WriteAttribute; + +/******************** Meta Factory **************************************/ +#ifdef IDL_COMPILER + +#define PRV_SV_DECL_META_FACTORY( Class ) \ + static SvAttributeList * pAttribList; \ + static SvAttributeList & GetAttributeList(); \ + static SvMetaObject * Create() { return new Class; } \ + static const char * GetClassName() { return #Class; } + +#define PRV_SV_IMPL_META_FACTORY( Class ) \ + SvAttributeList * Class::pAttribList = NULL; + +#else + +#define PRV_SV_DECL_META_FACTORY( Class ) + +#define PRV_SV_IMPL_META_FACTORY( Class ) + +#endif // IDL_COMPILER + +#define SV_DECL_META_FACTORY( Class, CLASS_ID ) \ + SV_DECL_PERSIST( Class, CLASS_ID ) \ + PRV_SV_DECL_META_FACTORY( Class ) \ + SvMetaObject * MakeClone() const; \ + Class * Clone() const { return (Class *)MakeClone(); } + + +#define SV_DECL_META_FACTORY1( Class, Super1, CLASS_ID ) \ + SV_DECL_PERSIST1( Class, Super1, CLASS_ID ) \ + PRV_SV_DECL_META_FACTORY( Class ) \ + SvMetaObject * MakeClone() const; \ + Class * Clone() const { return (Class *)MakeClone(); } + +#define SV_IMPL_META_FACTORY( Class ) \ + PRV_SV_IMPL_META_FACTORY( Class ) \ + SV_IMPL_PERSIST( Class ) \ + SvMetaObject * Class::MakeClone() const { return new Class( *this ); } + + +#define SV_IMPL_META_FACTORY1( Class, Super1 ) \ + PRV_SV_IMPL_META_FACTORY( Class ) \ + SV_IMPL_PERSIST1( Class, Super1 ) \ + SvMetaObject * Class::MakeClone() const { return new Class( *this ); } + + +/******************** class SvMetaObject ********************************/ +class SvMetaObject : public SvPersistBase +{ +public: + SV_DECL_META_FACTORY1( SvMetaObject, SvPersistBase, 14 ) + SvMetaObject(); + +#ifdef IDL_COMPILER + static void WriteTab( SvStream & rOutStm, USHORT nTab ); + static BOOL TestAndSeekSpaceOnly( SvStream &, ULONG nBegPos ); + static void Back2Delemitter( SvStream & ); + static void WriteStars( SvStream & ); + + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); + + virtual void WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaObject) +//SV_DECL_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *) +SV_DECL_PERSIST_LIST(SvMetaObject,SvMetaObject *) +SV_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *) + + +class SvMetaObjectMemberStack +{ + SvMetaObjectMemberList aList; +public: + SvMetaObjectMemberStack() {;} + + void Push( SvMetaObject * pObj ) + { aList.Insert( pObj, LIST_APPEND ); } + SvMetaObject * Pop() { return aList.Remove( aList.Count() -1 ); } + SvMetaObject * Top() const { return aList.GetObject( aList.Count() -1 ); } + void Clear() { aList.Clear(); } + ULONG Count() const { return aList.Count(); } + + SvMetaObject * Get( TypeId nType ) + { + SvMetaObject * pObj = aList.Last(); + while( pObj ) + { + if( pObj->IsA( nType ) ) + return pObj; + pObj = aList.Prev(); + } + return NULL; + } +}; + +/******************** class SvMetaName **********************************/ +class SvMetaName : public SvMetaObject +{ + SvString aName; + SvHelpContext aHelpContext; + SvHelpText aHelpText; + SvString aConfigName; + SvString aDescription; + +protected: +#ifdef IDL_COMPILER + virtual BOOL ReadNameSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + void DoReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm, + char c = '\0' ); + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0); + virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaName, SvMetaObject, 15 ) + SvMetaName(); + + virtual BOOL SetName( const ByteString & rName, SvIdlDataBase * = NULL ); + void SetDescription( const ByteString& rText ) + { aDescription = rText; } + const SvHelpContext& GetHelpContext() const { return aHelpContext; } + virtual const SvString & GetName() const { return aName; } + virtual const SvString & GetHelpText() const { return aHelpText; } + virtual const SvString & GetConfigName() const{ return aConfigName; } + virtual const SvString& GetDescription() const{ return aDescription; } + +#ifdef IDL_COMPILER + virtual BOOL Test( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0); + void WriteDescription( SvIdlDataBase& rBase, SvStream& rOutStm ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaName) +SV_DECL_IMPL_PERSIST_LIST(SvMetaName,SvMetaName *) + + +/******************** class SvMetaReference *****************************/ +SV_DECL_REF(SvMetaReference) +class SvMetaReference : public SvMetaName +{ +protected: + SvMetaReferenceRef aRef; +public: + SV_DECL_META_FACTORY1( SvMetaReference, SvMetaName, 17 ) + SvMetaReference(); + + const SvString & GetName() const + { + return ( !aRef.Is() + || SvMetaName::GetName().Len() ) + ? SvMetaName::GetName() + : aRef->GetName(); + } + + const SvString & GetHelpText() const + { + return ( !aRef.Is() + || SvMetaName::GetHelpText().Len() ) + ? SvMetaName::GetHelpText() + : aRef->GetHelpText(); + } + + const SvString & GetConfigName() const + { + return ( !aRef.Is() + || SvMetaName::GetConfigName().Len() ) + ? SvMetaName::GetConfigName() + : aRef->GetConfigName(); + } + + const SvString & GetDescription() const + { + return ( !aRef.Is() + || SvMetaName::GetDescription().Len() ) + ? SvMetaName::GetDescription() + : aRef->GetDescription(); + } + SvMetaReference * GetRef() const { return aRef; } + void SetRef( SvMetaReference * pRef ) + { aRef = pRef; } +}; +SV_IMPL_REF(SvMetaReference) +SV_DECL_IMPL_PERSIST_LIST(SvMetaReference,SvMetaReference *) + + +/******************** class SvMetaExtern *********************************/ +class SvMetaModule; +class SvMetaExtern : public SvMetaReference +{ + SvMetaModule * pModule; // in welchem Modul enthalten + + SvUUId aUUId; + SvVersion aVersion; + BOOL bReadUUId; + BOOL bReadVersion; +public: + SV_DECL_META_FACTORY1( SvMetaExtern, SvMetaName, 16 ) + SvMetaExtern(); + + SvMetaModule * GetModule() const; + + const SvGlobalName &GetUUId() const; + const SvVersion & GetVersion() const { return aVersion; } +#ifdef IDL_COMPILER + void SetModule( SvIdlDataBase & rBase ); + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0); +protected: + virtual void ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0); +#endif +}; +SV_DECL_IMPL_REF(SvMetaExtern) +SV_DECL_IMPL_PERSIST_LIST(SvMetaExtern,SvMetaExtern *) + + +#endif // _BASOBJ_HXX + + diff --git a/idl/inc/bastype.hxx b/idl/inc/bastype.hxx new file mode 100644 index 000000000000..9654d09eff23 --- /dev/null +++ b/idl/inc/bastype.hxx @@ -0,0 +1,399 @@ +/************************************************************************* + * + * $RCSfile: bastype.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _BASTYPE_HXX +#define _BASTYPE_HXX + + +#ifndef _GLOBNAME_HXX //autogen +#include +#endif + +#ifndef _GEN_HXX //autogen +#include +#endif + +#ifndef _STREAM_HXX //autogen +#include +#endif + +#ifndef _UNQID_HXX //autogen +#include +#endif + +#ifndef _STRING_HXX //autogen +#include +#endif + +class SvStringHashEntry; +class SvIdlDataBase; +class SvTokenStream; + +ByteString MakeDefineName( const ByteString & rName ); +/************class RangeUniqueIdContainer ****************************/ +class RangeUniqueIdContainer : private UniqueIdContainer +{ + UINT32 nMax, nMin; +public: + RangeUniqueIdContainer(); + RangeUniqueIdContainer( const Range & rRange ); + ~RangeUniqueIdContainer(); + + RangeUniqueIdContainer & operator = ( const RangeUniqueIdContainer & ); + + BOOL CreateId( UniqueItemId * ); + BOOL CreateId( UINT32 nIdValue, UniqueItemId * ); + + UINT32 GetMin() const { return nMin; } + UINT32 GetMax() const { return nMax; } +}; + + +/******************** class SvUINT32 **********************************/ +class SvUINT32 +{ + UINT32 nVal; +public: + SvUINT32() { nVal = 0; } + SvUINT32( UINT32 n ) : nVal( n ) {} + SvUINT32 & operator = ( UINT32 n ) { nVal = n; return *this; } + + operator UINT32 &() { return nVal; } + + static UINT32 Read( SvStream & rStm ); + static void Write( SvStream & rStm, UINT32 nVal ); + + friend SvStream& operator << (SvStream & rStm, const SvUINT32 & r ) + { SvUINT32::Write( rStm, r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvUINT32 & r ) + { r.nVal = SvUINT32::Read( rStm ); return rStm; } + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); +#endif +}; + + +/******************** class SvINT16 **********************************/ +class SvINT16 +{ + short nVal; +public: + SvINT16() { nVal = 0; } + SvINT16( short n ) : nVal( n ) {} + SvINT16 & operator = ( short n ) { nVal = n; return *this; } + + operator short &() { return nVal; } + + friend SvStream& operator << (SvStream & rStm, const SvINT16 & r ) + { SvUINT32::Write( rStm, (UINT32)r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvINT16 & r ) + { r.nVal = (short)SvUINT32::Read( rStm ); return rStm; } + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); +#endif +}; + + +/******************** class SvUINT16 **********************************/ +class SvUINT16 +{ + USHORT nVal; +public: + SvUINT16() { nVal = 0; } + SvUINT16( USHORT n ) : nVal( n ) {} + SvUINT16 & operator = ( USHORT n ) { nVal = n; return *this; } + + operator UINT16 &() { return nVal; } + + friend SvStream& operator << (SvStream & rStm, const SvUINT16 & r ) + { SvUINT32::Write( rStm, (UINT32)r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvUINT16 & r ) + { r.nVal = (USHORT)SvUINT32::Read( rStm ); return rStm; } + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); +#endif +}; + + +/******************** class SvINT32 **********************************/ +class SvINT32 +{ + INT32 nVal; +public: + SvINT32() { nVal = 0; } + SvINT32( INT32 n ) : nVal( n ) {} + SvINT32 & operator = ( INT32 n ) { nVal = n; return *this; } + + operator INT32 &() { return nVal; } + + friend SvStream& operator << (SvStream & rStm, const SvINT32 & r ) + { SvUINT32::Write( rStm, (UINT32)r.nVal ); return rStm; } + friend SvStream& operator >> (SvStream & rStm, SvINT32 & r ) + { r.nVal = (INT32)SvUINT32::Read( rStm ); return rStm; } + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); +#endif +}; + + +/******************** class Svint **********************************/ +class Svint +{ + int nVal; + BOOL bSet; +public: + Svint() { nVal = bSet = 0; } + Svint( int n ) : nVal( n ), bSet( TRUE ) {} + Svint( int n, BOOL bSetP ) : nVal( n ), bSet( bSetP ) {} + Svint & operator = ( int n ) { nVal = n; bSet = TRUE; return *this; } + + operator int ()const { return nVal; } + BOOL IsSet() const { return bSet; } + + friend SvStream& operator << (SvStream & rStm, const Svint & r ) + { SvUINT32::Write( rStm, (UINT32)r.nVal ); rStm << r.bSet; return rStm; } + friend SvStream& operator >> (SvStream & rStm, Svint & r ) + { r.nVal = (int)SvUINT32::Read( rStm ); rStm >> r.bSet ; return rStm; } + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); +#endif +}; + + +/******************** class SvBOOL **********************************/ +class SvBOOL +{ + BOOL nVal:1, + bSet:1; +public: + SvBOOL() { bSet = nVal = FALSE; } + SvBOOL( BOOL n ) : nVal( n ), bSet( TRUE ) {} + SvBOOL( BOOL n, BOOL bSetP ) : nVal( n ), bSet( bSetP ) {} + SvBOOL & operator = ( BOOL n ) { nVal = n; bSet = TRUE; return *this; } + + operator BOOL() const { return nVal; } +#ifdef STC + operator int() const { return nVal; } +#endif + BOOL Is() const { return nVal; } + BOOL IsSet() const { return bSet; } + + friend SvStream& operator << (SvStream &, const SvBOOL &); + friend SvStream& operator >> (SvStream &, SvBOOL &); + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ); + ByteString GetSvIdlString( SvStringHashEntry * pName ); +#endif +}; + + +/******************** class SvIdentifier **********************************/ +class SvIdentifier : public ByteString +{ +public: + SvIdentifier(){}; + SvIdentifier & operator = ( const ByteString & rStr ) + { ByteString::operator =( rStr ); return *this; } + friend SvStream& operator << (SvStream &, const SvIdentifier &); + friend SvStream& operator >> (SvStream &, SvIdentifier &); + + BOOL IsSet() const { return Len() != 0; } +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, + USHORT nTab ); +#endif +}; + + +/******************** class SvIdentifier **********************************/ +class SvNumberIdentifier : public SvIdentifier +{ + UINT32 nValue; + // darf nicht benutzt werden + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); +public: + SvNumberIdentifier() : nValue( 0 ) {}; + BOOL IsSet() const + { + return SvIdentifier::IsSet() || nValue != 0; + } + UINT32 GetValue() const { return nValue; } + void SetValue( UINT32 nVal ) { nValue = nVal; } + + friend SvStream& operator << (SvStream &, const SvNumberIdentifier &); + friend SvStream& operator >> (SvStream &, SvNumberIdentifier &); +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + BOOL ReadSvIdl( SvIdlDataBase &, SvStringHashEntry * pName, + SvTokenStream & rInStm ); +#endif +}; + + +/******************** class SvString **********************************/ +class SvString : public ByteString +{ +public: + SvString(){}; + SvString & operator = ( const ByteString & rStr ) + { ByteString::operator =( rStr ); return *this; } + BOOL IsSet() const { return Len() != 0; } + friend SvStream& operator << (SvStream &, const SvString &); + friend SvStream& operator >> (SvStream &, SvString &); + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, + USHORT nTab ); +#endif +}; + + +/******************** class SvHelpText **********************************/ +class SvHelpText : public SvString +{ +public: + SvHelpText() {} +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ); +#endif +}; + + +/******************** class SvHelpContext *******************************/ +class SvHelpContext : public SvNumberIdentifier +{ +/* + UniqueItemId aId; + BOOL bSet; +public: + SvHelpContext() : bSet( FALSE ) {} + + BOOL IsSet() const { return bSet; } + UINT32 GetId() const { return aId.GetId(); } + +#ifdef IDL_COMPILER + BOOL ReadSvIdl( RangeUniqueIdContainer & rCont, + SvTokenStream & rInStm ); + BOOL WriteSvIdl( RangeUniqueIdContainer & rCont, SvStream & rOutStm, + USHORT nTab ); +#endif +*/ +}; + +/******************** class SvUUId *************************************/ +class SvUUId : public SvGlobalName +{ +public: + SvUUId() {} +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStream & rOutStm ); +#endif +}; + + +/******************** class SvVersion **********************************/ +class SvVersion +{ + USHORT nMajorVersion; + USHORT nMinorVersion; +public: + SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {} + BOOL operator == ( const SvVersion & r ) + { + return (r.nMajorVersion == nMajorVersion) + && (r.nMinorVersion == nMinorVersion); + } + BOOL operator != ( const SvVersion & r ) + { + return !(*this == r); + } + + USHORT GetMajorVersion() const { return nMajorVersion; } + USHORT GetMinorVersion() const { return nMinorVersion; } + + friend SvStream& operator << (SvStream &, const SvVersion &); + friend SvStream& operator >> (SvStream &, SvVersion &); +#ifdef IDL_COMPILER + BOOL ReadSvIdl( SvTokenStream & rInStm ); + BOOL WriteSvIdl( SvStream & rOutStm ); +#endif +}; + + +#endif // _BASTYPE_HXX + diff --git a/idl/inc/char.hxx b/idl/inc/char.hxx new file mode 100644 index 000000000000..d4d0ab0d4c1c --- /dev/null +++ b/idl/inc/char.hxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * $RCSfile: char.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _CHAR_HXX +#define _CHAR_HXX + +#ifndef _STRING_HXX //autogen +#include +#endif + +/******************* T y p e s *******************************************/ +class SvChar +{ +public: + static BOOL MakeChar( char * pChar, char ** ppStr ); + static char * GetTable( CharSet nSource, CharSet nDest ); +}; + + +#endif // _CHAR_HXX diff --git a/idl/inc/command.hxx b/idl/inc/command.hxx new file mode 100644 index 000000000000..2c18ae9d296a --- /dev/null +++ b/idl/inc/command.hxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * $RCSfile: command.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _COMMAND_HXX +#define _COMMAND_HXX + + +#ifndef _LIST_HXX //autogen +#include +#endif + +#ifndef _STRING_HXX //autogen +#include +#endif + +#ifndef STRING_LIST +#define STRING_LIST +DECLARE_LIST( StringList, String * ) +#endif + +DECLARE_LIST( ByteStringList, ByteString* ) + +/******************** class SvCommand ************************************/ +class SvCommand +{ +public: + String aDataBaseFile; + StringList aInFileList; + String aListFile; + String aSlotMapFile; + String aSfxItemFile; + String aODLFile; + String aCallingFile; + String aCxxFile; + String aHxxFile; + String aSrcFile; + String aPath; + String aCHeaderFile; + String aCSourceFile; + String aTargetFile; + ByteString aSrsLine; + String aHelpIdFile; + String aCSVFile; + String aExportFile; + String aDocuFile; + UINT32 nFlags; + + SvCommand(); + SvCommand( int argc, char ** argv ); + ~SvCommand(); +}; + +void Init( const SvCommand & rCommand ); +class SvIdlWorkingBase; +BOOL ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ); +void DeInit(); + +#endif // _COMMAND_HXX + diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx new file mode 100644 index 000000000000..5b181efbd377 --- /dev/null +++ b/idl/inc/database.hxx @@ -0,0 +1,231 @@ +/************************************************************************* + * + * $RCSfile: database.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _DATABASE_HXX +#define _DATABASE_HXX + +#include +#include +#include + +#ifndef _PSTM_HXX //autogen +#include +#endif + +/************************************************************************* +*************************************************************************/ + +#ifdef IDL_COMPILER +/******************** class SvIdlError ***********************************/ +class SvIdlError +{ + ByteString aText; +public: + UINT32 nLine, nColumn; + + SvIdlError() : nLine(0), nColumn(0) {} + SvIdlError( UINT32 nL, UINT32 nC ) + : nLine(nL), nColumn(nC) {} + + const ByteString & GetText() const { return aText; } + void SetText( const ByteString & rT ) { aText = rT; } + BOOL IsError() const { return nLine != 0; } + void Clear() { nLine = nColumn = 0; } + SvIdlError & operator = ( const SvIdlError & rRef ) + { aText = rRef.aText; + nLine = rRef.nLine; + nColumn = rRef.nColumn; + return *this; + } +}; +#endif + +/******************** class SvIdlDataBase ********************************/ +class SvIdlDataBase +{ + BOOL bExport; + String aExportFile; + ULONG nUniqueId; + String aDataBaseFile; + SvFileStream * pStm; + BOOL bIsModified; + SvPersistStream aPersStream; + StringList aIdFileList; + SvStringHashTable * pIdTable; + + SvMetaTypeMemberList aTypeList; + SvMetaClassMemberList aClassList; + SvMetaModuleMemberList aModuleList; + SvMetaAttributeMemberList aAttrList; + SvMetaTypeMemberList aTmpTypeList; // nicht Persistent + +protected: +#ifdef IDL_COMPILER + SvMetaAttributeMemberList& GetAttrList() { return aAttrList; } + ByteString aModulePrefix; + SvMetaObjectMemberStack aContextStack; + String aPath; + SvIdlError aError; + void WriteReset() + { + aUsedTypes.Clear(); + aIFaceName.Erase(); + } +#endif +public: + SvIdlDataBase(); + ~SvIdlDataBase(); + static BOOL IsBinaryFormat( SvStream & rInStm ); + + void Load( SvStream & rInStm ); + void Save( SvStream & rInStm, UINT32 nContextFlags ); + + BOOL IsModified() const; + + + SvStringHashTable * GetIdTable() { return pIdTable; } + SvMetaTypeMemberList & GetTypeList(); + SvMetaClassMemberList & GetClassList() { return aClassList; } + SvMetaModuleMemberList & GetModuleList() { return aModuleList; } + SvMetaModule * GetModule( const ByteString & rName ); + + // Liste der benutzten Typen beim Schreiben + SvMetaTypeMemberList aUsedTypes; + ByteString aIFaceName; + SvNumberIdentifier aStructSlotId; + +#ifdef IDL_COMPILER + void StartNewFile( const String& rName ); + void SetExportFile( const String& rName ) + { aExportFile = rName; } + void AppendAttr( SvMetaAttribute *pSlot ); + const ByteString& GetActModulePrefix() const { return aModulePrefix; } + const SvIdlError & GetError() const { return aError; } + void SetError( const SvIdlError & r ) + { aError = r; } + + const String & GetPath() const { return aPath; } + SvMetaObjectMemberStack & GetStack() { return aContextStack; } + + void Write( const ByteString & rText ); + void WriteError( const ByteString & rErrWrn, + const ByteString & rFileName, + const ByteString & rErrorText, + ULONG nRow = 0, ULONG nColumn = 0 ) const; + void WriteError( SvTokenStream & rInStm ); + void SetError( const ByteString & rError, SvToken * pTok ); + void Push( SvMetaObject * pObj ); + BOOL Pop( BOOL bOk, SvTokenStream & rInStm, UINT32 nTokPos ) + { + GetStack().Pop(); + if( bOk ) + aError.Clear(); + else + rInStm.Seek( nTokPos ); + return bOk; + } + BOOL FillTypeList( SvMetaTypeList & rOutList, + SvToken * pNameTok ); + + ULONG GetUniqueId() { return ++nUniqueId; } + BOOL FindId( const ByteString & rIdName, ULONG * pVal ); + BOOL InsertId( const ByteString & rIdName, ULONG nVal ); + BOOL ReadIdFile( const String & rFileName ); + + SvMetaType * FindType( const ByteString & rName ); + static SvMetaType * FindType( const SvMetaType *, SvMetaTypeMemberList & ); + static ByteString * FindName( const ByteString & rName, ByteStringList & ); + + SvMetaType * ReadKnownType( SvTokenStream & rInStm ); + SvMetaAttribute * FindAttr( SvMetaAttributeMemberList *, SvMetaAttribute * ) const; + SvMetaAttribute * ReadKnownAttr( SvTokenStream & rInStm, + SvMetaType * pType = NULL ); + SvMetaAttribute * SearchKnownAttr( const SvNumberIdentifier& ); + SvMetaClass * ReadKnownClass( SvTokenStream & rInStm ); +#endif +}; + +#ifdef IDL_COMPILER +class SvIdlWorkingBase : public SvIdlDataBase +{ +public: + SvIdlWorkingBase(); + + BOOL ReadSvIdl( SvTokenStream &, BOOL bImported, const String & rPath ); + BOOL WriteSvIdl( SvStream & ); + + BOOL WriteSfx( SvStream & ); + BOOL WriteHelpIds( SvStream & ); + BOOL WriteCHeader( SvStream & ); + BOOL WriteCSource( SvStream & ); + BOOL WriteSfxItem( SvStream & ); +// BOOL WriteSbx( SvStream & ); + BOOL WriteOdl( SvStream & ); + BOOL WriteSrc( SvStream & ); + BOOL WriteCxx( SvStream & ); + BOOL WriteHxx( SvStream & ); + BOOL WriteCSV( SvStream& ); + BOOL WriteDocumentation( SvStream& ); +}; +#endif + +#endif // _DATABASE_HXX + diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx new file mode 100644 index 000000000000..a91ba05e76d9 --- /dev/null +++ b/idl/inc/globals.hxx @@ -0,0 +1,274 @@ +/************************************************************************* + * + * $RCSfile: globals.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _GLOBALS_HXX +#define _GLOBALS_HXX + +#ifdef IDL_COMPILER +#include + +#ifdef ICC +#undef _Export +#endif + +class SvIdlWorkingBase; +class SvClassManager; +struct SvGlobalHashNames +{ + SvStringHashEntryRef MM_Name; + SvStringHashEntryRef MM_module; + SvStringHashEntryRef MM_interface; + SvStringHashEntryRef MM_in; + SvStringHashEntryRef MM_out; + SvStringHashEntryRef MM_inout; + SvStringHashEntryRef MM_String; + SvStringHashEntryRef MM_UCHAR; + SvStringHashEntryRef MM_USHORT; + SvStringHashEntryRef MM_uuid; + SvStringHashEntryRef MM_HelpContext; + SvStringHashEntryRef MM_HelpText; + SvStringHashEntryRef MM_void; + SvStringHashEntryRef MM_shell; + SvStringHashEntryRef MM_Get; + SvStringHashEntryRef MM_Set; + SvStringHashEntryRef MM_SlotId; + SvStringHashEntryRef MM_HasCoreId; + SvStringHashEntryRef MM_Cachable; + SvStringHashEntryRef MM_Volatile; + SvStringHashEntryRef MM_Toggle; + SvStringHashEntryRef MM_AutoUpdate; + SvStringHashEntryRef MM_Synchron; + SvStringHashEntryRef MM_Asynchron; + SvStringHashEntryRef MM_RecordPerSet; + SvStringHashEntryRef MM_RecordPerItem; + SvStringHashEntryRef MM_RecordManual; + SvStringHashEntryRef MM_NoRecord; + SvStringHashEntryRef MM_RecordAbsolute; + SvStringHashEntryRef MM_enum; + SvStringHashEntryRef MM_UINT16; + SvStringHashEntryRef MM_INT16; + SvStringHashEntryRef MM_UINT32; + SvStringHashEntryRef MM_INT32; + SvStringHashEntryRef MM_int; + SvStringHashEntryRef MM_BOOL; + SvStringHashEntryRef MM_char; + SvStringHashEntryRef MM_BYTE; + SvStringHashEntryRef MM_float; + SvStringHashEntryRef MM_double; + SvStringHashEntryRef MM_item; + SvStringHashEntryRef MM_PseudoSlots; + SvStringHashEntryRef MM_map; + SvStringHashEntryRef MM_Default; + SvStringHashEntryRef MM_HelpFile; + SvStringHashEntryRef MM_Version; + SvStringHashEntryRef MM_import; + SvStringHashEntryRef MM_SlotIdFile; + SvStringHashEntryRef MM_SvName; + SvStringHashEntryRef MM_SbxName; + SvStringHashEntryRef MM_ItemName; + SvStringHashEntryRef MM_OdlName; + SvStringHashEntryRef MM_include; + SvStringHashEntryRef MM_ExecMethod; + SvStringHashEntryRef MM_StateMethod; + SvStringHashEntryRef MM_GroupId; + SvStringHashEntryRef MM_HasDialog; + SvStringHashEntryRef MM_TypeLibFile; + SvStringHashEntryRef MM_Export; + SvStringHashEntryRef MM_Automation; + SvStringHashEntryRef MM_PseudoPrefix; + SvStringHashEntryRef MM_define; + SvStringHashEntryRef MM_MenuConfig; + SvStringHashEntryRef MM_ToolBoxConfig; + SvStringHashEntryRef MM_StatusBarConfig; + SvStringHashEntryRef MM_AccelConfig; + SvStringHashEntryRef MM_AllConfig; + SvStringHashEntryRef MM_FastCall; + SvStringHashEntryRef MM_SbxObject; + SvStringHashEntryRef MM_Container; + SvStringHashEntryRef MM_PlugComm; + SvStringHashEntryRef MM_IsCollection; + SvStringHashEntryRef MM_ReadOnlyDoc; + SvStringHashEntryRef MM_ConfigName; + SvStringHashEntryRef MM_union; + SvStringHashEntryRef MM_struct; + SvStringHashEntryRef MM_typedef; + SvStringHashEntryRef MM_Readonly; + SvStringHashEntryRef MM_SlotType; + SvStringHashEntryRef MM_ModulePrefix; + SvStringHashEntryRef MM_DisableFlags; + SvStringHashEntryRef MM_Hidden; + SvStringHashEntryRef MM_Description; + SvStringHashEntryRef MM_UnoName; + + SvGlobalHashNames(); +}; + +class IdlDll +{ +public: + SvStringHashTable * pHashTable; + SvClassManager * pClassMgr; + SvGlobalHashNames * pGlobalNames; + + IdlDll(); + ~IdlDll(); +}; + +IdlDll * GetIdlApp(); +#define IDLAPP GetIdlApp() + +#define SV_GLOBAL_HASH_ACCESS( Name ) \ + if( !IDLAPP->pGlobalNames ) \ + IDLAPP->pGlobalNames = new SvGlobalHashNames(); \ + return IDLAPP->pGlobalNames->MM_##Name; + +#define HASH_INLINE( Name ) \ +inline SvStringHashEntry * SvHash_##Name() { SV_GLOBAL_HASH_ACCESS( Name ) } + +HASH_INLINE(Name) +HASH_INLINE(module) +HASH_INLINE(interface) +HASH_INLINE(in) +HASH_INLINE(out) +HASH_INLINE(inout) +HASH_INLINE(String) +HASH_INLINE(UCHAR) +HASH_INLINE(USHORT) +HASH_INLINE(uuid) +HASH_INLINE(HelpContext) +HASH_INLINE(HelpText) +HASH_INLINE(void) +HASH_INLINE(shell) +HASH_INLINE(Get) +HASH_INLINE(Set) +HASH_INLINE(SlotId) +HASH_INLINE(HasCoreId) +HASH_INLINE(Cachable) +HASH_INLINE(Volatile) +HASH_INLINE(Toggle) +HASH_INLINE(AutoUpdate) +HASH_INLINE(Synchron) +HASH_INLINE(Asynchron) +HASH_INLINE(RecordPerItem) +HASH_INLINE(RecordPerSet) +HASH_INLINE(RecordManual) +HASH_INLINE(NoRecord) +HASH_INLINE(RecordAbsolute) +HASH_INLINE(enum) +HASH_INLINE(UINT16) +HASH_INLINE(INT16) +HASH_INLINE(UINT32) +HASH_INLINE(INT32) +HASH_INLINE(int) +HASH_INLINE(BOOL) +HASH_INLINE(char) +HASH_INLINE(BYTE) +HASH_INLINE(item) +HASH_INLINE(PseudoSlots) +HASH_INLINE(map) +HASH_INLINE(Default) +HASH_INLINE(HelpFile) +HASH_INLINE(Version) +HASH_INLINE(import) +HASH_INLINE(SlotIdFile) +HASH_INLINE(SvName) +HASH_INLINE(SbxName) +HASH_INLINE(ItemName) +HASH_INLINE(OdlName) +HASH_INLINE(include) +HASH_INLINE(ExecMethod) +HASH_INLINE(StateMethod) +HASH_INLINE(GroupId) +HASH_INLINE(float) +HASH_INLINE(double) +HASH_INLINE(HasDialog) +HASH_INLINE(TypeLibFile) +HASH_INLINE(Export) +HASH_INLINE(Automation) +HASH_INLINE(PseudoPrefix) +HASH_INLINE(define) +HASH_INLINE(MenuConfig) +HASH_INLINE(ToolBoxConfig) +HASH_INLINE(StatusBarConfig) +HASH_INLINE(AccelConfig) +HASH_INLINE(AllConfig) +HASH_INLINE(FastCall) +HASH_INLINE(SbxObject) +HASH_INLINE(Container) +HASH_INLINE(PlugComm) +HASH_INLINE(IsCollection) +HASH_INLINE(ReadOnlyDoc) +HASH_INLINE(ConfigName) +HASH_INLINE(union) +HASH_INLINE(struct) +HASH_INLINE(typedef) +HASH_INLINE(Readonly) +HASH_INLINE(SlotType) +HASH_INLINE(ModulePrefix) +HASH_INLINE(DisableFlags) +HASH_INLINE(Hidden) +HASH_INLINE(Description) +HASH_INLINE(UnoName) + + +#endif // IDL_COMPILER +#endif // _GLOBALS_HXX + diff --git a/idl/inc/hash.hxx b/idl/inc/hash.hxx new file mode 100644 index 000000000000..59c2a4d605c2 --- /dev/null +++ b/idl/inc/hash.hxx @@ -0,0 +1,164 @@ +/************************************************************************* + * + * $RCSfile: hash.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _HASH_HXX +#define _HASH_HXX + + + +#ifndef _REF_HXX //autogen +#include +#endif + +#ifndef _STRING_HXX //autogen +#include +#endif + +/****************** H a s h - T a b l e **********************************/ +class SvHashTable +{ + UINT32 nMax; // size of hash-tabel + UINT32 nFill; // elements in hash-tabel + UINT32 lAsk; // Anzahl der Anfragen + UINT32 lTry; // Anzahl der Versuche +protected: + BOOL Test_Insert( const void *, BOOL bInsert, UINT32 * pInsertPos ); + + // compare element with entry + virtual StringCompare Compare( const void * , UINT32 ) const = 0; + // get hash value from subclass + virtual UINT32 HashFunc( const void * ) const = 0; +public: + SvHashTable( UINT32 nMaxEntries ); + ~SvHashTable(); + + UINT32 GetMax() const { return nMax; } + + virtual BOOL IsEntry( UINT32 ) const = 0; +}; + +/************** S t r i n g H a s h T a b l e E n t r y ******************/ +class SvStringHashTable; +class SvStringHashEntry : public SvRefBase +{ +friend SvStringHashTable; + ByteString aName; + UINT32 nHashId; + ULONG nValue; + BOOL bHasId; +public: + SvStringHashEntry() : bHasId( FALSE ) {;} + SvStringHashEntry( const ByteString & rName, UINT32 nIdx ) + : aName( rName ) + , nHashId( nIdx ) + , bHasId( TRUE ) + , nValue( 0 ) {} + ~SvStringHashEntry(); + + const ByteString & GetName() const { return aName; } + BOOL HasId() const { return bHasId; } + UINT32 GetId() const { return nHashId; } + + void SetValue( ULONG n ) { nValue = n; } + ULONG GetValue() const { return nValue; } + + BOOL operator == ( const SvStringHashEntry & rRef ) + { return nHashId == rRef.nHashId; } + BOOL operator != ( const SvStringHashEntry & rRef ) + { return ! operator == ( rRef ); } + SvStringHashEntry & operator = ( const SvStringHashEntry & rRef ) + { SvRefBase::operator=( rRef ); + aName = rRef.aName; + nHashId = rRef.nHashId; + nValue = rRef.nValue; + bHasId = rRef.bHasId; + return *this; + } +}; + +SV_DECL_IMPL_REF(SvStringHashEntry) + +/****************** S t r i n g H a s h T a b l e ************************/ +DECLARE_LIST(SvStringHashList,SvStringHashEntry *) + +class SvStringHashTable : public SvHashTable +{ + SvStringHashEntry * pEntries; +protected: + virtual UINT32 HashFunc( const void * pElement ) const; + virtual StringCompare Compare( const void * pElement, UINT32 nIndex ) const; +public: + SvStringHashTable( UINT32 nMaxEntries ); // max size of hash-tabel + ~SvStringHashTable(); + + ByteString GetNearString( const ByteString & rName ) const; + virtual BOOL IsEntry( UINT32 nIndex ) const; + + BOOL Insert( const ByteString & rStr, UINT32 * pHash ); // insert string + BOOL Test( const ByteString & rStr, UINT32 * pHash ) const; // test of insert string + SvStringHashEntry * Get ( UINT32 nIndex ) const; // return pointer to string + SvStringHashEntry & operator []( UINT32 nPos ) const + { return pEntries[ nPos ]; } + + void FillHashList( SvStringHashList * rList ) const; +}; + +#endif // _RSCHASH_HXX diff --git a/idl/inc/lex.hxx b/idl/inc/lex.hxx new file mode 100644 index 000000000000..d14ebc2558d1 --- /dev/null +++ b/idl/inc/lex.hxx @@ -0,0 +1,315 @@ +/************************************************************************* + * + * $RCSfile: lex.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _LEX_HXX +#define _LEX_HXX + +#include + +#ifndef _GEN_HXX //autogen +#include +#endif + +#ifndef _STREAM_HXX //autogen +#include +#endif + +/******************** enum ***********************************************/ +enum SVTOKEN_ENUM { SVTOKEN_EMPTY, SVTOKEN_COMMENT, + SVTOKEN_INTEGER, SVTOKEN_STRING, + SVTOKEN_BOOL, SVTOKEN_IDENTIFIER, + SVTOKEN_CHAR, SVTOKEN_RTTIBASE, + SVTOKEN_EOF, SVTOKEN_HASHID }; + +/******************** class SvToken **************************************/ +class BigInt; +class SvToken +{ +friend class SvTokenStream; + ULONG nLine, nColumn; + SVTOKEN_ENUM nType; + ByteString aString; + union + { + ULONG nLong; + BOOL bBool; + char cChar; +// SvRttiBase * pComplexObj; + SvStringHashEntry * pHash; + }; +public: + SvToken(); + SvToken( const SvToken & rObj ); + SvToken( ULONG n ); + SvToken( SVTOKEN_ENUM nTypeP, BOOL b ); + SvToken( char c ); + SvToken( SVTOKEN_ENUM nTypeP, const ByteString & rStr ); +// SvToken( SvRttiBase * pComplexObj ); + SvToken( SVTOKEN_ENUM nTypeP ); + + SvToken & operator = ( const SvToken & rObj ); + + ByteString GetTokenAsString() const; + ByteString Print() const; + SVTOKEN_ENUM GetType() const { return nType; } + + void SetLine( ULONG nLineP ) { nLine = nLineP; } + ULONG GetLine() const { return nLine; } + + void SetColumn( ULONG nColumnP ) { nColumn = nColumnP; } + ULONG GetColumn() const { return nColumn; } + + BOOL IsEmpty() const { return nType == SVTOKEN_EMPTY; } + BOOL IsComment() const { return nType == SVTOKEN_COMMENT; } + BOOL IsInteger() const { return nType == SVTOKEN_INTEGER; } + BOOL IsString() const { return nType == SVTOKEN_STRING; } + BOOL IsBool() const { return nType == SVTOKEN_BOOL; } + BOOL IsIdentifierHash() const + { return nType == SVTOKEN_HASHID; } + BOOL IsIdentifier() const + { + return nType == SVTOKEN_IDENTIFIER + || nType == SVTOKEN_HASHID; + } + BOOL IsChar() const { return nType == SVTOKEN_CHAR; } + BOOL IsRttiBase() const { return nType == SVTOKEN_RTTIBASE; } + BOOL IsEof() const { return nType == SVTOKEN_EOF; } + + const ByteString & GetString() const + { + return IsIdentifierHash() + ? pHash->GetName() + : aString; + } + ULONG GetNumber() const { return nLong; } + BOOL GetBool() const { return bBool; } + char GetChar() const { return cChar; } +// SvRttiBase *GetObject() const { return pComplexObj; } + + void SetHash( SvStringHashEntry * pHashP ) + { pHash = pHashP; nType = SVTOKEN_HASHID; } + BOOL HasHash() const + { return nType == SVTOKEN_HASHID; } + SvStringHashEntry * GetHash() const { return pHash; } + BOOL Is( SvStringHashEntry * pEntry ) const + { return IsIdentifierHash() && pHash == pEntry; } +}; + +inline SvToken::SvToken() + : nType( SVTOKEN_EMPTY ) {} + +inline SvToken::SvToken( ULONG n ) + : nType( SVTOKEN_INTEGER ), nLong( n ) {} + +inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, BOOL b ) + : nType( nTypeP ), bBool( b ) {} + +inline SvToken::SvToken( char c ) + : nType( SVTOKEN_CHAR ), cChar( c ) {} + +inline SvToken::SvToken( SVTOKEN_ENUM nTypeP, const ByteString & rStr ) + : nType( nTypeP ), aString( rStr ) {} + +/* +inline SvToken::SvToken( SvRttiBase * pObj ) + : nType( SVTOKEN_RTTIBASE ), pComplexObj( pObj ) + { pObj->AddRef(); } +*/ + +inline SvToken::SvToken( SVTOKEN_ENUM nTypeP ) +: nType( nTypeP ) {} + +DECLARE_LIST( SvTokenList, SvToken * ) + +/******************** class SvTokenStream ********************************/ +class SvTokenStream +{ + ULONG nLine, nColumn; + int nBufPos; + int c; // naechstes Zeichen + CharSet nCharSet; + char * pCharTab; // Zeiger auf die Konverierungstabelle + USHORT nTabSize; // Tabulator Laenge + ByteString aStrTrue; + ByteString aStrFalse; + ULONG nMaxPos; + + SvFileStream * pInStream; + SvStream & rInStream; + String aFileName; + SvTokenList aTokList; + SvToken * pCurToken; + + void InitCtor(); + + ByteString aBufStr; + int GetNextChar(); + int GetFastNextChar() + { + return aBufStr.GetChar((USHORT)nBufPos++); + } + + void FillTokenList(); + ULONG GetNumber(); + BOOL MakeToken( SvToken & ); + BOOL IsEof() const { return rInStream.IsEof(); } + void SetMax() + { + ULONG n = Tell(); + if( n > nMaxPos ) + nMaxPos = n; + } + void CalcColumn() + { + // wenn Zeilenende berechnung sparen + if( 0 != c ) + { + USHORT n = 0; + nColumn = 0; + while( n < nBufPos ) + nColumn += aBufStr.GetChar(n++) == '\t' ? nTabSize : 1; + } + } +public: + SvTokenStream( const String & rFileName ); + SvTokenStream( SvStream & rInStream, const String & rFileName ); + ~SvTokenStream(); + + static BOOL GetHexValue( const ByteString & rStr, BigInt * pValue ); + const String & GetFileName() const { return aFileName; } + SvStream & GetStream() { return rInStream; } + + void SetCharSet( CharSet nSet ); + CharSet GetCharSet() const { return nCharSet; } + + void SetTabSize( USHORT nTabSizeP ) + { nTabSize = nTabSizeP; } + USHORT GetTabSize() const { return nTabSize; } + + SvToken * GetToken_PrevAll() + { + SvToken * pRetToken = pCurToken; + if( NULL == (pCurToken = aTokList.Prev()) ) + // Current Zeiger nie Null + pCurToken = pRetToken; + + return pRetToken; + } + SvToken * GetToken_NextAll() + { + SvToken * pRetToken = pCurToken; + if( NULL == (pCurToken = aTokList.Next()) ) + // Current Zeiger nie Null + pCurToken = pRetToken; + SetMax(); + return pRetToken; + } + SvToken * GetToken_Next() + { + // Kommentare werden initial entfernt + return GetToken_NextAll(); + } + SvToken * GetToken() const { return pCurToken; } + BOOL Skip( char cStart, char cEnd, UINT32 * pBegin ); + BOOL Read( char cChar ) + { + if( pCurToken->IsChar() + && cChar == pCurToken->GetChar() ) + { + GetToken_Next(); + return TRUE; + } + else + return FALSE; + } + void ReadDelemiter() + { + if( pCurToken->IsChar() + && (';' == pCurToken->GetChar() + || ',' == pCurToken->GetChar()) ) + { + GetToken_Next(); + } + } + + UINT32 Tell() const + { return aTokList.GetCurPos(); } + void Seek( UINT32 nPos ) + { + pCurToken = aTokList.Seek( nPos ); + SetMax(); + } + void SeekRel( INT32 nRelPos ) + { + pCurToken = aTokList.Seek( Tell() + nRelPos ); + SetMax(); + } + void SeekEnd() + { + pCurToken = aTokList.Seek( nMaxPos ); + } + void Replace( const Range & rRange, SvToken * pToken ); +}; + + + +#endif // _LEX_HXX + diff --git a/idl/inc/module.hxx b/idl/inc/module.hxx new file mode 100644 index 000000000000..64d0d0463c5a --- /dev/null +++ b/idl/inc/module.hxx @@ -0,0 +1,151 @@ +/************************************************************************* + * + * $RCSfile: module.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _MODULE_HXX +#define _MODULE_HXX + +#include +#include + +struct SvNamePos +{ + SvGlobalName aUUId; + UINT32 nStmPos; + SvNamePos( const SvGlobalName & rName, UINT32 nPos ) + : aUUId( rName ) + , nStmPos( nPos ) {} +}; +DECLARE_LIST( SvNamePosList, SvNamePos *) + +/******************** class SvMetaModule *********************************/ +class SvMetaModule : public SvMetaExtern +{ + SvMetaClassMemberList aClassList; + SvMetaTypeMemberList aTypeList; + SvMetaAttributeMemberList aAttrList; +// Browser + String aIdlFileName; + SvString aHelpFileName; + SvString aSlotIdFile; + SvString aTypeLibFile; + SvString aModulePrefix; + +#ifdef IDL_COMPILER + BOOL bImported : 1, + bIsModified : 1; + SvGlobalName aBeginName; + SvGlobalName aEndName; + SvGlobalName aNextName; +protected: + virtual void ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaModule, SvMetaExtern, 13 ) + SvMetaModule(); + + const String & GetIdlFileName() const { return aIdlFileName; } + const ByteString & GetModulePrefix() const { return aModulePrefix; } + + virtual BOOL SetName( const ByteString & rName, SvIdlDataBase * = NULL ); + + const ByteString & GetHelpFileName() const { return aHelpFileName; } + const ByteString & GetTypeLibFileName() const { return aTypeLibFile; } + + const SvMetaAttributeMemberList & GetAttrList() const { return aAttrList; } + const SvMetaTypeMemberList & GetTypeList() const { return aTypeList; } + const SvMetaClassMemberList & GetClassList() const { return aClassList; } + +#ifdef IDL_COMPILER + SvMetaModule( const String & rIdlFileName, + BOOL bImported ); + + BOOL FillNextName( SvGlobalName * ); + BOOL IsImported() const { return bImported; } + BOOL IsModified() const { return bIsModified; } + + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + + virtual void WriteAttributes( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); +// virtual void WriteSbx( SvIdlDataBase & rBase, SvStream & rOutStm, SvNamePosList & rList ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); + virtual void WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm, + Table* pTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table *pIdTable ); + + virtual void WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaModule) +SV_DECL_IMPL_PERSIST_LIST(SvMetaModule,SvMetaModule *) + + +#endif // _MODULE_HXX + diff --git a/idl/inc/object.hxx b/idl/inc/object.hxx new file mode 100644 index 000000000000..e2624986de2f --- /dev/null +++ b/idl/inc/object.hxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * $RCSfile: object.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _OBJECT_HXX +#define _OBJECT_HXX + +#define _SVSTDARR_ULONGS +//#include +#include +#include + +struct SvSlotElement +{ + SvMetaSlotRef xSlot; + ByteString aPrefix; + SvSlotElement( SvMetaSlot * pS, const ByteString & rPrefix ) + : xSlot( pS ) + , aPrefix( rPrefix ) + {} +}; +DECLARE_LIST( SvSlotElementList, SvSlotElement* ) +class SvMetaClass; +DECLARE_LIST( SvMetaClassList, SvMetaClass* ) + +class SvULongs : public List +{ +public: + void Insert( ULONG& rId, ULONG nPos ) { ULONG nId(rId ); List::Insert( (void*) nId, nPos ); } + void Remove( ULONG& rId ){ ULONG nId(rId ); List::Remove( (void*) nId ); } + ULONG GetObject( ULONG nPos ){ return (ULONG) List::GetObject( nPos ); } +}; + +/******************** class SvClassElement *******************************/ +SV_DECL_REF(SvMetaClass) +class SvClassElement : public SvPersistBase +{ + SvBOOL aAutomation; + ByteString aPrefix; + SvMetaClassRef xClass; +public: + SV_DECL_PERSIST1( SvClassElement, SvPersistBase, 1 ) + SvClassElement(); + + void SetPrefix( const ByteString & rPrefix ) + { aPrefix = rPrefix; } + const ByteString & GetPrefix() const + { return aPrefix; } + + void SetAutomation( BOOL rAutomation ) + { aAutomation = rAutomation; } + BOOL GetAutomation() const + { return aAutomation; } + + void SetClass( SvMetaClass * pClass ) + { xClass = pClass; } + SvMetaClass * GetClass() const + { return xClass; } +}; + +SV_DECL_IMPL_REF(SvClassElement) +SV_DECL_IMPL_PERSIST_LIST(SvClassElement,SvClassElement *) + +/******************** class SvMetaClass *********************************/ +class SvMetaModule; +SV_DECL_PERSIST_LIST(SvMetaClass,SvMetaClass *) +class SvMetaClass : public SvMetaType +{ + SvMetaAttributeMemberList aAttrList; + SvClassElementMemberList aClassList; + SvMetaClassRef aSuperClass; + SvBOOL aAutomation; + SvMetaClassRef xAutomationInterface; + +// void FillSbxMemberObject( SvIdlDataBase & rBase, +// SbxObject *, StringList &, +// BOOL bVariable ); + BOOL TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, + SvMetaAttribute & rAttr ) const; +#ifdef IDL_COMPILER + void WriteSlotStubs( const ByteString & rShellName, + SvSlotElementList & rSlotList, + ByteStringList & rList, + SvStream & rOutStm ); + USHORT WriteSlotParamArray( SvIdlDataBase & rBase, + SvSlotElementList & rSlotList, + SvStream & rOutStm ); + USHORT WriteSlots( const ByteString & rShellName, USHORT nCount, + SvSlotElementList & rSlotList, + SvIdlDataBase & rBase, + SvStream & rOutStm ); + + void InsertSlots( SvSlotElementList& rList, SvULongs& rSuperList, + SvMetaClassList & rClassList, + const ByteString & rPrefix, SvIdlDataBase& rBase ); + +protected: + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + virtual void ReadContextSvIdl( SvIdlDataBase &, + SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + void WriteOdlMembers( ByteStringList & rSuperList, + BOOL bVariable, BOOL bWriteTab, + SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaClass, SvMetaType, 6 ) + SvMetaClass(); + + BOOL GetAutomation() const + { return aAutomation; } + SvMetaClass * GetSuperClass() const + { return aSuperClass; } + + void FillClasses( SvMetaClassList & rList ); +// virtual void FillSbxObject( SvIdlDataBase & rBase, SbxObject * ); + + const SvClassElementMemberList& + GetClassList() const + { return aClassList; } + +#ifdef IDL_COMPILER + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType, WriteAttribute = 0 ); + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); + virtual void WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm, + Table* pTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ); + virtual void WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); +#endif +}; +SV_IMPL_REF(SvMetaClass) +SV_IMPL_PERSIST_LIST(SvMetaClass,SvMetaClass *) + + +#endif // _OBJECT_HXX + diff --git a/idl/inc/slot.hxx b/idl/inc/slot.hxx new file mode 100644 index 000000000000..8b218fd1a658 --- /dev/null +++ b/idl/inc/slot.hxx @@ -0,0 +1,308 @@ +/************************************************************************* + * + * $RCSfile: slot.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SLOT_HXX +#define _SLOT_HXX + +#include +#include + +/******************** class SvMetaSlot **********************************/ +//class SbxObject; +class SvMetaSlotMemberList; +class SvMetaSlot : public SvMetaAttribute +{ + SvMetaTypeRef aSlotType; + SvMetaAttributeRef aMethod; + SvIdentifier aGroupId; + SvBOOL aHasCoreId; + SvIdentifier aConfigId; + SvIdentifier aExecMethod; + SvIdentifier aStateMethod; + SvIdentifier aDefault; + SvBOOL aPseudoSlots; + SvBOOL aGet; + SvBOOL aSet; + + SvBOOL aCachable; // exclusiv + SvBOOL aVolatile; + SvBOOL aToggle; + SvBOOL aAutoUpdate; + + SvBOOL aSynchron; // exclusiv + SvBOOL aAsynchron; + + SvBOOL aRecordPerItem;// exclusiv + SvBOOL aRecordPerSet; + SvBOOL aRecordManual; + SvBOOL aNoRecord; + SvBOOL aRecordAbsolute; + + SvBOOL aHasDialog; + SvBOOL aMenuConfig; + SvBOOL aToolBoxConfig; + SvBOOL aStatusBarConfig; + SvBOOL aAccelConfig; + SvBOOL aFastCall; + SvBOOL aContainer; + SvBOOL aPlugComm; + SvIdentifier aPseudoPrefix; + SvString aDisableFlags; + SvMetaSlot* pLinkedSlot; + SvMetaSlot* pNextSlot; + ULONG nListPos; + SvMetaEnumValue* pEnumValue; + SvString aUnoName; + +#ifdef IDL_COMPILER + void WriteSlot( const ByteString & rShellName, + USHORT nCount, const ByteString & rSlotId, + const ByteString & rValEnum, + SvSlotElementList &rList, + const ByteString & rPrefix, + SvIdlDataBase & rBase, SvStream & rOutStm ); + virtual void Write( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); + + void SetEnumValue(SvMetaEnumValue *p) + { pEnumValue = p; } +#endif +protected: + void SetCachable( BOOL bSet ) + { + aCachable = bSet; + if( bSet ) + aVolatile = FALSE; + } + void SetVolatile( BOOL bSet ) + { + aVolatile = bSet; + if( bSet ) + aCachable = FALSE; + } + void SetToggle( BOOL bSet ) + { + aToggle = bSet; + } + void SetAutoUpdate( BOOL bSet ) + { + aAutoUpdate = bSet; + } + + void SetSynchron( BOOL bSet ) + { + aSynchron = bSet; + if( bSet ) + aAsynchron = FALSE; + } + void SetAsynchron( BOOL bSet ) + { + aAsynchron = bSet; + if( bSet ) + aSynchron = FALSE; + } + + void SetRecordPerItem( BOOL bSet ) + { + aRecordPerItem = bSet; + if( bSet ) + aRecordPerSet = aRecordManual = aNoRecord = FALSE; + } + void SetRecordPerSet( BOOL bSet ) + { + aRecordPerSet = bSet; + if( bSet ) + aRecordPerItem = aRecordManual = aNoRecord = FALSE; + } + void SetRecordManual( BOOL bSet ) + { + aRecordManual = bSet; + if( bSet ) + aRecordPerItem = aRecordPerSet = aNoRecord = FALSE; + } + void SetNoRecord( BOOL bSet ) + { + aNoRecord = bSet; + if( bSet ) + aRecordPerItem = aRecordPerSet = aRecordManual = FALSE; + } + void SetRecordAbsolute( BOOL bSet ) + { aRecordAbsolute = bSet; } + void SetHasDialog( BOOL bSet ) + { aHasDialog = bSet; } + void SetMenuConfig( BOOL bSet ) + { aMenuConfig = bSet; } + void SetToolBoxConfig( BOOL bSet ) + { aToolBoxConfig = bSet; } + void SetStatusBarConfig( BOOL bSet ) + { aStatusBarConfig = bSet; } + void SetAccelConfig( BOOL bSet ) + { aAccelConfig = bSet; } + void SetAllConfig( BOOL bSet ) + { + aMenuConfig = bSet; + aToolBoxConfig = bSet; + aStatusBarConfig = bSet; + aAccelConfig = bSet; + } + void SetFastCall( BOOL bSet ) + { aFastCall = bSet; } + void SetContainer( BOOL bSet ) + { aContainer = bSet; } + void SetPlugComm( BOOL bSet ) + { aPlugComm = bSet; } + +public: + SV_DECL_META_FACTORY1( SvMetaSlot, SvMetaReference, 11 ) + SvMetaSlot(); + SvMetaSlot( SvMetaType * pType ); + + virtual BOOL IsVariable() const; + virtual BOOL IsMethod() const; + virtual ByteString GetMangleName( BOOL bVariable ) const; + + SvMetaAttribute * GetMethod() const; + SvMetaType * GetSlotType() const; + BOOL GetHasCoreId() const; + const ByteString & GetGroupId() const; + const ByteString & GetConfigId() const; + const ByteString & GetExecMethod() const; + const ByteString & GetStateMethod() const; + const ByteString & GetDefault() const; + const ByteString & GetDisableFlags() const; + BOOL GetPseudoSlots() const; + /* + BOOL GetGet() const; + BOOL GetSet() const; + */ + BOOL GetCachable() const; + BOOL GetVolatile() const; + BOOL GetToggle() const; + BOOL GetAutoUpdate() const; + + BOOL GetSynchron() const; + BOOL GetAsynchron() const; + + BOOL GetRecordPerItem() const; + BOOL GetRecordPerSet() const; + BOOL GetRecordManual() const; + BOOL GetNoRecord() const; + BOOL GetRecordAbsolute() const; + + BOOL GetHasDialog() const; + const ByteString & GetPseudoPrefix() const; + const ByteString & GetUnoName() const; + BOOL GetMenuConfig() const; + BOOL GetToolBoxConfig() const; + BOOL GetStatusBarConfig() const; + BOOL GetAccelConfig() const; + BOOL GetFastCall() const; + BOOL GetContainer() const; + BOOL GetPlugComm() const; + SvMetaSlot* GetLinkedSlot() const + { return pLinkedSlot; } + SvMetaSlot* GetNextSlot() const + { return pNextSlot; } + ULONG GetListPos() const + { return nListPos; } + void SetListPos(ULONG n) + { nListPos = n; } + void ResetSlotPointer() + { pNextSlot = pLinkedSlot = 0; } + +// void FillSbxObject( SvIdlDataBase & rBase, SbxObject *, BOOL bProp ); +#ifdef IDL_COMPILER + SvMetaEnumValue* GetEnumValue() const + { return pEnumValue; } + virtual BOOL Test( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + virtual void Insert( SvSlotElementList&, const ByteString & rPrefix, + SvIdlDataBase& ); + void WriteSlotStubs( const ByteString & rShellName, + ByteStringList & rList, + SvStream & rOutStm ); + USHORT WriteSlotMap( const ByteString & rShellName, + USHORT nCount, + SvSlotElementList&, + const ByteString &, + SvIdlDataBase & rBase, + SvStream & rOutStm ); + USHORT WriteSlotParamArray( SvIdlDataBase & rBase, + SvStream & rOutStm ); + virtual void WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteCSV( SvIdlDataBase&, SvStream& ); + void CompareSlotAttributes( SvMetaSlot *pOther ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaSlot) +SV_DECL_IMPL_PERSIST_LIST(SvMetaSlot,SvMetaSlot *) + +#endif // _SLOT_HXX diff --git a/idl/inc/types.hxx b/idl/inc/types.hxx new file mode 100644 index 000000000000..62980f698b52 --- /dev/null +++ b/idl/inc/types.hxx @@ -0,0 +1,379 @@ +/************************************************************************* + * + * $RCSfile: types.hxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _TYPES_HXX +#define _TYPES_HXX + +#include +#include + +class SvSlotElementList; +struct SvSlotElement; + +/******************** class SvMetaAttribute *****************************/ +SV_DECL_REF(SvMetaType) +SV_DECL_REF(SvMetaAttribute) +SV_DECL_PERSIST_LIST(SvMetaAttribute,SvMetaAttribute *) +class SvMetaAttribute : public SvMetaReference +{ + SvMetaTypeRef aType; + SvNumberIdentifier aSlotId; + SvBOOL aAutomation; + SvBOOL aExport; + SvBOOL aReadonly; + SvBOOL aIsCollection; + SvBOOL aReadOnlyDoc; + SvBOOL aHidden; + BOOL bNewAttr; + +protected: +#ifdef IDL_COMPILER + virtual void WriteCSource( SvIdlDataBase & rBase, + SvStream & rOutStm, BOOL bSet ); + ULONG MakeSlotValue( SvIdlDataBase & rBase, BOOL bVariable ) const; + virtual void WriteAttributes( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); + virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaAttribute, SvMetaReference, 2 ) + SvMetaAttribute(); + SvMetaAttribute( SvMetaType * ); + + void SetNewAttribute( BOOL bNew ) + { bNewAttr = bNew; } + BOOL IsNewAttribute() const + { return bNewAttr; } + BOOL GetReadonly() const; + + void SetSlotId( const SvNumberIdentifier & rId ) + { aSlotId = rId; } + const SvNumberIdentifier & GetSlotId() const; + + void SetExport( BOOL bSet ) + { aExport = bSet; } + BOOL GetExport() const; + + void SetHidden( BOOL bSet ) + { aHidden = bSet; } + BOOL GetHidden() const; + + void SetAutomation( BOOL bSet ) + { aAutomation = bSet; } + BOOL GetAutomation() const; + + void SetIsCollection( BOOL bSet ) + { aIsCollection = bSet; } + BOOL GetIsCollection() const; + void SetReadOnlyDoc( BOOL bSet ) + { aReadOnlyDoc = bSet; } + BOOL GetReadOnlyDoc() const; + + void SetType( SvMetaType * pT ) { aType = pT; } + SvMetaType * GetType() const; + + virtual BOOL IsMethod() const; + virtual BOOL IsVariable() const; + virtual ByteString GetMangleName( BOOL bVariable ) const; + +// void FillSbxObject( SbxInfo * pInfo, USHORT nSbxFlags = 0 ); +// virtual void FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj, BOOL bVariable ); + +#ifdef IDL_COMPILER + virtual BOOL Test( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void WriteParam( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType ); + void WriteRecursiv_Impl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); + ULONG MakeSfx( ByteString * pAtrrArray ); + virtual void Insert( SvSlotElementList&, const ByteString & rPrefix, + SvIdlDataBase& ); + virtual void WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ); + virtual void WriteCSV( SvIdlDataBase&, SvStream& ); + void FillIDTable(Table *pIDTable); + ByteString Compare( SvMetaAttribute *pAttr ); +#endif +}; +SV_IMPL_REF(SvMetaAttribute) +SV_IMPL_PERSIST_LIST(SvMetaAttribute,SvMetaAttribute *) + + +/******************** class SvType *********************************/ +enum { CALL_VALUE, CALL_POINTER, CALL_REFERENCE }; +enum { TYPE_METHOD, TYPE_STRUCT, TYPE_BASE, TYPE_ENUM, TYPE_UNION, + TYPE_CLASS, TYPE_POINTER }; +class SvMetaType : public SvMetaExtern +{ + SvBOOL aIn; // Eingangsparameter + SvBOOL aOut; // Returnparameter + Svint aCall0, aCall1; + Svint aSbxDataType; + SvIdentifier aSvName; + SvIdentifier aSbxName; + SvIdentifier aOdlName; + SvIdentifier aCName; + SvIdentifier aBasicPostfix; + SvIdentifier aBasicName; + SvMetaAttributeMemberList * pAttrList; + int nType; + BOOL bIsItem; + BOOL bIsShell; + char cParserChar; + +#ifdef IDL_COMPILER + void WriteSfx( const ByteString & rItemName, SvIdlDataBase & rBase, + SvStream & rOutStm ); +protected: + BOOL ReadNamesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + virtual void ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase &, SvStream & rOutStm, + USHORT nTab ); + + virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType, WriteAttribute = 0 ); + virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); + BOOL ReadHeaderSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + void WriteHeaderSvIdl( SvIdlDataBase &, SvStream & rOutStm, + USHORT nTab ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaType, SvMetaExtern, 18 ) + SvMetaType(); + SvMetaType( const ByteString & rTypeName, char cParserChar, + const ByteString & rCName ); + SvMetaType( const ByteString & rTypeName, const ByteString & rSbxName, + const ByteString & rOdlName, char cParserChar, + const ByteString & rCName, const ByteString & rBasicName, + const ByteString & rBasicPostfix/*, SbxDataType nT = SbxEMPTY */); + + SvMetaAttributeMemberList & GetAttrList() const; + ULONG GetAttrCount() const + { + return pAttrList ? pAttrList->Count() : 0L; + } + void AppendAttr( SvMetaAttribute * pAttr ) + { + GetAttrList().Append( pAttr ); + } + + void SetType( int nT ); + int GetType() const { return nType; } + SvMetaType * GetBaseType() const; + SvMetaType * GetReturnType() const; + BOOL IsItem() const { return bIsItem; } + BOOL IsShell() const { return bIsShell; } + +// void SetSbxDataType( SbxDataType nT ) +// { aSbxDataType = (int)nT; } +// SbxDataType GetSbxDataType() const; + + void SetIn( BOOL b ) { aIn = b; } + BOOL GetIn() const; + + void SetOut( BOOL b ) { aOut = b; } + BOOL GetOut() const; + + void SetCall0( int e ); + int GetCall0() const; + + void SetCall1( int e); + int GetCall1() const; + + void SetBasicName(const ByteString& rName) + { aBasicName = rName; } + + const ByteString & GetBasicName() const; + ByteString GetBasicPostfix() const; + const ByteString & GetSvName() const; + const ByteString & GetSbxName() const; + const ByteString & GetOdlName() const; + const ByteString & GetCName() const; + char GetParserChar() const { return cParserChar; } + + virtual BOOL SetName( const ByteString & rName, SvIdlDataBase * = NULL ); + +// void FillSbxObject( SbxVariable * pObj, BOOL bVariable ); + +#ifdef IDL_COMPILER + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); + ByteString GetCString() const; + void WriteSvIdlType( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + void WriteOdlType( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + void AppendParserString (ByteString &rString); + + ULONG MakeSfx( ByteString * pAtrrArray ); + virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ); + //BOOL ReadTypePrefix( SvIdlDataBase &, SvTokenStream & rInStm ); + BOOL ReadMethodArgs( SvIdlDataBase & rBase, + SvTokenStream & rInStm ); + void WriteTypePrefix( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, WriteType ); + void WriteMethodArgs( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, WriteType ); + void WriteTheType( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, WriteType ); + ByteString GetParserString() const; + void WriteParamNames( SvIdlDataBase & rBase, SvStream & rOutStm, + const ByteString & rChief ); +#endif +}; +SV_IMPL_REF(SvMetaType) +DECLARE_LIST(SvMetaTypeList,SvMetaType *) +SV_DECL_IMPL_PERSIST_LIST(SvMetaType,SvMetaType *) + + +/******************** class SvTypeString *********************************/ +class SvMetaTypeString : public SvMetaType +{ +public: + SV_DECL_META_FACTORY1( SvMetaTypeString, SvMetaType, 19 ) + SvMetaTypeString(); +}; +SV_DECL_IMPL_REF(SvMetaTypeString) +SV_DECL_IMPL_PERSIST_LIST(SvMetaTypeString,SvMetaTypeString *) + + +/******************** class SvMetaEnumValue **********************************/ +class SvMetaEnumValue : public SvMetaName +{ + ByteString aEnumValue; +public: + SV_DECL_META_FACTORY1( SvMetaEnumValue, SvMetaName, 20 ) + SvMetaEnumValue(); + +#ifdef IDL_COMPILER + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaEnumValue) +SV_DECL_IMPL_PERSIST_LIST(SvMetaEnumValue,SvMetaEnumValue *) + + +/******************** class SvTypeEnum *********************************/ +class SvMetaTypeEnum : public SvMetaType +{ + SvMetaEnumValueMemberList aEnumValueList; + ByteString aPrefix; +protected: +#ifdef IDL_COMPILER + virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteContextSvIdl( SvIdlDataBase &, SvStream & rOutStm, + USHORT nTab ); + virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab, + WriteType, WriteAttribute = 0 ); +#endif +public: + SV_DECL_META_FACTORY1( SvMetaTypeEnum, SvMetaType, 21 ) + SvMetaTypeEnum(); + + USHORT GetMaxValue() const; + ULONG Count() const { return aEnumValueList.Count(); } + const ByteString & GetPrefix() const { return aPrefix; } + SvMetaEnumValue * GetObject( ULONG n ) const + { return aEnumValueList.GetObject( n ); } + +#ifdef IDL_COMPILER + virtual BOOL ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ); + virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, USHORT nTab ); + + virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType, WriteAttribute = 0 ); +#endif +}; +SV_DECL_IMPL_REF(SvMetaTypeEnum) +SV_DECL_IMPL_PERSIST_LIST(SvMetaTypeEnum,SvMetaTypeEnum *) + + +/******************** class SvTypeVoid ***********************************/ +class SvMetaTypevoid : public SvMetaType +{ +public: + SV_DECL_META_FACTORY1( SvMetaTypevoid, SvMetaName, 22 ) + SvMetaTypevoid(); +}; +SV_DECL_IMPL_REF(SvMetaTypevoid) +SV_DECL_IMPL_PERSIST_LIST(SvMetaTypevoid,SvMetaTypevoid *) + + +#endif // _TYPES_HXX + diff --git a/idl/prj/d.lst b/idl/prj/d.lst new file mode 100644 index 000000000000..bd88bc495f72 --- /dev/null +++ b/idl/prj/d.lst @@ -0,0 +1,2 @@ +..\%__SRC%\bin\svidl.exe %_DEST%\bin%_EXT%\svidl.exe +..\%__SRC%\bin\svidl %_DEST%\bin%_EXT%\svidl diff --git a/idl/source/cmptools/char.cxx b/idl/source/cmptools/char.cxx new file mode 100644 index 000000000000..4b0ca177a508 --- /dev/null +++ b/idl/source/cmptools/char.cxx @@ -0,0 +1,247 @@ +/************************************************************************* + * + * $RCSfile: char.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/****************** I N C L U D E S **************************************/ +#include +#include + +#ifndef _TABLE_HXX //autogen +#include +#endif + +#include +#pragma hdrstop + +/****************** D A T E N ********************************************/ +static unsigned char EqualTab[ 256 ] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, +100, 101, 102, 103, 104, 105, 106, 107, 108, 109, +110, 111, 112, 113, 114, 115, 116, 117, 118, 119, +120, 121, 122, 123, 124, 125, 126, 127, 128, 129, +130, 131, 132, 133, 134, 135, 136, 137, 138, 139, +140, 141, 142, 143, 144, 145, 146, 147, 148, 149, +150, 151, 152, 153, 154, 155, 156, 157, 158, 159, +160, 161, 162, 163, 164, 165, 166, 167, 168, 169, +170, 171, 172, 173, 174, 175, 176, 177, 178, 179, +180, 181, 182, 183, 184, 185, 186, 187, 188, 189, +190, 191, 192, 193, 194, 195, 196, 197, 198, 199, +200, 201, 202, 203, 204, 205, 206, 207, 208, 209, +210, 211, 212, 213, 214, 215, 216, 217, 218, 219, +220, 221, 222, 223, 224, 225, 226, 227, 228, 229, +230, 231, 232, 233, 234, 235, 236, 237, 238, 239, +240, 241, 242, 243, 244, 245, 246, 247, 248, 249, +250, 251, 252, 253, 254, 255 }; + + +/************************************************************************* +|* +|* RscChar::GetTable() +|* +|* Beschreibung +|* Ersterstellung MM 08.08.91 +|* Letzte Aenderung MM 08.08.91 +|* +*************************************************************************/ +Table * pCharTable = NULL; +unsigned char * pChange = EqualTab; +char * SvChar::GetTable( CharSet nSource , CharSet nDest ) +{ + if( nSource == nDest ) + return (char *)EqualTab; + + if( !pCharTable ) + pCharTable = new Table(); + + BYTE * pSet; + pSet = (BYTE *)pCharTable->Get( (ULONG)nSource << 16 + (ULONG)nDest ); + + if( !pSet ) + { + pSet = new BYTE[ 256 ]; + memcpy( pSet, EqualTab, sizeof( EqualTab ) ); + for( USHORT i = 128; i < 256; i++ ) + { + char c = ByteString::Convert( pSet[i], nSource, nDest ); + if( c ) + pSet[ i ] = (BYTE)c; + } + pCharTable->Insert( (ULONG)nSource << 16 + (ULONG)nDest, pSet ); + } + + return (char *)pSet; +}; + + +/************************************************************************* +|* +|* RscChar::MakeChar() +|* +|* Beschreibung Der ByteString wird nach C-Konvention umgesetzt +|* Ersterstellung MM 20.03.91 +|* Letzte Aenderung MM 20.03.91 +|* +*************************************************************************/ +BOOL SvChar::MakeChar( char * pChar, char ** ppStr ) +{ + char c; + BOOL bDoInc = TRUE; // Noch einmal erhoehen + + if( **ppStr == '\\' ) + { + ++*ppStr; + switch( **ppStr ) + { + case 'a': + c = '\a'; + break; + case 'b': + c = '\b'; + break; + case 'f': + c = '\f'; + break; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'v': + c = '\v'; + break; + case '\\': + c = '\\'; + break; + case '?': + c = '\?'; + break; + case '\'': + c = '\''; + break; + case '\"': + c = '\"'; + break; + default: + { + if( '0' <= **ppStr && '7' >= **ppStr ) + { + bDoInc = FALSE; + + USHORT nChar = 0; + USHORT i = 0; + while( '0' <= **ppStr && '7' >= **ppStr && i != 3 ) + { + nChar = nChar * 8 + (BYTE)**ppStr - (BYTE)'0'; + ++*ppStr; + i++; + } + if( nChar > 255 ) + // Wert zu gross, oder kein 3 Ziffern + return( FALSE ); + c = (char)nChar; + } + else if( 'x' == **ppStr ) + { + bDoInc = FALSE; + + USHORT nChar = 0; + USHORT i = 0; + ++*ppStr; + while( isxdigit( **ppStr ) && i != 2 ) + { + if( isdigit( **ppStr ) ) + nChar = nChar * 16 + (BYTE)**ppStr - (BYTE)'0'; + else if( isupper( **ppStr ) ) + nChar = nChar * 16 + (BYTE)**ppStr - (BYTE)'A' +10; + else + nChar = nChar * 16 + (BYTE)**ppStr - (BYTE)'a' +10; + ++*ppStr; + i++; + } + c = (char)nChar; + } + else + c = **ppStr; + //c = pChange [ (unsigned char)**ppStr ]; + }; + } + } + else + c = **ppStr; + //c = pChange [ (unsigned char)**ppStr ]; + + if( **ppStr && bDoInc ) ++*ppStr; + *pChar = c; + return( TRUE ); +}; + diff --git a/idl/source/cmptools/hash.cxx b/idl/source/cmptools/hash.cxx new file mode 100644 index 000000000000..2f14e1b01d99 --- /dev/null +++ b/idl/source/cmptools/hash.cxx @@ -0,0 +1,367 @@ +/************************************************************************* + * + * $RCSfile: hash.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/****************** I N C L U D E S **************************************/ +// C and C++ Includes. +#include +#include +#include + +// Programmabh„ngige Includes. +#include + +#ifndef _TOOLS_DEBUG_HXX //autogen +#include +#endif + +#pragma hdrstop + +/****************** C O D E **********************************************/ +/************************************************************************* +|* +|* SvStringHashEntry::~SvStringHashEntry() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashEntry::~SvStringHashEntry() { }; + +/************************************************************************* +|* +|* SvHashTable::SvHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvHashTable::SvHashTable( ULONG nMaxEntries ) +{ + nMax = nMaxEntries; // set max entries + nFill = 0; // no entries + lTry = 0; + lAsk = 0; +} + +/************************************************************************* +|* +|* SvHashTable::~SvHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvHashTable::~SvHashTable() +{ +#ifdef DOS_NIE + printf( "Maximum: %ld, Fllung: %ld\n", (ULONG)nMax, (ULONG)nFill ); + printf( "Anfragen: %ld, Versuche: %ld", (ULONG)lAsk, (ULONG)lTry ); + if( lTry != 0 ) + printf( ", V/E = %ld\n", lTry / lAsk ); +#endif +} + +/************************************************************************* +|* +|* SvHashTable::Test_Insert() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvHashTable::Test_Insert( const void * pElement, BOOL bInsert, + UINT32 * pInsertPos ) +{ + UINT32 nHash; + UINT32 nIndex; + UINT32 nLoop; + + lAsk++; + lTry++; + + nHash = HashFunc( pElement ); + nIndex = nHash % nMax; + +// const char* s = ((ByteString*) pElement)->GetStr(); +// fprintf(stderr,"### Hash: %lu , Name: %s\n",nIndex,s ); + + nLoop = 0; // divide to range + while( (nMax != nLoop) && IsEntry( nIndex ) ) + { // is place occupied + if( COMPARE_EQUAL == Compare( pElement, nIndex ) ) + { + if( pInsertPos ) + *pInsertPos = nIndex; // place of Element + return TRUE; + } + nLoop++; + lTry++; + nIndex = (USHORT)(nIndex + nHash + 7) % nMax; + } + + if( bInsert ) + { + DBG_ASSERT( nMax != nLoop, "Hash table full" ) + if( nMax != nLoop ) + { + nFill++; + *pInsertPos = nIndex; // return free place + return TRUE; + } + } + return( FALSE ); +} + +/************************************************************************/ +/************************************************************************* +|* +|* SvStringHashTable::SvStringHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashTable::SvStringHashTable( UINT32 nMaxEntries ) + : SvHashTable( nMaxEntries ) +{ +#ifdef WIN + DBG_ASSERT( (UINT32)nMaxEntries * sizeof( SvStringHashEntry ) <= 0xFF00, + "Hash table size cannot exeed 64k byte" ) +#endif + pEntries = new SvStringHashEntry[ nMaxEntries ]; + + // RefCount auf eins setzen + SvStringHashEntry * pPos, *pEnd; + pPos = pEntries; + pEnd = pEntries + nMaxEntries; + while( pPos != pEnd ) + { + pPos->AddRef(); + pPos++; + } +} + +/************************************************************************* +|* +|* ~SvStringHashTable::SvStringHashTable() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashTable::~SvStringHashTable() +{ + // RefCount auf eins setzen + SvStringHashEntry * pPos, *pEnd; + pPos = pEntries; + pEnd = pEntries + GetMax(); +#ifdef DBG_UTIL + while( pPos != pEnd ) + { + DBG_ASSERT( pPos->GetRefCount() == 1, "Reference count != 1" ) + pPos++; + } +#endif + +#ifdef MPW + // der MPW-Compiler ruft sonst keine Dtoren! + for ( USHORT n = 0; n < GetMax(); ++n ) + (pEntries+n)->SvStringHashEntry::~SvStringHashEntry(); + delete (void*) pEntries; +#else + delete [] pEntries; +#endif +} + +/************************************************************************* +|* +|* SvStringHashTable::HashFunc() +|* +|* Beschreibung +|* +*************************************************************************/ +UINT32 SvStringHashTable::HashFunc( const void * pElement ) const +{ + UINT32 nHash = 0; // hash value + const char * pStr = ((const ByteString * )pElement)->GetBuffer(); + + int nShift = 0; + while( *pStr ) + { + if( isupper( *pStr ) ) + nHash ^= UINT32(*pStr - 'A' + 26) << nShift; + else + nHash ^= UINT32(*pStr - 'a') << nShift; + if( nShift == 28 ) + nShift = 0; + else + nShift += 4; + pStr++; + } + return( nHash ); +} + +/************************************************************************* +|* +|* SvStringHashTable::GetNearString() +|* +|* Beschreibung +|* +*************************************************************************/ +ByteString SvStringHashTable::GetNearString( const ByteString & rName ) const +{ + for( UINT32 i = 0; i < GetMax(); i++ ) + { + SvStringHashEntry * pE = Get( i ); + if( pE ) + { + if( pE->GetName().EqualsIgnoreCaseAscii( rName ) && !pE->GetName().Equals( rName ) ) + return pE->GetName(); + } + } + return ByteString(); +} + +/************************************************************************* +|* +|* SvStringHashTable::IsEntry() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvStringHashTable::IsEntry( UINT32 nIndex ) const +{ + if( nIndex >= GetMax() ) + return FALSE; + return pEntries[ nIndex ].HasId(); +} + +/************************************************************************* +|* +|* SvStringHashTable::Insert() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvStringHashTable::Insert( const ByteString & rName, UINT32 * pIndex ) +{ + UINT32 nIndex; + + if( !pIndex ) pIndex = &nIndex; + + if( !SvHashTable::Test_Insert( &rName, TRUE, pIndex ) ) + return FALSE; + + if( !IsEntry( *pIndex ) ) + pEntries[ *pIndex ] = SvStringHashEntry( rName, *pIndex ); + return TRUE; +} + +/************************************************************************* +|* +|* SvStringHashTable::Test() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvStringHashTable::Test( const ByteString & rName, UINT32 * pPos ) const +{ + return ((SvStringHashTable *)this)->SvHashTable:: + Test_Insert( &rName, FALSE, pPos ); +} + +/************************************************************************* +|* +|* SvStringHashTable::Get() +|* +|* Beschreibung +|* +*************************************************************************/ +SvStringHashEntry * SvStringHashTable::Get( UINT32 nIndex ) const +{ + if( IsEntry( nIndex ) ) + return pEntries + nIndex; + return( NULL ); +} + +/************************************************************************* +|* +|* SvStringHashTable::Get() +|* +|* Beschreibung +|* +*************************************************************************/ +StringCompare SvStringHashTable::Compare( const void * pElement, + UINT32 nIndex ) const +{ + return ((const ByteString *)pElement)->CompareTo( pEntries[ nIndex ].GetName() ); +} + +/************************************************************************* +|* +|* SvStringHashTable::FillHashList() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvStringHashTable::FillHashList( SvStringHashList * pList ) const +{ + for( UINT32 n = 0; n < GetMax(); n++ ) + { + if( IsEntry( n ) ) + pList->Insert( Get( n ), LIST_APPEND ); + } + // Hash Reihenfolge, jetzt sortieren +} diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx new file mode 100644 index 000000000000..3162eafbb3c5 --- /dev/null +++ b/idl/source/cmptools/lex.cxx @@ -0,0 +1,677 @@ +/************************************************************************* + * + * $RCSfile: lex.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#include +#include + +#include +#include +#include +#include + +#ifndef _BIGINT_HXX //autogen +#include +#endif + +#pragma hdrstop + +/****************** SvToken **********************************************/ +/************************************************************************* +|* +|* SvToken::Print() +|* +|* Beschreibung +|* +*************************************************************************/ +ByteString SvToken::GetTokenAsString() const +{ + ByteString aStr; + switch( nType ) + { + case SVTOKEN_EMPTY: + break; + case SVTOKEN_COMMENT: + aStr = aString; + break; + case SVTOKEN_INTEGER: + aStr = nLong; + break; + case SVTOKEN_STRING: + aStr = aString; + break; + case SVTOKEN_BOOL: + aStr = bBool ? "TRUE" : "FALSE"; + break; + case SVTOKEN_IDENTIFIER: + aStr = aString; + break; + case SVTOKEN_CHAR: + aStr = cChar; + break; + case SVTOKEN_RTTIBASE: + aStr = "RTTIBASE";//(ULONG)pComplexObj; + break; + case SVTOKEN_EOF: + break; + } + + return aStr; +} + +/************************************************************************* +|* +|* SvToken::Print() +|* +|* Beschreibung +|* +*************************************************************************/ +ByteString SvToken::Print() const +{ + ByteString aStr; + aStr += "Line = "; + aStr += nLine; + aStr += ", Column = "; + aStr += nColumn; + aStr += ", "; + switch( nType ) + { + case SVTOKEN_EMPTY: + aStr += "Empty"; + break; + case SVTOKEN_COMMENT: + aStr += "Comment = "; + break; + case SVTOKEN_INTEGER: + aStr += "Integer = "; + break; + case SVTOKEN_STRING: + aStr += "ByteString = "; + break; + case SVTOKEN_BOOL: + aStr += "Bool = "; + break; + case SVTOKEN_IDENTIFIER: + aStr += "Identifier = "; + break; + case SVTOKEN_CHAR: + aStr += "char = "; + break; + case SVTOKEN_RTTIBASE: + aStr += "SvRttiBase = "; + break; + case SVTOKEN_EOF: + aStr += "end of file"; + break; + } + aStr += GetTokenAsString(); + + return aStr; +} + +/************************************************************************* +|* +|* SvToken::SvToken() +|* +|* Beschreibung +|* +*************************************************************************/ +SvToken::SvToken( const SvToken & rObj ) +{ + nLine = rObj.nLine; + nColumn = rObj.nColumn; + nType = rObj.nType; + aString = rObj.aString; +/* + if( SVTOKEN_RTTIBASE = nType ) + { + pComplexObj = rObj.pComplexObj; + pComplexObj->AddRef(); + } + else +*/ + nLong = rObj.nLong; +} + +/************************************************************************* +|* +|* SvToken::operator = () +|* +|* Beschreibung +|* +*************************************************************************/ +SvToken & SvToken::operator = ( const SvToken & rObj ) +{ + if( this != &rObj ) + { +/* + if( SVTOKEN_RTTIBASE = nType ) + pComplexObj->ReleaseRef(); +*/ + nLine = rObj.nLine; + nColumn = rObj.nColumn; + nType = rObj.nType; + aString = rObj.aString; +/* + if( SVTOKEN_RTTIBASE = nType ) + { + pComplexObj = rObj.pComplexObj; + pComplexObj->AddRef(); + } + else +*/ + nLong = rObj.nLong; + } + return *this; +} + +/****************** SvTokenStream ****************************************/ +/************************************************************************* +|* SvTokenStream::InitCtor() +|* +|* Beschreibung +*************************************************************************/ +void SvTokenStream::InitCtor() +{ +#ifdef DOS + SetCharSet( CHARSET_ANSI ); +#else + SetCharSet( gsl_getSystemTextEncoding() ); +#endif + aStrTrue = "TRUE"; + aStrFalse = "FALSE"; + nLine = nColumn = 0; + nBufPos = 0; + nTabSize = 4; + pCurToken = NULL; + nMaxPos = 0; + c = GetNextChar(); + FillTokenList(); +} + +/************************************************************************* +|* SvTokenStream::SvTokenStream() +|* +|* Beschreibung +*************************************************************************/ +SvTokenStream::SvTokenStream( const String & rFileName ) + : aFileName( rFileName ) + , pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) ) + , rInStream( *pInStream ) + , aTokList( 0x8000, 0x8000 ) +{ + InitCtor(); +} + +/************************************************************************* +|* SvTokenStream::SvTokenStream() +|* +|* Beschreibung +*************************************************************************/ +SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName ) + : aFileName( rFileName ) + , pInStream( NULL ) + , rInStream( rStream ) + , aTokList( 0x8000, 0x8000 ) +{ + InitCtor(); +} + +/************************************************************************* +|* SvTokenStream::~SvTokenStream() +|* +|* Beschreibung +*************************************************************************/ +SvTokenStream::~SvTokenStream() +{ + delete pInStream; + SvToken * pTok = aTokList.Last(); + while( pTok ) + { + delete pTok; + pTok = aTokList.Prev(); + } +} + +/************************************************************************* +|* SvTokenStream::GetHexValue() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvTokenStream::GetHexValue( const ByteString & rStr, BigInt * pValue ) +{ + short nLog = 16; + + *pValue = 0; + char * pStr = (char *)rStr.GetBuffer(); + while( isxdigit( *pStr ) ) + { + if( isdigit( *pStr ) ) + *pValue = *pValue * BigInt( nLog ) + BigInt(*pStr - '0'); + else + *pValue = *pValue * BigInt( nLog ) + BigInt(toupper( *pStr ) - 'A' + 10 ); + pStr++; + } + return '\0' == *pStr; +} + + +/************************************************************************* +|* SvTokenStream::FillTokenList() +|* +|* Beschreibung +*************************************************************************/ +void SvTokenStream::FillTokenList() +{ + SvToken * pToken = new SvToken(); + aTokList.Insert( pToken, LIST_APPEND ); + do + { + if( !MakeToken( *pToken ) ) + { + SvToken * p = aTokList.Prev(); + *pToken = SvToken(); + if( p ) + { + pToken->SetLine( p->GetLine() ); + pToken->SetColumn( p->GetColumn() ); + } + break; + } + else if( pToken->IsComment() ) + *pToken = SvToken(); + else if( pToken->IsEof() ) + break; + else + { + pToken = new SvToken(); + aTokList.Insert( pToken, LIST_APPEND ); + } + } + while( !pToken->IsEof() ); + pCurToken = aTokList.First(); +} + +/************************************************************************* +|* SvTokenStream::Skip() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvTokenStream::Skip( char cStart, char cEnd, UINT32 * pBegin ) +{ + SvToken * pTok = GetToken_Next(); + while( !pTok->IsEof() + && (!pTok->IsChar() || cStart != pTok->GetChar()) ) + pTok = GetToken_Next(); + + if( pBegin ) + *pBegin = Tell() -1; + UINT32 nContextCount = 1; + + while( !pTok->IsEof() && nContextCount != 0 ) + { + pTok = GetToken_Next(); + if( pTok->IsChar() ) + { + if( cEnd == pTok->GetChar() ) + nContextCount--; + if( cStart == pTok->GetChar() ) + nContextCount++; + } + } + pTok = GetToken(); + if( cEnd == '}' && pTok->IsChar() && pTok->GetChar() == ';' ) + // siehe aerger rsc, }; ausgemerzt + pTok = GetToken_Next(); + return nContextCount == 0; +} + +/************************************************************************* +|* SvTokenStream::Replace() +|* +|* Beschreibung +|* Invariante Range immer gueltig +*************************************************************************/ +void SvTokenStream::Replace( const Range & rRange, SvToken * pNewTok ) +{ + // Robuster SeekCursor + ULONG nSeekPos = aTokList.GetCurPos(); + if( nSeekPos >= (ULONG)rRange.Min() ) + if( nSeekPos <= (ULONG)rRange.Max() ) + nSeekPos = rRange.Min(); + else + nSeekPos -= rRange.Len(); + + long nLen = rRange.Len(); + aTokList.Seek( (ULONG)rRange.Min() ); + while( nLen-- ) + delete aTokList.Remove(); + + Seek( nSeekPos ); +} + +/************************************************************************* +|* SvTokenStrem::SetCharSet() +|* +|* Beschreibung +*************************************************************************/ +void SvTokenStream::SetCharSet( CharSet nSet ) +{ + nCharSet = nSet; + +#ifdef DOS + pCharTab = SvChar::GetTable( nSet, CHARSET_ANSI ); +#else + pCharTab = SvChar::GetTable( nSet, gsl_getSystemTextEncoding() ); +#endif +} + +/************************************************************************* +|* SvTokeStream::GetNextChar() +|* +|* Beschreibung +*************************************************************************/ +int SvTokenStream::GetNextChar() +{ + int nChar; + if( (int)aBufStr.Len() < nBufPos ) + { + if( rInStream.ReadLine( aBufStr ) ) + { + nLine++; + nColumn = 0; + nBufPos = 0; + } + else + { + aBufStr.Erase(); + nColumn = 0; + nBufPos = 0; + return '\0'; + } + } + nChar = aBufStr.GetChar( (USHORT)nBufPos++ ); + nColumn += nChar == '\t' ? nTabSize : 1; + return nChar; +} + +/************************************************************************* +|* SvTokenStrem::GetNumber() +|* +|* Beschreibung +*************************************************************************/ +ULONG SvTokenStream::GetNumber() +{ + ULONG l = 0; + short nLog = 10; + + if( '0' == c ) + { + c = GetFastNextChar(); + if( 'x' == c ) + { + nLog = 16; + c = GetFastNextChar(); + } + }; + + if( nLog == 16 ) + { + while( isxdigit( c ) ) + { + if( isdigit( c ) ) + l = l * nLog + (c - '0'); + else + l = l * nLog + (toupper( c ) - 'A' + 10 ); + c = GetFastNextChar(); + } + } + else + { + while( isdigit( c ) || 'x' == c ) + { + l = l * nLog + (c - '0'); + c = GetFastNextChar(); + } + } + + return( l ); +} + +/************************************************************************* +|* SvTokenStream::MakeToken() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvTokenStream::MakeToken( SvToken & rToken ) +{ + int c1; + USHORT i; + + do + { + if( 0 == c ) + c = GetNextChar(); + // Leerzeichen ueberlesen + while( isspace( c ) || 26 == c ) + { + c = GetFastNextChar(); + nColumn += c == '\t' ? nTabSize : 1; + } + } + while( 0 == c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) ); + + ULONG nLastLine = nLine; + ULONG nLastColumn = nColumn; + // Kommentar + if( '/' == c ) + { + // Zeit Optimierung, keine Kommentare + //ByteString aComment( (char)c ); + c1 = c; + c = GetFastNextChar(); + if( '/' == c ) + { + while( '\0' != c ) + { + //aComment += (char)c; + c = GetFastNextChar(); + } + c = GetNextChar(); + rToken.nType = SVTOKEN_COMMENT; + //rToken.aString = aComment; + } + else if( '*' == c ) + { + //aComment += (char)c; + c = GetFastNextChar(); + do + { + //aComment += (char)c; + while( '*' != c ) + { + if( '\0' == c ) + { + c = GetNextChar(); + if( IsEof() ) + return FALSE; + } + else + c = GetFastNextChar(); + //aComment += (char)c; + } + c = GetFastNextChar(); + } + while( '/' != c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) ); + if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) ) + return FALSE; + //aComment += (char)c; + c = GetNextChar(); + rToken.nType = SVTOKEN_COMMENT; + //rToken.aString = aComment; + CalcColumn(); + } + else + { + rToken.nType = SVTOKEN_CHAR; + rToken.cChar = (char)c1; + } + } + else if( c == '"' ) + { + ByteString aStr; + i = 0; + BOOL bDone = FALSE; + while( !bDone && !IsEof() && c ) + { + c = GetFastNextChar(); + if( '\0' == c ) + { + // Strings auch "uber das Zeilenende hinauslesen + aStr += '\n'; + c = GetNextChar(); + if( IsEof() ) + return FALSE; + } + if( c == '"' ) + { + c = GetFastNextChar(); + if( c == '"' ) + { + aStr += '"'; + aStr += '"'; + } + else + bDone = TRUE; + } + else if( c == '\\' ) + { + aStr += '\\'; + c = GetFastNextChar(); + if( c ) + aStr += (char)c; + } + else + aStr += (char)c; + } + if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) ) + return FALSE; + char * pStr = (char *)aStr.GetBuffer(); + while( *pStr ) + { + *pStr = pCharTab[ (unsigned char)*pStr ]; + pStr++; + }; + rToken.nType = SVTOKEN_STRING; + rToken.aString = aStr; + } + else if( isdigit( c ) ) + { + rToken.nType = SVTOKEN_INTEGER; + rToken.nLong = GetNumber(); + + } + else if( isalpha (c) || (c == '_') ) + { + ByteString aStr; + + while( isalnum( c ) || c == '_' ) + { + aStr += (char)c; + c = GetFastNextChar(); + } + if( aStr.EqualsIgnoreCaseAscii( aStrTrue ) ) + { + rToken.nType = SVTOKEN_BOOL; + rToken.bBool = TRUE; + } + else if( aStr.EqualsIgnoreCaseAscii( aStrFalse ) ) + { + rToken.nType = SVTOKEN_BOOL; + rToken.bBool = FALSE; + } + else + { + UINT32 nHashId; + if( IDLAPP->pHashTable->Test( aStr, &nHashId ) ) + rToken.SetHash( IDLAPP->pHashTable->Get( nHashId ) ); + else + { + rToken.nType = SVTOKEN_IDENTIFIER; + rToken.aString = aStr; + } + } + } + else if( IsEof() ) + { + rToken.nType = SVTOKEN_EOF; + } + else + { + rToken.nType = SVTOKEN_CHAR; + rToken.cChar = (char)c; + c = GetFastNextChar(); + } + rToken.SetLine( nLastLine ); + rToken.SetColumn( nLastColumn ); + return rInStream.GetError() == SVSTREAM_OK; +} + diff --git a/idl/source/cmptools/makefile.mk b/idl/source/cmptools/makefile.mk new file mode 100644 index 000000000000..9a718c175dae --- /dev/null +++ b/idl/source/cmptools/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PRJPCH= + +PROJECTPCH4DLL=TRUE +PROJECTPCH=idlpch +PROJECTPCHSOURCE=$(PRJ)$/util$/idlpch + +PRJNAME=SVIDL +TARGET=cmptools + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.IF "$(COM)"=="WTC" +CFLAGS+=-od +.ENDIF + +CDEFS+=-DIDL_COMPILER +# --- Files -------------------------------------------------------------- + +CXXFILES= char.cxx \ + lex.cxx \ + hash.cxx \ + $(PROJECTPCHSOURCE).cxx + +OBJFILES= $(OBJ)$/lex.obj \ + $(OBJ)$/char.obj \ + $(OBJ)$/hash.obj + +# --- Targets ------------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/idl/source/objects/basobj.cxx b/idl/source/objects/basobj.cxx new file mode 100644 index 000000000000..1cfa683cb170 --- /dev/null +++ b/idl/source/objects/basobj.cxx @@ -0,0 +1,863 @@ +/************************************************************************* + * + * $RCSfile: basobj.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include + +#include +#include +#include +#include +#include +#pragma hdrstop + +/****************** SvMetaObject *****************************************/ +SV_IMPL_META_FACTORY1( SvMetaObject, SvRttiBase ) +#ifdef IDL_COMPILER +SvAttributeList & SvMetaObject::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* SvMetaObject::SvMetaObject() +|* +|* Beschreibung +*************************************************************************/ +SvMetaObject::SvMetaObject() +{ +} + +void SvMetaObject::Load( SvPersistStream & ) +{ +} + +void SvMetaObject::Save( SvPersistStream & ) +{ +} + +/************************************************************************* +|* SvMetaObject::WriteTab() +|* +|* Beschreibung +*************************************************************************/ +#ifdef IDL_COMPILER +void SvMetaObject::WriteTab( SvStream & rOutStm, USHORT nTab ) +{ + while( nTab-- ) + rOutStm << " "; +// rOutStm << '\t'; +} + +/************************************************************************* +|* SvMetaObject::WriteStart() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaObject::WriteStars( SvStream & rOutStm ) +{ + rOutStm << '/'; + for( int i = 6; i > 0; i-- ) + rOutStm << "**********"; + rOutStm << '/' << endl; +} + +/************************************************************************* +|* SvMetaObject::TestAndSeekSpaceOnly() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaObject::TestAndSeekSpaceOnly( SvStream & rOutStm, ULONG nBegPos ) +{ + // keine leeren Klammern schreiben + ULONG nPos = rOutStm.Tell(); + rOutStm.Seek( nBegPos ); + BOOL bOnlySpace = TRUE; + while( bOnlySpace && rOutStm.Tell() < nPos ) + { + char c; + rOutStm >> c; + if( !isspace( c ) ) + bOnlySpace = FALSE; + } + if( bOnlySpace ) + // nichts geschrieben + rOutStm.Seek( nBegPos ); + else + rOutStm.Seek( nPos ); + return bOnlySpace; +} + +/************************************************************************* +|* SvMetaObject::Back2Delemitter() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaObject::Back2Delemitter( SvStream & rOutStm ) +{ + // keine leeren Klammern schreiben + ULONG nPos = rOutStm.Tell(); + rOutStm.SeekRel( -1 ); + char c = 0; + rOutStm >> c; + + while( isspace( c ) && rOutStm.Tell() != 1 ) + { + rOutStm.SeekRel( -2 ); + rOutStm >> c; + } + + if( c == ';' || c == ',' ) + rOutStm.SeekRel( -1 ); + else + rOutStm.Seek( nPos ); +} + +/************************************************************************* +|* SvMetaObject::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaObject::ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) +{ + return FALSE; +} + +/************************************************************************* +|* SvMetaObject::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaObject::WriteSvIdl( SvIdlDataBase &, SvStream &, USHORT /*nTab */ ) +{ +} + +/************************************************************************* +|* SvMetaObject::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaObject::Write( SvIdlDataBase &, SvStream &, USHORT /*nTab */, + WriteType, WriteAttribute ) +{ +} + +/************************************************************************* +|* SvMetaObject::WriteCxx() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaObject::WriteCxx( SvIdlDataBase &, SvStream &, USHORT /*nTab */ ) +{ +} + +/************************************************************************* +|* SvMetaObject::WriteHxx() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaObject::WriteHxx( SvIdlDataBase &, SvStream &, USHORT /*nTab */ ) +{ +} + +#endif + +/****************** SvMetaName *****************************************/ +SV_IMPL_META_FACTORY1( SvMetaName, SvMetaObject ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaName::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + pAttribList->Append( new SV_ATTRIBUTE( Name, Name ) ); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* SvMetaName::SvMetaName() +|* +|* Beschreibung +*************************************************************************/ +SvMetaName::SvMetaName() +{ +} + +void SvMetaName::Load( SvPersistStream & rStm ) +{ + SvMetaObject::Load( rStm ); + BYTE nMask; + rStm >> nMask; + + if( nMask >= 0x20 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) rStm >> aName; + if( nMask & 0x02 ) rStm >> aHelpContext; + if( nMask & 0x04 ) rStm >> aHelpText; + if( nMask & 0x08 ) rStm >> aConfigName; + if( nMask & 0x10 ) rStm >> aDescription; +} + +void SvMetaName::Save( SvPersistStream & rStm ) +{ + SvMetaObject::Save( rStm ); + BYTE nMask = 0; + if( aName.IsSet() ) nMask |= 0x01; + if( aHelpContext.IsSet() ) nMask |= 0x02; + if( aHelpText.IsSet() ) nMask |= 0x04; + if( aConfigName.IsSet() ) nMask |= 0x08; + if( aDescription.IsSet() ) nMask |= 0x10; + + rStm << nMask; + if( nMask & 0x01 ) rStm << aName; + if( nMask & 0x02 ) rStm << aHelpContext; + if( nMask & 0x04 ) rStm << aHelpText; + if( nMask & 0x08 ) rStm << aConfigName; + if( nMask & 0x10 ) rStm << aDescription; +} + +/************************************************************************* +|* +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaName::SetName( const ByteString & rName, SvIdlDataBase * ) +{ + aName = rName; + return TRUE; +} + +#ifdef IDL_COMPILER +/************************************************************************* +|* SvMetaName::ReadNameSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaName::ReadNameSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + // Modulnamen lesen + if( pTok->IsIdentifier() ) + if( SetName( pTok->GetString(), &rBase ) ) + return TRUE; + + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* SvMetaName::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + if( aName.ReadSvIdl( SvHash_Name(), rInStm ) ) + { + if( !SetName( aName, &rBase ) ) + rInStm.Seek( nTokPos ); + } + aHelpContext.ReadSvIdl( rBase, SvHash_HelpContext(), rInStm ); + aHelpText.ReadSvIdl( rBase, rInStm ); + aConfigName.ReadSvIdl( SvHash_ConfigName(), rInStm ); + aDescription.ReadSvIdl( SvHash_Description(), rInStm ); +/* + aHelpContext.ReadSvIdl( GetModule()->GetInfo()->GetHelpContextContainer(), + rInStm ); +*/ +} + +/************************************************************************* +|* SvMetaName::DoReadContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::DoReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm, char cDel ) +{ + UINT32 nBeginPos = 0; // kann mit Tell nicht vorkommen + while( nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + ReadContextSvIdl( rBase, rInStm ); + if( cDel == '\0' ) + rInStm.ReadDelemiter(); + else + rInStm.Read( cDel ); + } +} + +/************************************************************************* +|* SvMetaName::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ +} + +/************************************************************************* +|* SvMetaName::Test() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaName::Test( SvIdlDataBase &, SvTokenStream & ) +{ + return TRUE; +} + +/************************************************************************* +|* SvMetaName::WriteContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ +} + +/************************************************************************* +|* SvMetaName::WriteDescription() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::WriteDescription( SvIdlDataBase & rBase, + SvStream & rOutStm ) +{ + rOutStm << "" << endl; + + ByteString aDescription( GetDescription() ); + USHORT nPos = aDescription.Search( '\n' ); + while ( nPos != STRING_NOTFOUND ) + { + rOutStm << aDescription.Copy( 0, nPos ).GetBuffer() << endl; + aDescription.Erase(0,nPos+1); + nPos = aDescription.Search( '\n' ); + } + + rOutStm << aDescription.GetBuffer() << endl + << "" << endl; +} + +/************************************************************************* +|* SvMetaName::WriteAttributesIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ + if( aHelpContext.IsSet() || aHelpText.IsSet() || aConfigName.IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaName" << endl; + } + if( aHelpContext.IsSet() ) + { + WriteTab( rOutStm, nTab ); + aHelpContext.WriteSvIdl( SvHash_HelpContext(), rOutStm, nTab ); + rOutStm << ';' << endl; + } + if( aHelpText.IsSet() ) + { + WriteTab( rOutStm, nTab ); + aHelpText.WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << ';' << endl; + } + if( aConfigName.IsSet() ) + { + WriteTab( rOutStm, nTab ); + aConfigName.WriteSvIdl( SvHash_ConfigName(), rOutStm, nTab ); + rOutStm << ';' << endl; + } +} + +/************************************************************************* +|* SvMetaName::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaName::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + BOOL bOk = TRUE; + if( rInStm.Read( '[' ) ) + { + UINT32 nBeginPos = 0; // kann mit Tell nicht vorkommen + while( nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + ReadAttributesSvIdl( rBase, rInStm ); + rInStm.ReadDelemiter(); + } + bOk = rInStm.Read( ']' ); + } + + if( bOk ) + { + if( rInStm.Read( '{' ) ) + { + DoReadContextSvIdl( rBase, rInStm ); + bOk = rInStm.Read( '}' ); + } + } + + if( !bOk ) + rInStm.Seek( nTokPos ); + return bOk; +} + +/************************************************************************* +|* SvMetaName::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + ULONG nBeginPos = rOutStm.Tell(); + WriteTab( rOutStm, nTab ); + rOutStm << '[' << endl; + ULONG nOldPos = rOutStm.Tell(); + WriteAttributesSvIdl( rBase, rOutStm, nTab +1 ); + + // keine leeren Klammern schreiben + if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) ) + // nichts geschrieben + rOutStm.Seek( nBeginPos ); + else + { + WriteTab( rOutStm, nTab ); + rOutStm << ']'; + nBeginPos = rOutStm.Tell(); + rOutStm << endl; + } + + WriteTab( rOutStm, nTab ); + rOutStm << '{' << endl; + nOldPos = rOutStm.Tell(); + WriteContextSvIdl( rBase, rOutStm, nTab +1 ); + + // keine leeren Klammern schreiben + if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) ) + // nichts geschrieben + rOutStm.Seek( nBeginPos ); + else + { + WriteTab( rOutStm, nTab ); + rOutStm << '}'; + } +} + +/************************************************************************* +|* SvMetaName::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + ULONG nBeginPos = rOutStm.Tell(); + WriteTab( rOutStm, nTab ); + rOutStm << '[' << endl; + ULONG nOldPos = rOutStm.Tell(); + WriteAttributes( rBase, rOutStm, nTab +1, nT, nA ); + + // keine leeren Klammern schreiben + ULONG nPos = rOutStm.Tell(); + rOutStm.Seek( nOldPos ); + BOOL bOnlySpace = TRUE; + while( bOnlySpace && rOutStm.Tell() < nPos ) + { + char c; + rOutStm >> c; + if( !isspace( c ) ) + bOnlySpace = FALSE; + } + if( bOnlySpace ) + // nichts geschrieben + rOutStm.Seek( nBeginPos ); + else + { + rOutStm.Seek( nPos ); + WriteTab( rOutStm, nTab ); + rOutStm << ']' << endl; + } +} + +/************************************************************************* +|* SvMetaName::WriteAttributes() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + if( GetHelpText().IsSet() || GetHelpContext().IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaName" << endl; + } + if( GetHelpText().IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "helpstring(\"" << GetHelpText().GetBuffer() << "\")," << endl; + } + if( GetHelpContext().IsSet() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "helpcontext(" + << ByteString( GetHelpContext().GetValue() ).GetBuffer() + << ")," << endl; + } +} + +/************************************************************************* +|* SvMetaName::WriteContext() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaName::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ +} +#endif // IDL_COMPILER + +/****************** SvMetaReference *****************************************/ +SV_IMPL_META_FACTORY1( SvMetaReference, SvMetaName ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaReference::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif + +/************************************************************************* +|* SvMetaReference::SvMetaReference() +|* +|* Beschreibung +*************************************************************************/ +SvMetaReference::SvMetaReference() +{ +} + +void SvMetaReference::Load( SvPersistStream & rStm ) +{ + SvMetaName::Load( rStm ); + + BYTE nMask; + rStm >> nMask; + if( nMask >= 0x2 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) + { + SvMetaReference * pRef; + rStm >> pRef; + aRef = pRef; + } +} + +void SvMetaReference::Save( SvPersistStream & rStm ) +{ + SvMetaName::Save( rStm ); + + // Maske erstellen + BYTE nMask = 0; + if( aRef.Is() ) + nMask |= 0x01; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x01 ) rStm << aRef; +} + +/**************************************************************************/ +/****************** SvMetaExtern ******************************************/ +SV_IMPL_META_FACTORY1( SvMetaExtern, SvMetaReference ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaExtern::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif + +/************************************************************************* +|* SvMetaExtern::SvMetaExtern() +|* +|* Beschreibung +*************************************************************************/ +SvMetaExtern::SvMetaExtern() + : pModule( NULL ) + , bReadUUId( FALSE ) + , bReadVersion( FALSE ) +{ +} + +void SvMetaExtern::Load( SvPersistStream & rStm ) +{ + SvMetaReference::Load( rStm ); + + BYTE nMask; + rStm >> nMask; + if( nMask >= 0x20 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) rStm >> pModule; + if( nMask & 0x02 ) rStm >> aUUId; + if( nMask & 0x04 ) rStm >> aVersion; + if( nMask & 0x08 ) bReadUUId = TRUE; + if( nMask & 0x10 ) bReadVersion = TRUE; +} + +void SvMetaExtern::Save( SvPersistStream & rStm ) +{ + SvMetaReference::Save( rStm ); + + // Maske erstellen + BYTE nMask = 0; + if( pModule ) nMask |= 0x01; + if( aUUId != SvGlobalName() ) nMask |= 0x02; + if( aVersion != SvVersion() ) nMask |= 0x04; + if( bReadUUId ) nMask |= 0x08; + if( bReadVersion ) nMask |= 0x10; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x01 ) rStm << pModule; + if( nMask & 0x02 ) rStm << aUUId; + if( nMask & 0x04 ) rStm << aVersion; +} + +/************************************************************************* +|* SvMetaExtern::GetModule() +|* +|* Beschreibung +*************************************************************************/ +SvMetaModule * SvMetaExtern::GetModule() const +{ + DBG_ASSERT( pModule != NULL, "module not set" ) + return pModule; +} + +/************************************************************************* +|* SvMetaExtern::GetUUId() +|* +|* Beschreibung +*************************************************************************/ +const SvGlobalName & SvMetaExtern::GetUUId() const +{ +#ifdef IDL_COMPILER + if( aUUId == SvGlobalName() ) + GetModule()->FillNextName( &((SvMetaExtern *)this)->aUUId ); +#endif + return aUUId; +} + +#ifdef IDL_COMPILER +/************************************************************************* +|* SvMetaExtern::SetModule() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaExtern::SetModule( SvIdlDataBase & rBase ) +{ + pModule = (SvMetaModule *)rBase.GetStack().Get( TYPE( SvMetaModule ) ); +} + +/************************************************************************* +|* SvMetaExtern::ReadAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaExtern::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaReference::ReadAttributesSvIdl( rBase, rInStm ); + if( aUUId.ReadSvIdl( rBase, rInStm ) ) + bReadUUId = TRUE; + if( aVersion.ReadSvIdl( rInStm ) ) + bReadVersion = TRUE; +} + +/************************************************************************* +|* SvMetaExtern::WriteAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaExtern::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ) +{ + SvMetaReference::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + if( bReadUUId || bReadVersion ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaExtern" << endl; + + if( bReadUUId ) + { + WriteTab( rOutStm, nTab ); + aUUId.WriteSvIdl( rOutStm ); + rOutStm << ';' << endl; + } + if( bReadVersion ) + { + WriteTab( rOutStm, nTab ); + aVersion.WriteSvIdl( rOutStm ); + rOutStm << ';' << endl; + } + } +} + +/************************************************************************* +|* SvMetaExtern::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaExtern::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + SetModule( rBase ); + GetUUId(); // Id wird angelegt + return SvMetaReference::ReadSvIdl( rBase, rInStm ); +} + +/************************************************************************* +|* SvMetaExtern::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaExtern::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + SvMetaReference::WriteSvIdl( rBase, rOutStm, nTab ); +} + +/************************************************************************* +|* SvMetaExtern::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaExtern::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaReference::Write( rBase, rOutStm, nTab, nT, nA ); +} + +/************************************************************************* +|* SvMetaExtern::WriteAttributes() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaExtern::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaReference::WriteAttributes( rBase, rOutStm, nTab, nT, nA ); + + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaExtern" << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "uuid(" << ByteString( GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << ")," << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "version(" << ByteString::CreateFromInt32( aVersion.GetMajorVersion() ).GetBuffer() << '.' + << ByteString::CreateFromInt32( aVersion.GetMinorVersion() ).GetBuffer() << ")," << endl; +} + +#endif // IDL_COMPILER + + diff --git a/idl/source/objects/bastype.cxx b/idl/source/objects/bastype.cxx new file mode 100644 index 000000000000..9bdc05520cc3 --- /dev/null +++ b/idl/source/objects/bastype.cxx @@ -0,0 +1,1045 @@ +/************************************************************************* + * + * $RCSfile: bastype.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#pragma hdrstop + +/************************************************************************/ +ByteString MakeDefineName( const ByteString & rName ) +{ + ByteString aDefName; + if( rName.Len() ) + { + char * pStr = (char *)rName.GetBuffer(); + aDefName = *pStr; + while( *++pStr ) + { + if( isupper( *pStr ) ) + aDefName += '_'; + aDefName += (char)toupper( *pStr ); + } + } + return aDefName; +} + +#ifdef IDL_COMPILER +/************************************************************************/ +static BOOL ReadRangeSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm, + long nMin, ULONG nMax, long * pValue ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( pName ) ) + { + BOOL bOk = TRUE; + BOOL bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + short nSign = 1; + pTok = rInStm.GetToken_Next(); + if( pTok->IsChar() && pTok->GetChar() == '-' ) + { + nSign = -1; + pTok = rInStm.GetToken_Next(); + } + else if( pTok->IsChar() && pTok->GetChar() == '+' ) + pTok = rInStm.GetToken_Next(); + + if( pTok->IsInteger() ) + { + ULONG n = pTok->GetNumber(); + if( nSign == -1 || n <= nMax ) + { // nich tueber dem Maximum + if( (nSign == -1 && n < 0x8000000 + && -(long)n >= nMin) + || (nSign == 1 && n >= 0x8000000 || (long)n > nMin) ) + { + *pValue = (long)n; + } + else + bOk = FALSE; + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + else + bOk = pTok->IsChar() && pTok->GetChar() == ')'; + } + if( bOk ) + return TRUE; + } + rInStm.Seek( nTokPos ); + return FALSE; +} +#endif + +/************************************************************************/ +/************************************************************************* +|* +|* RangeUniqueIdContainer::RangeUniqueIdContainer() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +RangeUniqueIdContainer::RangeUniqueIdContainer( const Range & rRange ) + : UniqueIdContainer( rRange.Min() ), + nMax( rRange.Max() ), nMin( rRange.Min() ) +{ +} + +/************************************************************************* +|* +|* RangeUniqueIdContainer::RangeUniqueIdContainer() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +RangeUniqueIdContainer::RangeUniqueIdContainer() + : UniqueIdContainer( 0 ), + nMax( 0 ), nMin( 0 ) +{ +} + +RangeUniqueIdContainer::~RangeUniqueIdContainer() +{ +} + +/************************************************************************* +|* +|* RangeUniqueIdContainer:: opearator =() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +RangeUniqueIdContainer & RangeUniqueIdContainer::operator = + ( const RangeUniqueIdContainer & rObj ) +{ + UniqueIdContainer::operator = ( rObj ); + nMin = rObj.nMin; + nMax = rObj.nMax; + return *this; +} + +/************************************************************************* +|* +|* RangeUniqueIdContainer::CreateId() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL RangeUniqueIdContainer::CreateId( UniqueItemId * pId ) +{ + { + // wegen Scope von aId + UniqueItemId aId = UniqueIdContainer::CreateId(); + if( aId.GetId() <= nMax ) + { + *pId = aId; + return TRUE; + } + } + Clear( FALSE ); // nicht gebrauchte freigeben + // noch einmal versuchen + { + // wegen Scope von aId + UniqueItemId aId = UniqueIdContainer::CreateId(); + if( aId.GetId() <= nMax ) + { + *pId = aId; + return TRUE; + } + } + return FALSE; +} + +/************************************************************************* +|* +|* RangeUniqueIdContainer::CreateId() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL RangeUniqueIdContainer::CreateId( UINT32 nIdValue, UniqueItemId * pId ) +{ + if( nIdValue >= nMin && nIdValue <= nMax ) + { + if( IsIndexValid( nIdValue ) ) + return FALSE; + *pId = CreateIdProt( nIdValue ); + return TRUE; + } + *pId = UniqueIdContainer::CreateFreeId( nIdValue ); + return TRUE; +} + +/************************************************************************* +|* +|* SvUINT32::Read() +|* SvUINT32::Write() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +UINT32 SvUINT32::Read( SvStream & rStm ) +{ + return SvPersistStream::ReadCompressed( rStm ); +} + +void SvUINT32::Write( SvStream & rStm, UINT32 nVal ) +{ + SvPersistStream::WriteCompressed( rStm, nVal ); +} + +/************************************************************************* +|* +|* SvStream& operator << ( SvBOOL ) +|* SvStream& operator >> ( SvBOOL ) +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +SvStream& operator << (SvStream & rStm, const SvBOOL & rb ) +{ + BYTE n = rb.nVal; + if( rb.bSet ) + n |= 0x02; + rStm << n; + return rStm; +} +SvStream& operator >> (SvStream & rStm, SvBOOL & rb ) +{ + BYTE n; + rStm >> n; + rb.nVal = (n & 0x01) ? TRUE : FALSE; + rb.bSet = (n & 0x02) ? TRUE : FALSE; + if( n & ~0x03 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "format error" ) + } + return rStm; +} + +/************************************************************************* +|* +|* SvStream& operator << ( SvVersion ) +|* SvStream& operator >> ( SvVersion ) +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +SvStream& operator << (SvStream & rStm, const SvVersion & r ) +{ + if( (r.GetMajorVersion() || r.GetMinorVersion()) + && r.GetMajorVersion() <= 0x0F && r.GetMinorVersion() <= 0x0F ) + { // Versionsnummer in 1 Byte komprimieren + // Format 4 Bit fuer Major, dann 4 Bit fuer Minor. + // 0.0 wird nicht komprimiert + + BYTE n = r.GetMajorVersion() << 4; + n |= r.GetMinorVersion(); + rStm << n; + } + else + { + rStm << (BYTE)0; + rStm << r.GetMajorVersion(); + rStm << r.GetMinorVersion(); + } + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvVersion & r ) +{ + BYTE n; + rStm >> n; + if( n == 0 ) + { // nicht komprimiert + rStm >> r.nMajorVersion; + rStm >> r.nMinorVersion; + } + else + { // komprimiert + r.nMajorVersion = (n >> 4) & 0x0F; + r.nMinorVersion = n & 0x0F; + } + return rStm; +} + + +#ifdef IDL_COMPILER +/************************************************************************/ +/************************************************************************* +|* +|* SvINT16::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvINT16::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + long n; + + if( ReadRangeSvIdl( pName, rInStm, -(long)0x8000, 0x7FFF, &n ) ) + { + nVal = (short)n; + return TRUE; + } + return FALSE; +} + +/************************************************************************* +|* +|* SvINT16::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvINT16::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ) +{ + rOutStm << pName->GetName().GetBuffer() << "(\"" + << ByteString::CreateFromInt32( nVal ).GetBuffer() << "\")"; + return TRUE; +} + + +/************************************************************************* +|* +|* SvUINT16::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvUINT16::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + long n; + + if( ReadRangeSvIdl( pName, rInStm, 0, 0xFFFF, &n ) ) + { + nVal = (UINT16)n; + return TRUE; + } + return FALSE; +} + +/************************************************************************* +|* +|* SvUINT16::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvUINT16::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ) +{ + rOutStm << pName->GetName().GetBuffer() << "(\"" + << ByteString::CreateFromInt32( nVal ).GetBuffer() << "\")"; + return TRUE; +} + + +/************************************************************************* +|* +|* SvINT32::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvINT32::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + long n; + + if( ReadRangeSvIdl( pName, rInStm, (-2147483647L-1L), 0x7FFFFFFF, &n ) ) + { + nVal = (INT32)n; + return TRUE; + } + return FALSE; +} + +/************************************************************************* +|* +|* SvINT32::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvINT32::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ) +{ + rOutStm << pName->GetName().GetBuffer() << "(\"" + << ByteString::CreateFromInt32( nVal ).GetBuffer() << "\")"; + return TRUE; +} + + +/************************************************************************* +|* +|* SvUINT32::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvUINT32::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + long n; + + if( ReadRangeSvIdl( pName, rInStm, 0, 0xFFFFFFFF, &n ) ) + { + nVal = (UINT32)n; + return TRUE; + } + return FALSE; +} + +/************************************************************************* +|* +|* SvUINT32::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvUINT32::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ) +{ + rOutStm << pName->GetName().GetBuffer() << "(\"" + << ByteString::CreateFromInt32( nVal ).GetBuffer() << "\")"; + return TRUE; +} + + +/************************************************************************/ +/************************************************************************* +|* +|* Svint::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL Svint::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + long n; + + if( ReadRangeSvIdl( pName, rInStm, INT_MIN, INT_MAX, &n ) ) + { + nVal = (int)n; + return TRUE; + } + return FALSE; +} + +/************************************************************************* +|* +|* Svint::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL Svint::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ) +{ + rOutStm << pName->GetName().GetBuffer() << "(\"" + << ByteString::CreateFromInt32( nVal ).GetBuffer() << "\")"; + return TRUE; +} + + +/************************************************************************* +|* +|* SvBOOL::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvBOOL::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( pName ) ) + { + BOOL bOk = TRUE; + BOOL bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsBool() ) + { + *this = pTok->GetBool(); + + rInStm.GetToken_Next(); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + else + *this = TRUE; //Defaultaktion ist auf TRUE setzen + if( bOk ) + return TRUE; + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvBOOL::WriteSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvBOOL::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm ) +{ + if( nVal ) + rOutStm << pName->GetName().GetBuffer(); + else + rOutStm << pName->GetName().GetBuffer() << "(FALSE)"; + return TRUE; +} + +/************************************************************************* +|* +|* SvBOOL::WriteSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +ByteString SvBOOL::GetSvIdlString( SvStringHashEntry * pName ) +{ + if( nVal ) + return pName->GetName(); + else + { + ByteString aTmp( pName->GetName() ); + aTmp += "(FALSE)"; + return aTmp; + } +} + + +/************************************************************************/ +/************************************************************************* +|* +|* SvIdentifier::ReadSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvIdentifier::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( pName ) ) + { + BOOL bOk = TRUE; + BOOL bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsIdentifier() ) + { + *(ByteString *)this = pTok->GetString(); + rInStm.GetToken_Next(); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + if( bOk ) + return TRUE; + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvIdentifier::WriteSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvIdentifier::WriteSvIdl( SvStringHashEntry * pName, + SvStream & rOutStm, + USHORT /*nTab */ ) +{ + rOutStm << pName->GetName().GetBuffer() << '('; + rOutStm << GetBuffer() << ')'; + return TRUE; +} + +SvStream& operator << (SvStream & rStm, const SvIdentifier & r ) +{ + rStm.WriteByteString( r ); + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvIdentifier & r ) +{ + rStm.ReadByteString( r ); + return rStm; +} + + +/************************************************************************/ +/************************************************************************* +|* +|* SvNumberIdentifier::ReadSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvNumberIdentifier::ReadSvIdl( SvIdlDataBase & rBase, + SvStringHashEntry * pName, + SvTokenStream & rInStm ) +{ + if( SvIdentifier::ReadSvIdl( pName, rInStm ) ) + { + ULONG n; + if( rBase.FindId( *this, &n ) ) + { + nValue = n; + return TRUE; + } + else + { + ByteString aStr ("no value for identifier <"); + aStr += *this; + aStr += "> "; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + return FALSE; +} + +/************************************************************************* +|* +|* SvNumberIdentifier::ReadSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvNumberIdentifier::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->IsIdentifier() ) + { + ULONG n; + if( rBase.FindId( pTok->GetString(), &n ) ) + { + *(ByteString *)this = pTok->GetString(); + nValue = n; + return TRUE; + } + else + { + ByteString aStr ("no value for identifier <"); + aStr += *this; + aStr += "> "; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvStream& operator << ( SvNumberIdentifier ) +|* SvStream& operator >> ( SvNumberIdentifier ) +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +SvStream& operator << (SvStream & rStm, const SvNumberIdentifier & r ) +{ + rStm << (SvIdentifier &)r; + SvPersistStream::WriteCompressed( rStm, r.nValue ); + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvNumberIdentifier & r ) +{ + rStm >> (SvIdentifier &)r; + r.nValue = SvPersistStream::ReadCompressed( rStm ); + return rStm; +} + + +/************************************************************************/ +/************************************************************************* +|* +|* SvString::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvString::ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( pName ) ) + { + BOOL bOk = TRUE; + BOOL bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsString() ) + { + *(ByteString *)this = pTok->GetString(); + rInStm.GetToken_Next(); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + if( bOk ) + return TRUE; + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvString::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvString::WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm, + USHORT /*nTab */ ) +{ + rOutStm << pName->GetName().GetBuffer() << "(\""; + rOutStm << GetBuffer() << "\")"; + return TRUE; +} + +SvStream& operator << (SvStream & rStm, const SvString & r ) +{ + rStm.WriteByteString( r ); + return rStm; +} + +SvStream& operator >> (SvStream & rStm, SvString & r ) +{ + rStm.ReadByteString( r ); + return rStm; +} + + +/************************************************************************* +|* +|* SvHelpText::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvHelpText::ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) +{ + return SvString::ReadSvIdl( SvHash_HelpText(), rInStm ); +} + +/************************************************************************* +|* +|* SvHelpText::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvHelpText::WriteSvIdl( SvIdlDataBase &, SvStream & rOutStm, USHORT nTab ) +{ + return SvString::WriteSvIdl( SvHash_HelpText(), rOutStm, nTab ); +} + +#ifdef sdvnmsd +/************************************************************************* +|* +|* SvHelpContext::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvHelpContext::ReadSvIdl( RangeUniqueIdContainer & rCont, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + long n = 0; + + if( ReadRangeSvIdl( SvHash_HelpContext(), rInStm, 0, 0xFFFFFFFF, &n ) ) + { + if( n == 0 ) + { + //if( rCont.CreateId( &aId ) ) + // erst beim Schreiben anlegen + bSet = TRUE; + return TRUE; + } + else + { + if( (UINT32)n <= rCont.GetMax() && (UINT32)n >= rCont.GetMin() ) + { + aId = UniqueIdContainer::CreateFreeId( (UINT32)n ); + bSet = TRUE; + return TRUE; + } + else if( rCont.CreateId( (UINT32)n, &aId ) ) + { + bSet = TRUE; + return TRUE; + } + } + } + + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvHelpContext::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvHelpContext::WriteSvIdl( RangeUniqueIdContainer & rCont, + SvStream & rOutStm, USHORT ) +{ + if( IsSet() && GetId() == 0 ) + if( !rCont.CreateId( &aId ) ) + return FALSE; + rOutStm << (const char *)SvHash_HelpContext()->GetName() << '(' + << (const char *)ByteString( GetId() ) << ')'; + return TRUE; +} +#endif + +/************************************************************************/ +/************************************************************************* +|* +|* SvUUId::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvUUId::ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( SvHash_uuid() ) ) + { + BOOL bOk = TRUE; + BOOL bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + pTok = rInStm.GetToken(); + if( pTok->IsString() ) + { + pTok = rInStm.GetToken_Next(); + bOk = MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + } + if( bOk && bBraket ) + bOk = rInStm.Read( ')' ); + } + if( bOk ) + return TRUE; + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvMetaObject::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvUUId::WriteSvIdl( SvStream & rOutStm ) +{ + // Global Id schreiben + rOutStm << SvHash_uuid()->GetName().GetBuffer() << "(\""; + rOutStm << ByteString( GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << "\")"; + return TRUE; +} + + +/************************************************************************/ +/************************************************************************* +|* +|* SvVersion::ReadSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvVersion::ReadSvIdl( SvTokenStream & rInStm ) +{ + long n; + + UINT32 nTokPos = rInStm.Tell(); + if( ReadRangeSvIdl( SvHash_Version(), rInStm, 0 , 0xFFFF, &n ) ) + { + nMajorVersion = (USHORT)n; + if( rInStm.Read( '.' ) ) + { + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->IsInteger() && pTok->GetNumber() <= 0xFFFF ) + { + nMinorVersion = (USHORT)pTok->GetNumber(); + return TRUE; + } + } + else + return TRUE; + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvVersion::WriteSvIdl() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvVersion::WriteSvIdl( SvStream & rOutStm ) +{ + rOutStm << SvHash_Version()->GetName().GetBuffer() << '(' + << ByteString::CreateFromInt32( nMajorVersion ).GetBuffer() << '.' + << ByteString::CreateFromInt32( nMinorVersion ).GetBuffer() << ')'; + return TRUE; +} +#endif //IDL_COMPILER + + diff --git a/idl/source/objects/makefile.mk b/idl/source/objects/makefile.mk new file mode 100644 index 000000000000..8c57d435177b --- /dev/null +++ b/idl/source/objects/makefile.mk @@ -0,0 +1,103 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PROJECTPCH4DLL=TRUE +PROJECTPCH=idlpch +PROJECTPCHSOURCE=$(PRJ)$/util$/idlpch + +PRJNAME=SVIDL +TARGET=objects + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.IF "$(COM)"=="WTC" +CFLAGS+=-od +.ENDIF + +CDEFS+=-DIDL_COMPILER +# --- Files -------------------------------------------------------------- + +CXXFILES= bastype.cxx \ + basobj.cxx \ + types.cxx \ + object.cxx \ + slot.cxx \ + module.cxx \ + $(PROJECTPCHSOURCE).cxx + +OBJFILES= $(OBJ)$/bastype.obj \ + $(OBJ)$/basobj.obj \ + $(OBJ)$/types.obj \ + $(OBJ)$/object.obj \ + $(OBJ)$/slot.obj \ + $(OBJ)$/module.obj + +# --- Targets ------------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/idl/source/objects/module.cxx b/idl/source/objects/module.cxx new file mode 100644 index 000000000000..d795f5cacb72 --- /dev/null +++ b/idl/source/objects/module.cxx @@ -0,0 +1,732 @@ +/************************************************************************* + * + * $RCSfile: module.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include +#include +#include +#include + +#ifndef _FSYS_HXX //autogen +#include +#endif +#include + +#pragma hdrstop + + +/****************** SvMetaModule ******************************************/ +SV_IMPL_META_FACTORY1( SvMetaModule, SvMetaExtern ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaModule::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif + +/************************************************************************* +|* +|* SvMetaModule::SvMetaModule() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +SvMetaModule::SvMetaModule() +#ifdef IDL_COMPILER + : bImported( FALSE ) + , bIsModified( FALSE ) +#endif +{ +} + +#ifdef IDL_COMPILER +SvMetaModule::SvMetaModule( const String & rIdlFileName, BOOL bImp ) + : aIdlFileName( rIdlFileName ) + , bImported( bImp ), bIsModified( FALSE ) +{ +} +#endif + +/************************************************************************* +|* +|* SvMetaModule::Load() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +#define MODULE_VER 0x0001 +void SvMetaModule::Load( SvPersistStream & rStm ) +{ + bImported = TRUE; // immer importiert + SvMetaExtern::Load( rStm ); + + USHORT nVer; + + rStm >> nVer; // Version + DBG_ASSERT( (nVer & ~IDL_WRITE_MASK) == MODULE_VER, "false version" ) + + rStm >> aClassList; + rStm >> aTypeList; + rStm >> aAttrList; + // Browser + rStm.ReadByteString( aIdlFileName ); + rStm.ReadByteString( aHelpFileName ); + rStm.ReadByteString( aSlotIdFile ); + rStm.ReadByteString( aModulePrefix ); + + // Compiler Daten lesen + USHORT nCmpLen; + rStm >> nCmpLen; +#ifdef IDL_COMPILER + DBG_ASSERT( (nVer & IDL_WRITE_MASK) == IDL_WRITE_COMPILER, + "no idl compiler format" ) + rStm >> aBeginName; + rStm >> aEndName; + rStm >> aNextName; +#else + rStm->SeekRel( nCmpLen ); +#endif +} + +/************************************************************************* +|* +|* SvMetaModule::Save() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +void SvMetaModule::Save( SvPersistStream & rStm ) +{ + SvMetaExtern::Save( rStm ); + + rStm << (USHORT)(MODULE_VER | IDL_WRITE_COMPILER); // Version + + rStm << aClassList; + rStm << aTypeList; + rStm << aAttrList; + // Browser + rStm.WriteByteString( aIdlFileName ); + rStm.WriteByteString( aHelpFileName ); + rStm.WriteByteString( aSlotIdFile ); + rStm.WriteByteString( aModulePrefix ); + + // Compiler Daten schreiben + USHORT nCmpLen = 0; + ULONG nLenPos = rStm.Tell(); + rStm << nCmpLen; +#ifdef IDL_COMPILER + rStm << aBeginName; + rStm << aEndName; + rStm << aNextName; + // Laenge der Compiler Daten schreiben + ULONG nPos = rStm.Tell(); + rStm.Seek( nLenPos ); + rStm << (USHORT)( nPos - nLenPos - sizeof( USHORT ) ); + rStm.Seek( nPos ); +#endif +} + +/************************************************************************* +|* +|* SvMetaModule::SetName() +|* +|* Beschreibung +|* Ersterstellung MM 12.12.94 +|* Letzte Aenderung MM 12.12.94 +|* +*************************************************************************/ +BOOL SvMetaModule::SetName( const ByteString & rName, SvIdlDataBase * pBase ) +{ + if( pBase ) + { + if( pBase->GetModule( rName ) ) + return FALSE; + } + return SvMetaExtern::SetName( rName ); +} + +#ifdef IDL_COMPILER +/************************************************************************* +|* SvMetaModule::GetNextName() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaModule::FillNextName( SvGlobalName * pName ) +{ + *pName = aNextName; + + if( aNextName < aEndName ) + { + ++aNextName; + bIsModified = TRUE; + return TRUE; + } + return FALSE; +} + +/************************************************************************* +|* SvMetaModule::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaModule::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm ); + + aHelpFileName.ReadSvIdl( SvHash_HelpFile(), rInStm ); + if( aSlotIdFile.ReadSvIdl( SvHash_SlotIdFile(), rInStm ) ) + { + UINT32 nTokPos = rInStm.Tell(); + if( !rBase.ReadIdFile( String::CreateFromAscii( aSlotIdFile.GetBuffer() ) ) ) + { + ByteString aStr = "cannot read file: "; + aStr += aSlotIdFile; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + + rInStm.Seek( nTokPos ); + } + } + aTypeLibFile.ReadSvIdl( SvHash_TypeLibFile(), rInStm ); + aModulePrefix.ReadSvIdl( SvHash_ModulePrefix(), rInStm ); +} + +/************************************************************************* +|* SvMetaModule::WriteAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaModule::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ + SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + if( aTypeLibFile.Len() || aSlotIdFile.Len() || aTypeLibFile.Len() ) + { + if( aHelpFileName.Len() ) + { + WriteTab( rOutStm, nTab ); + aHelpFileName.WriteSvIdl( SvHash_HelpFile(), rOutStm, nTab +1 ); + rOutStm << ';' << endl; + } + if( aSlotIdFile.Len() ) + { + WriteTab( rOutStm, nTab ); + aSlotIdFile.WriteSvIdl( SvHash_SlotIdFile(), rOutStm, nTab +1 ); + rOutStm << ';' << endl; + } + if( aTypeLibFile.Len() ) + { + WriteTab( rOutStm, nTab ); + aTypeLibFile.WriteSvIdl( SvHash_TypeLibFile(), rOutStm, nTab +1 ); + rOutStm << ';' << endl; + } + } +} + +/************************************************************************* +|* SvMetaModule::ReadContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaModule::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + if( rInStm.GetToken()->Is( SvHash_interface() ) + || rInStm.GetToken()->Is( SvHash_shell() ) ) + { + SvMetaClassRef aClass = new SvMetaClass(); + if( aClass->ReadSvIdl( rBase, rInStm ) ) + { + aClassList.Append( aClass ); + // Global bekanntgeben + rBase.GetClassList().Append( aClass ); + } + } + else if( rInStm.GetToken()->Is( SvHash_enum() ) ) + { + SvMetaTypeEnumRef aEnum = new SvMetaTypeEnum(); + + if( aEnum->ReadSvIdl( rBase, rInStm ) ) + { + // Im Modul deklariert + aTypeList.Append( aEnum ); + // Global bekanntgeben + rBase.GetTypeList().Append( aEnum ); + } + } + else if( rInStm.GetToken()->Is( SvHash_item() ) + || rInStm.GetToken()->Is( SvHash_struct() ) + || rInStm.GetToken()->Is( SvHash_typedef() ) ) + { + SvMetaTypeRef xItem = new SvMetaType(); + + if( xItem->ReadSvIdl( rBase, rInStm ) ) + { + // Im Modul deklariert + aTypeList.Append( xItem ); + // Global bekanntgeben + rBase.GetTypeList().Append( xItem ); + } + } + else if( rInStm.GetToken()->Is( SvHash_include() ) ) + { + BOOL bOk = FALSE; + rInStm.GetToken_Next(); + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + { + DirEntry aFullName( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + rBase.StartNewFile( aFullName.GetFull() ); + if( aFullName.Find( rBase.GetPath() ) ) + { + SvTokenStream aTokStm( aFullName.GetFull() ); + if( SVSTREAM_OK == aTokStm.GetStream().GetError() ) + { + // Fehler aus alter Datei retten + SvIdlError aOldErr = rBase.GetError(); + // Fehler zuruecksetzen + rBase.SetError( SvIdlError() ); + + UINT32 nBeginPos = 0xFFFFFFFF; // kann mit Tell nicht vorkommen + while( nBeginPos != aTokStm.Tell() ) + { + nBeginPos = aTokStm.Tell(); + ReadContextSvIdl( rBase, aTokStm ); + aTokStm.ReadDelemiter(); + } + bOk = aTokStm.GetToken()->IsEof(); + if( !bOk ) + { + rBase.WriteError( aTokStm ); + } + // Fehler aus alter Datei wieder herstellen + rBase.SetError( aOldErr ); + } + else + { + ByteString aStr = "cannot open file: "; + aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 ); + rBase.SetError( aStr, pTok ); + } + } + else + { + ByteString aStr = "cannot find file: "; + aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 ); + rBase.SetError( aStr, pTok ); + } + } + if( !bOk ) + rInStm.Seek( nTokPos ); + } + else + { + SvMetaSlotRef xSlot = new SvMetaSlot(); + + if( xSlot->ReadSvIdl( rBase, rInStm ) ) + { + if( xSlot->Test( rBase, rInStm ) ) + { + // Im Modul deklariert + aAttrList.Append( xSlot ); + // Global bekanntgeben + rBase.AppendAttr( xSlot ); + } + } + } +} + +/************************************************************************* +|* SvMetaModule::WriteContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaModule::WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ + SvMetaExtern::WriteContextSvIdl( rBase, rOutStm, nTab ); + ULONG n; + for( n = 0; n < aTypeList.Count(); n++ ) + { + WriteTab( rOutStm, nTab ); + aTypeList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + } + rOutStm << endl; + for( n = 0; n < aAttrList.Count(); n++ ) + { + WriteTab( rOutStm, nTab ); + aAttrList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + } + rOutStm << endl; + for( n = 0; n < aClassList.Count(); n++ ) + { + WriteTab( rOutStm, nTab ); + aClassList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + } +} + +/************************************************************************* +|* +|* SvMetaModule::ReadSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvMetaModule::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + bIsModified = TRUE; // bisher immer wenn Compiler laueft + + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + BOOL bOk = FALSE; + bOk = pTok->Is( SvHash_module() ); + if( bOk ) + { + pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + bOk = aBeginName.MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + } + rInStm.ReadDelemiter(); + if( bOk ) + { + pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + bOk = aEndName.MakeId( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + } + rInStm.ReadDelemiter(); + if( bOk ) + { + aNextName = aBeginName; + + rBase.Push( this ); // auf den Context Stack + + if( ReadNameSvIdl( rBase, rInStm ) ) + { + // Zeiger auf sich selbst setzen + SetModule( rBase ); + bOk = SvMetaName::ReadSvIdl( rBase, rInStm ); + } + rBase.GetStack().Pop(); // und runter + } + if( !bOk ) + rInStm.Seek( nTokPos ); + return bOk; +} + +/************************************************************************* +|* +|* SvMetaModule::WriteSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvMetaModule::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + rOutStm << SvHash_module()->GetName().GetBuffer() << endl + << '\"'; + rOutStm.WriteByteString( aBeginName.GetHexName() ); + rOutStm << '\"' << endl << '\"'; + rOutStm.WriteByteString( aEndName.GetHexName() ); + rOutStm << '\"' << endl; + SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab ); +} + +/************************************************************************* +|* SvMetaModule::WriteSfx() +*************************************************************************/ +void SvMetaModule::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteSfx( rBase, rOutStm ); + } +} + +void SvMetaModule::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm, + Table* pTable ) +{ + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteHelpIds( rBase, rOutStm, pTable ); + } +} + +/************************************************************************* +|* SvMetaModule::WriteAttributes() +*************************************************************************/ +void SvMetaModule::WriteAttributes( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA ); + if( aHelpFileName.Len() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "// class SvMetaModule" << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "helpfile(\"" << aHelpFileName.GetBuffer() << "\");" << endl; + } +} + +/************************************************************************* +|* SvMetaModule::WriteSbx() +*************************************************************************/ +/* +void SvMetaModule::WriteSbx( SvIdlDataBase & rBase, SvStream & rOutStm, + SvNamePosList & rList ) +{ + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( !pClass->IsShell() && pClass->GetAutomation() ) + { + rList.Insert( new SvNamePos( pClass->GetUUId(), rOutStm.Tell() ), + LIST_APPEND ); + SbxObjectRef xSbxObj = new SbxObject( pClass->GetName() ); + pClass->FillSbxObject( rBase, xSbxObj ); + xSbxObj->Store( rOutStm ); + } + } +} + */ + +/************************************************************************* +|* SvMetaModule::Write() +*************************************************************************/ +void SvMetaModule::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + switch ( nT ) + { + case WRITE_ODL: + { + if( aSlotIdFile.Len() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "#include \"" << aSlotIdFile.GetBuffer() << '"' << endl << endl; + } + SvMetaExtern::Write( rBase, rOutStm, nTab, nT, nA ); + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "library " << GetName().GetBuffer() << endl; + WriteTab( rOutStm, nTab ); + rOutStm << '{' << endl; + WriteTab( rOutStm, nTab ); + rOutStm << "importlib(\"STDOLE.TLB\");" << endl; + + /* + for( ULONG n = 0; n < aTypeList.Count(); n++ ) + { + SvMetaType * pType = aTypeList.GetObject( n ); + if( !pType ->Write( rBase, rOutStm, nTab +1, nT, nA ) ) + return FALSE; + } + */ + /* + for( ULONG n = 0; n < rBase.GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = rBase.GetModuleList().GetObject( n ); + const SvMetaTypeMemberList &rTypeList = pModule->GetTypeList(); + for( ULONG n = 0; n < rTypeList.Count(); n++ ) + { + SvMetaType * pType = rTypeList.GetObject( n ); + pType->Write( rBase, rOutStm, nTab +1, nT, nA ); + } + } + */ + + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( !pClass->IsShell() && pClass->GetAutomation() ) + { + WriteTab( rOutStm, nTab ); + WriteStars( rOutStm ); + pClass->Write( rBase, rOutStm, nTab +1, nT, nA ); + if( n +1 < aClassList.Count() ) + rOutStm << endl; + } + } + + rOutStm << '}' << endl; + } + break; + case WRITE_DOCU: + { + rOutStm << "SvIDL interface documentation" << endl << endl; + rOutStm << "" << endl << GetName().GetBuffer() << endl; + WriteDescription( rBase, rOutStm ); + rOutStm << "" << endl << endl; + + rOutStm << "" << endl; + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( !pClass->IsShell() ) + { + rOutStm << pClass->GetName().GetBuffer(); + SvMetaClass* pSC = pClass->GetSuperClass(); + if( pSC ) + rOutStm << " : " << pSC->GetName().GetBuffer(); + + // Importierte Klassen + const SvClassElementMemberList& rClassList = pClass->GetClassList(); + if ( rClassList.Count() ) + { + rOutStm << " ( "; + + for( ULONG m=0; mGetClass(); + rOutStm << pCl->GetName().GetBuffer(); + if ( m+1 == rClassList.Count() ) + rOutStm << " )"; + else + rOutStm << " , "; + } + } + + rOutStm << endl; + } + } + rOutStm << "" << endl << endl; + // kein Break! + } + + case WRITE_C_SOURCE: + case WRITE_C_HEADER: + { + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( !pClass->IsShell() /* && pClass->GetAutomation() */ ) + pClass->Write( rBase, rOutStm, nTab, nT, nA ); + } + } + break; + } +} + +/************************************************************************* +|* SvMetaModule::WriteSrc() +*************************************************************************/ +void SvMetaModule::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ) +{ +// rOutStm << "#pragma CHARSET IBMPC" << endl; + if( aSlotIdFile.Len() ) + rOutStm << "//#include <" << aSlotIdFile.GetBuffer() << '>' << endl; + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + aClassList.GetObject( n )->WriteSrc( rBase, rOutStm, pTable ); + } +} + +/************************************************************************* +|* SvMetaModule::WriteHxx() +*************************************************************************/ +void SvMetaModule::WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteHxx( rBase, rOutStm, nTab ); + } +} + +/************************************************************************* +|* SvMetaModule::WriteCxx() +*************************************************************************/ +void SvMetaModule::WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + pClass->WriteCxx( rBase, rOutStm, nTab ); + } +} + +#endif // IDL_COMPILER + diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx new file mode 100644 index 000000000000..6e885d525542 --- /dev/null +++ b/idl/source/objects/object.cxx @@ -0,0 +1,1091 @@ +/************************************************************************* + * + * $RCSfile: object.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include + +#include +#include +#include +#include +#pragma hdrstop + + +/******************** class SvClassElement *******************************/ +SV_IMPL_PERSIST1( SvClassElement, SvPersistBase ); + +/************************************************************************* +|* SvClassElement::SvClassElement() +|* +|* Beschreibung +*************************************************************************/ +SvClassElement::SvClassElement() +{ +}; + +/************************************************************************* +|* SvClassElement::Load() +|* +|* Beschreibung +*************************************************************************/ +void SvClassElement::Load( SvPersistStream & rStm ) +{ + BYTE nMask; + rStm >> nMask; + if( nMask >= 0x08 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) rStm >> aAutomation; + if( nMask & 0x02 ) rStm.ReadByteString( aPrefix ); + if( nMask & 0x04 ) + { + SvMetaClass * p; + rStm >> p; + xClass = p; + } +} + +/************************************************************************* +|* SvClassElement::Save() +|* +|* Beschreibung +*************************************************************************/ +void SvClassElement::Save( SvPersistStream & rStm ) +{ + // Maske erstellen + BYTE nMask = 0; + if( aAutomation.IsSet() ) nMask |= 0x1; + if( aPrefix.Len() ) nMask |= 0x2; + if( xClass.Is() ) nMask |= 0x4; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x01 ) rStm << aAutomation; + if( nMask & 0x02 ) rStm.WriteByteString( aPrefix ); + if( nMask & 0x04 ) rStm << xClass; +} + +/****************** SvMetaClass ******************************************/ +SV_IMPL_META_FACTORY1( SvMetaClass, SvMetaType ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaClass::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* SvMetaClass::SvMetaClass() +|* +|* Beschreibung +*************************************************************************/ +SvMetaClass::SvMetaClass() + : aAutomation( TRUE, FALSE ) +{ +} + +/************************************************************************* +|* SvMetaClass::Load() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::Load( SvPersistStream & rStm ) +{ + SvMetaType::Load( rStm ); + + BYTE nMask; + rStm >> nMask; + if( nMask >= 0x20 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) rStm >> aAttrList; + if( nMask & 0x02 ) + { + SvMetaClass * pSuper; + rStm >> pSuper; + aSuperClass = pSuper; + } + if( nMask & 0x04 ) rStm >> aClassList; + if( nMask & 0x8 ) + { + SvMetaClass * p; + rStm >> p; + xAutomationInterface = p; + } + if( nMask & 0x10 ) rStm >> aAutomation; +} + +/************************************************************************* +|* SvMetaClass::Save() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::Save( SvPersistStream & rStm ) +{ + SvMetaType::Save( rStm ); + + // Maske erstellen + BYTE nMask = 0; + if( aAttrList.Count() ) nMask |= 0x1; + if( aSuperClass.Is() ) nMask |= 0x2; + if( aClassList.Count() ) nMask |= 0x4; + if( xAutomationInterface.Is() ) nMask |= 0x8; + if( aAutomation.IsSet() ) nMask |= 0x10; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x01 ) rStm << aAttrList; + if( nMask & 0x02 ) rStm << aSuperClass; + if( nMask & 0x04 ) rStm << aClassList; + if( nMask & 0x08 ) rStm << xAutomationInterface; + if( nMask & 0x10 ) rStm << aAutomation; +} + +/************************************************************************* +|* SvMetaClass::FillSbxObject() +|* +|* Beschreibung +*************************************************************************/ +/* +void SvMetaClass::FillSbxMemberObject( SvIdlDataBase & rBase, + SbxObject * pObj, + StringList & rSuperList, + BOOL bVariable ) +{ + // alle Attribute der Klasse schreiben + ULONG n ; + for( n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( n ); + + ByteString aMangleName = pAttr->GetMangleName( bVariable ); + ByteString * pS = SvIdlDataBase::FindName( aMangleName, rSuperList ); + + if( !pS && pAttr->GetExport() ) + { + // nicht doppelt + if( bVariable && pAttr->IsVariable() ) + { + rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND ); + pAttr->FillSbxObject( rBase, pObj, bVariable ); + } + else if( !bVariable && pAttr->IsMethod() ) + { + rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND ); + pAttr->FillSbxObject( rBase, pObj, bVariable ); + } + } + } + // alle Attribute der importierten Klassen schreiben + for( n = 0; n < aClassList.Count(); n++ ) + { + SvClassElement * pEle = aClassList.GetObject( n ); + SvMetaClass * pClass = pEle->GetClass(); + pClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable ); + } + // alle Attribute der Superklassen schreiben + if( aSuperClass.Is() ) + aSuperClass->FillSbxMemberObject( rBase, pObj, rSuperList, bVariable ); +} +*/ +/************************************************************************* +|* SvMetaClass::FillSbxObject() +|* +|* Beschreibung +*************************************************************************/ +/* +void SvMetaClass::FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj ) +{ + StringList aSuperList; + FillSbxMemberObject( rBase, pObj, aSuperList, TRUE ); + FillSbxMemberObject( rBase, pObj, aSuperList, FALSE ); + + ByteString * pStr = aSuperList.First(); + while( pStr ) + { + delete pStr; + pStr = aSuperList.Next(); + } +} + */ +#ifdef IDL_COMPILER +/************************************************************************* +|* SvMetaClass::ReadAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaType::ReadAttributesSvIdl( rBase, rInStm ); + aAutomation.ReadSvIdl( SvHash_Automation(), rInStm ); +} + +/************************************************************************* +|* SvMetaClass::WriteAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ) +{ + SvMetaType::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + + if( !aAutomation ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "//class SvMetaClass" << endl; + if( !aAutomation ) + { + WriteTab( rOutStm, nTab ); + aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm ); + rOutStm << ';' << endl; + } + } +} + +/************************************************************************* +|* SvMetaClass::ReadContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( SvHash_import() ) ) + { + SvMetaClass * pClass = rBase.ReadKnownClass( rInStm ); + if( pClass ) + { + SvClassElementRef xEle = new SvClassElement(); + xEle->SetClass( pClass ); + aClassList.Append( xEle ); + + if( rInStm.Read( '[' ) ) + { + pTok = rInStm.GetToken_Next(); + if( pTok->Is( SvHash_Automation() ) ) + { + if( rInStm.Read( ']' ) ) + { + if( xAutomationInterface.Is() ) + { + // Fehler setzen + rBase.SetError( "Automation allready set", + rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + xAutomationInterface = pClass; + xEle->SetAutomation( TRUE ); + } + else + { + // Fehler setzen + rBase.SetError( "missing ]", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + else + { + // Fehler setzen + rBase.SetError( "only attribute Automation allowed", + rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + pTok = rInStm.GetToken(); + if( pTok->IsString() ) + { + xEle->SetPrefix( pTok->GetString() ); + rInStm.GetToken_Next(); + } + return; + } + else + { + // Fehler setzen + rBase.SetError( "unknown imported interface", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + else + { + rInStm.Seek( nTokPos ); + SvMetaType * pType = rBase.ReadKnownType( rInStm ); + + BOOL bOk = FALSE; + SvMetaAttributeRef xAttr; + if( !pType || pType->IsItem() ) + { + xAttr = new SvMetaSlot( pType ); + if( xAttr->ReadSvIdl( rBase, rInStm ) ) + bOk = xAttr->Test( rBase, rInStm ); + } + else + { + xAttr = new SvMetaAttribute( pType ); + if( xAttr->ReadSvIdl( rBase, rInStm ) ) + bOk = xAttr->Test( rBase, rInStm ); + } + + if( bOk ) + bOk = TestAttribute( rBase, rInStm, *xAttr ); + if( bOk ) + { + if( !xAttr->GetSlotId().IsSet() ) + { + SvNumberIdentifier aI; + aI.SetValue( rBase.GetUniqueId() ); + xAttr->SetSlotId( aI ); + } + aAttrList.Append( xAttr ); + return; + } + } + rInStm.Seek( nTokPos ); +} + +/************************************************************************* +|* SvMetaClass::WriteContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::WriteContextSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab +) +{ + //SvMetaType::WriteContextSvIdl( rBase, rOutStm, nTab ); + ULONG n; + for( n = 0; n < aAttrList.Count(); n++ ) + { + WriteTab( rOutStm, nTab ); + aAttrList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << ';' << endl; + } + for( n = 0; n < aClassList.Count(); n++ ) + { + SvClassElement * pEle = aClassList.GetObject( n ); + SvMetaClass * pCl = pEle->GetClass(); + WriteTab( rOutStm, nTab ); + rOutStm << SvHash_import()->GetName().GetBuffer() << ' ' + << pEle->GetPrefix().GetBuffer(); + if( pEle->GetAutomation() ) + rOutStm << " [ " << SvHash_Automation()->GetName().GetBuffer() + << " ]"; + if( pEle->GetPrefix().Len() ) + rOutStm << ' ' << pEle->GetPrefix().GetBuffer(); + rOutStm << ';' << endl; + } +} + +/************************************************************************* +|* SvMetaClass::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaClass::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + ULONG nTokPos = rInStm.Tell(); + if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) && GetType() == TYPE_CLASS ) + { + BOOL bOk = TRUE; + if( rInStm.Read( ':' ) ) + { + aSuperClass = rBase.ReadKnownClass( rInStm ); + bOk = aSuperClass.Is(); + if( !bOk ) + { + // Fehler setzen + rBase.SetError( "unknown super class", + rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + if( bOk ) + { + rBase.Write( '.' ); + bOk = SvMetaName::ReadSvIdl( rBase, rInStm ); + } + if( bOk ) + return bOk; + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* SvMetaClass::TestAttribute() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaClass::TestAttribute( SvIdlDataBase & rBase, SvTokenStream & rInStm, + SvMetaAttribute & rAttr ) const +{ + if ( !rAttr.GetRef() && rAttr.IsA( TYPE( SvMetaSlot ) ) ) + { + DBG_ERROR( "Neuer Slot : " ); + DBG_ERROR( rAttr.GetSlotId().GetBuffer() ); + } + + for( ULONG n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pS = aAttrList.GetObject( n ); + if( pS->GetName() == rAttr.GetName() ) + { + // Werte muessen uebereinstimmen + if( pS->GetSlotId().GetValue() != rAttr.GetSlotId().GetValue() ) + { + DBG_ERROR( "Gleicher Name in MetaClass : " ); + DBG_ERROR( pS->GetName().GetBuffer() ); + DBG_ERROR( pS->GetSlotId().GetBuffer() ); + DBG_ERROR( rAttr.GetSlotId().GetBuffer() ); + + ByteString aStr( "Attribute's " ); + aStr += pS->GetName(); + aStr += " with different id's"; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + return FALSE; + } + } + else + { + UINT32 nId1 = pS->GetSlotId().GetValue(); + UINT32 nId2 = rAttr.GetSlotId().GetValue(); + if( nId1 == nId2 && nId1 != 0 /*&& nId2 != 0 ist ueberfluessig*/ ) + { + DBG_ERROR( "Gleiche Id in MetaClass : " ); + DBG_ERROR( ByteString::CreateFromInt32( pS->GetSlotId().GetValue() ).GetBuffer() ); + DBG_ERROR( pS->GetSlotId().GetBuffer() ); + DBG_ERROR( rAttr.GetSlotId().GetBuffer() ); + + ByteString aStr( "Attribute " ); + aStr += pS->GetName(); + aStr += " and Attribute "; + aStr += rAttr.GetName(); + aStr += " with equal id's"; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + return FALSE; + } + } + } + SvMetaClass * pSC = aSuperClass; + if( pSC ) + return pSC->TestAttribute( rBase, rInStm, rAttr ); + return TRUE; +} + +/************************************************************************* +|* SvMetaClass::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + WriteHeaderSvIdl( rBase, rOutStm, nTab ); + if( aSuperClass.Is() ) + rOutStm << " : " << aSuperClass->GetName().GetBuffer(); + rOutStm << endl; + SvMetaName::WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << endl; +} + +/************************************************************************* +|* SvMetaClass::WriteOdlMember() +|* +|* Beschreibung +*************************************************************************/ +/* +void SvMetaClass::WriteOdlMembers( ByteStringList & rSuperList, + BOOL bVariable, BOOL bWriteTab, + SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab ) +{ + // alle Attribute schreiben + ULONG n; + for( n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( n ); + + ByteString aMangleName = pAttr->GetMangleName( bVariable ); + ByteString * pS = rBase.FindName( aMangleName, rSuperList ); + + if( !pS && pAttr->GetExport() ) + { + // nicht doppelt + if( bVariable && pAttr->IsVariable() ) + { + rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND ); + pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL, + WA_VARIABLE ); + rOutStm << ';' << endl; + } + else if( !bVariable && pAttr->IsMethod() ) + { + rSuperList.Insert( new ByteString( aMangleName ), LIST_APPEND ); + pAttr->Write( rBase, rOutStm, nTab +1, WRITE_ODL, + WA_METHOD ); + rOutStm << ';' << endl; + } + } + else + continue; + } + // alle Attribute der importierten Klassen schreiben + for( n = 0; n < aClassList.Count(); n++ ) + { + SvClassElement * pEle = aClassList.GetObject( n ); + SvMetaClass * pCl = pEle->GetClass(); + pCl->WriteOdlMembers( rSuperList, bVariable, bWriteTab, + rBase, rOutStm, nTab ); + } + // alle Attribute der Superklassen schreiben + SvMetaClass * pSC = aSuperClass; + if( pSC ) + pSC->WriteOdlMembers( rSuperList, bVariable, bWriteTab, + rBase, rOutStm, nTab ); +} + */ + +/************************************************************************* +|* SvMetaClass::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + rBase.aIFaceName = GetName(); + switch( nT ) + { + case WRITE_ODL: + { + DBG_ERROR( "Not supported anymore!" ) +/* + // Schreibt die Attribute + SvMetaName::Write( rBase, rOutStm, nTab, nT, nA ); + + WriteTab( rOutStm, nTab ); + rOutStm << "dispinterface " << GetName().GetBuffer() << endl; + WriteTab( rOutStm, nTab ); + rOutStm << '{' << endl; + + WriteTab( rOutStm, nTab ); + rOutStm << "properties:"; + rOutStm << endl; + + StringList aSuperList; + WriteOdlMembers( aSuperList, TRUE, TRUE, rBase, rOutStm, nTab ); + + WriteTab( rOutStm, nTab ); + rOutStm << "methods:"; + rOutStm << endl; + + WriteOdlMembers( aSuperList, FALSE, TRUE, rBase, rOutStm, nTab ); + + ByteString * pStr = aSuperList.First(); + while( pStr ) + { + delete pStr; + pStr = aSuperList.Next(); + } + + WriteTab( rOutStm, 1 ); + rOutStm << '}' << endl; + */ + break; + } + case WRITE_C_SOURCE: + case WRITE_C_HEADER: + { + DBG_ERROR( "Not supported anymore!" ) +/* + StringList aSuperList; + if( nT == WRITE_C_SOURCE ) + { + rOutStm << "#pragma code_seg (\"" << GetName().GetBuffer() + << "\",\"CODE\")" << endl; + } + WriteCFunctions( aSuperList, rBase, rOutStm, nTab, nT ); + */ + break; + } + case WRITE_DOCU: + { + rOutStm << "" << endl + << GetName().GetBuffer(); + if ( GetAutomation() ) + rOutStm << " ( Automation ) "; + rOutStm << endl; + WriteDescription( rBase, rOutStm ); + rOutStm << "" << endl << endl; + + // alle Attribute schreiben + ULONG n; + for( n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( n ); + if( !pAttr->GetHidden() ) + { + if( pAttr->IsMethod() ) + pAttr->Write( rBase, rOutStm, nTab, nT, WA_METHOD ); + + if( pAttr->IsVariable() ) + pAttr->Write( rBase, rOutStm, nTab, nT, WA_VARIABLE ); + } + } + + break; + } + } +} + +/************************************************************************* +|* SvMetaClass::WriteSlotParamArray() +|* +|* Beschreibung +*************************************************************************/ +USHORT SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase, + SvSlotElementList & rSlotList, + SvStream & rOutStm ) +{ + USHORT nCount = 0; + for( ULONG n = 0; n < rSlotList.Count(); n++ ) + { + SvSlotElement *pEle = rSlotList.GetObject( n ); + SvMetaSlot *pAttr = pEle->xSlot; + nCount += pAttr->WriteSlotParamArray( rBase, rOutStm ); + } + + return nCount; +} + +/************************************************************************* +|* SvMetaClass::WriteSlots() +|* +|* Beschreibung +*************************************************************************/ +USHORT SvMetaClass::WriteSlots( const ByteString & rShellName, + USHORT nCount, SvSlotElementList & rSlotList, + SvIdlDataBase & rBase, + SvStream & rOutStm ) +{ + USHORT nSCount = 0; + for( ULONG n = 0; n < rSlotList.Count(); n++ ) + { + rSlotList.Seek(n); + SvSlotElement * pEle = rSlotList.GetCurObject(); + SvMetaSlot * pAttr = pEle->xSlot; + nSCount += pAttr->WriteSlotMap( rShellName, nCount + nSCount, + rSlotList, pEle->aPrefix, rBase, + rOutStm ); + } + + return nSCount; +} + +/************************************************************************* +|* SvMetaClass::InsertSlots() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::InsertSlots( SvSlotElementList& rList, SvULongs& rSuperList, + SvMetaClassList &rClassList, + const ByteString & rPrefix, SvIdlDataBase& rBase) +{ + // Wurde diese Klasse schon geschrieben ? + if ( rClassList.GetPos(this) != LIST_ENTRY_NOTFOUND ) + return; + + rClassList.Insert(this, LIST_APPEND); + + // alle direkten Attribute schreiben + ULONG n; + for( n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( n ); + + ULONG nId = pAttr->GetSlotId().GetValue(); + USHORT nPos; + for ( nPos=0; nPos < rSuperList.Count(); nPos++ ) + { + if ( rSuperList.GetObject(nPos) == nId ) + break; + } + + if( nPos == rSuperList.Count() ) + { + // nur schreiben, wenn nicht schon bei SubClass oder + // importiertem Interface geschrieben + rSuperList.Insert( nId, nPos ); + pAttr->Insert(rList, rPrefix, rBase); + } + } + + // Alle schon von SuperShells importierten Interfaces sollen nicht + // mehr geschrieben werden + // Es ist also verboten, da\s Shell und SuperShell die gleiche Klasse + // direkt importieren ! + if( IsShell() && aSuperClass.Is() ) + aSuperClass->FillClasses( rClassList ); + + // alle Attribute der importierten Klassen schreiben, sofern diese nicht + // schon von der Superklasse importiert wurden + for( n = 0; n < aClassList.Count(); n++ ) + { + SvClassElement * pEle = aClassList.GetObject( n ); + SvMetaClass * pCl = pEle->GetClass(); + ByteString rPre = rPrefix; + if( rPre.Len() && pEle->GetPrefix().Len() ) + rPre += '.'; + rPre += pEle->GetPrefix(); + + // Zun"achst die direkt importierten Interfaces schreiben + pCl->InsertSlots( rList, rSuperList, rClassList, rPre, rBase ); + } + + // Superklassen nur schreiben, wenn keine Shell und nicht in der Liste + if( !IsShell() && aSuperClass.Is() ) + { + aSuperClass->InsertSlots( rList, rSuperList, rClassList, rPrefix, rBase ); + } +} + +/************************************************************************* +|* SvMetaClass::FillClasses() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::FillClasses( SvMetaClassList & rList ) +{ + // Bin ich noch nicht drin ? + if ( rList.GetPos(this) == LIST_ENTRY_NOTFOUND ) + { + rList.Insert(this, LIST_APPEND); + + // Meine Imports + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvClassElement * pEle = aClassList.GetObject( n ); + SvMetaClass * pCl = pEle->GetClass(); + pCl->FillClasses( rList ); + } + + // Meine Superklasse + if( aSuperClass.Is() ) + aSuperClass->FillClasses( rList ); + } +} + + +/************************************************************************* +|* SvMetaClass::WriteSlotStubs() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::WriteSlotStubs( const ByteString & rShellName, + SvSlotElementList & rSlotList, + ByteStringList & rList, + SvStream & rOutStm ) +{ + // alle Attribute schreiben + for( ULONG n = 0; n < rSlotList.Count(); n++ ) + { + SvSlotElement *pEle = rSlotList.GetObject( n ); + SvMetaSlot *pAttr = pEle->xSlot; + pAttr->WriteSlotStubs( rShellName, rList, rOutStm ); + } +} + +/************************************************************************* +|* SvMetaClass::WriteSfx() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + WriteStars( rOutStm ); + // Klasse definieren + rOutStm << "#ifdef " << GetName().GetBuffer() << endl; + rOutStm << "#undef ShellClass" << endl; + rOutStm << "#undef " << GetName().GetBuffer() << endl; + rOutStm << "#define ShellClass " << GetName().GetBuffer() << endl; + +// rOutStm << "SFX_TYPELIB(" << GetName().GetBuffer() << ',' << endl +// << "\t/* library type */" +// << '"' << ByteString( GetModule()->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << "\"," << endl +// << "\t\"" << GetModule()->GetTypeLibFileName().GetBuffer() << "\"," +// << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMajorVersion() ).GetBuffer() << ',' +// << ByteString::CreateFromInt32( GetModule()->GetVersion().GetMinorVersion() ).GetBuffer() << ',' << endl +// << "\t/* shell type */" +// << '"'; +// if( xAutomationInterface.Is() ) +// rOutStm << ByteString( xAutomationInterface->GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer(); +// else +// rOutStm << ByteString( GetUUId().GetHexName(), RTL_TEXTENCODING_UTF8 ).GetBuffer(); +// rOutStm << "\");" << endl << endl; + + // Fuer Interfaces werden kein Slotmaps geschrieben + if( !IsShell() ) + { + rOutStm << "#endif" << endl << endl; + return; + } + // Parameter Array schreiben + //rOutStm << "SfxArgList " << GetName().GetBuffer() << "ArgMap[] = {" << endl; + rOutStm << "SFX_ARGUMENTMAP(" << GetName().GetBuffer() << ')' << endl + << '{' << endl; + + SvULongs aSuperList; + SvMetaClassList aClassList; + SvSlotElementList aSlotList; + InsertSlots(aSlotList, aSuperList, aClassList, ByteString(), rBase); + ULONG n; + for ( n=0; nxSlot; + pSlot->SetListPos(n); + } + + ULONG nSlotCount = aSlotList.Count(); + + // alle Attribute schreiben + USHORT nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm ); + if( nArgCount ) + Back2Delemitter( rOutStm ); + else + { + // mindestens einen dummy + WriteTab( rOutStm, 1 ); + rOutStm << "SFX_ARGUMENT( 0, 0, SfxVoidItem )" << endl; + } + rOutStm << endl << "};" << endl << endl; + + ByteStringList aStringList; + WriteSlotStubs( GetName(), aSlotList, aStringList, rOutStm ); + ByteString * pStr = aStringList.First(); + while( pStr ) + { + delete pStr; + pStr = aStringList.Next(); + } + + rOutStm << endl; + + // Slotmap schreiben + rOutStm << "SFX_SLOTMAP_ARG(" << GetName().GetBuffer() << ')' << endl + << '{' << endl; + + // alle Attribute schreiben + WriteSlots( GetName(), 0, aSlotList, rBase, rOutStm ); + if( nSlotCount ) + Back2Delemitter( rOutStm ); + else + { + // mindestens einen dummy + WriteTab( rOutStm, 1 ); + rOutStm << "SFX_SLOT_ARG(" << GetName().GetBuffer() + << ", 0, 0, " + << "SFX_STUB_PTR_EXEC_NONE," + << "SFX_STUB_PTR_STATE_NONE," + << "0, SfxVoidItem, 0, 0, \"\", 0 )" << endl; + } + rOutStm << endl << "};" << endl << "#endif" << endl << endl; + + for( n=0; nxSlot; + pAttr->ResetSlotPointer(); + } + + for ( n=0; nWriteHelpId( rBase, rOutStm, pTable ); + } +} + +/************************************************************************* +|* SvMetaShell::WriteSrc() +*************************************************************************/ +void SvMetaClass::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ) +{ + for( ULONG n=0; nWriteSrc( rBase, rOutStm, pTable ); + } +} + +/************************************************************************* +|* SvMetaClass::WriteHxx() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + ByteString aSuperName( "SvDispatch" ); + if( GetSuperClass() ) + aSuperName = GetSuperClass()->GetName(); + const char * pSup = aSuperName.GetBuffer(); + + rOutStm + << "class " << GetSvName().GetBuffer() + << ": public " << pSup << endl + << '{' << endl + << "protected:" << endl + << "\tvirtual SvGlobalName GetTypeName() const;" << endl + << "\tvirtual BOOL FillTypeLibInfo( SvGlobalName *, USHORT * pMajor," << endl + << "\t USHORT * pMinor ) const;" << endl + << "\tvirtual BOOL FillTypeLibInfo( ByteString * pName, USHORT * pMajor," << endl; + rOutStm + << "\t USHORT * pMinor ) const;" << endl + << "\tvirtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) = 0;" << endl + << "public:" << endl + << "\t static SvGlobalName ClassName()" << endl + << "\t { return SvGlobalName( " << ByteString( GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " ); }" << endl + << "};" << endl; +} + +/************************************************************************* +|* SvMetaClass::WriteCxx() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaClass::WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + ByteString aSuperName( "SvDispatch" ); + if( GetSuperClass() ) + aSuperName = GetSuperClass()->GetName(); + const char * pSup = aSuperName.GetBuffer(); + + ByteString aName = GetSvName(); + // GetTypeName + rOutStm << "SvGlobalName " << aName.GetBuffer() << "::GetTypeName() const" << endl + << '{' << endl + << "\treturn ClassName();" << endl + << '}' << endl; + + SvMetaModule * pMod = GetModule(); + // FillTypeLibInfo + rOutStm << "BOOL " << aName.GetBuffer() << "::FillTypeLibInfo( SvGlobalName * pGN," << endl + << "\t USHORT * pMajor," << endl + << "\t USHORT * pMinor ) const" << endl + << '{' << endl + << "\tSvGlobalName aN( " << ByteString( pMod->GetUUId().GetctorName(), RTL_TEXTENCODING_UTF8 ).GetBuffer() << " );" << endl; + rOutStm << "\t*pGN = aN;" << endl + << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl + << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl + << "\treturn TRUE;" << endl + << '}' << endl; + + // FillTypeLibInfo + rOutStm << "BOOL " << aName.GetBuffer() << "::FillTypeLibInfo( ByteString * pName," + << "\t USHORT * pMajor," << endl + << "\t USHORT * pMinor ) const" << endl; + rOutStm << '{' << endl + << "\t*pName = \"" << pMod->GetTypeLibFileName().GetBuffer() << "\";" << endl + << "\t*pMajor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMajorVersion()).GetBuffer() << ';' << endl + << "\t*pMinor = " << ByteString::CreateFromInt32(pMod->GetVersion().GetMinorVersion()).GetBuffer() << ';' << endl + << "\treturn TRUE;" << endl + << '}' << endl; + + rOutStm << "void " << aName.GetBuffer() << "::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )" << endl + << '{' << endl + << "\t" << pSup << "::Notify( rBC, rHint );" << endl + << '}' << endl; +} + +#endif // IDL_COMPILER + diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx new file mode 100644 index 000000000000..3f6fc3a2015f --- /dev/null +++ b/idl/source/objects/slot.cxx @@ -0,0 +1,2011 @@ +/************************************************************************* + * + * $RCSfile: slot.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#pragma hdrstop + + +/****************** SvMetaSlot *****************************************/ +SV_IMPL_META_FACTORY1( SvMetaSlot, SvMetaAttribute ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaSlot::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif + +/************************************************************************* +|* SvMetaSlot::SvMetaSlot() +|* +|* Beschreibung Zweites FALSE bei den SvBOOL-Objekten bedeutet, +|* IsSet() liefert FALSE (Defaultinitialisierung). +*************************************************************************/ +SvMetaSlot::SvMetaSlot() + : aCachable( TRUE, FALSE ) + , aSynchron( TRUE, FALSE ) + , aRecordPerSet( TRUE, FALSE ) + , aRecordAbsolute( FALSE, FALSE ) + , pLinkedSlot(0) + , pNextSlot(0) + , pEnumValue(0) +{ +} + +SvMetaSlot::SvMetaSlot( SvMetaType * pType ) + : SvMetaAttribute( pType ) + , aCachable( TRUE, FALSE ) + , aSynchron( TRUE, FALSE ) + , aRecordPerSet( TRUE, FALSE ) + , aRecordAbsolute( FALSE, FALSE ) + , pLinkedSlot(0) + , pNextSlot(0) + , pEnumValue(0) +{ +} + +/* +#define TEST_READ \ +{ \ + UINT32 nPos; \ + rStm >> nPos; \ + DBG_ASSERT( nPos +4 == rStm.Tell(), "stream pos error" ); \ +} + +#define TEST_WRITE \ + rStm << (UINT32)rStm.Tell(); +*/ +#define TEST_READ +#define TEST_WRITE + +void SvMetaSlot::Load( SvPersistStream & rStm ) +{ + SvMetaAttribute::Load( rStm ); + + USHORT nMask; + rStm >> nMask; + + TEST_READ + if( nMask & 0x0001 ) + { + SvMetaAttribute * pMeth; + rStm >> pMeth; + aMethod = pMeth; + } + + TEST_READ + if( nMask & 0x0002 ) rStm >> aGroupId; + TEST_READ + if( nMask & 0x0004 ) rStm >> aHasCoreId; + TEST_READ + if( nMask & 0x0008 ) rStm >> aConfigId; + TEST_READ + if( nMask & 0x0010 ) rStm >> aExecMethod; + TEST_READ + if( nMask & 0x0020 ) rStm >> aStateMethod; + TEST_READ + if( nMask & 0x0040 ) rStm >> aDefault; + TEST_READ + if( nMask & 0x0080 ) rStm >> aPseudoSlots; + TEST_READ + if( nMask & 0x0100 ) rStm >> aGet; + TEST_READ + if( nMask & 0x0200 ) rStm >> aSet; + TEST_READ + if( nMask & 0x0400 ) rStm >> aCachable; + TEST_READ + if( nMask & 0x0800 ) rStm >> aVolatile; + TEST_READ + if( nMask & 0x1000 ) rStm >> aToggle; + TEST_READ + if( nMask & 0x2000 ) rStm >> aAutoUpdate; + TEST_READ + if( nMask & 0x4000 ) rStm >> aSynchron; + TEST_READ + if( nMask & 0x8000 ) rStm >> aAsynchron; + + nMask = 0; + rStm >> nMask; + + TEST_READ + if( nMask & 0x0001 ) rStm >> aRecordPerItem; + TEST_READ + if( nMask & 0x0002 ) rStm >> aRecordManual; + TEST_READ + if( nMask & 0x0004 ) rStm >> aNoRecord; + TEST_READ + if( nMask & 0x0008 ) rStm >> aHasDialog; + TEST_READ + if( nMask & 0x0010 ) rStm >> aDisableFlags; + TEST_READ + if( nMask & 0x0020 ) rStm >> aPseudoPrefix; + TEST_READ + if( nMask & 0x0040 ) rStm >> aRecordPerSet; + TEST_READ + if( nMask & 0x0080 ) rStm >> aMenuConfig; + TEST_READ + if( nMask & 0x0100 ) rStm >> aToolBoxConfig; + TEST_READ + if( nMask & 0x0200 ) rStm >> aStatusBarConfig; + TEST_READ + if( nMask & 0x0400 ) rStm >> aAccelConfig; + TEST_READ + if( nMask & 0x0800 ) rStm >> aFastCall; + TEST_READ + if( nMask & 0x1000 ) rStm >> aContainer; + TEST_READ + + if( nMask & 0x2000 ) + { + SvMetaType * pT; + rStm >> pT; + aSlotType = pT; + } + + TEST_READ + if( nMask & 0x4000 ) rStm >> aRecordAbsolute; + TEST_READ + if( nMask & 0x8000 ) rStm >> aPlugComm; + + nMask = 0; + rStm >> nMask; + + TEST_READ + if( nMask & 0x0001 ) rStm >> aUnoName; +} + +void SvMetaSlot::Save( SvPersistStream & rStm ) +{ + SvMetaAttribute::Save( rStm ); + + // Maske erstellen + USHORT nMask = 0; + if( aMethod.Is() ) nMask |= 0x0001; + if( aGroupId.Len() ) nMask |= 0x0002; + if( aHasCoreId.IsSet() ) nMask |= 0x0004; + if( aConfigId.Len() ) nMask |= 0x0008; + if( aExecMethod.Len() ) nMask |= 0x0010; + if( aStateMethod.Len() ) nMask |= 0x0020; + if( aDefault.Len() ) nMask |= 0x0040; + if( aPseudoSlots.IsSet() ) nMask |= 0x0080; + if( aGet.IsSet() ) nMask |= 0x0100; + if( aSet.IsSet() ) nMask |= 0x0200; + if( aCachable.IsSet() ) nMask |= 0x0400; + if( aVolatile.IsSet() ) nMask |= 0x0800; + if( aToggle.IsSet() ) nMask |= 0x1000; + if( aAutoUpdate.IsSet() ) nMask |= 0x2000; + if( aSynchron.IsSet() ) nMask |= 0x4000; + if( aAsynchron.IsSet() ) nMask |= 0x8000; + + // Daten schreiben + rStm << nMask; + TEST_WRITE + if( nMask & 0x0001 ) rStm << aMethod; + TEST_WRITE + if( nMask & 0x0002 ) rStm << aGroupId; + TEST_WRITE + if( nMask & 0x0004 ) rStm << aHasCoreId; + TEST_WRITE + if( nMask & 0x0008 ) rStm << aConfigId; + TEST_WRITE + if( nMask & 0x0010 ) rStm << aExecMethod; + TEST_WRITE + if( nMask & 0x0020 ) rStm << aStateMethod; + TEST_WRITE + if( nMask & 0x0040 ) rStm << aDefault; + TEST_WRITE + if( nMask & 0x0080 ) rStm << aPseudoSlots; + TEST_WRITE + if( nMask & 0x0100 ) rStm << aGet; + TEST_WRITE + if( nMask & 0x0200 ) rStm << aSet; + TEST_WRITE + if( nMask & 0x0400 ) rStm << aCachable; + TEST_WRITE + if( nMask & 0x0800 ) rStm << aVolatile; + TEST_WRITE + if( nMask & 0x1000 ) rStm << aToggle; + TEST_WRITE + if( nMask & 0x2000 ) rStm << aAutoUpdate; + TEST_WRITE + if( nMask & 0x4000 ) rStm << aSynchron; + TEST_WRITE + if( nMask & 0x8000 ) rStm << aAsynchron; + + // naechste Fuhre schreiben + // Maske erstellen + nMask = 0; + if( aRecordPerItem.IsSet() ) nMask |= 0x0001; + if( aRecordManual.IsSet() ) nMask |= 0x0002; + if( aNoRecord.IsSet() ) nMask |= 0x0004; + if( aHasDialog.IsSet() ) nMask |= 0x0008; + if ( aDisableFlags.IsSet() ) nMask |= 0x0010; + if( aPseudoPrefix.Len() ) nMask |= 0x0020; + if( aRecordPerSet.IsSet() ) nMask |= 0x0040; + if( aMenuConfig.IsSet() ) nMask |= 0x0080; + if( aToolBoxConfig.IsSet() ) nMask |= 0x0100; + if( aStatusBarConfig.IsSet() )nMask |= 0x0200; + if( aAccelConfig.IsSet() ) nMask |= 0x0400; + if( aFastCall.IsSet() ) nMask |= 0x0800; + if( aContainer.IsSet() ) nMask |= 0x1000; + if( aSlotType.Is() ) nMask |= 0x2000; + if( aRecordAbsolute.IsSet() ) nMask |= 0x4000; + if( aPlugComm.IsSet() ) nMask |= 0x8000; + + // Daten schreiben + rStm << nMask; + TEST_WRITE + if( nMask & 0x0001 ) rStm << aRecordPerItem; + TEST_WRITE + if( nMask & 0x0002 ) rStm << aRecordManual; + TEST_WRITE + if( nMask & 0x0004 ) rStm << aNoRecord; + TEST_WRITE + if( nMask & 0x0008 ) rStm << aHasDialog; + TEST_WRITE + if( nMask & 0x0010 ) rStm << aDisableFlags; + TEST_WRITE + if( nMask & 0x0020 ) rStm << aPseudoPrefix; + TEST_WRITE + if( nMask & 0x0040 ) rStm << aRecordPerSet; + TEST_WRITE + if( nMask & 0x0080 ) rStm << aMenuConfig; + TEST_WRITE + if( nMask & 0x0100 ) rStm << aToolBoxConfig; + TEST_WRITE + if( nMask & 0x0200 ) rStm << aStatusBarConfig; + TEST_WRITE + if( nMask & 0x0400 ) rStm << aAccelConfig; + TEST_WRITE + if( nMask & 0x0800 ) rStm << aFastCall; + TEST_WRITE + if( nMask & 0x1000 ) rStm << aContainer; + TEST_WRITE + if( nMask & 0x2000 ) rStm << aSlotType; + TEST_WRITE + if( nMask & 0x4000 ) rStm << aRecordAbsolute; + TEST_WRITE + if( nMask & 0x8000 ) rStm << aPlugComm; + + nMask = 0; + if( aUnoName.IsSet() ) nMask |= 0x0001; + + rStm << nMask; + TEST_WRITE + if( nMask & 0x0001 ) rStm << aUnoName; +} + +/************************************************************************* +|* SvMetaSlot::IsVariable() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaSlot::IsVariable() const +{ + return SvMetaAttribute::IsVariable(); +} + +/************************************************************************* +|* SvMetaSlot::IsMethod() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaSlot::IsMethod() const +{ + BOOL b = SvMetaAttribute::IsMethod(); + b |= NULL != GetMethod(); + return b; +} + +/************************************************************************* +|* SvMetaSlot::HasMethods() +|* +|* Beschreibung +*************************************************************************/ +ByteString SvMetaSlot::GetMangleName( BOOL bVariable ) const +{ + if( !bVariable ) + { + SvMetaAttribute * pMeth = GetMethod(); + if( pMeth ) + return pMeth->GetName(); + } + return GetName(); +} + +/************************************************************************* +|* Referenz +|* +|* Beschreibung Zweites FALSE bei den SvBOOL-Objekten bedeutet, +|* IsSet() liefert FALSE (Defaultinitialisierung). +*************************************************************************/ +/** Referenz Aufloesung **/ +SvMetaType * SvMetaSlot::GetSlotType() const +{ + if( aSlotType.Is() || !GetRef() ) return aSlotType; + return ((SvMetaSlot *)GetRef())->GetSlotType(); +} +SvMetaAttribute * SvMetaSlot::GetMethod() const +{ + if( aMethod.Is() || !GetRef() ) return aMethod; + return ((SvMetaSlot *)GetRef())->GetMethod(); +} +BOOL SvMetaSlot::GetHasCoreId() const +{ + if( aHasCoreId.IsSet() || !GetRef() ) return aHasCoreId; + return ((SvMetaSlot *)GetRef())->GetHasCoreId(); +} +const ByteString & SvMetaSlot::GetGroupId() const +{ + if( aGroupId.Len() || !GetRef() ) return aGroupId; + return ((SvMetaSlot *)GetRef())->GetGroupId(); +} +const ByteString & SvMetaSlot::GetDisableFlags() const +{ + if( aDisableFlags.Len() || !GetRef() ) return aDisableFlags; + return ((SvMetaSlot *)GetRef())->GetDisableFlags(); +} +const ByteString & SvMetaSlot::GetConfigId() const +{ + if( aConfigId.Len() || !GetRef() ) return aConfigId; + return ((SvMetaSlot *)GetRef())->GetConfigId(); +} +const ByteString & SvMetaSlot::GetExecMethod() const +{ + if( aExecMethod.Len() || !GetRef() ) return aExecMethod; + return ((SvMetaSlot *)GetRef())->GetExecMethod(); +} +const ByteString & SvMetaSlot::GetStateMethod() const +{ + if( aStateMethod.Len() || !GetRef() ) return aStateMethod; + return ((SvMetaSlot *)GetRef())->GetStateMethod(); +} +const ByteString & SvMetaSlot::GetDefault() const +{ + if( aDefault.Len() || !GetRef() ) return aDefault; + return ((SvMetaSlot *)GetRef())->GetDefault(); +} +BOOL SvMetaSlot::GetPseudoSlots() const +{ + if( aPseudoSlots.IsSet() || !GetRef() ) return aPseudoSlots; + return ((SvMetaSlot *)GetRef())->GetPseudoSlots(); +} +/* +BOOL SvMetaSlot::GetGet() const +{ + if( aGet.IsSet() || !GetRef() ) return aGet; + return ((SvMetaSlot *)GetRef())->GetGet(); +} +BOOL SvMetaSlot::GetSet() const +{ + if( aSet.IsSet() || !GetRef() ) return aSet; + return ((SvMetaSlot *)GetRef())->GetSet(); +} +*/ +BOOL SvMetaSlot::GetCachable() const +{ + // Cachable und Volatile sind exclusiv + if( !GetRef() || aCachable.IsSet() || aVolatile.IsSet() ) + return aCachable; + return ((SvMetaSlot *)GetRef())->GetCachable(); +} +BOOL SvMetaSlot::GetVolatile() const +{ + // Cachable und Volatile sind exclusiv + if( !GetRef() || aVolatile.IsSet() || aCachable.IsSet() ) + return aVolatile; + return ((SvMetaSlot *)GetRef())->GetVolatile(); +} +BOOL SvMetaSlot::GetToggle() const +{ + if( aToggle.IsSet() || !GetRef() ) return aToggle; + return ((SvMetaSlot *)GetRef())->GetToggle(); +} +BOOL SvMetaSlot::GetAutoUpdate() const +{ + if( aAutoUpdate.IsSet() || !GetRef() ) return aAutoUpdate; + return ((SvMetaSlot *)GetRef())->GetAutoUpdate(); +} +BOOL SvMetaSlot::GetSynchron() const +{ + // Synchron und Asynchron sind exclusiv + if( !GetRef() || aSynchron.IsSet() || aAsynchron.IsSet() ) + return aSynchron; + return ((SvMetaSlot *)GetRef())->GetSynchron(); +} +BOOL SvMetaSlot::GetAsynchron() const +{ + // Synchron und Asynchron sind exclusiv + if( !GetRef() || aAsynchron.IsSet() || aSynchron.IsSet() ) + return aAsynchron; + return ((SvMetaSlot *)GetRef())->GetAsynchron(); +} +BOOL SvMetaSlot::GetRecordPerItem() const +{ + // Record- PerItem, No, PerSet und Manual sind exclusiv + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aRecordPerItem; + return ((SvMetaSlot *)GetRef())->GetRecordPerItem(); +} +BOOL SvMetaSlot::GetRecordPerSet() const +{ + // Record- PerItem, No, PerSet und Manual sind exclusiv + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aRecordPerSet; + return ((SvMetaSlot *)GetRef())->GetRecordPerSet(); +} +BOOL SvMetaSlot::GetRecordManual() const +{ + // Record- PerItem, No, PerSet und Manual sind exclusiv + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aRecordManual; + return ((SvMetaSlot *)GetRef())->GetRecordManual(); +} +BOOL SvMetaSlot::GetNoRecord() const +{ + // Record- PerItem, No, PerSet und Manual sind exclusiv + if( !GetRef() || aRecordPerItem.IsSet() || aNoRecord.IsSet() + || aRecordPerSet.IsSet() || aRecordManual.IsSet() ) + return aNoRecord; + return ((SvMetaSlot *)GetRef())->GetNoRecord(); +} +BOOL SvMetaSlot::GetRecordAbsolute() const +{ + if( !GetRef() || aRecordAbsolute.IsSet() ) + return aRecordAbsolute; + return ((SvMetaSlot *)GetRef())->GetRecordAbsolute(); +} +BOOL SvMetaSlot::GetHasDialog() const +{ + if( aHasDialog.IsSet() || !GetRef() ) return aHasDialog; + return ((SvMetaSlot *)GetRef())->GetHasDialog(); +} +const ByteString & SvMetaSlot::GetPseudoPrefix() const +{ + if( aPseudoPrefix.Len() || !GetRef() ) return aPseudoPrefix; + return ((SvMetaSlot *)GetRef())->GetPseudoPrefix(); +} +BOOL SvMetaSlot::GetMenuConfig() const +{ + if( aMenuConfig.IsSet() || !GetRef() ) return aMenuConfig; + return ((SvMetaSlot *)GetRef())->GetMenuConfig(); +} +BOOL SvMetaSlot::GetToolBoxConfig() const +{ + if( aToolBoxConfig.IsSet() || !GetRef() ) return aToolBoxConfig; + return ((SvMetaSlot *)GetRef())->GetToolBoxConfig(); +} +BOOL SvMetaSlot::GetStatusBarConfig() const +{ + if( aStatusBarConfig.IsSet() || !GetRef() ) return aStatusBarConfig; + return ((SvMetaSlot *)GetRef())->GetStatusBarConfig(); +} +BOOL SvMetaSlot::GetAccelConfig() const +{ + if( aAccelConfig.IsSet() || !GetRef() ) return aAccelConfig; + return ((SvMetaSlot *)GetRef())->GetAccelConfig(); +} +BOOL SvMetaSlot::GetFastCall() const +{ + if( aFastCall.IsSet() || !GetRef() ) return aFastCall; + return ((SvMetaSlot *)GetRef())->GetFastCall(); +} +BOOL SvMetaSlot::GetContainer() const +{ + if( aContainer.IsSet() || !GetRef() ) return aContainer; + return ((SvMetaSlot *)GetRef())->GetContainer(); +} + +BOOL SvMetaSlot::GetPlugComm() const +{ + if( aPlugComm.IsSet() || !GetRef() ) return aPlugComm; + return ((SvMetaSlot *)GetRef())->GetPlugComm(); +} + +const ByteString& SvMetaSlot::GetUnoName() const +{ + if( aUnoName.IsSet() || !GetRef() ) return aUnoName; + return ((SvMetaSlot *)GetRef())->GetUnoName(); +} + +/************************************************************************* +|* SvMetaSlot::FillSbxObject() +|* +|* Beschreibung +*************************************************************************/ +/* +void SvMetaSlot::FillSbxObject( SvIdlDataBase & rBase, SbxObject * pObj, + BOOL bVariable ) +{ + // keine Attribut fuer Automation + if( !GetAutomation() || !GetExport() ) + return; + + if( !bVariable ) + { + SvMetaAttributeRef xM = GetMethod(); + if( xM.Is() ) + { + SvMetaType * pType = xM->GetType(); + SvMetaType * pRetBaseType = pType->GetReturnType()->GetBaseType(); + ByteString aName = xM->GetName(); + + SbxMethodRef xMeth = new SbxMethod( aName, + pRetBaseType->GetSbxDataType() ); + pType->FillSbxObject( xMeth, bVariable ); + xMeth->SetUserData( MakeSlotValue(rBase, FALSE) ); + + pObj->Insert( &xMeth ); + return; + } + } + + SvMetaAttribute::FillSbxObject( rBase, pObj, bVariable ); +} + */ + +#ifdef IDL_COMPILER +/************************************************************************* +|* SvMetaSlot::ReadAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaAttribute::ReadAttributesSvIdl( rBase, rInStm ); + + BOOL bOk = FALSE; + bOk |= aDefault.ReadSvIdl( SvHash_Default(), rInStm ); + bOk |= aPseudoSlots.ReadSvIdl( SvHash_PseudoSlots(), rInStm ); + bOk |= aHasCoreId.ReadSvIdl( SvHash_HasCoreId(), rInStm ); + bOk |= aGroupId.ReadSvIdl( SvHash_GroupId(), rInStm ); + bOk |= aExecMethod.ReadSvIdl( SvHash_ExecMethod(), rInStm ); + bOk |= aStateMethod.ReadSvIdl( SvHash_StateMethod(), rInStm ); + bOk |= aDisableFlags.ReadSvIdl( SvHash_DisableFlags(), rInStm ); + if( aGet.ReadSvIdl( SvHash_Get(), rInStm ) ) + { + rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ), + " old style, use Readonly", + rInStm.GetToken()->GetLine(), + rInStm.GetToken()->GetColumn() ); + } + if( aSet.ReadSvIdl( SvHash_Set(), rInStm ) ) + { + rBase.WriteError( "warning", ByteString( rInStm.GetFileName(), RTL_TEXTENCODING_UTF8 ), + " old style, use method declaration", + rInStm.GetToken()->GetLine(), + rInStm.GetToken()->GetColumn() ); + } + + if( aCachable.ReadSvIdl( SvHash_Cachable(), rInStm ) ) + SetCachable( aCachable ), bOk = TRUE; + if( aVolatile.ReadSvIdl( SvHash_Volatile(), rInStm ) ) + SetVolatile( aVolatile ), bOk = TRUE; + if( aToggle.ReadSvIdl( SvHash_Toggle(), rInStm ) ) + SetToggle( aToggle ), bOk = TRUE; + if( aAutoUpdate.ReadSvIdl( SvHash_AutoUpdate(), rInStm ) ) + SetAutoUpdate( aAutoUpdate ), bOk = TRUE; + + if( aSynchron.ReadSvIdl( SvHash_Synchron(), rInStm ) ) + SetSynchron( aSynchron ), bOk = TRUE; + if( aAsynchron.ReadSvIdl( SvHash_Asynchron(), rInStm ) ) + SetAsynchron( aAsynchron ), bOk = TRUE; + + if( aRecordAbsolute.ReadSvIdl( SvHash_RecordAbsolute(), rInStm ) ) + SetRecordAbsolute( aRecordAbsolute), bOk = TRUE; + if( aRecordPerItem.ReadSvIdl( SvHash_RecordPerItem(), rInStm ) ) + SetRecordPerItem( aRecordPerItem ), bOk = TRUE; + if( aRecordPerSet.ReadSvIdl( SvHash_RecordPerSet(), rInStm ) ) + SetRecordPerSet( aRecordPerSet ), bOk = TRUE; + if( aRecordManual.ReadSvIdl( SvHash_RecordManual(), rInStm ) ) + SetRecordManual( aRecordManual ), bOk = TRUE; + if( aNoRecord.ReadSvIdl( SvHash_NoRecord(), rInStm ) ) + SetNoRecord( aNoRecord ), bOk = TRUE; + + bOk |= aHasDialog.ReadSvIdl( SvHash_HasDialog(), rInStm ); + bOk |= aPseudoPrefix.ReadSvIdl( SvHash_PseudoPrefix(), rInStm ); + bOk |= aMenuConfig.ReadSvIdl( SvHash_MenuConfig(), rInStm ); + bOk |= aToolBoxConfig.ReadSvIdl( SvHash_ToolBoxConfig(), rInStm ); + bOk |= aStatusBarConfig.ReadSvIdl( SvHash_StatusBarConfig(), rInStm ); + bOk |= aAccelConfig.ReadSvIdl( SvHash_AccelConfig(), rInStm ); + + SvBOOL aAllConfig; + if( aAllConfig.ReadSvIdl( SvHash_AllConfig(), rInStm ) ) + SetAllConfig( aAllConfig ), bOk = TRUE; + bOk |= aFastCall.ReadSvIdl( SvHash_FastCall(), rInStm ); + bOk |= aContainer.ReadSvIdl( SvHash_Container(), rInStm ); + bOk |= aPlugComm.ReadSvIdl( SvHash_PlugComm(), rInStm ); + bOk |= aUnoName.ReadSvIdl( SvHash_UnoName(), rInStm ); + + if( !bOk ) + { + if( !aSlotType.Is() ) + { + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->Is( SvHash_SlotType() ) ) + { + BOOL bBraket = rInStm.Read( '(' ); + if( bBraket || rInStm.Read( '=' ) ) + { + aSlotType = rBase.ReadKnownType( rInStm ); + if( aSlotType.Is() ) + { + if( aSlotType->IsItem() ) + { + if( bBraket ) + { + if( rInStm.Read( ')' ) ) + return; + } + else + return; + } + rBase.SetError( "the SlotType is not a item", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + rBase.SetError( "SlotType with unknown item type", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + rInStm.Seek( nTokPos ); + + } + if( !aMethod.Is() ) + { + SvToken * pTok = rInStm.GetToken(); + if( pTok->IsIdentifier() ) + { + aMethod = new SvMetaSlot(); + UINT32 nTokPos = rInStm.Tell(); + if( aMethod->ReadSvIdl( rBase, rInStm ) ) + { + if( aMethod->IsMethod() ) + { + aMethod->SetSlotId( GetSlotId() ); + if( aMethod->Test( rBase, rInStm ) ) + return; + } + rInStm.Seek( nTokPos ); + } + aMethod.Clear(); + } + } + } +} + +/************************************************************************* +|* SvMetaSlot::WriteAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaSlot::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ + SvMetaAttribute::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + + if( aSlotType.Is() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << SvHash_SlotType()->GetName().GetBuffer() << '('; + aSlotType->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ");" << endl; + } + if( aMethod.Is() ) + { + WriteTab( rOutStm, nTab ); + aMethod->WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << ';' << endl; + } + if( aHasCoreId ) + { + aHasCoreId.WriteSvIdl( SvHash_HasCoreId(), rOutStm ); + rOutStm << ';' << endl; + } + if( aGroupId.Len() ) + { + WriteTab( rOutStm, nTab ); + aGroupId.WriteSvIdl( SvHash_GroupId(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + if( aExecMethod.Len() ) + { + WriteTab( rOutStm, nTab ); + aExecMethod.WriteSvIdl( SvHash_ExecMethod(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + if( aStateMethod.Len() ) + { + WriteTab( rOutStm, nTab ); + aStateMethod.WriteSvIdl( SvHash_StateMethod(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + + if( aDisableFlags.Len() ) + { + WriteTab( rOutStm, nTab ); + aDisableFlags.WriteSvIdl( SvHash_DisableFlags(), rOutStm, nTab +1); + rOutStm << ';' << endl; + } + + if( aSet || aGet || aPseudoSlots ) + { + WriteTab( rOutStm, nTab ); + char * p = ""; + if( aPseudoSlots ) + { + aPseudoSlots.WriteSvIdl( SvHash_PseudoSlots(), rOutStm ); + p = ", "; + } + if( aGet ) + { + rOutStm << p; + aGet.WriteSvIdl( SvHash_Get(), rOutStm ); + p = ", "; + } + if( aSet ) + { + rOutStm << p; + aSet.WriteSvIdl( SvHash_Set(), rOutStm ); + } + rOutStm << ';' << endl; + } + + ByteString aDel( ", " ); + ByteString aOut; + if( aVolatile ) + aOut += aVolatile.GetSvIdlString( SvHash_Volatile() ); + else if( !aCachable ) + // wegen Default == TRUE, nur wenn kein anderer gesetzt + aOut += aCachable.GetSvIdlString( SvHash_Cachable() ); + else + aDel.Erase(); + + if( aToggle ) + { + ( aOut += aDel ) += aToggle.GetSvIdlString( SvHash_Toggle() ); + aDel = ", "; + } + if( aAutoUpdate ) + { + (aOut += aDel ) += aAutoUpdate.GetSvIdlString( SvHash_AutoUpdate() ); + aDel = ", "; + } + + ByteString aDel1( ", " ); + if( aAsynchron ) + ( aOut += aDel ) += aAsynchron.GetSvIdlString( SvHash_Asynchron() ); + else if( !aSynchron ) + // wegen Default == TRUE, nur wenn kein anderer gesetzt + ( aOut += aDel ) += aSynchron.GetSvIdlString( SvHash_Synchron() ); + else + aDel1 = aDel; + + aDel = ", "; + if( aRecordManual ) + ( aOut += aDel1 ) += aRecordManual.GetSvIdlString( SvHash_RecordManual() ); + else if( aNoRecord ) + ( aOut += aDel1 ) += aNoRecord.GetSvIdlString( SvHash_NoRecord() ); + else if( !aRecordPerSet ) + // wegen Default == TRUE, nur wenn kein anderer gesetzt + ( aOut += aDel1 ) += aRecordPerSet.GetSvIdlString( SvHash_RecordPerSet() ); + else if( aRecordPerItem ) + ( aOut += aDel1 ) += aRecordPerItem.GetSvIdlString( SvHash_RecordPerItem() ); + else + aDel = aDel1; + + if( aRecordAbsolute ) + { + ( aOut += aDel ) += aRecordAbsolute.GetSvIdlString( SvHash_RecordAbsolute() ); + aDel = ", "; + } + if( aHasDialog ) + { + ( aOut += aDel ) += aHasDialog.GetSvIdlString( SvHash_HasDialog() ); + aDel = ", "; + } + if( aMenuConfig ) + { + ( aOut += aDel ) += aMenuConfig.GetSvIdlString( SvHash_MenuConfig() ); + aDel = ", "; + } + if( aToolBoxConfig ) + { + ( aOut += aDel ) += aToolBoxConfig.GetSvIdlString( SvHash_ToolBoxConfig() ); + aDel = ", "; + } + if( aStatusBarConfig ) + { + ( aOut += aDel ) += aStatusBarConfig.GetSvIdlString( SvHash_StatusBarConfig() ); + aDel = ", "; + } + if( aAccelConfig ) + { + ( aOut += aDel ) += aAccelConfig.GetSvIdlString( SvHash_AccelConfig() ); + aDel = ", "; + } + if( aFastCall ) + { + ( aOut += aDel ) += aFastCall.GetSvIdlString( SvHash_FastCall() ); + aDel = ", "; + } + if( aContainer ) + { + ( aOut += aDel ) += aContainer.GetSvIdlString( SvHash_Container() ); + aDel = ", "; + } + if( aPlugComm ) + { + ( aOut += aDel ) += aPlugComm.GetSvIdlString( SvHash_PlugComm() ); + aDel = ", "; + } + + if( aOut.Len() ) + { + WriteTab( rOutStm, nTab ); + rOutStm << aOut.GetBuffer() << endl; + } +} + + +/************************************************************************* +|* SvMetaSlot::Test() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaSlot::Test( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + BOOL bOk = SvMetaAttribute::Test( rBase, rInStm ); + if( bOk ) + { + SvMetaType * pType = GetType(); + if( pType->GetType() == TYPE_METHOD ) + pType = pType->GetReturnType(); + SvMetaType * pBaseType = pType->GetBaseType(); + if( !pType->IsItem() ) + { + rBase.SetError( "this attribute is not a slot", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = FALSE; + } + } + +/* + if ( bOk ) + { + SvMetaSlot* pRef = (SvMetaSlot*) GetRef(); + if ( pRef ) + CompareSlotAttributes( pRef ); + } +*/ + return bOk; +} + +/************************************************************************* +|* SvMetaSlot::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaSlot::ReadSvIdl( SvIdlDataBase & rBase, SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + BOOL bOk = TRUE; + + SvMetaAttribute * pAttr = rBase.ReadKnownAttr( rInStm, GetType() ); + if( pAttr ) + { + // F"ur Testzwecke: Referenz bei Kurz-Syntax + SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr ); + if( pKnownSlot ) + { + SetRef( pKnownSlot ); + SetName( pKnownSlot->GetName(), &rBase ); + bOk = SvMetaName::ReadSvIdl( rBase, rInStm ); + } + else + { + ByteString aStr( "attribute " ); + aStr += pAttr->GetName(); + aStr += " is method or variable but not a slot"; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = FALSE; + } + } + else + { + bOk = SvMetaAttribute::ReadSvIdl( rBase, rInStm ); + + SvMetaAttribute *pAttr = rBase.SearchKnownAttr( GetSlotId() ); + if( pAttr ) + { + // F"ur Testzwecke: Referenz bei kompletter Definition + SvMetaSlot * pKnownSlot = PTR_CAST( SvMetaSlot, pAttr ); + if( pKnownSlot ) + { + SetRef( pKnownSlot ); + + // Namen d"urfen abweichen, da mit angegeben +// SetName( pKnownSlot->GetName(), &rBase ); + } + else + { + ByteString aStr( "attribute " ); + aStr += pAttr->GetName(); + aStr += " is method or variable but not a slot"; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = FALSE; + } + } + } + + if( !bOk ) + rInStm.Seek( nTokPos ); + + return bOk; +} + +/************************************************************************* +|* SvMetaSlot::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaSlot::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + SvMetaAttribute::WriteSvIdl( rBase, rOutStm, nTab ); +} + +/************************************************************************* +|* SvMetaSlot::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaSlot::Write( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + if ( nT == WRITE_DOCU ) + { + if ( GetHidden() ) + return; + } + else + { + // keine Attribut fuer Automation + if( !GetAutomation() || !GetExport() ) + return; + } + + if( !(nA & WA_VARIABLE) ) + { + SvMetaAttributeRef xM = GetMethod(); + if( xM.Is() ) + { + xM->SetSlotId( GetSlotId() ); + xM->SetDescription( GetDescription() ); + xM->Write( rBase, rOutStm, nTab, nT, nA ); + return; + } + } + + SvMetaAttribute::Write( rBase, rOutStm, nTab, nT, nA ); +} + + +void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix, + SvIdlDataBase& rBase) +{ + // Einf"ugeposition durch bin"are Suche in der SlotListe ermitteln + USHORT nId = (USHORT) GetSlotId().GetValue(); + USHORT nListCount = (USHORT) rList.Count(); + USHORT nPos; + if ( !nListCount ) + nPos = 0; + else if ( nListCount == 1 ) + nPos = rList.GetObject(0)->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1; + else + { + USHORT nMid, nLow = 0; + USHORT nHigh = nListCount - 1; + BOOL bFound = FALSE; + while ( !bFound && nLow <= nHigh ) + { + nMid = (nLow + nHigh) >> 1; + DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" ); + int nDiff = (int) nId - (int) rList.GetObject(nMid)->xSlot->GetSlotId().GetValue(); + if ( nDiff < 0) + { + if ( nMid == 0 ) + break; + nHigh = nMid - 1; + } + else if ( nDiff > 0 ) + { + nLow = nMid + 1; + if ( nLow == 0 ) + break; + } + else + bFound = TRUE; + } + + DBG_ASSERT(!bFound, "SlotId ist doppelt !"); + nPos = bFound ? nMid : nLow; + } + + DBG_ASSERT( nPos <= nListCount, + "nPos zu groá" ); + DBG_ASSERT( nPos == nListCount || nId <= + (USHORT) rList.GetObject(nPos)->xSlot->GetSlotId().GetValue(), + "Nachfolger hat kleinere SlotId" ); + DBG_ASSERT( nPos == 0 || nId > + (USHORT) rList.GetObject(nPos-1)->xSlot->GetSlotId().GetValue(), + "Vorg„nger hat gr”áere SlotId" ); + DBG_ASSERT( nPos+1 >= nListCount || nId < + (USHORT) rList.GetObject(nPos+1)->xSlot->GetSlotId().GetValue(), + "Nachfolger hat kleinere SlotId" ); + + rList.Insert( new SvSlotElement( this, rPrefix ), nPos ); + + // EnumSlots plattklopfen + SvMetaTypeEnum * pEnum = NULL; + SvMetaType * pBType = GetType()->GetBaseType(); + pEnum = PTR_CAST( SvMetaTypeEnum, pBType ); + if( GetPseudoSlots() && pEnum && pEnum->Count() ) + { + // Den MasterSlot clonen + SvMetaSlotRef xEnumSlot = Clone(); + SvMetaSlot *pFirstEnumSlot = xEnumSlot; + for( ULONG n = 0; n < pEnum->Count(); n++ ) + { + // Die Slaves sind kein Master ! + xEnumSlot->aPseudoSlots = FALSE; + + // Die SlotId erzeugen + SvMetaEnumValue *pEnumValue = pEnum->GetObject(n); + xEnumSlot->SetEnumValue(pEnumValue); + ByteString aValName = pEnumValue->GetName(); + ByteString aSId( GetSlotId() ); + if( GetPseudoPrefix().Len() ) + aSId = GetPseudoPrefix(); + aSId += '_'; + USHORT nLen = pEnum->GetPrefix().Len(); + aSId += aValName.Copy( pEnum->GetPrefix().Len() ); + + ULONG nValue; + if ( rBase.FindId(aSId , &nValue) ) + { + SvNumberIdentifier aId; + *((SvIdentifier*)&aId) = aSId; + aId.SetValue(nValue); + xEnumSlot->SetSlotId(aId); + } + + if ( xEnumSlot->GetSlotId().GetValue() < + pFirstEnumSlot->GetSlotId().GetValue() ) + { + pFirstEnumSlot = xEnumSlot; + } + + // Den erzeugten Slave ebenfalls einf"ugen + xEnumSlot->Insert( rList, rPrefix, rBase); + + // Die EnumSlots mit dem Master verketten + xEnumSlot->pLinkedSlot = this; + + // N"achster EnumSlot + if ( n != pEnum->Count() - 1 ) + xEnumSlot = Clone(); + } + + // Master zeigt auf den ersten Slave + pLinkedSlot = pFirstEnumSlot; + + // Slaves untereinander verketten + rList.Seek(0UL); + xEnumSlot = pFirstEnumSlot; + SvSlotElement *pEle; + do + { + pEle = rList.Next(); + if ( pEle && pEle->xSlot->pLinkedSlot == this ) + { + xEnumSlot->pNextSlot = pEle->xSlot; + xEnumSlot = pEle->xSlot; + } + } + while ( pEle ); + xEnumSlot->pNextSlot = pFirstEnumSlot; + } +} + + +/************************************************************************* +|* SvMetaSlot::WriteSlotMap() +|* +|* Beschreibung +*************************************************************************/ +static ByteString MakeSlotName( SvStringHashEntry * pEntry ) +{ + ByteString aName( "SFX_SLOT_" ); + aName += pEntry->GetName(); + return aName.ToUpperAscii(); +}; + +void SvMetaSlot::WriteSlotStubs( const ByteString & rShellName, + ByteStringList & rList, + SvStream & rOutStm ) +{ +/* + ByteString aName = GetName(); + SvMetaAttribute * pAttr = rAttrList.First(); + while( pAttr ) + { + if( pAttr->GetName() == aName ) + break; + pAttr = rAttrList.Next(); + } + if( pAttr ) + return; +*/ + if ( !GetExport() && !GetHidden() ) + return; + + ByteString aMethodName( GetExecMethod() ); + if ( aMethodName.Len() && aMethodName != "NoExec" ) + { + BOOL bIn = FALSE; + for( USHORT n = 0; n < rList.Count(); n++ ) + { + if( *(rList.GetObject(n)) == aMethodName ) + { + bIn=TRUE; + break; + } + } + + if ( !bIn ) + { + rList.Insert( new ByteString(aMethodName), LIST_APPEND ); + rOutStm << "SFX_EXEC_STUB(" + << rShellName.GetBuffer() + << ',' + << aMethodName.GetBuffer() + << ')' << endl; + } + } + + aMethodName = GetStateMethod(); + if ( aMethodName.Len() && aMethodName != "NoState" ) + { + BOOL bIn = FALSE; + for ( USHORT n=0; n < rList.Count(); n++ ) + { + if ( *(rList.GetObject(n)) == aMethodName ) + { + bIn=TRUE; + break; + } + } + + if ( !bIn ) + { + rList.Insert( new ByteString(aMethodName), LIST_APPEND ); + rOutStm << "SFX_STATE_STUB(" + << rShellName.GetBuffer() + << ',' + << aMethodName.GetBuffer() + << ')' << endl; + } + } +} + +void SvMetaSlot::WriteSlot( const ByteString & rShellName, USHORT nCount, + const ByteString & rSlotId, + const ByteString & rValueName, + SvSlotElementList& rSlotList, + const ByteString & rPrefix, + SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + if ( !GetExport() && !GetHidden() ) + return; + +// BOOL bIsEnumSlot = 0 != rValueName.Len(); + BOOL bIsEnumSlot = 0 != pEnumValue; + + rOutStm << "// Slot Nr. " << ByteString::CreateFromInt32(nListPos).GetBuffer() << " : "; + ByteString aSlotIdValue( ByteString::CreateFromInt32( GetSlotId().GetValue() ) ); + rOutStm << aSlotIdValue.GetBuffer() << endl; + WriteTab( rOutStm, 1 ); + if( bIsEnumSlot ) + rOutStm << "SFX_NEW_SLOT_ENUM( "; + else + rOutStm << "SFX_NEW_SLOT_ARG( " << rShellName.GetBuffer() << ',' ; + + rOutStm << rSlotId.GetBuffer() << ','; + const SvHelpContext& rHlpCtx = GetHelpContext(); + if( rHlpCtx.IsSet() ) + rOutStm << rHlpCtx.GetBuffer() << ','; + else + rOutStm << rSlotId.GetBuffer() << ','; + + // GroupId + if( GetGroupId().Len() ) + rOutStm << GetGroupId().GetBuffer(); + else + rOutStm << '0'; + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + + if( bIsEnumSlot ) + { + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << ByteString::CreateFromInt32(pLinkedSlot->GetListPos()).GetBuffer() + << "] /*Offset Master*/, " << endl; + WriteTab( rOutStm, 4 ); + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << ByteString::CreateFromInt32(pNextSlot->GetListPos()).GetBuffer() + << "] /*Offset Next*/, " << endl; + + WriteTab( rOutStm, 4 ); + + // SlotId + if( GetSlotId().Len() ) + rOutStm << pLinkedSlot->GetSlotId().GetBuffer(); + else + rOutStm << '0'; + rOutStm << ','; + rOutStm << pEnumValue->GetName().GetBuffer(); + } + else + { + // Den n"achsten Slot suchen, der die gleiche StateMethod hat wie ich + // Die SlotList ist auf den aktuellen Slot geseekt + SvSlotElement * pEle = rSlotList.Next(); + pNextSlot = pEle ? &pEle->xSlot : NULL; + while ( pNextSlot ) + { + if ( !pNextSlot->pNextSlot && + pNextSlot->GetStateMethod() == GetStateMethod() ) + break; + pEle = rSlotList.Next(); + pNextSlot = pEle ? &pEle->xSlot : NULL; + } + + if ( !pNextSlot ) + { + // Es gibt nach mir keinen Slot mehr, der die gleiche ExecMethode + // hat. Also suche ich den ersten Slot, der diese hatte (das + // k"onnte auch ich selbst sein) + pEle = rSlotList.First(); + pNextSlot = pEle ? &pEle->xSlot : NULL; + while ( pNextSlot != this ) + { + if ( !pNextSlot->pEnumValue && + pNextSlot->GetStateMethod() == GetStateMethod() ) + break; + pEle = rSlotList.Next(); + pNextSlot = pEle ? &pEle->xSlot : NULL; + } + } + + if ( !pLinkedSlot ) + { + rOutStm << "0 ,"; + } + else + { + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << ByteString::CreateFromInt32(pLinkedSlot->GetListPos()).GetBuffer() + << "] /*Offset Linked*/, " << endl; + WriteTab( rOutStm, 4 ); + } + + rOutStm << "&a" << rShellName.GetBuffer() << "Slots_Impl[" + << ByteString::CreateFromInt32(pNextSlot->GetListPos()).GetBuffer() + << "] /*Offset Next*/, " << endl; + + WriteTab( rOutStm, 4 ); + + // ExecMethod schreiben, wenn nicht angegeben, standard Namen + if( GetExecMethod().Len() && GetExecMethod() != "NoExec") + rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ',' + << GetExecMethod().GetBuffer() << ')'; + else + rOutStm << "SFX_STUB_PTR_EXEC_NONE"; + rOutStm << ','; + + // StateMethod schreiben, wenn nicht angegeben, standard Namen + if( GetStateMethod().Len() && GetStateMethod() != "NoState") + rOutStm << "SFX_STUB_PTR(" << rShellName.GetBuffer() << ',' + << GetStateMethod().GetBuffer() << ')'; + else + rOutStm << "SFX_STUB_PTR_STATE_NONE"; + } + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + + // Flags schreiben + if( GetHasCoreId() ) + rOutStm << MakeSlotName( SvHash_HasCoreId() ).GetBuffer() << '|'; + if( GetCachable() ) + rOutStm << MakeSlotName( SvHash_Cachable() ).GetBuffer() << '|'; + if( GetVolatile() ) + rOutStm << MakeSlotName( SvHash_Volatile() ).GetBuffer() << '|'; + if( GetToggle() ) + rOutStm << MakeSlotName( SvHash_Toggle() ).GetBuffer() << '|'; + if( GetAutoUpdate() ) + rOutStm << MakeSlotName( SvHash_AutoUpdate() ).GetBuffer() << '|'; + if( GetSynchron() ) + rOutStm << MakeSlotName( SvHash_Synchron() ).GetBuffer() << '|'; + if( GetAsynchron() ) + rOutStm << MakeSlotName( SvHash_Asynchron() ).GetBuffer() << '|'; + if( GetRecordPerItem() ) + rOutStm << MakeSlotName( SvHash_RecordPerItem() ).GetBuffer() << '|'; + if( GetRecordPerSet() ) + rOutStm << MakeSlotName( SvHash_RecordPerSet() ).GetBuffer() << '|'; + if( GetRecordManual() ) + rOutStm << MakeSlotName( SvHash_RecordManual() ).GetBuffer() << '|'; + if( GetNoRecord() ) + rOutStm << MakeSlotName( SvHash_NoRecord() ).GetBuffer() << '|'; + if( GetRecordAbsolute() ) + rOutStm << MakeSlotName( SvHash_RecordAbsolute() ).GetBuffer() << '|'; + if( GetHasDialog() ) + rOutStm << MakeSlotName( SvHash_HasDialog() ).GetBuffer() << '|'; + if( GetMenuConfig() ) + rOutStm << MakeSlotName( SvHash_MenuConfig() ).GetBuffer() << '|'; + if( GetToolBoxConfig() ) + rOutStm << MakeSlotName( SvHash_ToolBoxConfig() ).GetBuffer() << '|'; + if( GetStatusBarConfig() ) + rOutStm << MakeSlotName( SvHash_StatusBarConfig() ).GetBuffer() << '|'; + if( GetAccelConfig() ) + rOutStm << MakeSlotName( SvHash_AccelConfig() ).GetBuffer() << '|'; + if( GetFastCall() ) + rOutStm << MakeSlotName( SvHash_FastCall() ).GetBuffer() << '|'; + if( GetContainer() ) + rOutStm << MakeSlotName( SvHash_Container() ).GetBuffer() << '|'; + if ( GetReadOnlyDoc() ) + rOutStm << MakeSlotName( SvHash_ReadOnlyDoc() ).GetBuffer() << '|'; + if( GetPlugComm() ) + rOutStm << MakeSlotName( SvHash_PlugComm() ).GetBuffer() << '|'; + + rOutStm << '0'; + + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + if ( !GetDisableFlags().Len() ) + rOutStm << "0"; + else + rOutStm << GetDisableFlags().GetBuffer(); + + // Attribut Typ schreiben + if( !bIsEnumSlot ) + { + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + + SvMetaType * pT = GetSlotType(); + if( !pT ) + { + if( !IsVariable() ) + pT = rBase.FindType( "SfxVoidItem" ); + else + pT = GetType(); + } + if( pT ) + { + rOutStm << pT->GetName().GetBuffer(); + if( !rBase.FindType( pT, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pT ); + } + else + rOutStm << "SfxVoidItem not defined"; + } + else + { + SvMetaType *pT = rBase.FindType( "SfxBoolItem" ); + if ( pT && !rBase.FindType( pT, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pT ); + } + + if( !bIsEnumSlot ) + { + rOutStm << ',' << endl; + WriteTab( rOutStm, 4 ); + rOutStm << ByteString::CreateFromInt32( nCount ).GetBuffer() << "/*Offset*/, "; + + if( IsMethod() ) + { + SvMetaAttribute * pMethod = GetMethod(); + SvMetaType * pType; + if( pMethod ) + pType = pMethod->GetType(); + else + pType = GetType(); + ULONG nSCount = pType->GetAttrCount(); + rOutStm << ByteString::CreateFromInt32( nSCount ).GetBuffer() << "/*Count*/"; + } + else + rOutStm << '0'; + + // Name f"urs Recording + if ( GetExport() ) + { + rOutStm << ",\""; + if( rPrefix.Len() ) + rOutStm << rPrefix.GetBuffer(); + rOutStm << '.'; + if ( !IsVariable() || !GetType() || + GetType()->GetBaseType()->GetType() != TYPE_STRUCT ) + rOutStm << GetMangleName( FALSE ).GetBuffer(); + rOutStm << "\","; + } + else + rOutStm << ", 0, "; + + // Method/Property Flags + if( IsMethod() ) + rOutStm << "SFX_SLOT_METHOD|"; + if( IsVariable() ) + { + rOutStm << "SFX_SLOT_PROPGET|"; + if( !GetReadonly() ) + rOutStm << "SFX_SLOT_PROPSET|"; + } + + rOutStm << '0'; + } + + if ( GetUnoName().Len() ) + { + rOutStm << ",\""; + rOutStm << GetUnoName().GetBuffer(); + rOutStm << "\""; + } + else + rOutStm << ", 0"; + + rOutStm << " )," << endl; +} + +USHORT SvMetaSlot::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + if ( !GetExport() && !GetHidden() ) + return 0; + + SvMetaAttribute * pMethod = GetMethod(); + if( IsMethod() ) + { + SvMetaType * pType; + if( pMethod ) + pType = pMethod->GetType(); + else + pType = GetType(); + + if( !rBase.FindType( pType, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pType ); + + const SvMetaAttributeMemberList & rList = + pType->GetAttrList(); + for( ULONG n = 0; n < rList.Count(); n++ ) + { + SvMetaAttribute * pPar = rList.GetObject( n ); + SvMetaType * pPType = pPar->GetType(); + WriteTab( rOutStm, 1 ); + rOutStm << "SFX_ARGUMENT(" + << pPar->GetSlotId().GetBuffer() << ',' // SlodId + // Parameter Name + << "\"" << pPar->GetName().GetBuffer() << "\"," + // Item Name + << pPType->GetName().GetBuffer() << ")," << endl; + if( !rBase.FindType( pPType, rBase.aUsedTypes ) ) + rBase.aUsedTypes.Append( pPType ); + } + return (USHORT)rList.Count(); + } + return 0; +} + +USHORT SvMetaSlot::WriteSlotMap( const ByteString & rShellName, USHORT nCount, + SvSlotElementList& rSlotList, + const ByteString & rPrefix, + SvIdlDataBase & rBase, + SvStream & rOutStm ) +{ + // SlotId, wenn nicht angegeben, aus Namen generieren + ByteString aSlotId = GetSlotId(); + + USHORT nSCount = 0; + if( IsMethod() ) + { + SvMetaType * pType; + SvMetaAttribute * pMethod = GetMethod(); + if( pMethod ) + pType = pMethod->GetType(); + else + pType = GetType(); + + nSCount = (USHORT)pType->GetAttrCount(); + } + + WriteSlot( rShellName, nCount, aSlotId, ByteString(), + rSlotList, rPrefix, rBase, rOutStm ); +/* + SvMetaTypeEnum * pEnum = NULL; + SvMetaType * pBType = GetType()->GetBaseType(); + pEnum = PTR_CAST( SvMetaTypeEnum, pBType ); + if( aPseudoSlots && pEnum ) + { + rBase.nMasterPos = rBase.nSlotPos-1; + rBase.nEnumPos = rBase.nMasterPos + pEnum->Count() + 1; + + for( ULONG n = 0; n < pEnum->Count(); n++ ) + { + ByteString aValName = pEnum->GetObject( n )->GetName(); + ByteString aSId( aSlotId ); + if( GetPseudoPrefix().Len() ) + aSId = GetPseudoPrefix(); + aSId += '_'; + USHORT nLen = pEnum->GetPrefix().Len(); + aSId += aValName.Copy( pEnum->GetPrefix().Len() ); + WriteSlot( rShellName, nCount + nSCount, aSId, aValName, rSlotList, rBase, rOutStm ); + } + } +*/ + return nSCount; +} + +/************************************************************************* +|* SvMetaSlot::WriteSrc() +*************************************************************************/ +void SvMetaSlot::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ) +{ + if (!GetToolBoxConfig() && !GetAccelConfig() && !GetMenuConfig() && !GetStatusBarConfig() ) + return; + + ULONG nSId = GetSlotId().GetValue(); + if( !pTable->IsKeyValid( nSId ) ) + { + pTable->Insert( nSId, this ); + rOutStm << "SfxSlotInfo " << ByteString::CreateFromInt32( nSId ).GetBuffer() + << endl << '{' << endl; + + WriteTab( rOutStm, 1 ); + ByteString aStr = GetConfigName(); + if( !aStr.Len() ) + aStr = GetName(); + + rOutStm << "SlotName = \"" << aStr.GetBuffer() << "\";" << endl; + + aStr = GetHelpText(); + if( aStr.Len() ) + { + WriteTab( rOutStm, 1 ); + rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl; + } + + rOutStm << "};" << endl; + } + + SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() ); + if( GetPseudoSlots() && pEnum ) + { + for( ULONG n = 0; n < pEnum->Count(); n++ ) + { + ByteString aValName = pEnum->GetObject( n )->GetName(); + ByteString aSId( GetSlotId() ); + if( GetPseudoPrefix().Len() ) + aSId = GetPseudoPrefix(); + aSId += '_'; + USHORT nLen = pEnum->GetPrefix().Len(); + aSId += aValName.Copy( pEnum->GetPrefix().Len() ); + + ULONG nSId; + BOOL bIdOk = FALSE; + if( rBase.FindId( aSId, &nSId ) ) + { + aSId = ByteString::CreateFromInt32( nSId ); + bIdOk = TRUE; + } + + // wenn Id nicht gefunden, immer schreiben + if( !bIdOk || !pTable->IsKeyValid( nSId ) ) + { + pTable->Insert( nSId, this ); + rOutStm << "SfxSlotInfo " << aSId.GetBuffer() + << endl << '{' << endl; + + WriteTab( rOutStm, 1 ); + rOutStm << "SlotName = \"" << aValName.GetBuffer() << "\";" << endl; + + ByteString aStr = GetHelpText(); + if( aStr.Len() ) + { + WriteTab( rOutStm, 1 ); + rOutStm << "HelpText = \"" << aStr.GetBuffer() << "\";" << endl; + } + rOutStm << "};" << endl; + } + } + } +} + +void SvMetaSlot::WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pTable ) +{ + ULONG nSId = GetSlotId().GetValue(); + if( !pTable->IsKeyValid( nSId ) ) + { + pTable->Insert( nSId, this ); + rOutStm << "#define " << GetSlotId().GetBuffer() << '\t' << ByteString::CreateFromInt32( nSId ).GetBuffer() << endl; + } + + SvMetaTypeEnum * pEnum = PTR_CAST( SvMetaTypeEnum, GetType() ); + if( GetPseudoSlots() && pEnum ) + { + for( ULONG n = 0; n < pEnum->Count(); n++ ) + { + ByteString aValName = pEnum->GetObject( n )->GetName(); + ByteString aSId( GetSlotId() ); + if( GetPseudoPrefix().Len() ) + aSId = GetPseudoPrefix(); + aSId += '_'; + USHORT nLen = pEnum->GetPrefix().Len(); + aSId += aValName.Copy( pEnum->GetPrefix().Len() ); + + ULONG nSId; + BOOL bIdOk = FALSE; + if( rBase.FindId( aSId, &nSId ) ) + { + aSId = ByteString::CreateFromInt32( nSId ); + bIdOk = TRUE; + } + + // wenn Id nicht gefunden, immer schreiben + if( !bIdOk || !pTable->IsKeyValid( nSId ) ) + { + pTable->Insert( nSId, this ); + + rOutStm << "#define " << aSId.GetBuffer() << '\t' + << ByteString::CreateFromInt32( nSId ).GetBuffer() << endl; + } + } + } +} + + +void SvMetaSlot::CompareSlotAttributes( SvMetaSlot* pSlot ) +{ + ByteString aStr = Compare( pSlot ); + + if ( GetMenuConfig() || GetToolBoxConfig() || GetAccelConfig() || GetStatusBarConfig() ) + { + if ( GetHelpText().Len() ) + { + ByteString aRefText( pSlot->GetHelpText() ); + ByteString aText( GetHelpText() ); + if ( !aText.Equals( aRefText ) ) + { + aStr += " HelpText\n"; + aStr += aText; + aStr += '\n'; + aStr += aRefText; + aStr += '\n'; + } + } + + if ( GetConfigName().Len() ) + { + ByteString aRefText( pSlot->GetConfigName() ); + ByteString aText( GetConfigName() ); + if ( !aText.Equals( aRefText ) ) + { + aStr += " ConfigName\n"; + aStr += aText; + aStr += '\n'; + aStr += aRefText; + aStr += '\n'; + } + } + } + + if ( GetExport() && !GetName().Equals( pSlot->GetName() ) ) + { + aStr += " Name\n"; + aStr += GetName(); + aStr += '\n'; + aStr += pSlot->GetName(); + aStr += '\n'; + } + + if ( (SvMetaType *)GetSlotType() != (SvMetaType *)pSlot->GetSlotType() ) + aStr += " SlotType\n"; + + if ( GetMethod() && !pSlot->GetMethod() || + !GetMethod() && pSlot->GetMethod() ) + aStr += " Method\n"; + + if ( GetMethod() && pSlot->GetMethod() ) + GetMethod()->Compare( pSlot->GetMethod() ); + + if ( !GetGroupId().Equals( pSlot->GetGroupId() ) ) + aStr += " GroupId\n"; + + if ( GetHasCoreId() != (BOOL) pSlot->GetHasCoreId() ) + aStr += " HasCoreId\n"; + + if ( !GetConfigId().Equals( pSlot->GetConfigId() ) ) + aStr += " ConfigId\n"; + + if ( !GetDefault().Equals( pSlot->GetDefault() ) ) + aStr += " Default\n"; + + if ( GetPseudoSlots() != pSlot->GetPseudoSlots() ) + aStr += " PseudoSlots\n"; + + if ( GetCachable() != pSlot->GetCachable() ) + aStr += " Cachable\n"; + + if ( GetVolatile() != pSlot->GetVolatile() ) + aStr += " Volatile"; + + if ( GetToggle() != pSlot->GetToggle() ) + aStr += " Toggle\n"; + + if ( GetAutoUpdate() != pSlot->GetAutoUpdate() ) + aStr += " AutoUpdate\n"; + + if ( GetSynchron() != pSlot->GetSynchron() ) + aStr += " Synchron\n"; + + if ( GetAsynchron() != pSlot->GetAsynchron() ) + aStr += " Asynchron\n"; + + if ( GetRecordPerItem() != pSlot->GetRecordPerItem() ) + aStr += " RecordPerItem\n"; + + if ( GetRecordPerSet() != pSlot->GetRecordPerSet() ) + aStr += " RecordPerSet\n"; + + if ( GetRecordManual() != pSlot->GetRecordManual() ) + aStr += " RecordManual\n"; + + if ( GetNoRecord() != pSlot->GetNoRecord() ) + aStr += " NoRecord\n"; + + if ( GetRecordAbsolute() != pSlot->GetRecordAbsolute() ) + aStr += " RecordAbsolute\n"; + + if ( GetHasDialog() != pSlot->GetHasDialog() ) + aStr += " HasDialog\n"; + + if ( GetMenuConfig() != pSlot->GetMenuConfig() ) + aStr += " MenuConfig\n"; + + if ( GetToolBoxConfig() != pSlot->GetToolBoxConfig() ) + aStr += " ToolBoxConfig\n"; + + if ( GetStatusBarConfig() != pSlot->GetStatusBarConfig() ) + aStr += " StatusBarConfig\n"; + + if ( GetAccelConfig() != pSlot->GetAccelConfig() ) + aStr += " AccelConfig\n"; + + if ( pSlot->GetFastCall() && !GetFastCall() ) + aStr += " FastCall\n"; + + if ( GetContainer() != pSlot->GetContainer() ) + aStr += " Container\n"; + + if ( GetPlugComm() != pSlot->GetPlugComm() ) + aStr += " PlugComm\n"; + + if ( !GetPseudoPrefix().Equals( pSlot->GetPseudoPrefix() ) ) + aStr += " PseudoPrefix\n"; + + if ( IsVariable() != pSlot->IsVariable() ) + aStr += " Variable\n"; + + if ( aStr.Len() ) + { + DBG_ERROR( GetSlotId().GetBuffer() ); + DBG_ERROR( aStr.GetBuffer() ); + } +} + +void WriteBool( BOOL bSet, SvStream& rStream ) +{ + if ( bSet ) + rStream << "TRUE" << ','; + else + rStream << "FALSE" << ','; +} + +void SvMetaSlot::WriteCSV( SvIdlDataBase& rBase, SvStream& rStrm ) +{ + rStrm << "PROJECT" << ",,"; + if ( GetSlotType() ) + rStrm << GetSlotType()->GetName().GetBuffer() << ','; + else + rStrm << ','; + + rStrm << GetType()->GetSvName().GetBuffer() << ','; + rStrm << GetName().GetBuffer() << ','; + rStrm << GetUnoName().GetBuffer() << ','; + rStrm << GetSlotId().GetBuffer() << ','; + USHORT nId = (USHORT) GetSlotId().GetValue(); + rStrm << ByteString::CreateFromInt32( GetSlotId().GetValue() ).GetBuffer() << ','; + rStrm << "\"" << GetConfigName().GetBuffer() << "\"" << ','; + rStrm << "\"" << GetHelpText().GetBuffer() << "\"" << ','; + + rStrm << ",,,"; + + WriteBool( GetAccelConfig(), rStrm ); + WriteBool( GetAutomation(), rStrm ); + WriteBool( GetAutoUpdate(), rStrm ); + + if ( GetCachable() ) + rStrm << "Cachable" << ','; + else + rStrm << "Volatile" << ','; + + WriteBool( GetContainer(), rStrm ); + WriteBool( GetExport(), rStrm ); + WriteBool( GetFastCall(), rStrm ); + WriteBool( GetHidden(), rStrm ); + + rStrm << GetGroupId().GetBuffer() << ','; + + rStrm << ','; + rStrm << GetDisableFlags().GetBuffer() << ','; + + WriteBool( GetHasCoreId(), rStrm ); + WriteBool( GetHasDialog(), rStrm ); + WriteBool( GetIsCollection(), rStrm ); + WriteBool( GetMenuConfig(), rStrm ); + WriteBool( GetPlugComm(), rStrm ); + WriteBool( GetReadonly(), rStrm ); + WriteBool( GetReadOnlyDoc(), rStrm ); + + if( GetRecordPerSet() ) + rStrm << "RecordPerSet" << ','; + else + rStrm << "RecordPerItem" << ','; + + WriteBool( GetRecordAbsolute(), rStrm ); + + rStrm << ','; + + WriteBool( GetStatusBarConfig(), rStrm ); + + if( GetSynchron() ) + rStrm << "Synchron" << ','; + else + rStrm << "Asynchron" << ','; + + WriteBool( GetToggle(), rStrm ); + WriteBool( GetToolBoxConfig(), rStrm ); + + if ( GetPseudoPrefix().Len() ) + rStrm << GetPseudoPrefix().GetBuffer() << ','; + else + rStrm << ','; + + rStrm << ','; + + if ( GetType()->GetType() != TYPE_METHOD && GetMethod() ) + { + rStrm << GetMethod()->GetType()->GetReturnType()->GetName().GetBuffer() << ','; + rStrm << GetMethod()->GetName().GetBuffer() << ','; + } + else + { + rStrm << ",,"; + } + + rStrm << "TRUE,"; + + if ( GetType()->GetType() == TYPE_METHOD || GetMethod() ) + { + SvMetaAttributeMemberList *pList = &GetType()->GetAttrList(); + if ( GetMethod() ) + pList = &GetMethod()->GetType()->GetAttrList(); + + if( pList && pList->Count() ) + { + rStrm << "\"("; + SvMetaAttribute* pAttr = pList->First(); + while( pAttr ) + { + pAttr->WriteCSV( rBase, rStrm ); + pAttr = pList->Next(); + if( pAttr ) + rStrm << ','; + } + rStrm << ")\""; + } + else + rStrm << "()"; + } + + rStrm << endl; +} + +#endif // IDL_COMPILER + + diff --git a/idl/source/objects/types.cxx b/idl/source/objects/types.cxx new file mode 100644 index 000000000000..82ea116b4d39 --- /dev/null +++ b/idl/source/objects/types.cxx @@ -0,0 +1,2840 @@ +/************************************************************************* + * + * $RCSfile: types.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include + +#include + +#include +#include +#include +#include +#pragma hdrstop + +/****************** SvMetaAttribute *************************************/ +/************************************************************************/ +SV_IMPL_META_FACTORY1( SvMetaAttribute, SvMetaReference ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaAttribute::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* SvMetaAttribute::SvMetaAttribute() +|* +|* Beschreibung +*************************************************************************/ +SvMetaAttribute::SvMetaAttribute() + : aExport( TRUE, FALSE ) + , aHidden( FALSE, FALSE ) + , aIsCollection ( FALSE, FALSE ) + , aReadOnlyDoc ( TRUE, FALSE ) + , aAutomation( TRUE, FALSE ) + , bNewAttr( FALSE ) +{ +} + +SvMetaAttribute::SvMetaAttribute( SvMetaType * pType ) + : aExport( TRUE, FALSE ) + , aHidden( FALSE, FALSE ) + , aAutomation( TRUE, FALSE ) + , aIsCollection ( FALSE, FALSE) + , aReadOnlyDoc ( TRUE, FALSE) + , aType( pType ) + , bNewAttr( FALSE ) +{ +} + +/************************************************************************* +|* SvMetaAttribute::Load() +|* SvMetaAttribute::Save() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::Load( SvPersistStream & rStm ) +{ + SvMetaReference::Load( rStm ); + + BYTE nMask; + rStm >> nMask; + if( nMask >= 0x100 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) + { + SvMetaType * pType; + rStm >> pType; + aType = pType; + } + if( nMask & 0x02 ) rStm >> aSlotId; + if( nMask & 0x04 ) rStm >> aExport; + if( nMask & 0x08 ) rStm >> aReadonly; + if( nMask & 0x10 ) rStm >> aAutomation; + if( nMask & 0x20 ) rStm >> aIsCollection; + if( nMask & 0x40 ) rStm >> aReadOnlyDoc; + if( nMask & 0x80 ) rStm >> aHidden; +} + +void SvMetaAttribute::Save( SvPersistStream & rStm ) +{ + SvMetaReference::Save( rStm ); + + // Maske erstellen + BYTE nMask = 0; + if( aType.Is() ) nMask |= 0x1; + if( aSlotId.IsSet() ) nMask |= 0x2; + if( aExport.IsSet() ) nMask |= 0x4; + if( aReadonly.IsSet() ) nMask |= 0x8; + if( aAutomation.IsSet() ) nMask |= 0x10; + if( aIsCollection.IsSet() ) nMask |= 0x20; + if( aReadOnlyDoc.IsSet() ) nMask |= 0x40; + if( aHidden.IsSet() ) nMask |= 0x80; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x1 ) rStm << aType; + if( nMask & 0x2 ) rStm << aSlotId; + if( nMask & 0x4 ) rStm << aExport; + if( nMask & 0x8 ) rStm << aReadonly; + if( nMask & 0x10 ) rStm << aAutomation; + if( nMask & 0x20 ) rStm << aIsCollection; + if( nMask & 0x40 ) rStm << aReadOnlyDoc; + if( nMask & 0x80 ) rStm << aHidden; +} + +/************************************************************************* +|* SvMetaAttribute::GetType() +|* +|* Beschreibung +*************************************************************************/ +SvMetaType * SvMetaAttribute::GetType() const +{ + if( aType.Is() || !GetRef() ) return aType; + return ((SvMetaAttribute *)GetRef())->GetType(); +} + +/************************************************************************* +|* SvMetaAttribute::GetSlotId() +|* +|* Beschreibung +*************************************************************************/ +const SvNumberIdentifier & SvMetaAttribute::GetSlotId() const +{ + if( aSlotId.IsSet() || !GetRef() ) return aSlotId; + return ((SvMetaAttribute *)GetRef())->GetSlotId(); +} + +/************************************************************************* +|* SvMetaAttribute::GetReadonly() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaAttribute::GetReadonly() const +{ + if( aReadonly.IsSet() || !GetRef() ) return aReadonly; + return ((SvMetaAttribute *)GetRef())->GetReadonly(); +} + +/************************************************************************* +|* SvMetaAttribute::GetExport() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaAttribute::GetExport() const +{ + if( aExport.IsSet() || !GetRef() ) return aExport; + return ((SvMetaAttribute *)GetRef())->GetExport(); +} + +/************************************************************************* +|* SvMetaAttribute::GetHidden() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaAttribute::GetHidden() const +{ + // Wenn Export gesetzt wurde, aber Hidden nicht, gilt der Default + // aHidden = !aExport + if ( aExport.IsSet() && !aHidden.IsSet() ) + return !aExport; + else if( aHidden.IsSet() || !GetRef() ) + return aHidden; + else + return ((SvMetaAttribute *)GetRef())->GetHidden(); +} + +/************************************************************************* +|* SvMetaAttribute::GetAutomation() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaAttribute::GetAutomation() const +{ + if( aAutomation.IsSet() || !GetRef() ) return aAutomation; + return ((SvMetaAttribute *)GetRef())->GetAutomation(); +} + +BOOL SvMetaAttribute::GetIsCollection() const +{ + BOOL bRet; + if( aIsCollection.IsSet() || !GetRef() ) + { + if ( aIsCollection.IsSet() ) + { + bRet = aIsCollection; + return bRet; + } + + return aIsCollection; + } + + return ((SvMetaSlot *)GetRef())->GetIsCollection(); +} + +BOOL SvMetaAttribute::GetReadOnlyDoc() const +{ + if( aReadOnlyDoc.IsSet() || !GetRef() ) return aReadOnlyDoc; + return ((SvMetaSlot *)GetRef())->GetReadOnlyDoc(); +} + +/************************************************************************* +|* SvMetaAttribute::IsMethod() +|* SvMetaAttribute::IsVariable() +|* SvMetaAttribute::GetMangleName() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaAttribute::IsMethod() const +{ + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ) + return pType->GetType() == TYPE_METHOD; +} + +BOOL SvMetaAttribute::IsVariable() const +{ + SvMetaType * pType = GetType(); + return pType->GetType() != TYPE_METHOD; +} + +ByteString SvMetaAttribute::GetMangleName( BOOL bVariable ) const +{ + return GetName(); +} + +/************************************************************************* +|* SvMetaAttribute::FillSbxObject() +|* +|* Beschreibung +*************************************************************************/ +/* +void SvMetaAttribute::FillSbxObject( SbxInfo * pInfo, USHORT nSbxFlags ) +{ + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ) + if( !nSbxFlags ) + { // Flags koennen vom Aufrufer ueberschrieben werden + if( pType->GetOut() ) + { + nSbxFlags |= SBX_WRITE; + if( pType->GetIn() ) + nSbxFlags |= SBX_READ; + } + else + nSbxFlags |= SBX_READ; + } + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ) + if( pBaseType->GetType() == TYPE_STRUCT ) + { + const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList(); + ULONG nCount = rList.Count(); + for( ULONG i = 0; i < nCount; i++ ) + rList.GetObject( i )->FillSbxObject( pInfo, nSbxFlags ); + } + else + //MI: pInfo->AddParam( GetName(), pBaseType->GetSbxDataType(), nSbxFlags ); + pInfo->AddParam( GetName(), SbxVARIANT, nSbxFlags ); +} +*/ + +/************************************************************************* +|* SvMetaAttribute::FillSbxObject() +|* +|* Beschreibung +*************************************************************************/ +/* +void SvMetaAttribute::FillSbxObject( SvIdlDataBase & rBase, + SbxObject * pObj, BOOL bVariable ) +{ + // keine Attribut fuer Automation + if( !GetAutomation() || !GetExport() ) + return; + + if( bVariable && IsVariable() ) + { + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ) + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ) + + if( pBaseType->GetType() == TYPE_STRUCT ) + { + SvNumberIdentifier aSlotId = rBase.aStructSlotId; + if ( GetSlotId().Len() ) + rBase.aStructSlotId = GetSlotId(); + const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList(); + ULONG nCount = rList.Count(); + for( ULONG i = 0; i < nCount; i++ ) + rList.GetObject( i )->FillSbxObject( rBase, pObj, bVariable ); + rBase.aStructSlotId = aSlotId; + } + else + { + SbxPropertyRef xProp = new SbxProperty( GetName(), SbxVARIANT ); + //MI: pBaseType->GetSbxDataType() ); + if ( GetReadonly() || IsMethod() ) + xProp->ResetFlag( SBX_WRITE ); + xProp->SetUserData( MakeSlotValue( rBase, TRUE ) ); + pType->FillSbxObject( xProp, bVariable ); + + pObj->Insert( &xProp ); + } + } + else if( !bVariable && IsMethod() ) + { + SvMetaType * pType = GetType(); + SvMetaType * pRetBaseType = GetType()->GetReturnType()->GetBaseType(); + SbxMethodRef xMeth = new SbxMethod( GetName(), + pRetBaseType->GetSbxDataType() ); + xMeth->ResetFlag( SBX_WRITE ); + xMeth->SetUserData( MakeSlotValue( rBase, FALSE ) ); + pType->FillSbxObject( xMeth, bVariable ); + + pObj->Insert( &xMeth ); + } +} +*/ +#ifdef IDL_COMPILER +/************************************************************************* +|* SvMetaAttribute::Test() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaAttribute::Test( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + BOOL bOk = TRUE; + if( GetType()->IsItem() && !GetSlotId().IsSet() ) + { + rBase.SetError( "slot without id declared", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = FALSE; + } + /* + if( !GetType()->IsItem() && GetSlotId().IsSet() ) + { + rBase.SetError( "slot without item declared", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + bOk = FALSE; + } + */ + return bOk; +} + +/************************************************************************* +|* SvMetaAttribute::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaAttribute::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken(); + if( !GetType() ) + // Es wurde kein Typ im ctor mitgegeben + aType = rBase.ReadKnownType( rInStm ); + BOOL bOk = FALSE; + if( GetType() ) + { + ReadNameSvIdl( rBase, rInStm ); + aSlotId.ReadSvIdl( rBase, rInStm ); + + bOk = TRUE; + SvToken * pTok = rInStm.GetToken(); + if( bOk && pTok->IsChar() && pTok->GetChar() == '(' ) + { + SvMetaTypeRef xT = new SvMetaType(); + xT->SetRef( GetType() ); + aType = xT; + bOk = aType->ReadMethodArgs( rBase, rInStm ); + } + if( bOk ) + bOk = SvMetaName::ReadSvIdl( rBase, rInStm ); + } + else + rBase.SetError( "unknown type", rInStm.GetToken() ); + + if( !bOk ) + rInStm.Seek( nTokPos ); + return bOk; +} + +/************************************************************************* +|* SvMetaAttribute::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::WriteSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab +) +{ + SvMetaType * pType = GetType(); + pType->WriteTypePrefix( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ' ' << GetName().GetBuffer(); + if( aSlotId.IsSet() ) + rOutStm << ' ' << aSlotId.GetBuffer(); + if( pType->GetType() == TYPE_METHOD ) + pType->WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL ); + ULONG nPos = rOutStm.Tell(); + rOutStm << endl; + SvMetaName::WriteSvIdl( rBase, rOutStm, nTab ); + TestAndSeekSpaceOnly( rOutStm, nPos ); +} + +/************************************************************************* +|* SvMetaAttribute::ReadAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaReference::ReadAttributesSvIdl( rBase, rInStm ); + aSlotId.ReadSvIdl( rBase, SvHash_SlotId(), rInStm ); + aExport.ReadSvIdl( SvHash_Export(), rInStm ); + aHidden.ReadSvIdl( SvHash_Hidden(), rInStm ); + aAutomation.ReadSvIdl( SvHash_Automation(), rInStm ); + aIsCollection.ReadSvIdl( SvHash_IsCollection(), rInStm ); + aReadOnlyDoc.ReadSvIdl( SvHash_ReadOnlyDoc(), rInStm ); + if( aReadonly.ReadSvIdl( SvHash_Readonly(), rInStm ) ) + { + if( GetType()->GetType() == TYPE_METHOD ) + { + // Fehler setzen + rBase.SetError( "Readonly in function attribute", rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } +} + +/************************************************************************* +|* SvMetaAttribute::WriteAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::WriteAttributesSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab +) +{ + SvMetaReference::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + + //aSlotId.WriteSvIdl( SvHash_SlotId(), rOutStm, nTab ); + if( !aExport || !aAutomation || aReadonly ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "//class SvMetaAttribute" << endl; + if( !aExport ) + { + WriteTab( rOutStm, nTab ); + aExport.WriteSvIdl( SvHash_Export(), rOutStm ); + rOutStm << ';' << endl; + } + if ( aHidden != aExport ) + { + WriteTab( rOutStm, nTab ); + aExport.WriteSvIdl( SvHash_Hidden(), rOutStm ); + rOutStm << ';' << endl; + } + if( aReadonly ) + { + WriteTab( rOutStm, nTab ); + aReadonly.WriteSvIdl( SvHash_Readonly(), rOutStm ); + rOutStm << ';' << endl; + } + if( !aAutomation ) + { + WriteTab( rOutStm, nTab ); + aAutomation.WriteSvIdl( SvHash_Automation(), rOutStm ); + rOutStm << ';' << endl; + } + if( aIsCollection ) + { + WriteTab( rOutStm, nTab ); + aIsCollection.WriteSvIdl( SvHash_IsCollection(), rOutStm ); + rOutStm << ';' << endl; + } + if( !aReadOnlyDoc ) + { + WriteTab( rOutStm, nTab ); + aReadOnlyDoc.WriteSvIdl( SvHash_ReadOnlyDoc(), rOutStm ); + rOutStm << ';' << endl; + } + } +} + +/************************************************************************* +|* SvMetaAttribute::WriteParam() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::WriteParam( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab, + WriteType nT ) +{ + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ) + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ) + + if( nT == WRITE_ODL || nT == WRITE_DOCU + || nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + if( pBaseType->GetType() == TYPE_STRUCT ) + { + const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList(); + ULONG nCount = rList.Count(); + for( ULONG i = 0; i < nCount; i++ ) + { + rList.GetObject( i )->WriteParam( rBase, rOutStm, nTab, nT ); + if( i+1WriteTypePrefix( rBase, rOutStm, nTab, nT ); + } + + if( GetName().Len() ) + { + rOutStm << ' '; + rOutStm << GetName().GetBuffer(); + } + + if ( nT == WRITE_DOCU ) + { + if( pBaseType->GetType() == TYPE_METHOD || + pBaseType->GetType() == TYPE_STRUCT || + pBaseType->GetType() == TYPE_ENUM ) + { + DBG_ERROR( "Falscher Parametertyp!" ); + } + else + rOutStm << pBaseType->GetBasicPostfix().GetBuffer(); + } + } + } +/* + else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + rOutStm << ' '; + rOutStm << GetName().GetBuffer(); + } +*/ +} + +/************************************************************************* +|* SvMetaSlot::WriteSlotId() +|* +|* Beschreibung +*************************************************************************/ +ULONG SvMetaAttribute::MakeSlotValue( SvIdlDataBase & rBase, BOOL bVar ) const +{ + const SvNumberIdentifier & rId = GetSlotId(); + ULONG n = rId.GetValue(); + if( rBase.aStructSlotId.Len() ) + { + n = n << 20; + n += rBase.aStructSlotId.GetValue(); + } + if( PTR_CAST( SvMetaSlot, this ) ) + n |= 0x20000; + if( !bVar ) + n += 0x10000; + else if ( GetIsCollection() ) + n += 0x40000; + return n; +} + +/************************************************************************* +|* SvMetaSlot::WriteAttributes() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + if( nT == WRITE_ODL ) + { + const SvNumberIdentifier & rId = GetSlotId(); + BOOL bReadonly = GetReadonly() || ( nA & WA_READONLY ); + if( (rId.IsSet() && !(nA & WA_STRUCT)) || bReadonly ) + { + BOOL bVar = IsVariable(); + if( nA & WA_VARIABLE ) + bVar = TRUE; + else if( nA & WA_METHOD ) + bVar = FALSE; + + WriteTab( rOutStm, nTab ); + rOutStm << "//class SvMetaAttribute" << endl; + if( rId.IsSet() && !(nA & WA_STRUCT) ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "id(" + << ByteString::CreateFromInt32(MakeSlotValue( rBase, bVar )).GetBuffer() + << ")," << endl; + } + if( bVar && (bReadonly || IsMethod()) ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "readonly," << endl; + } + } + } +} + +/************************************************************************* +|* SvMetaAttribute::WriteCSource() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::WriteCSource( SvIdlDataBase & rBase, SvStream & rOutStm, + BOOL bSet ) +{ + rOutStm << endl; + SvMetaType * pType = GetType(); + SvMetaType * pBaseType = pType->GetBaseType(); + + // Bei Set ist der Return immer void + BOOL bVoid = bSet; + if( pBaseType->GetType() == TYPE_METHOD ) + bVoid = pBaseType->GetReturnType()->GetBaseType()->GetName() == "void"; + + // Methoden/Funktions-Body ausgeben + rOutStm << '{' << endl; + WriteTab( rOutStm, 1 ); +// rOutStm << "if( SvIPCIsConnected() )" << endl; +// WriteTab( rOutStm, 1 ); +// rOutStm << '{' << endl; +// WriteTab( rOutStm, 2 ); + + if( !bVoid ) + { + if ( pBaseType->GetCName() == "double" ) + { + rOutStm << "return *(double*)"; + } + else + { + rOutStm << "return ("; + pType->WriteTypePrefix( rBase, rOutStm, 2, WRITE_C_SOURCE ); + rOutStm << ") "; + } + } + rOutStm << "pODKCallFunction( " + << ByteString::CreateFromInt32(MakeSlotValue( rBase, IsVariable() )).GetBuffer(); + rOutStm << ',' << endl; + WriteTab( rOutStm, 3 ); + rOutStm << " h" << rBase.aIFaceName.GetBuffer() << " , "; + + ByteString aParserStr; + if( pBaseType->GetType() == TYPE_METHOD || bSet ) + aParserStr = pBaseType->GetParserString(); + if( aParserStr.Len() ) + { + rOutStm << '\"'; + rOutStm << aParserStr.GetBuffer(); + rOutStm << "\", "; + } + else + rOutStm << "NULL, "; + + if( pBaseType->GetType() == TYPE_METHOD && !bVoid ) + { + rOutStm << "'"; + rOutStm << pBaseType->GetReturnType()->GetBaseType()->GetParserChar(); + rOutStm << "'"; + } + else if ( !bSet ) + { + rOutStm << "'"; + rOutStm << pBaseType->GetParserChar(); + rOutStm << "'"; + } + else + rOutStm << '0'; + + if( aParserStr.Len() ) + { + rOutStm << ", "; + if( IsMethod() ) + // void SetPosSize( C_Object *, C_Rectangle * pRect ); + pBaseType->WriteParamNames( rBase, rOutStm, ByteString() ); + else if( bSet ) + pBaseType->WriteParamNames( rBase, rOutStm, GetName() ); + } + + rOutStm << " );" << endl; +// WriteTab( rOutStm, 1 ); +// rOutStm << '}' << endl; +// if( !bVoid ) +// { +// WriteTab( rOutStm, 1 ); +// rOutStm << "return 0;" << endl; +// } + rOutStm << '}' << endl; +} + +/************************************************************************* +|* SvMetaAttribute::WriteRecursiv_Impl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::WriteRecursiv_Impl( SvIdlDataBase & rBase, + SvStream & rOutStm, USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + const SvMetaAttributeMemberList & rList = GetType()->GetBaseType()->GetAttrList(); + ULONG nCount = rList.Count(); + + SvNumberIdentifier aSlotId = rBase.aStructSlotId; + if ( GetSlotId().Len() ) + rBase.aStructSlotId = GetSlotId(); + + // Offizielle Hack-Schnittstelle von MM: spezielle Schalter werden "uber + // die WriteAttribute "ubergeben + if ( GetReadonly() ) + nA |= WA_READONLY; + + for( ULONG i = 0; i < nCount; i++ ) + { + SvMetaAttribute *pAttr = rList.GetObject( i ); + if ( nT == WRITE_DOCU ) + pAttr->SetDescription( GetDescription() ); + pAttr->Write( rBase, rOutStm, nTab, nT, nA ); + if( nT == WRITE_ODL && i +1 < nCount ) + rOutStm << ';' << endl; + } + + rBase.aStructSlotId = aSlotId; +} + +/************************************************************************* +|* SvMetaAttribute::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + // keine Attribut fuer Automation + if( nT == WRITE_DOCU ) + { + if ( GetHidden() ) + return; + } + else if ( !GetAutomation() || !GetExport() ) + return; + + BOOL bVariable; + if( nA & WA_VARIABLE ) + bVariable = TRUE; + else if( nA & WA_METHOD ) + bVariable = FALSE; + else + bVariable = IsVariable(); + + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ) + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ) + int nBType = pBaseType->GetType(); + + if( nT == WRITE_ODL ) + { + if( (bVariable && IsVariable()) || (!bVariable && IsMethod()) ) + { + if( nBType == TYPE_STRUCT ) + WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA ); + else + { + SvMetaReference::Write( rBase, rOutStm, nTab, nT, nA ); + WriteTab( rOutStm, nTab ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + + if( GetName().Len() ) + { + rOutStm << ' '; + rOutStm << GetName().GetBuffer(); + } + if( pType->GetType() == TYPE_METHOD ) + pType->WriteMethodArgs( rBase, rOutStm, nTab, nT ); + } + } + } + else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + if( !bVariable && IsMethod() ) + { + ByteString aName; // (rBase.GetActModulePrefix()); + aName += rBase.aIFaceName; + aName += GetName(); + const char * pName = aName.GetBuffer(); + // Beispiel + // void SetPosSize( C_Object *, C_Rectangle * ); + WriteTab( rOutStm, nTab ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); +// rOutStm << " SYSCALL"; + rOutStm << ' ' << pName; + pType->WriteMethodArgs( rBase, rOutStm, nTab, nT ); + if( nT == WRITE_C_HEADER ) + rOutStm << ';' << endl << endl; + else + WriteCSource( rBase, rOutStm, FALSE ); + } + else if ( bVariable && IsVariable() ) + { + if( nBType == TYPE_STRUCT ) + { + // Zur Hilfe den Namen des Properties als Kommentar ausgeben + rOutStm << "/* " << GetName().GetBuffer() << " */" << endl; + + WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA ); + } + else + { + // Beispiel + // void SetValue( C_Object *, USHORT n ); + ByteString aName = GetName(); + + BOOL bReadonly = GetReadonly() || ( nA & WA_READONLY ); + if ( !bReadonly && !IsMethod() ) + { + // Zuweisung + WriteTab( rOutStm, nTab ); + rOutStm << "void "; +// rOutStm << "SYSCALL "; +// if ( rBase.GetActModulePrefix().Len() ) +// rOutStm << rBase.GetActModulePrefix().GetBuffer(); + rOutStm << rBase.aIFaceName.GetBuffer() + << "Set" << aName.GetBuffer() << "( " << C_PREF + << "Object h" << rBase.aIFaceName.GetBuffer() << ", " << endl; + WriteTab( rOutStm, nTab+1 ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + rOutStm << ' ' << aName.GetBuffer() << " )"; + if( nT == WRITE_C_HEADER ) + rOutStm << ';' << endl << endl; + else + WriteCSource( rBase, rOutStm, TRUE ); + } + + // Zugriff + WriteTab( rOutStm, nTab ); + pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT ); + rOutStm << ' '; +// rOutStm << "SYSCALL "; +// if ( rBase.GetActModulePrefix().Len() ) +// rOutStm << rBase.GetActModulePrefix().GetBuffer(); + rOutStm << rBase.aIFaceName.GetBuffer() + << "Get" << aName.GetBuffer() << "( " << C_PREF + << "Object h" << rBase.aIFaceName.GetBuffer() << " )"; + if( nT == WRITE_C_HEADER ) + rOutStm << ';' << endl << endl; + else + WriteCSource( rBase, rOutStm, FALSE ); + } + } + } + else if ( nT == WRITE_DOCU ) + { + if( !bVariable && IsMethod() ) + { + rOutStm << "" << endl + << GetSlotId().GetBuffer() << endl + << GetName().GetBuffer() << endl + << endl; // readonly + + // Returntype + SvMetaType* pType = GetType(); + SvMetaType* pBaseType = pType->GetBaseType(); + rOutStm << pBaseType->GetReturnType()->GetBaseType()->GetBasicName().GetBuffer() << endl; + + DBG_ASSERT( pBaseType->GetReturnType()->GetBaseType()->GetBasicName().Len(), + "Leerer BasicName" ); + + // Syntax + rOutStm << GetName().GetBuffer(); + pType->WriteMethodArgs( rBase, rOutStm, nTab, nT ); + + // C-Returntype + pBaseType->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER ); + rOutStm << endl; + + // Bei Methoden auch C-Syntax + rOutStm << "" << endl; + Write( rBase, rOutStm, 0, WRITE_C_HEADER, nA ); + rOutStm << "" << endl; + + // Description + WriteDescription( rBase, rOutStm ); + rOutStm << "" << endl << endl; + } + else if( bVariable && IsVariable() ) + { + if( nBType == TYPE_STRUCT ) + { + WriteRecursiv_Impl( rBase, rOutStm, nTab, nT, nA ); + } + else + { + rOutStm << "" << endl + << GetSlotId().GetBuffer() << endl + << GetName().GetBuffer() << endl; + if ( GetReadonly() ) + rOutStm << "(nur lesen)" << endl; + else + rOutStm << endl; + + // Bei properties Type anstelle des return value + rOutStm << pBaseType->GetBasicName().GetBuffer() << endl; + + DBG_ASSERT( pBaseType->GetBasicName().Len(), + "Leerer BasicName" ); + + // Bei properties keine Syntax + rOutStm << endl; + + // C-Returntype + pBaseType->WriteTypePrefix( rBase, rOutStm, 0, WRITE_C_HEADER ); + rOutStm << endl; + + // Description + WriteDescription( rBase, rOutStm ); + rOutStm << "" << endl << endl; + } + } + } +} + +/************************************************************************* +|* SvMetaAttribute::MakeSfx() +|* +|* Beschreibung +*************************************************************************/ +ULONG SvMetaAttribute::MakeSfx( ByteString * pAttrArray ) +{ + SvMetaType * pType = GetType(); + DBG_ASSERT( pType, "no type for attribute" ) + SvMetaType * pBaseType = pType->GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ) + if( pBaseType->GetType() == TYPE_STRUCT ) + return pBaseType->MakeSfx( pAttrArray ); + else + { + *pAttrArray += '{'; + *pAttrArray += GetSlotId(); + *pAttrArray += ",\""; + *pAttrArray += GetName(); + *pAttrArray += "\"}"; + return 1; + } +} + +void SvMetaAttribute::Insert (SvSlotElementList&, const ByteString &, SvIdlDataBase&) +{ +} + +/************************************************************************* +|* SvMetaAttribute::WriteSrc() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaAttribute::WriteSrc( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ) +{ +} + +void SvMetaAttribute::WriteHelpId( SvIdlDataBase & rBase, SvStream & rOutStm, + Table * pIdTable ) +{ +} + +#endif // IDL_COMPILER + +/****************** SvMetaType *************************************/ +/************************************************************************/ +SV_IMPL_META_FACTORY1( SvMetaType, SvMetaExtern ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaType::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* SvMetaType::SvMetaType() +|* +|* Beschreibung +*************************************************************************/ +#define CTOR \ + : aCall0( CALL_VALUE, FALSE ) \ + , aCall1( CALL_VALUE, FALSE ) \ + , aSbxDataType( 0, FALSE ) \ + , pAttrList( NULL ) \ + , nType( TYPE_BASE ) \ + , bIsShell( FALSE ) \ + , bIsItem( FALSE ) \ + , cParserChar( 'h' ) + +SvMetaType::SvMetaType() + CTOR +{ +} + +SvMetaType::SvMetaType( const ByteString & rName, char cPC, + const ByteString & rCName ) + CTOR +{ + SetName( rName ); + cParserChar = cPC; + aCName = rCName; +} + +SvMetaType::SvMetaType( const ByteString & rName, + const ByteString & rSbxName, + const ByteString & rOdlName, + char cPc, + const ByteString & rCName, + const ByteString & rBasicName, + const ByteString & rBasicPostfix ) + CTOR +{ +// aSbxDataType = (int)nT; + SetName( rName ); + aSbxName = rSbxName; + aOdlName = rOdlName; + cParserChar = cPc; + aCName = rCName; + aBasicName = rBasicName; + aBasicPostfix = rBasicPostfix; +} + +void SvMetaType::Load( SvPersistStream & rStm ) +{ + SvMetaExtern::Load( rStm ); + + USHORT nMask; + rStm >> nMask; + if( nMask & 0x0001 ) rStm >> aIn; + if( nMask & 0x0002 ) rStm >> aOut; + if( nMask & 0x0004 ) rStm >> aCall0; + if( nMask & 0x0008 ) rStm >> aCall1; + if( nMask & 0x0010 ) rStm >> aSbxDataType; + if( nMask & 0x0020 ) rStm >> aSvName; + if( nMask & 0x0040 ) rStm >> aSbxName; + if( nMask & 0x0080 ) rStm >> aOdlName; + if( nMask & 0x0100 ) rStm >> GetAttrList(); + if( nMask & 0x0200 ) bIsItem = TRUE; + if( nMask & 0x0400 ) bIsShell = TRUE; + if( nMask & 0x0800 ) + { + USHORT nT; + rStm >> nT; + nType = nT; + } + if( nMask & 0x1000 ) rStm >> cParserChar; + if( nMask & 0x2000 ) rStm >> aCName; + if( nMask & 0x4000 ) rStm >> aBasicName; + if( nMask & 0x8000 ) rStm >> aBasicPostfix; +} + +void SvMetaType::Save( SvPersistStream & rStm ) +{ + SvMetaExtern::Save( rStm ); + + // Maske erstellen + USHORT nMask = 0; + if( aIn.IsSet() ) nMask |= 0x0001; + if( aOut.IsSet() ) nMask |= 0x0002; + if( aCall0.IsSet() ) nMask |= 0x0004; + if( aCall1.IsSet() ) nMask |= 0x0008; + if( aSbxDataType.IsSet() ) nMask |= 0x0010; + if( aSvName.IsSet() ) nMask |= 0x0020; + if( aSbxName.IsSet() ) nMask |= 0x0040; + if( aOdlName.IsSet() ) nMask |= 0x0080; + if( GetAttrCount() ) nMask |= 0x0100; + if( bIsItem ) nMask |= 0x0200; + if( bIsShell ) nMask |= 0x0400; + if( nType != TYPE_BASE ) nMask |= 0x0800; + if( cParserChar != 'h' ) nMask |= 0x1000; + if( aCName.IsSet() ) nMask |= 0x2000; + if( aBasicName.IsSet() ) nMask |= 0x4000; + if( aBasicPostfix.IsSet() ) nMask |= 0x8000; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x0001 ) rStm << aIn; + if( nMask & 0x0002 ) rStm << aOut; + if( nMask & 0x0004 ) rStm << aCall0; + if( nMask & 0x0008 ) rStm << aCall1; + if( nMask & 0x0010 ) rStm << aSbxDataType; + if( nMask & 0x0020 ) rStm << aSvName; + if( nMask & 0x0040 ) rStm << aSbxName; + if( nMask & 0x0080 ) rStm << aOdlName; + if( nMask & 0x0100 ) rStm << *pAttrList; + if( nMask & 0x0800 ) rStm << (USHORT)nType; + if( nMask & 0x1000 ) rStm << cParserChar; + if( nMask & 0x2000 ) rStm << aCName; + if( nMask & 0x4000 ) rStm << aBasicName; + if( nMask & 0x8000 ) rStm << aBasicPostfix; +} + +/************************************************************************* +|* SvMetaType::GetAttrList() +|* +|* Beschreibung +*************************************************************************/ +SvMetaAttributeMemberList & SvMetaType::GetAttrList() const +{ + if( !pAttrList ) + ((SvMetaType *)this)->pAttrList = new SvMetaAttributeMemberList(); + return *pAttrList; +} + +/************************************************************************* +|* SvMetaType::SetType() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::SetType( int nT ) +{ + nType = nT; + if( nType == TYPE_ENUM ) + { + aOdlName = "short"; +// aSbxDataType = SbxINTEGER; + } + else if( nType == TYPE_CLASS ) + { + aCName = C_PREF; + aCName += "Object *"; + } +} + +/************************************************************************* +|* SvMetaType::GetBaseType() +|* +|* Beschreibung +*************************************************************************/ +SvMetaType * SvMetaType::GetBaseType() const +{ + if( GetRef() && GetType() == TYPE_BASE ) + return ((SvMetaType *)GetRef())->GetBaseType(); + return (SvMetaType *)this; +} + +/************************************************************************* +|* SvMetaType::GetReturnType() +|* +|* Beschreibung +*************************************************************************/ +SvMetaType * SvMetaType::GetReturnType() const +{ + DBG_ASSERT( GetType() == TYPE_METHOD, "no method" ) + DBG_ASSERT( GetRef(), "no return type" ) + return (SvMetaType *)GetRef(); +} + +/************************************************************************* +|* SvMetaType::GetSbxDataType() +|* +|* Beschreibung +*************************************************************************/ +/* +SbxDataType SvMetaType::GetSbxDataType() const +{ + if( aSbxDataType.IsSet() || !GetRef() ) + return (SbxDataType)(int)aSbxDataType; + else + return ((SvMetaType *)GetRef())->GetSbxDataType(); +} +*/ +/************************************************************************* +|* SvMetaType::GetBasicName() +|* +|* Beschreibung +*************************************************************************/ +const ByteString& SvMetaType::GetBasicName() const +{ + if( aBasicName.IsSet() || !GetRef() ) + return aBasicName; + else + return ((SvMetaType*)GetRef())->GetBasicName(); +} + +/************************************************************************* +|* SvMetaType::GetBasicPostfix() +|* +|* Beschreibung +*************************************************************************/ +ByteString SvMetaType::GetBasicPostfix() const +{ + + ByteString aRet; + + // MBN und Co wollen immer "As xxx" +/* + if( aBasicPostfix.IsSet() || !GetRef() ) + aRet = aBasicPostfix; + else + aRet = ((SvMetaType*)GetRef())->GetBasicPostfix(); + + if ( !aRet.Len() && GetBasicName().Len() ) +*/ + { + + aRet = " As "; + aRet += GetBasicName(); + } + + return aRet; +} + +/************************************************************************* +|* SvMetaType::GetIn() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaType::GetIn() const +{ + if( aIn.IsSet() || !GetRef() ) + return aIn; + else + return ((SvMetaType *)GetRef())->GetIn(); +} + +/************************************************************************* +|* SvMetaType::GetOut() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaType::GetOut() const +{ + if( aOut.IsSet() || !GetRef() ) + return aOut; + else + return ((SvMetaType *)GetRef())->GetOut(); +} + +/************************************************************************* +|* SvMetaType::SetCall0() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::SetCall0( int e ) +{ + aCall0 = (int)e; + if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE ) + { + if( GetType() == TYPE_POINTER ) + SetType( TYPE_BASE ); + } + else + { + DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE, + "set no base type to pointer" ) + SetType( TYPE_POINTER ); + } +} + +/************************************************************************* +|* SvMetaType::GetCall0() +|* +|* Beschreibung +*************************************************************************/ +int SvMetaType::GetCall0() const +{ + if( aCall0.IsSet() || !GetRef() ) + return aCall0; + else + return ((SvMetaType *)GetRef())->GetCall0(); +} + +/************************************************************************* +|* SvMetaType::SetCall1() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::SetCall1( int e ) +{ + aCall1 = (int)e; + if( aCall0 == CALL_VALUE && aCall1 == CALL_VALUE ) + { + if( GetType() == TYPE_POINTER ) + SetType( TYPE_BASE ); + } + else + { + DBG_ASSERT( nType == TYPE_POINTER || nType == TYPE_BASE, + "set no base type to pointer" ) + SetType( TYPE_POINTER ); + } +} + +/************************************************************************* +|* SvMetaType::GetCall1() +|* +|* Beschreibung +*************************************************************************/ +int SvMetaType::GetCall1() const +{ + if( aCall1.IsSet() || !GetRef() ) + return aCall1; + else + return ((SvMetaType *)GetRef())->GetCall1(); +} + +/************************************************************************* +|* SvMetaType::GetSvName() +|* +|* Beschreibung +*************************************************************************/ +const ByteString & SvMetaType::GetSvName() const +{ + if( aSvName.IsSet() || !GetRef() ) + return aSvName; + else + return ((SvMetaType *)GetRef())->GetSvName(); +} + +/************************************************************************* +|* SvMetaType::GetSbxName() +|* +|* Beschreibung +*************************************************************************/ +const ByteString & SvMetaType::GetSbxName() const +{ + if( aSbxName.IsSet() || !GetRef() ) + return aSbxName; + else + return ((SvMetaType *)GetRef())->GetSbxName(); +} + +/************************************************************************* +|* SvMetaType::GetOdlName() +|* +|* Beschreibung +*************************************************************************/ +const ByteString & SvMetaType::GetOdlName() const +{ + if( aOdlName.IsSet() || !GetRef() ) + return aOdlName; + else + return ((SvMetaType *)GetRef())->GetOdlName(); +} + +/************************************************************************* +|* SvMetaType::GetCName() +|* +|* Beschreibung +*************************************************************************/ +const ByteString & SvMetaType::GetCName() const +{ + if( aCName.IsSet() || !GetRef() ) + return aCName; + else + return ((SvMetaType *)GetRef())->GetCName(); +} + +/************************************************************************* +|* SvMetaType::SetName() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaType::SetName( const ByteString & rName, SvIdlDataBase * pBase ) +{ + aSvName = rName; + aSbxName = rName; + aCName = rName; + if( GetType() != TYPE_ENUM ) + aOdlName = rName; + return SvMetaReference::SetName( rName, pBase ); +} + +/************************************************************************* +|* SvMetaType::FillSbxObject() +|* +|* Beschreibung +*************************************************************************/ +/* +void SvMetaType::FillSbxObject( SbxVariable * pObj, BOOL bVariable ) +{ + if( PTR_CAST( SbxMethod, pObj ) ) + { + if( GetType() == TYPE_METHOD ) + { + ULONG nCount = GetAttrCount(); + if( nCount ) + { + SbxInfoRef xInfo = pObj->GetInfo(); + if( !xInfo.Is() ) + { + xInfo = new SbxInfo(); + pObj->SetInfo( xInfo ); + } + for( ULONG n = nCount; n > 0; n-- ) + pAttrList->GetObject( n -1 )->FillSbxObject( xInfo ); + } + } + } +} +*/ +#ifdef IDL_COMPILER +/************************************************************************* +|* SvMetaType::GetString() +|* +|* Beschreibung +*************************************************************************/ +ByteString SvMetaType::GetCString() const +{ + ByteString aOut( GetSvName() ); + if( aCall0 == (int)CALL_POINTER ) + aOut += " *"; + else if( aCall0 == (int)CALL_REFERENCE ) + aOut += " &"; + if( aCall1 == (int)CALL_POINTER ) + aOut += '*'; + else if( aCall1 == (int)CALL_REFERENCE ) + aOut += '&'; + return aOut; +} + +/************************************************************************* +|* SvMetaType::ReadHeaderSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaType::ReadHeaderSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + BOOL bOk = FALSE; + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->Is( SvHash_interface() ) + || pTok->Is( SvHash_shell() ) ) + { + if( pTok->Is( SvHash_shell() ) ) + bIsShell = TRUE; + SetType( TYPE_CLASS ); + bOk = ReadNamesSvIdl( rBase, rInStm ); + + } + else if( pTok->Is( SvHash_struct() ) ) + { + SetType( TYPE_STRUCT ); + bOk = ReadNamesSvIdl( rBase, rInStm ); + } + else if( pTok->Is( SvHash_union() ) ) + { + SetType( TYPE_UNION ); + if( ReadNameSvIdl( rBase, rInStm ) ) + return TRUE; + } + else if( pTok->Is( SvHash_enum() ) ) + { + SetType( TYPE_ENUM ); + bOk = ReadNameSvIdl( rBase, rInStm ); + } + else if( pTok->Is( SvHash_typedef() ) + || pTok->Is( SvHash_item() ) ) + { + if( pTok->Is( SvHash_item() ) ) + bIsItem = TRUE; + + SvMetaType * pType = rBase.ReadKnownType( rInStm ); + if( pType ) + { + SetRef( pType ); + if( ReadNameSvIdl( rBase, rInStm ) ) + { + /* // um aufwaertskompatibel zu bleiben + aOdlName = pType->GetOdlName(); + */ + if( rInStm.Read( '(' ) ) + { + //DoReadContextSvIdl( rBase, rInStm, ',' ); + DoReadContextSvIdl( rBase, rInStm ); + if( rInStm.Read( ')' ) ) + { + SetType( TYPE_METHOD ); + bOk = TRUE; + } + } + else + { + bOk = TRUE; + } + } + } + else + { + ByteString aStr = "wrong typedef: "; + rBase.SetError( aStr, rInStm.GetToken() ); + rBase.WriteError( rInStm ); + } + } + if( bOk ) + SetModule( rBase ); + else + rInStm.Seek( nTokPos ); + return bOk; +} + +/************************************************************************* +|* SvMetaType::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaType::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + if( ReadHeaderSvIdl( rBase, rInStm ) ) + { + rBase.Write( '.' ); + return SvMetaExtern::ReadSvIdl( rBase, rInStm ); + } + return FALSE; +} + +/************************************************************************* +|* SvMetaType::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab +) +{ + WriteHeaderSvIdl( rBase, rOutStm, nTab ); + if( GetType() == TYPE_METHOD ) + WriteMethodArgs( rBase, rOutStm, nTab, WRITE_IDL ); + + ULONG nOldPos = rOutStm.Tell(); + rOutStm << endl; + SvMetaExtern::WriteSvIdl( rBase, rOutStm, nTab ); + if( TestAndSeekSpaceOnly( rOutStm, nOldPos ) ) + // nichts geschrieben + rOutStm.Seek( nOldPos ); + rOutStm << ';' << endl; +} + +/************************************************************************* +|* SvMetaType::WriteContext() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + if( GetAttrCount() ) + { + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + pAttr->Write( rBase, rOutStm, nTab, nT, nA ); + if( GetType() == TYPE_METHOD ) + rOutStm << ',' << endl; + else + rOutStm << ';' << endl; + pAttr = pAttrList->Next(); + } + } +} + +/************************************************************************* +|* SvMetaType::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + if( nT == WRITE_C_HEADER && nType != TYPE_ENUM ) + // nur enum schreiben + return; + + ByteString aName = GetName(); + if( nT == WRITE_ODL || nT == WRITE_C_HEADER || nT == WRITE_CXX_HEADER ) + { + switch( nType ) + { + case TYPE_CLASS: + { + } + break; + case TYPE_STRUCT: + case TYPE_UNION: + case TYPE_ENUM: + { + WriteStars( rOutStm ); + if( nType == TYPE_STRUCT || nType == TYPE_UNION ) + nA = WA_STRUCT; + + if( nT == WRITE_ODL || nT == WRITE_C_HEADER) + { + if ( nT == WRITE_C_HEADER ) + { + ByteString aStr = aName; + aStr.ToUpperAscii(); + rOutStm << "#ifndef " << C_PREF << aStr.GetBuffer() << "_DEF " << endl; + rOutStm << "#define " << C_PREF << aStr.GetBuffer() << "_DEF " << endl; + } + + WriteTab( rOutStm, nTab ); + rOutStm << "typedef" << endl; + if ( nT == WRITE_ODL ) + SvMetaName::Write( rBase, rOutStm, nTab, nT, nA ); + } + WriteTab( rOutStm, nTab ); + if( nType == TYPE_STRUCT ) + rOutStm << "struct"; + else if( nType == TYPE_UNION ) + rOutStm << "union"; + else + rOutStm << "enum"; + if( nT != WRITE_ODL && nT != WRITE_C_HEADER) + rOutStm << ' ' << aName.GetBuffer(); + + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << '{' << endl; + WriteContext( rBase, rOutStm, nTab +1, nT, nA ); + WriteTab( rOutStm, nTab ); + rOutStm << '}'; + if( nT == WRITE_ODL || nT == WRITE_C_HEADER ) + { + rOutStm << ' ' << C_PREF << aName.GetBuffer(); + } + rOutStm << ';' << endl; + + if ( nT == WRITE_C_HEADER ) + rOutStm << "#endif"; + +/*keine Funktionen fuer New und Delete + if( nT == WRITE_C_HEADER && nType != TYPE_ENUM ) + { + rOutStm << aName.GetBuffer() << " * New_" + << aName.GetBuffer() << "();" << endl; + rOutStm << "void Delete_" + << aName.GetBuffer() << "( " + << aName.GetBuffer() <<" * );" << endl; + } +*/ + rOutStm << endl; + } + break; + case TYPE_POINTER: + case TYPE_BASE: + { + } + break; + case TYPE_METHOD: + { + } + break; + } + } + +/*keine Funktionen fuer New und Delete + if( nT == WRITE_C_SOURCE ) + { + switch( nType ) + { + case TYPE_STRUCT: + case TYPE_UNION: + { + rOutStm << aName.GetBuffer() << " * New_" + << aName.GetBuffer() << "() { return new " + << aName.GetBuffer() << "; }" << endl; + rOutStm << "void Delete_" + << aName.GetBuffer() << "( " + << aName.GetBuffer() <<" * ) { delete " + << aName.GetBuffer() << "; }" << endl; + } + break; + } + } +*/ +} + +/************************************************************************* +|* SvMetaType::ReadNamesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaType::ReadNamesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + BOOL bOk = ReadNameSvIdl( rBase, rInStm ); +/* + if( bOk ) + { + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->IsIdentifier() ) + { + aSbxName = pTok->GetString(); + + nTokPos = rInStm.Tell(); + pTok = rInStm.GetToken_Next(); + if( pTok->IsIdentifier() ) + { + aItemName = pTok->GetString(); + nTokPos = rInStm.Tell(); + } + } + rInStm.Seek( nTokPos ); + } +*/ + return bOk; +} + +/************************************************************************* +|* SvMetaType::WriteHeaderSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteHeaderSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ + switch( nType ) + { + case TYPE_CLASS: + { + if( IsShell() ) + rOutStm << SvHash_shell()->GetName().GetBuffer(); + else + rOutStm << SvHash_interface()->GetName().GetBuffer(); + rOutStm << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_STRUCT: + { + rOutStm << SvHash_struct()->GetName().GetBuffer() + << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_UNION: + { + rOutStm << SvHash_union()->GetName().GetBuffer() + << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_ENUM: + { + rOutStm << SvHash_enum()->GetName().GetBuffer() + << ' ' << GetName().GetBuffer(); + } + break; + case TYPE_POINTER: + case TYPE_BASE: + { + if( IsItem() ) + rOutStm << SvHash_item()->GetName().GetBuffer() << ' '; + else + rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' '; + if( GetRef() ) + { + ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ' '; + } + rOutStm << GetName().GetBuffer(); + } + break; + case TYPE_METHOD: + { + rOutStm << SvHash_typedef()->GetName().GetBuffer() << ' '; + ((SvMetaType *)GetRef())->WriteTheType( rBase, rOutStm, nTab, WRITE_IDL ); + rOutStm << ' ' << GetName().GetBuffer() << "( "; + WriteContextSvIdl( rBase, rOutStm, nTab ); + rOutStm << " )"; + } + break; + } +} + +/************************************************************************* +|* SvMetaType::ReadAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::ReadAttributesSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaExtern::ReadAttributesSvIdl( rBase, rInStm ); + aSvName.ReadSvIdl( SvHash_SvName(), rInStm ); + aSbxName.ReadSvIdl( SvHash_SbxName(), rInStm ); + aOdlName.ReadSvIdl( SvHash_OdlName(), rInStm ); +} + +/************************************************************************* +|* SvMetaType::WriteAttributesSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteAttributesSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ + SvMetaExtern::WriteAttributesSvIdl( rBase, rOutStm, nTab ); + ByteString aName = GetName(); + if( aSvName != aName || aSbxName != aName || aOdlName != aName ) + { + WriteTab( rOutStm, nTab ); + rOutStm << "class SvMetaType" << endl; + if( aSvName != aName ) + { + WriteTab( rOutStm, nTab ); + aSvName.WriteSvIdl( SvHash_SvName(), rOutStm, nTab ); + rOutStm << endl; + } + if( aSbxName != aName ) + { + WriteTab( rOutStm, nTab ); + aSbxName.WriteSvIdl( SvHash_SbxName(), rOutStm, nTab ); + rOutStm << endl; + } + if( aOdlName != aName ) + { + WriteTab( rOutStm, nTab ); + aOdlName.WriteSvIdl( SvHash_OdlName(), rOutStm, nTab ); + rOutStm << endl; + } + } +} + +/************************************************************************* +|* SvMetaType::ReadContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + SvMetaAttributeRef xAttr = new SvMetaAttribute(); + if( xAttr->ReadSvIdl( rBase, rInStm ) ) + { + if( xAttr->Test( rBase, rInStm ) ) + GetAttrList().Append( xAttr ); + } +} + +/************************************************************************* +|* SvMetaType::WriteContextSvIdl() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteContextSvIdl +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab +) +{ + if( GetAttrCount() ) + { + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + WriteTab( rOutStm, nTab ); + pAttr->WriteSvIdl( rBase, rOutStm, nTab ); + if( GetType() == TYPE_METHOD ) + rOutStm << ',' << endl; + else + rOutStm << ';' << endl; + pAttr = pAttrList->Next(); + } + } +} + +/************************************************************************* +|* SvMetaType::WriteAttributes() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaExtern::WriteAttributes( rBase, rOutStm, nTab, nT, nA ); +} + +/************************************************************************* +|* SvMetaType::MakeSfx() +|* +|* Beschreibung +*************************************************************************/ +ULONG SvMetaType::MakeSfx( ByteString * pAttrArray ) +{ + ULONG nC = 0; + + if( GetBaseType()->GetType() == TYPE_STRUCT ) + { + ULONG nAttrCount = GetAttrCount(); + // Die einzelnen Attribute schreiben + for( ULONG n = 0; n < nAttrCount; n++ ) + { + nC += pAttrList->GetObject( n )->MakeSfx( pAttrArray ); + if( n +1 < nAttrCount ) + *pAttrArray += ", "; + } + } + return nC; +} + +/************************************************************************* +|* SvMetaType::WriteSfx() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteSfx( const ByteString & rItemName, SvIdlDataBase & rBase, + SvStream & rOutStm ) +{ + WriteStars( rOutStm ); + ByteString aVarName = " a"; + aVarName += rItemName; + aVarName += "_Impl"; + + ByteString aTypeName = "SfxType"; + ByteString aAttrArray; + ULONG nAttrCount = MakeSfx( &aAttrArray ); + //ULONG nAttrCount = GetAttrCount(); + ByteString aAttrCount( ByteString::CreateFromInt32( nAttrCount ) ); + aTypeName += aAttrCount; + + rOutStm << "extern " << aTypeName.GetBuffer() + << aVarName.GetBuffer() << ';' << endl; + + // Den Implementationsteil schreiben + rOutStm << "#ifdef SFX_TYPEMAP" << endl + << aTypeName.GetBuffer() << aVarName.GetBuffer() + << " = " << endl; + rOutStm << '{' << endl + << "\tTYPE(" << rItemName.GetBuffer() << "), " + << aAttrCount.GetBuffer(); + if( nAttrCount ) + { + rOutStm << ", { "; + // Die einzelnen Attribute schreiben + rOutStm << aAttrArray.GetBuffer(); + rOutStm << " }"; + } + rOutStm << endl << "};" << endl + << "#endif" << endl << endl; +} + +/************************************************************************* +|* SvMetaType::WriteSfx() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) +{ + if( IsItem() ) + { + if( GetBaseType()->GetType() == TYPE_STRUCT ) + GetBaseType()->WriteSfx( GetName(), rBase, rOutStm ); + else + WriteSfx( GetName(), rBase, rOutStm ); + } +} + +/************************************************************************* +|* SvMetaType::ReadMethodArgs() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvMetaType::ReadMethodArgs( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + if( rInStm.Read( '(' ) ) + { + //DoReadContextSvIdl( rBase, rInStm, ',' ); + DoReadContextSvIdl( rBase, rInStm ); + if( rInStm.Read( ')' ) ) + { + SetType( TYPE_METHOD ); + return TRUE; + } + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* SvMetaType::WriteMethodArgs() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteMethodArgs +( + SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab, WriteType nT +) +{ + if( nT == WRITE_IDL ) + { + if( GetAttrCount() ) + { + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << '(' << endl; + + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + WriteTab( rOutStm, nTab +1 ); + pAttr->WriteSvIdl( rBase, rOutStm, nTab +1 ); + pAttr = pAttrList->Next(); + if( pAttr ) + rOutStm << ',' << endl; + } + rOutStm << endl; + WriteTab( rOutStm, nTab ); + rOutStm << ')'; + } + else + rOutStm << "()"; + } + else if ( nT == WRITE_DOCU ) + { + + rOutStm << '('; + if( GetAttrCount() ) + { + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + pAttr->WriteParam( rBase, rOutStm, nTab+1, nT ); + pAttr = pAttrList->Next(); + if( pAttr ) + rOutStm << ','; + else + rOutStm << ' '; + } + } + rOutStm << ')' << endl; + } + else + { + rOutStm << '('; + if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + rOutStm << ' ' << C_PREF << "Object h" << rBase.aIFaceName.GetBuffer(); + if( GetAttrCount() ) + rOutStm << ','; + else + rOutStm << ' '; + } + + if( GetAttrCount() ) + { + rOutStm << endl; + SvMetaAttribute * pAttr = pAttrList->First(); + while( pAttr ) + { + switch( nT ) + { + case WRITE_C_HEADER: + case WRITE_C_SOURCE: + case WRITE_ODL: + { + pAttr->WriteParam( rBase, rOutStm, nTab +1, nT ); + } + break; + + default: + { + DBG_ASSERT( FALSE, "WriteType not implemented" ) + } + } + pAttr = pAttrList->Next(); + if( pAttr ) + rOutStm << ',' << endl; + } + if( nT != WRITE_C_HEADER && nT != WRITE_C_SOURCE ) + { + rOutStm << endl; + WriteTab( rOutStm, nTab +1 ); + } + rOutStm << ' '; + } + rOutStm << ')'; + } +} + +/************************************************************************* +|* SvMetaType::WriteTypePrefix() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteTypePrefix( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, WriteType nT ) +{ + switch( nT ) + { + case WRITE_IDL: + { + if( GetIn() && GetOut() ) + rOutStm << SvHash_inout()->GetName().GetBuffer() << ' '; + else if( GetIn() ) + rOutStm << SvHash_in()->GetName().GetBuffer() << ' '; + else if( GetOut() ) + rOutStm << SvHash_out()->GetName().GetBuffer() << ' '; + rOutStm << GetCString().GetBuffer(); + } + break; + + case WRITE_ODL: + { + BOOL bIn = GetIn(); + BOOL bOut = GetOut(); + if( bIn || bOut ) + { + if( bIn && bOut ) + rOutStm << "[in,out] "; + else if( bIn ) + rOutStm << "[in] "; + else if( bOut ) + rOutStm << "[out] "; + } + + ByteString aOut; + if( GetType() == TYPE_METHOD ) + aOut = GetReturnType()->GetBaseType()->GetOdlName(); + else + { + SvMetaType * pBType = GetBaseType(); + aOut = pBType->GetOdlName(); + } + if( aCall0 == (int)CALL_POINTER + || aCall0 == (int)CALL_REFERENCE ) + rOutStm << " *"; + if( aCall1 == (int)CALL_POINTER + || aCall1 == (int)CALL_REFERENCE ) + rOutStm << " *"; + rOutStm << aOut.GetBuffer(); + } + break; + + case WRITE_C_HEADER: + case WRITE_C_SOURCE: + case WRITE_CXX_HEADER: + case WRITE_CXX_SOURCE: + { + + SvMetaType * pBaseType = GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ) + + if( pBaseType->GetType() == TYPE_METHOD ) + pBaseType->GetReturnType()->WriteTypePrefix( + rBase, rOutStm, nTab, nT ); + else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + { + if( TYPE_STRUCT == pBaseType->GetType() ) + rOutStm << C_PREF << pBaseType->GetName().GetBuffer() + << " *"; + else + { + if ( pBaseType->GetType() == TYPE_ENUM ) + rOutStm << C_PREF; + rOutStm << pBaseType->GetCName().GetBuffer(); + } + } + else + { + if( TYPE_STRUCT == pBaseType->GetType() ) + rOutStm << pBaseType->GetName().GetBuffer() << " *"; + else + rOutStm << pBaseType->GetName().GetBuffer(); + } + } + break; + + case WRITE_DOCU: + { + + SvMetaType * pBaseType = GetBaseType(); + DBG_ASSERT( pBaseType, "no base type for attribute" ) + + if( pBaseType->GetType() == TYPE_METHOD ) + { + pBaseType->GetReturnType()->WriteTypePrefix( + rBase, rOutStm, nTab, nT ); + } + else + { + if( TYPE_STRUCT == pBaseType->GetType() ) + rOutStm << "VARIANT" << pBaseType->GetName().GetBuffer(); + else if ( pBaseType->GetType() == TYPE_ENUM ) + rOutStm << "integer"; + else + rOutStm << pBaseType->GetOdlName().GetBuffer(); + } + } + + default: + { + DBG_ASSERT( FALSE, "WriteType not implemented" ) + } + } +} + +/************************************************************************* +|* SvMetaType::WriteTheType() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteTheType( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, WriteType nT ) +{ + WriteTypePrefix( rBase, rOutStm, nTab, nT ); + if( GetType() == TYPE_METHOD ) + WriteMethodArgs( rBase, rOutStm, nTab +2, nT ); +} + +/************************************************************************* +|* SvMetaType::GetParserString() +|* +|* Beschreibung +*************************************************************************/ +ByteString SvMetaType::GetParserString() const +{ + SvMetaType * pBT = GetBaseType(); + if( pBT != this ) + return pBT->GetParserString(); + + int nType = GetType(); + ByteString aPStr; + + if( TYPE_METHOD == nType || TYPE_STRUCT == nType ) + { + ULONG nAttrCount = GetAttrCount(); + // Die einzelnen Attribute schreiben + for( ULONG n = 0; n < nAttrCount; n++ ) + { + SvMetaAttribute * pT = pAttrList->GetObject( n ); + aPStr += pT->GetType()->GetParserString(); + } + } + else + aPStr = GetParserChar(); + return aPStr; +} + +/************************************************************************* +|* SvMetaType::WriteParamNames() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaType::WriteParamNames( SvIdlDataBase & rBase, + SvStream & rOutStm, + const ByteString & rChief ) +{ + SvMetaType * pBT = GetBaseType(); + if( pBT != this ) + pBT->WriteParamNames( rBase, rOutStm, rChief ); + else + { + int nType = GetType(); + ByteString aPStr; + + if( TYPE_METHOD == nType || TYPE_STRUCT == nType ) + { + ULONG nAttrCount = GetAttrCount(); + // Die einzelnen Attribute schreiben + for( ULONG n = 0; n < nAttrCount; n++ ) + { + SvMetaAttribute * pA = pAttrList->GetObject( n ); + // Fuer Methoden ist rChief immer "" + ByteString aStr = /*rChief; + if( aStr.Len() ) + aStr += "->"; + aStr += */pA->GetName(); + pA->GetType()->WriteParamNames( rBase, rOutStm, aStr ); + if( n +1 < nAttrCount ) + rOutStm << ", "; + } + } + else + rOutStm << rChief.GetBuffer(); + } +} + +#endif // IDL_COMPILER + +/************************************************************************/ +/************************************************************************/ +SV_IMPL_META_FACTORY1( SvMetaTypeString, SvMetaType ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaTypeString::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* +|* SvMetaTypeString::SvMetaTypeString() +|* +|* Beschreibung +|* +*************************************************************************/ +SvMetaTypeString::SvMetaTypeString() + : SvMetaType( "String", "SbxSTRING", "BSTR", 's', "char *", "String", "$" ) +{ +} + +void SvMetaTypeString::Load( SvPersistStream & rStm ) +{ + SvMetaType::Load( rStm ); +} + +void SvMetaTypeString::Save( SvPersistStream & rStm ) +{ + SvMetaType::Save( rStm ); +} + +/************************************************************************/ +/************************************************************************/ +SV_IMPL_META_FACTORY1( SvMetaEnumValue, SvMetaName ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaEnumValue::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* +|* SvMetaEnumValue::SvMetaEnumValue() +|* +|* Beschreibung +|* +*************************************************************************/ +SvMetaEnumValue::SvMetaEnumValue() +{ +} + +void SvMetaEnumValue::Load( SvPersistStream & rStm ) +{ + SvMetaName::Load( rStm ); + + BYTE nMask; + rStm >> nMask; + if( nMask >= 0x02 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) rStm.ReadByteString( aEnumValue ); +} + +void SvMetaEnumValue::Save( SvPersistStream & rStm ) +{ + SvMetaName::Save( rStm ); + + // Maske erstellen + BYTE nMask = 0; + if( aEnumValue.Len() ) nMask |= 0x01; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x01 ) rStm.WriteByteString( aEnumValue ); +} + +#ifdef IDL_COMPILER +/************************************************************************* +|* +|* SvMetaEnumValue::ReadSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvMetaEnumValue::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + if( !ReadNameSvIdl( rBase, rInStm ) ) + return FALSE; + return TRUE; +} + +/************************************************************************* +|* +|* SvMetaEnumValue::WriteSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvMetaEnumValue::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + rOutStm << GetName().GetBuffer(); +} + +/************************************************************************* +|* +|* SvMetaEnumValue::Write() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvMetaEnumValue::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + if ( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE ) + rOutStm << C_PREF << GetName().GetBuffer(); + else + rOutStm << GetName().GetBuffer(); +} +#endif // IDL_COMPILER + +/************************************************************************/ +/************************************************************************/ +SV_IMPL_META_FACTORY1( SvMetaTypeEnum, SvMetaType ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaTypeEnum::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* +|* SvMetaTypeEnum::SvMetaTypeEnum() +|* +|* Beschreibung +|* +*************************************************************************/ +SvMetaTypeEnum::SvMetaTypeEnum() +{ + SetBasicName( "Integer" ); +} + +void SvMetaTypeEnum::Load( SvPersistStream & rStm ) +{ + SvMetaType::Load( rStm ); + + BYTE nMask; + rStm >> nMask; + if( nMask >= 0x04 ) + { + rStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + DBG_ERROR( "wrong format" ) + return; + } + if( nMask & 0x01 ) rStm >> aEnumValueList; + if( nMask & 0x02 ) rStm.ReadByteString( aPrefix ); +} + +void SvMetaTypeEnum::Save( SvPersistStream & rStm ) +{ + SvMetaType::Save( rStm ); + + // Maske erstellen + BYTE nMask = 0; + if( aEnumValueList.Count() ) nMask |= 0x01; + if( aPrefix.Len() ) nMask |= 0x02; + + // Daten schreiben + rStm << nMask; + if( nMask & 0x01 ) rStm << aEnumValueList; + if( nMask & 0x02 ) rStm.WriteByteString( aPrefix ); +} + +/************************************************************************* +|* +|* SvMetaTypeEnum::GetMaxValue() +|* +|* Beschreibung +|* +*************************************************************************/ +/* +USHORT SvMetaTypeEnum::GetMaxValue() const +{ + USHORT nMax = 0; + for( ULONG n = 0; n < aEnumValueList.Count(); n++ ) + { + SvMetaEnumValue * pObj = aEnumValueList.GetObject( n ); + if( nMax < pObj->GetValue() ) + nMax = pObj->GetValue(); + } + return nMax; +} +*/ + +#ifdef IDL_COMPILER +/************************************************************************* +|* +|* SvMetaTypeEnum::ReadContextSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + + SvMetaEnumValueRef aEnumVal = new SvMetaEnumValue(); + BOOL bOk = aEnumVal->ReadSvIdl( rBase, rInStm ); + if( bOk ) + { + if( 0 == aEnumValueList.Count() ) + // der Erste + aPrefix = aEnumVal->GetName(); + else + { + USHORT nPos = aPrefix.Match( aEnumVal->GetName() ); + if( nPos != aPrefix.Len() && nPos != STRING_MATCH ) + aPrefix.Erase( nPos ); + } + aEnumValueList.Append( aEnumVal ); + } + if( !bOk ) + rInStm.Seek( nTokPos ); +} + +/************************************************************************* +|* +|* SvMetaTypeEnum::WriteSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvMetaTypeEnum::WriteContextSvIdl( SvIdlDataBase & rBase, + SvStream & rOutStm, + USHORT nTab ) +{ + WriteTab( rOutStm, nTab +1 ); + for( ULONG n = 0; n < aEnumValueList.Count(); n++ ) + { + aEnumValueList.GetObject( n )->WriteSvIdl( rBase, rOutStm, nTab ); + if( n +1 != aEnumValueList.Count() ) + rOutStm << ", "; + else + rOutStm << endl; + } +} + +/************************************************************************* +|* +|* SvMetaTypeEnum::ReadSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvMetaTypeEnum::ReadSvIdl( SvIdlDataBase & rBase, + SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + if( SvMetaType::ReadHeaderSvIdl( rBase, rInStm ) + && GetType() == TYPE_ENUM ) + { + if( SvMetaName::ReadSvIdl( rBase, rInStm ) ) + return TRUE; + } + rInStm.Seek( nTokPos ); + return FALSE; +} + +/************************************************************************* +|* +|* SvMetaTypeEnum::WriteSvIdl() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvMetaTypeEnum::WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab ) +{ + WriteHeaderSvIdl( rBase, rOutStm, nTab ); + rOutStm << endl; + SvMetaName::WriteSvIdl( rBase, rOutStm, nTab ); + rOutStm << endl; +} + +/************************************************************************* +|* +|* SvMetaTypeEnum::Write() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvMetaTypeEnum::Write( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + SvMetaType::Write( rBase, rOutStm, nTab, nT, nA ); +} + +/************************************************************************* +|* SvMetaTypeEnum::WriteContext() +|* +|* Beschreibung +*************************************************************************/ +void SvMetaTypeEnum::WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, + USHORT nTab, + WriteType nT, WriteAttribute nA ) +{ + WriteTab( rOutStm, nTab +1 ); + for( ULONG n = 0; n < aEnumValueList.Count(); n++ ) + { + aEnumValueList.GetObject( n )->Write( rBase, rOutStm, nTab +1, nT, nA ); + + if( n +1 != aEnumValueList.Count() ) + { + if( 2 == n % 3 ) + { + rOutStm << ',' << endl; + WriteTab( rOutStm, nTab +1 ); + } + else + rOutStm << ",\t"; + } + else + rOutStm << endl; + } + rOutStm << endl; +} + +#endif // IDL_COMPILER + +/************************************************************************/ +/************************************************************************/ +SV_IMPL_META_FACTORY1( SvMetaTypevoid, SvMetaType ); +#ifdef IDL_COMPILER +SvAttributeList & SvMetaTypevoid::GetAttributeList() +{ + if( !pAttribList ) + { + pAttribList = new SvAttributeList(); + } + return *pAttribList; +} +#endif +/************************************************************************* +|* +|* SvMetaTypevoid::SvMetaTypevoid() +|* +|* Beschreibung +|* +*************************************************************************/ +SvMetaTypevoid::SvMetaTypevoid() + : SvMetaType( "void", "SbxVOID", "void", 'v', "void", "", "" ) +{ +} + +void SvMetaTypevoid::Load( SvPersistStream & rStm ) +{ + SvMetaType::Load( rStm ); +} + +void SvMetaTypevoid::Save( SvPersistStream & rStm ) +{ + SvMetaType::Save( rStm ); +} + +ByteString SvMetaAttribute::Compare( SvMetaAttribute* pAttr ) +{ + ByteString aStr; + + if ( aType.Is() ) + { + if ( aType->GetType() == TYPE_METHOD ) + { + // Nur testen, wenn das Attribut eine Methode ist, nicht wenn es + // eine hat !! + if ( !pAttr->GetType()->GetType() == TYPE_METHOD ) + aStr += " IsMethod\n"; + else if ( aType->GetReturnType() && + aType->GetReturnType()->GetType() != pAttr->GetType()->GetReturnType()->GetType() ) + aStr += " ReturnType\n"; + + if ( aType->GetAttrCount() ) + { + USHORT nCount = aType->GetAttrCount(); + SvMetaAttributeMemberList& rList = aType->GetAttrList(); + SvMetaAttributeMemberList& rOtherList = pAttr->GetType()->GetAttrList(); + USHORT nOtherCount = pAttr->GetType()->GetAttrCount(); + if ( nOtherCount != nCount ) + { + aStr += " AttributeCount\n"; + } + else + { + for ( USHORT n=0; nCompare( pAttr2 ); + } + } + } + } + + if ( GetType()->GetType() != pAttr->GetType()->GetType() ) + aStr += " Type\n"; + + if ( !GetType()->GetSvName().Equals( pAttr->GetType()->GetSvName() ) ) + aStr += " ItemType\n"; + } + + if ( GetExport() != pAttr->GetExport() ) + aStr += " Export\n"; + + if ( GetAutomation() != pAttr->GetAutomation() ) + aStr += " Automation\n"; + + if ( GetIsCollection() != pAttr->GetIsCollection() ) + aStr += " IsCollection\n"; + + if ( GetReadOnlyDoc() != pAttr->GetReadOnlyDoc() ) + aStr += " ReadOnlyDoc\n"; + + if ( GetExport() && GetReadonly() != pAttr->GetReadonly() ) + aStr += " Readonly\n"; + + return aStr; +} + +void SvMetaAttribute::WriteCSV( SvIdlDataBase& rBase, SvStream& rStrm ) +{ + rStrm << GetType()->GetSvName().GetBuffer() << ' '; + rStrm << GetName().GetBuffer() << ' '; + rStrm << GetSlotId().GetBuffer(); +} + + diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx new file mode 100644 index 000000000000..9961f737339d --- /dev/null +++ b/idl/source/prj/command.cxx @@ -0,0 +1,472 @@ +/************************************************************************* + * + * $RCSfile: command.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include +#include +#include + +#include +#include +#include + +#ifndef _FSYS_HXX //autogen +#include +#endif + +#pragma hdrstop + +/************************************************************************* +|* +|* Syntaxbeschreibung +|* +*************************************************************************/ +char* SyntaxStrings[] = { +"basic-type:", +"\tvoid| char| int| float| double|", +"\tUINT16| INT16| UINT32| INT32| BOOL|", +"\tBYTE| String| SbxObject", +"", +"{ import \"filename\" }\n", +"module definition:", +"module", +"\tunique id range (ask MM)", +"modul-name", +"'['", +"\tSlotIdFile( \"filename\" )", +"']'", +"'{'", +"\t{ include \"filename\" }\n", + +"\titem definition:", +"\titem type item-name;\n", + +"\ttype definition:", +"\tstruct | union identifier", +"\t'{'", +"\t\t{ type idetifier }", +"\t'}'", +"\t|", +"\tenum identifier", +"\t'{'", +"\t\t{ identifier, }", +"\t'}'", +"\t|", +"\ttypedef type identifier\n", + +"\titem-method:", +"\titem identifier item-method-args\n", + +"\titem-method-args:", +"\t( { item parameter-name SLOT_ID } )\n", + +"\tslot definition:", +"\titem identifier SLOT_ID [ item-method-args ]", +"\t'['\n", + +"\t\titem-method-args", +"\t\tAccelConfig, MenuConfig, StatusBarConfig, ToolbarConfig", +"\t\tAutomation*", +"\t\tAutoUpdate", +"\t\tCachable*, Volatile", +"\t\tContainer", +"\t\tDefault = Identifier", +"\t\tExecMethod = Identifier", +"\t\tExport*", +"\t\tFastCall", +"\t\tGet, Set", +"\t\tGroupId = Identifier", +"\t\tHasCoreId", +"\t\tHasDialog", +"\t\tIsCollection", +"\t\tPlugComm", +"\t\tPseudoPrefix = Identifier", +"\t\tPseudoSlots", +"\t\tReadOnly", +"\t\tReadOnlyDoc*", +"\t\tRecordPerSet*, RecordPerItem, RecordManual, NoRecord", +"\t\tRecordAbsolute", +"\t\tStateMethod = Identifier", +"\t\tSynchron*, Asynchron", +"\t\tToggle", +"\t']'\n", + +"\tinterface definition:", +"\tshell | interface identifier ':' interface", +"\t'{'", +"\t\t{ slot }", +"\t'}'\n", +"---syntax example is sfx.idl---\n", +NULL }; + +char CommandLineSyntax[] = +"-fs -fl\n" +"-fo -fd\n" +"-fi -ft (not OLE)\n" +"-fr -fm\n" +"-fC -fH\n" +"-fc -fh\n" +"-rsc <*.srs header line>\n" +"-help, ? @ response file\n" +" \n"; + +/************************************************************************* +|* +|* Init() +|* +|* Beschreibung +|* Ersterstellung MM 15.12.94 +|* Letzte Aenderung MM 15.12.94 +|* +*************************************************************************/ +void Init( const SvCommand & rCommand ) +{ + if( !IDLAPP->pHashTable ) + IDLAPP->pHashTable = new SvStringHashTable( 2801 ); + if( !IDLAPP->pGlobalNames ) + IDLAPP->pGlobalNames = new SvGlobalHashNames(); +} + +/************************************************************************* +|* +|* DeInit() +|* +|* Beschreibung +|* +*************************************************************************/ +void DeInit() +{ + delete IDLAPP; +} + +/************************************************************************* +|* +|* DeInit() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ) +{ + for( USHORT n = 0; n < rCommand.aInFileList.Count(); n++ ) + { + String aFileName ( *rCommand.aInFileList.GetObject( n ) ); + SvFileStream aStm( aFileName, STREAM_STD_READ | STREAM_NOCREATE ); + if( aStm.GetError() == SVSTREAM_OK ) + { + if( pDataBase->IsBinaryFormat( aStm ) ) + { + pDataBase->Load( aStm ); + if( aStm.GetError() != SVSTREAM_OK ) + { + ByteString aStr; + if( aStm.GetError() == SVSTREAM_FILEFORMAT_ERROR ) + aStr = "error: incompatible format, file "; + else if( aStm.GetError() == SVSTREAM_WRONGVERSION ) + aStr = "error: wrong version, file "; + else + aStr = "error during load, file "; + aStr += ByteString( aFileName, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + return FALSE; + } + } + else + { + SvTokenStream aTokStm( aStm, aFileName ); + if( !pDataBase->ReadSvIdl( aTokStm, FALSE, rCommand.aPath ) ) + return FALSE; + } + } + else + return FALSE; + } + return TRUE; +} + +/************************************************************************* +|* +|* SvCommand::SvCommand() +|* +|* Beschreibung +|* Ersterstellung MM 15.12.94 +|* Letzte Aenderung MM 15.12.94 +|* +*************************************************************************/ +SvCommand::SvCommand() + : nFlags( 0 ) +{ + DirEntry aEntry; + aPath = aEntry.GetFull(); //Immer im Aktuellen Pfad suchen +} + +/************************************************************************* +|* +|* SvCommand::SvCommand() +|* +|* Beschreibung +|* +*************************************************************************/ +static BOOL ResponseFile( StringList * pList, int argc, char ** argv ) +{ + // Programmname + pList->Insert( new String( String::CreateFromAscii(*argv) ), LIST_APPEND ); + for( int i = 1; i < argc; i++ ) + { + if( '@' == **(argv +i) ) + { // wenn @, dann Response-Datei + SvFileStream aStm( String::CreateFromAscii((*(argv +i)) +1), STREAM_STD_READ | STREAM_NOCREATE ); + if( aStm.GetError() != SVSTREAM_OK ) + return FALSE; + + ByteString aStr; + while( aStm.ReadLine( aStr ) ) + { + USHORT n = 0; + USHORT nPos = 1; + while( n != nPos ) + { + while( aStr.GetChar(n) && isspace( aStr.GetChar(n) ) ) + n++; + nPos = n; + while( aStr.GetChar(n) && !isspace( aStr.GetChar(n) ) ) + n++; + if( n != nPos ) + pList->Insert( new String( String::CreateFromAscii( aStr.Copy( nPos, n - nPos ).GetBuffer() ) ), LIST_APPEND ); + } + } + } + else if( argv[ i ] ) + pList->Insert( new String( String::CreateFromAscii( argv[ i ] ) ), LIST_APPEND ); + } + return TRUE; +} + +/************************************************************************* +|* SvCommand::SvCommand() +|* +|* Beschreibung +*************************************************************************/ +SvCommand::SvCommand( int argc, char ** argv ) + : nFlags( 0 ) +{ + StringList aList; + + if( ResponseFile( &aList, argc, argv ) ) + for( ULONG i = 1; i < aList.Count(); i++ ) + { + String aParam( *aList.GetObject( i ) ); + sal_Unicode aFirstChar( aParam.GetChar(0) ); + if( '-' == aFirstChar ) + { + aParam.Erase( 0, 1 ); + aFirstChar = aParam.GetChar(0); + if( aFirstChar == 'F' || aFirstChar == 'f' ) + { + aParam.Erase( 0, 1 ); + aFirstChar = aParam.GetChar(0); + String aName( aParam.Copy( 1 ) ); + if( 's' == aFirstChar ) + { // Name der Slot-Ausgabe + aSlotMapFile = aName; + } + else if( 'l' == aFirstChar ) + { // Name der Listing + aListFile = aName; + } + else if( 'i' == aFirstChar ) + { // Name der Item-Datei +// aSfxItemFile = aName; + } + else if( 'o' == aFirstChar ) + { // Name der ODL-Datei +// aODLFile = aName; + } + else if( 'd' == aFirstChar ) + { // Name der Datenbasis-Datei + aDataBaseFile = aName; + } + else if( 'D' == aFirstChar ) + { // Name der Docu-Datei f"ur das API +// aDocuFile = aName; + } + else if( 'C' == aFirstChar ) + { // Name der cxx-Datei +// aCxxFile = aName; + } + else if( 'H' == aFirstChar ) + { // Name der hxx-Datei +// aHxxFile = aName; + } + else if( 'c' == aFirstChar ) + { // Name der C-Header-Datei +// aCSourceFile = aName; + } + else if( 'h' == aFirstChar ) + { // Name der C-Header-Datei +// aCHeaderFile = aName; + } + else if( 't' == aFirstChar ) + { // Name der Info-Datei +// aCallingFile = aName; + } + else if( 'm' == aFirstChar ) + { // Name der Info-Datei + aTargetFile = aName; + } + else if( 'r' == aFirstChar ) + { // Name der Resource-Datei +// aSrcFile = aName; + } + else if( 'z' == aFirstChar ) + { // Name der HelpId-Datei + aHelpIdFile = aName; + } + else if( 'y' == aFirstChar ) + { // Name der CSV-Datei + aCSVFile = aName; + } + else if( 'x' == aFirstChar ) + { // Name der IDL-Datei fuer die CSV-Datei + aExportFile = aName; + } + else + { + printf( "unknown switch: %s\n", aParam.GetBuffer() ); + exit( -1 ); + } + } + else if( aParam.EqualsIgnoreCaseAscii( "help" ) || aParam.EqualsIgnoreCaseAscii( "?" ) ) + { // Hilfe + printf( CommandLineSyntax ); + } + else if( aParam.EqualsIgnoreCaseAscii( "syntax" ) ) + { // Hilfe + int i = 0; + while(SyntaxStrings[i]) + printf("%s\n",SyntaxStrings[i++]); + } + else if( aParam.EqualsIgnoreCaseAscii( "i", 0, 1 ) ) + { // Include-Pfade definieren + String aName( aParam.Copy( 1 ) ); + if( aPath.Len() ) + aPath += DirEntry::GetSearchDelimiter(); + aPath += aName; + } + else if( aParam.EqualsIgnoreCaseAscii( "rsc", 0, 3 ) ) + { // erste Zeile im *.srs File + if( aList.GetObject( i +1 ) ) + { + aSrsLine = ByteString( *aList.GetObject( i +1 ), RTL_TEXTENCODING_UTF8 ); + i++; + } + } + else + { +#if SUPD>589 + // temporary compatibility hack + printf( "unknown switch: %s\n", aParam.GetBuffer() ); + exit( -1 ); +#endif + } + } + else + { + aInFileList.Insert( new String( aParam ), LIST_APPEND ); + } + } + else + { + printf( CommandLineSyntax ); + } + + String * pStr = aList.First(); + while( pStr ) + { + delete pStr; + pStr = aList.Next(); + } + + ByteString aInc( getenv( "INCLUDE" ) ); + // Include Environmentvariable anhaengen + if( aInc.Len() ) + { + if( aPath.Len() ) + aPath += DirEntry::GetSearchDelimiter(); + aPath += String::CreateFromAscii( aInc.GetBuffer() ); + } +} + +/************************************************************************* +|* +|* SvCommand::~SvCommand() +|* +|* Beschreibung +|* +*************************************************************************/ +SvCommand::~SvCommand() +{ + // ByteString Liste freigeben + String * pStr; + while( NULL != (pStr = aInFileList.Remove()) ) + delete pStr; +} + diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx new file mode 100644 index 000000000000..ec47b5d73530 --- /dev/null +++ b/idl/source/prj/database.cxx @@ -0,0 +1,1378 @@ +/************************************************************************* + * + * $RCSfile: database.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include +#include + +#ifndef _FSYS_HXX //autogen +#include +#endif +#include +#include +#include +#pragma hdrstop + + +/****************** SvIdlDataBase ****************************************/ +/************************************************************************* +|* SvIdlDataBase::SvIdlDataBase() +|* +|* Beschreibung +*************************************************************************/ +/* +void PrimeNumber(){ + USHORT i, n; + for( i = 5001; i < 5500; i += 2 ){ + for( n = 2; n < i && ((i % n) != 0); n++ ); + if( n == i ){ + printf( "\nPrimzahl: %d\n", i ); + return; + } + } +} +*/ + +SvIdlDataBase::SvIdlDataBase() + : bIsModified( FALSE ) + , bExport( FALSE ) + , aPersStream( *IDLAPP->pClassMgr, NULL ) + , pIdTable( NULL ) + , nUniqueId( 0 ) +{ + //PrimeNumber(); +} + +/************************************************************************* +|* SvIdlDataBase::~SvIdlDataBase() +|* +|* Beschreibung +*************************************************************************/ +SvIdlDataBase::~SvIdlDataBase() +{ + String * pStr = aIdFileList.First(); + while( pStr ) + { + delete pStr; + pStr = aIdFileList.Next(); + } + delete pIdTable; +} + +/************************************************************************* +|* SvIdlDataBase::IsModified() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlDataBase::IsModified() const +{ + for( ULONG n = 0; n < aModuleList.Count(); n++ ) + if( aModuleList.GetObject( n )->IsModified() ) + return TRUE; + //bIsModified; + return FALSE; +} + +/************************************************************************* +|* SvIdlDataBase::GetTypeList() +|* +|* Beschreibung +*************************************************************************/ +#define ADD_TYPE( Name, OdlName, ParserChar, CName, BasName, BasPost ) \ + aTypeList.Append( new SvMetaType( SvHash_##Name()->GetName(), \ + BasName, OdlName, ParserChar, CName, BasName, BasPost ) ); + +SvMetaTypeMemberList & SvIdlDataBase::GetTypeList() +{ + if( aTypeList.Count() == 0 ) + { // Initial fuellen + aTypeList.Append( new SvMetaTypeString() ); + aTypeList.Append( new SvMetaTypevoid() ); + + // MI: IDispatch::Invoke kann keine unsigned + ADD_TYPE( UINT16, "long", 'h', "unsigned short", "Long", "&" ); + ADD_TYPE( INT16, "short", 'h', "short", "Integer", "%" ); + ADD_TYPE( UINT32, "long", 'l', "unsigned long", "Long", "&" ); + ADD_TYPE( INT32, "long", 'l', "long", "Long", "&" ); + ADD_TYPE( int, "int", 'i', "int", "Integer", "%" ); + ADD_TYPE( BOOL, "boolean", 'b', "unsigned char", "Boolean", "" ); + ADD_TYPE( char, "char", 'c', "char", "Integer", "%" ); + ADD_TYPE( BYTE, "char", 'c', "unsigned char", "Integer", "%" ); + ADD_TYPE( float, "float", 'f', "float", "Single", "!" ); + ADD_TYPE( double, "double", 'F', "double", "Double", "#" ); + ADD_TYPE( SbxObject, "VARIANT", 'o', "C_Object", "Object", "" ); + + // A c h t u n g !!!, bei hinzufuegen von Typen werden alle + // bin„ren Datenbasen inkompatibel + + /* + // So tun als ob die Init-Daten auf einem Stream gelesen wurden + SvMemoryStream aStm; + aPersStream.SetStream( &aStm ); + // Alle Init-Daten Streamen + aPersStream << aTypeList; + // Nur die Id-Zuordnung merken + aPersStream.SetStream( NULL ); + */ + } + return aTypeList; +} + +/************************************************************************* +|* +|* SvIdlDataBase::GetModuleInfo() +|* +|* Beschreibung +|* Ersterstellung MM 13.12.94 +|* Letzte Aenderung MM 13.12.94 +|* +*************************************************************************/ +SvMetaModule * SvIdlDataBase::GetModule( const ByteString & rName ) +{ + for( ULONG n = 0; n < aModuleList.Count(); n++ ) + if( aModuleList.GetObject( n )->GetName() == rName ) + return aModuleList.GetObject( n ); + return NULL; +} + +/************************************************************************* +|* +|* SvIdlDataBase::IsBinaryFormat() +|* +|* Beschreibung +|* +*************************************************************************/ +#define DATABASE_SIGNATURE (UINT32)0x13B799F2 +#define DATABASE_VER 0x0006 +BOOL SvIdlDataBase::IsBinaryFormat( SvStream & rStm ) +{ + UINT32 nSig = 0; + ULONG nPos = rStm.Tell(); + rStm >> nSig; + rStm.Seek( nPos ); + + return nSig == DATABASE_SIGNATURE; +} + +/************************************************************************* +|* +|* SvIdlDataBase::Load() +|* +|* Beschreibung +|* +*************************************************************************/ +void SvIdlDataBase::Load( SvStream & rStm ) +{ + DBG_ASSERT( aTypeList.Count() == 0, "type list already initialized" ) + SvPersistStream aPStm( *IDLAPP->pClassMgr, &rStm ); + + USHORT nVersion = 0; + UINT32 nSig = 0; + + aPStm >> nSig; + aPStm >> nVersion; + if( nSig != DATABASE_SIGNATURE ) + { + aPStm.SetError( SVSTREAM_FILEFORMAT_ERROR ); + return; + } + if( nVersion != DATABASE_VER ) + { + aPStm.SetError( SVSTREAM_WRONGVERSION ); + return; + } + aPStm >> aClassList; + aPStm >> aTypeList; + aPStm >> aAttrList; + aPStm >> aModuleList; + aPStm >> nUniqueId; + + if( aPStm.IsEof() ) + aPStm.SetError( SVSTREAM_GENERALERROR ); +} + +/************************************************************************* +|* SvIdlDataBase::Save() +|* +|* Beschreibung +*************************************************************************/ +void SvIdlDataBase::Save( SvStream & rStm, UINT32 nFlags ) +{ + SvPersistStream aPStm( *IDLAPP->pClassMgr, &rStm ); + aPStm.SetContextFlags( nFlags ); + + aPStm << (UINT32)DATABASE_SIGNATURE; + aPStm << (USHORT)DATABASE_VER; + + BOOL bOnlyStreamedObjs = FALSE; + if( nFlags & IDL_WRITE_CALLING ) + bOnlyStreamedObjs = TRUE; + + if( bOnlyStreamedObjs ) + { + SvMetaClassMemberList aList; + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + aList.Append( pModule->GetClassList() ); + } + aPStm << aList; + } + else + aPStm << aClassList; + + //aClassList.WriteObjects( aPStm, bOnlyStreamedObjs ); + aTypeList.WriteObjects( aPStm, bOnlyStreamedObjs ); + aAttrList.WriteObjects( aPStm, bOnlyStreamedObjs ); + aModuleList.WriteObjects( aPStm, bOnlyStreamedObjs ); + aPStm << nUniqueId; +} + +/************************************************************************* +|* SvIdlDataBase::SetError() +|* +|* Beschreibung +*************************************************************************/ +void SvIdlDataBase::SetError( const ByteString & rError, SvToken * pTok ) +{ + if( pTok->GetLine() > 10000 ) + aError.SetText( "hgchcg" ); + + if( aError.nLine < pTok->GetLine() + || aError.nLine == pTok->GetLine() && aError.nColumn < pTok->GetColumn() ) + { + aError = SvIdlError( pTok->GetLine(), pTok->GetColumn() ); + aError.SetText( rError ); + } +} + +/************************************************************************* +|* SvIdlDataBase::Push() +|* +|* Beschreibung +*************************************************************************/ +void SvIdlDataBase::Push( SvMetaObject * pObj ) +{ + GetStack().Push( pObj ); +} + +#ifdef IDL_COMPILER +/************************************************************************* +|* +|* SvIdlDataBase::FindId() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvIdlDataBase::FindId( const ByteString & rIdName, ULONG * pVal ) +{ + if( pIdTable ) + { + UINT32 nHash; + if( pIdTable->Test( rIdName, &nHash ) ) + { + *pVal = pIdTable->Get( nHash )->GetValue(); + return TRUE; + } + } + return FALSE; +} + +/************************************************************************* +|* +|* SvIdlDataBase::InsertId() +|* +|* Beschreibung +|* +*************************************************************************/ +BOOL SvIdlDataBase::InsertId( const ByteString & rIdName, ULONG nVal ) +{ + if( !pIdTable ) + pIdTable = new SvStringHashTable( 20003 ); + + UINT32 nHash; + if( pIdTable->Insert( rIdName, &nHash ) ) + { + pIdTable->Get( nHash )->SetValue( nVal ); + return TRUE; + } + return FALSE; +} + +/************************************************************************* +|* SvIdlDataBase::ReadIdFile() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlDataBase::ReadIdFile( const String & rFileName ) +{ +#ifndef MAC + DirEntry aFullName( rFileName ); +#else + DirEntry aFullName( rFileName, FSYS_STYLE_UNX ); +#endif + aFullName.Find( GetPath() ); + + String * pIdFile = aIdFileList.First(); + while( pIdFile ) + { + if( *pIdFile == rFileName ) + return TRUE; // schon eingelesen + pIdFile = aIdFileList.Next(); + } + + aIdFileList.Insert( new String( rFileName ), LIST_APPEND ); + + SvTokenStream aTokStm( aFullName.GetFull() ); + if( aTokStm.GetStream().GetError() == SVSTREAM_OK ) + { + SvToken * pTok = aTokStm.GetToken_Next(); + + while( !pTok->IsEof() ) + { + if( pTok->IsChar() && pTok->GetChar() == '#' ) + { + pTok = aTokStm.GetToken_Next(); + if( pTok->Is( SvHash_define() ) ) + { + pTok = aTokStm.GetToken_Next(); + ByteString aDefName; + if( pTok->IsIdentifier() ) + aDefName = pTok->GetString(); + else + { + ByteString aStr( "unexpected token after define" ); + // Fehler setzen + SetError( aStr, pTok ); + WriteError( aTokStm ); + return FALSE; + } + + ULONG nVal = 0; + BOOL bOk = TRUE; + while( bOk ) + { + pTok = aTokStm.GetToken_Next(); + if( pTok->IsIdentifier() ) + { + ULONG n; + if( FindId( pTok->GetString(), &n ) ) + nVal += n; + else + bOk = FALSE; + } + else if( pTok->IsChar() ) + { + if( pTok->GetChar() == '-' + || pTok->GetChar() == '/' + || pTok->GetChar() == '*' + || pTok->GetChar() == '&' + || pTok->GetChar() == '|' + || pTok->GetChar() == '^' + || pTok->GetChar() == '~' ) + { + ByteString aStr( "unknown operator '" ); + aStr += pTok->GetChar(); + aStr += "'in define"; + // Fehler setzen + SetError( aStr, pTok ); + WriteError( aTokStm ); + return FALSE; + } + if( pTok->GetChar() != '+' + && pTok->GetChar() != '(' + && pTok->GetChar() != ')' ) + // nur + erlaubt, Klammern spielen kein Rolle, + // da + komutativ ist + break; + } + else if( pTok->IsInteger() ) + { + nVal += pTok->GetNumber(); + } + else + break; + } + if( bOk ) + { + if( !InsertId( aDefName, nVal ) ) + { + ByteString aStr = "hash table overflow: "; + SetError( aStr, pTok ); + WriteError( aTokStm ); + return FALSE; + } + } + } + else if( pTok->Is( SvHash_include() ) ) + { + pTok = aTokStm.GetToken_Next(); + ByteString aName; + if( pTok->IsString() ) + aName = pTok->GetString(); + else if( pTok->IsChar() && pTok->GetChar() == '<' ) + { + pTok = aTokStm.GetToken_Next(); + while( !pTok->IsEof() + && !(pTok->IsChar() && pTok->GetChar() == '>') ) + { + aName += pTok->GetTokenAsString(); + pTok = aTokStm.GetToken_Next(); + } + if( pTok->IsEof() ) + { + ByteString aStr( "unexpected eof in #include" ); + // Fehler setzen + SetError( aStr, pTok ); + WriteError( aTokStm ); + return FALSE; + } + } + if( !ReadIdFile( String::CreateFromAscii(aName.GetBuffer()) ) ) + { + ByteString aStr = "cannot read file: "; + aStr += aName; + SetError( aStr, pTok ); + WriteError( aTokStm ); + return FALSE; + } + } + } + else + pTok = aTokStm.GetToken_Next(); + } + } + else + return FALSE; + return TRUE; +} + +/************************************************************************* +|* SvIdlDataBase::FindType() +|* +|* Beschreibung +*************************************************************************/ +SvMetaType * SvIdlDataBase::FindType( const SvMetaType * pPType, + SvMetaTypeMemberList & rList ) +{ + SvMetaType * pType = rList.First(); + while( pType && pPType != pType ) + pType = rList.Next(); + return pType; +} + +SvMetaType * SvIdlDataBase::FindType( const ByteString & rName ) +{ + SvMetaType * pType = aTypeList.First(); + while( pType && rName != pType->GetName() ) + pType = aTypeList.Next(); + return pType; +} + +/************************************************************************* +|* SvIdlDataBase::FindName() +|* +|* Beschreibung +*************************************************************************/ +ByteString * SvIdlDataBase::FindName( const ByteString & rName, ByteStringList & rList ) +{ + ByteString * pS = rList.First(); + while( pS && *pS != rName ) + pS = rList.Next(); + return pS; +} + +/************************************************************************* +|* SvIdlDataBase::FillTypeList() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlDataBase::FillTypeList( SvMetaTypeList & rOutList, + SvToken * pNameTok ) +{ + rOutList.Clear(); +// if( pNameTok->IsIdentifierHash() ) Optimierung spaeter + if( pNameTok->IsIdentifier() ) + { + ByteString aName = pNameTok->GetString(); + SvMetaType * pMetaType = GetTypeList().First(); + while( pMetaType ) + { + if( pMetaType->GetName() == aName ) + rOutList.Insert( pMetaType, LIST_APPEND ); + pMetaType = GetTypeList().Next(); + } + } + return rOutList.Count() != 0; +} + +/************************************************************************* +|* SvIdlDataBase::ReadKnownType() +|* +|* Beschreibung +*************************************************************************/ +SvMetaType * SvIdlDataBase::ReadKnownType( SvTokenStream & rInStm ) +{ + BOOL bIn = FALSE; + BOOL bOut = FALSE; + int nCall0 = CALL_VALUE; + int nCall1 = CALL_VALUE; + BOOL bSet = FALSE; //irgent ein Attribut gesetzt + + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->HasHash() ) + { + UINT32 nBeginPos = 0; // kann mit Tell nicht vorkommen + while( nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + if( pTok->Is( SvHash_in() ) ) + { + bIn = TRUE; + pTok = rInStm.GetToken_Next(); + bSet = TRUE; + } + if( pTok->Is( SvHash_out() ) ) + { + bOut = TRUE; + pTok = rInStm.GetToken_Next(); + bSet = TRUE; + } + if( pTok->Is( SvHash_inout() ) ) + { + bIn = TRUE; + bOut = TRUE; + pTok = rInStm.GetToken_Next(); + bSet = TRUE; + } + } + } +/* + SvMetaTypeList aTmpTypeList; + if( FillTypeList( aTmpTypeList, pTok ) ) +*/ + if( pTok->IsIdentifier() ) + { + ByteString aName = pTok->GetString(); + SvMetaTypeMemberList & rList = GetTypeList(); + SvMetaType * pType = rList.First(); + while( pType ) + { + if( pType->GetName() == aName ) + break; + pType = rList.Next(); + } + if( pType ) + { + pTok = rInStm.GetToken(); + if( pTok->IsChar() ) + { + if( pTok->GetChar() == '&' || pTok->GetChar() == '*' ) + { + nCall0 = (pTok->GetChar() == '&') ? CALL_REFERENCE : + CALL_POINTER; + rInStm.GetToken_Next(); + pTok = rInStm.GetToken(); + if( pTok->GetChar() == '&' || pTok->GetChar() == '*' ) + { + nCall1 = (pTok->GetChar() == '&') ? CALL_REFERENCE : + CALL_POINTER; + rInStm.GetToken_Next(); + } + bSet = TRUE; + } + } + /* + SvMetaType * pMetaType = aTmpTypeList.First(); + while( pMetaType ) + { + if( pMetaType->GetIn() == bIn + && pMetaType->GetOut() == bOut + && pMetaType->GetCall0() == nCall0 + && pMetaType->GetCall1() == nCall1 ) + { + return pMetaType; + } + pMetaType = aTmpTypeList.Next(); + } + */ + //SvMetaType * pType = aTmpTypeList.First(); + if( !bSet ) + // Ist genau dieser Typ + return pType; + + DBG_ASSERT( aTmpTypeList.First(), "mindestens ein Element" ) + SvMetaTypeRef xType = new SvMetaType( pType->GetName(), 'h', "dummy" ); + xType->SetRef( pType ); + xType->SetIn( bIn ); + xType->SetOut( bOut ); + xType->SetCall0( nCall0 ); + xType->SetCall1( nCall1 ); + + aTmpTypeList.Append( xType ); + return xType; + } + } + rInStm.Seek( nTokPos ); + return NULL; +} + +/************************************************************************* +|* +|* SvIdlDataBase::ReadKnownAttr() +|* +|* Beschreibung +|* +*************************************************************************/ +SvMetaAttribute * SvIdlDataBase::FindAttr( SvMetaAttributeMemberList * pList, + SvMetaAttribute * pAttr ) const +{ + for( ULONG n = 0; n < pList->Count(); n++ ) + { + SvMetaAttribute * p = pList->GetObject( n ); + if( p->GetName() == pAttr->GetName() ) + return pAttr; + else if( p->GetSlotId().GetValue() == pAttr->GetSlotId().GetValue() ) + { + ByteString aStr = "different slot names with same id: "; + aStr += p->GetName(); + aStr += " and "; + aStr += pAttr->GetName(); + WriteError( "warning", "*.srs", aStr ); + return FALSE; + } + } + return NULL; +} + +/************************************************************************* +|* +|* SvIdlDataBase::ReadKnownAttr() +|* +|* Beschreibung +|* +*************************************************************************/ +SvMetaAttribute * SvIdlDataBase::ReadKnownAttr +( + SvTokenStream & rInStm, + SvMetaType * pType /* Wenn der pType == NULL, dann muss der Typ + noch gelesen werden. */ +) +{ + UINT32 nTokPos = rInStm.Tell(); + + if( !pType ) + pType = ReadKnownType( rInStm ); + + if( pType ) + { + // Wenn wir Slots auf die Wiese stellen, d"urfen wir nicht voraussetzen, + // da\s jeder Slot einen anderen Namen hat! +/* + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->IsIdentifier() ) + for( ULONG n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( n ); + if( pAttr->GetName() == pTok->GetString() ) + return pAttr; + } +*/ + } + else + { + // sonst SlotId? + SvToken * pTok = rInStm.GetToken_Next(); + if( pTok->IsIdentifier() ) + { + ULONG n; + if( FindId( pTok->GetString(), &n ) ) + { + for( ULONG n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( n ); + if( pAttr->GetSlotId() == pTok->GetString() ) + return pAttr; + } + } + + ByteString aStr( "Nicht gefunden : " ); + aStr += pTok->GetString(); + DBG_ERROR( aStr.GetBuffer() ); + } + } + + rInStm.Seek( nTokPos ); + return NULL; +} + +SvMetaAttribute* SvIdlDataBase::SearchKnownAttr +( + const SvNumberIdentifier& rId +) +{ + ULONG n; + if( FindId( rId, &n ) ) + { + for( ULONG n = 0; n < aAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = aAttrList.GetObject( n ); + if( pAttr->GetSlotId() == rId ) + return pAttr; + } + } + + return NULL; +} + +/************************************************************************* +|* SvIdlDataBase::ReadKnownClass() +|* +|* Beschreibung +*************************************************************************/ +SvMetaClass * SvIdlDataBase::ReadKnownClass( SvTokenStream & rInStm ) +{ + UINT32 nTokPos = rInStm.Tell(); + SvToken * pTok = rInStm.GetToken_Next(); + + if( pTok->IsIdentifier() ) + for( ULONG n = 0; n < aClassList.Count(); n++ ) + { + SvMetaClass * pClass = aClassList.GetObject( n ); + if( pClass->GetName() == pTok->GetString() ) + return pClass; + } + + rInStm.Seek( nTokPos ); + return NULL; +} + +/************************************************************************* +|* SvIdlDataBase::Write() +|* +|* Beschreibung +*************************************************************************/ +void SvIdlDataBase::Write( const ByteString & rText ) +{ +#ifndef W31 + fprintf( stdout, "%s", rText.GetBuffer() ); +#endif +} + +/************************************************************************* +|* SvIdlDataBase::WriteError() +|* +|* Beschreibung +*************************************************************************/ +void SvIdlDataBase::WriteError( const ByteString & rErrWrn, + const ByteString & rFileName, + const ByteString & rErrorText, + ULONG nRow, ULONG nColumn ) const +{ + //Fehlerbehandlung +#ifndef W31 + fprintf( stderr, "\n%s --- %s: ( %ld, %ld )\n", + rFileName.GetBuffer(), rErrWrn.GetBuffer(), nRow, nColumn ); + + if( rErrorText.Len() ) + { // Fehler gesetzt + fprintf( stderr, "\t%s\n", rErrorText.GetBuffer() ); + } +#endif +} + +/************************************************************************* +|* SvIdlDataBase::WriteError() +|* +|* Beschreibung +*************************************************************************/ +void SvIdlDataBase::WriteError( SvTokenStream & rInStm ) +{ + //Fehlerbehandlung +#ifndef W31 + String aFileName( rInStm.GetFileName() ); + ByteString aErrorText; + ULONG nRow = 0, nColumn = 0; + + rInStm.SeekEnd(); + SvToken *pTok = rInStm.GetToken(); + + // Fehlerposition + nRow = pTok->GetLine(); + nColumn = pTok->GetColumn(); + + if( aError.IsError() ) + { // Fehler gesetzt + // Fehler Token suchen + // Fehlertext + if( aError.GetText().Len() ) + { + aErrorText = "may be <"; + aErrorText += aError.GetText(); + } + SvToken * pPrevTok = NULL; + while( pTok != pPrevTok ) + { + pPrevTok = pTok; + if( pTok->GetLine() == aError.nLine + && pTok->GetColumn() == aError.nColumn ) + break; + pTok = rInStm.GetToken_PrevAll(); + } + + // Fehlerposition + aErrorText += "> at ( "; + aErrorText += aError.nLine; + aErrorText += ", "; + aErrorText += aError.nColumn; + aErrorText += " )"; + + // Fehler zuruecksetzen + aError = SvIdlError(); + } + + WriteError( "error", ByteString( aFileName, RTL_TEXTENCODING_UTF8 ), aErrorText, nRow, nColumn ); + + DBG_ASSERT( pTok, "token must be found" ) + if( !pTok ) + return; + + // Identifier in der Naehe suchen + if( !pTok->IsIdentifier() ) + { + rInStm.GetToken_PrevAll(); + pTok = rInStm.GetToken(); + } + if( pTok && pTok->IsIdentifier() ) + { + ByteString aN = IDLAPP->pHashTable->GetNearString( pTok->GetString() ); + if( aN.Len() ) + fprintf( stderr, "%s versus %s\n", pTok->GetString().GetBuffer(), aN.GetBuffer() ); + } +#endif +} + +/****************** SvIdlWorkingBase ****************************************/ +/************************************************************************* +|* SvIdlWorkingBase::SvIdlWorkingBase() +|* +|* Beschreibung +*************************************************************************/ +SvIdlWorkingBase::SvIdlWorkingBase() +{ +} + +/************************************************************************* +|* SvIdlWorkingBase::ReadSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::ReadSvIdl( SvTokenStream & rInStm, BOOL bImported, const String & rPath ) +{ + aPath = rPath; // nur fuer den durchlauf gueltig + SvToken * pTok; + BOOL bOk = TRUE; + pTok = rInStm.GetToken(); + // nur ein import ganz am Anfang + if( pTok->Is( SvHash_import() ) ) + { + rInStm.GetToken_Next(); + rInStm.Read( '(' ); // optional + pTok = rInStm.GetToken_Next(); + if( pTok->IsString() ) + { + DirEntry aFullName( String::CreateFromAscii( pTok->GetString().GetBuffer() ) ); + if( aFullName.Find( rPath ) ) + { + SvFileStream aStm( aFullName.GetFull(), + STREAM_STD_READ | STREAM_NOCREATE ); + Load( aStm ); + if( aStm.GetError() != SVSTREAM_OK ) + { + if( aStm.GetError() == SVSTREAM_WRONGVERSION ) + { + ByteString aStr( "wrong version, file " ); + aStr += ByteString( aFullName.GetFull(), RTL_TEXTENCODING_UTF8 ); + SetError( aStr, pTok ); + WriteError( rInStm ); + bOk = FALSE; + } + else + { + aStm.Seek( 0 ); + aStm.ResetError(); + SvTokenStream aTokStm( aStm, aFullName.GetFull() ); + bOk = ReadSvIdl( aTokStm, TRUE, rPath ); + } + } + } + else + bOk = FALSE; + } + else + bOk = FALSE; + } + + UINT32 nBeginPos = 0xFFFFFFFF; // kann mit Tell nicht vorkommen + + while( bOk && nBeginPos != rInStm.Tell() ) + { + nBeginPos = rInStm.Tell(); + pTok = rInStm.GetToken(); + if( pTok->IsEof() ) + return TRUE; + if( pTok->IsEmpty() ) + bOk = FALSE; + + // nur ein import ganz am Anfang + /*else */if( pTok->Is( SvHash_module() ) ) + { + SvMetaModuleRef aModule = new SvMetaModule( rInStm.GetFileName(), bImported ); + if( aModule->ReadSvIdl( *this, rInStm ) ) + GetModuleList().Append( aModule ); + else + bOk = FALSE; + } + else + bOk = FALSE; + } + if( !bOk || !pTok->IsEof() ) + { + //Fehlerbehandlung + WriteError( rInStm ); + return FALSE; + } + return TRUE; +} + +/************************************************************************* +|* SvIdlWorkingBase::WriteSvIdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteSvIdl( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + SvStringHashList aList; + if( GetIdTable() ) + { + GetIdTable()->FillHashList( &aList ); + SvStringHashEntry * pEntry = aList.First(); + while( pEntry ) + { + rOutStm << "#define " << pEntry->GetName().GetBuffer() + << '\t' << ByteString( pEntry->GetValue() ).GetBuffer() + << endl; + pEntry = aList.Next(); + } + } + + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + //if( !pModule->IsImported() ) + pModule->WriteSvIdl( *this, rOutStm, 0 ); + } + return TRUE; +} + +/************************************************************************* +|* SvIdlWorkingBase::WriteSfx() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteSfx( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + // alle Tmp-Variablen fuer das Schreiben zuruecksetzen + WriteReset(); + SvMemoryStream aTmpStm( 256000, 256000 ); + ULONG n; + for( n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->WriteSfx( *this, aTmpStm ); + aTmpStm.Seek( 0 ); + } + for( n = 0; n < aUsedTypes.Count(); n++ ) + { + SvMetaType * pType = aUsedTypes.GetObject( n ); + pType->WriteSfx( *this, rOutStm ); + } + aUsedTypes.Clear(); + rOutStm << aTmpStm; + return TRUE; +} + +BOOL SvIdlWorkingBase::WriteHelpIds( SvStream& rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + Table aIdTable; + ULONG n; + for( n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + //if( !pModule->IsImported() ) + pModule->WriteHelpIds( *this, rOutStm, &aIdTable ); + } + + const SvMetaAttributeMemberList & rAttrList = GetAttrList(); + for( n = 0; n < rAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = rAttrList.GetObject( n ); + pAttr->WriteHelpId( *this, rOutStm, &aIdTable ); + } + + return TRUE; +} + +/************************************************************************* +|* SvIdlWorkingBase::WriteCHeader() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteCHeader( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + ULONG n; + for( n = 0; n < GetTypeList().Count(); n++ ) + { + SvMetaType * pType = GetTypeList().GetObject( n ); + pType->Write( *this, rOutStm, 0, WRITE_C_HEADER ); + } + for( n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + { + aModulePrefix = pModule->GetModulePrefix(); + pModule->Write( *this, rOutStm, 0, WRITE_C_HEADER ); + } + } + return TRUE; +} + +/************************************************************************* +|* SvIdlWorkingBase::WriteCSource() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteCSource( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + ULONG n; + for( n = 0; n < GetTypeList().Count(); n++ ) + { + SvMetaType * pType = GetTypeList().GetObject( n ); + pType->Write( *this, rOutStm, 0, WRITE_C_SOURCE ); + } + rOutStm << endl; + for( n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + { + aModulePrefix = pModule->GetModulePrefix(); + pModule->Write( *this, rOutStm, 0, WRITE_C_SOURCE ); + } + } + return TRUE; +} + + + +/************************************************************************* +|* SvIdlWorkingBase::WriteSfxItem() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteSfxItem( SvStream & rOutStm ) +{ +/* + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + { + const SvMetaItemMemberList & rItemList = pModule->GetItemList(); + for( ULONG i = 0; i < rItemList.Count(); i++ ) + { + SvMetaItem * pItem = rItemList.GetObject( i ); + if( HAS_BASE( SvMetaItem, pItem ) ) + { + // Header + ((SvMetaItem*)pItem)->WriteSfxItem( *this, rOutStm, TRUE ); + // Source + ((SvMetaItem*)pItem)->WriteSfxItem( *this, rOutStm, FALSE ); + } + } + } + } + return TRUE; +*/ + return FALSE; +} + +/************************************************************************* +|* SvIdlWorkingBase::WriteSbx() +|* +|* Beschreibung +*************************************************************************/ +/* +BOOL SvIdlWorkingBase::WriteSbx( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + SvNamePosList aList; + SvMemoryStream aTmpStm( 256000, 256000 ); + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->WriteSbx( *this, aTmpStm, aList ); + } + // Version, steht auch in so2 auto.cxx + rOutStm << (UINT32)0x1258F170; + rOutStm << (UINT32)aList.Count(); + ULONG i ; + for( i = 0; i < aList.Count(); i++ ) + { + SvNamePos * p = aList.GetObject( i ); + rOutStm << p->aUUId; + rOutStm << (UINT32)0; + } + // Ende der Tabelle + ULONG nEndPos = rOutStm.Tell(); + rOutStm.Seek( 2 * sizeof( UINT32 ) ); + SvGlobalName aTmpName; + for( i = 0; i < aList.Count(); i++ ) + { + SvNamePos * p = aList.GetObject( i ); + // Um an die richtige Position zu gelangen + rOutStm >> aTmpName; + // richtigen Offset schreiben + rOutStm << (UINT32)(nEndPos + p->nStmPos); + } + aTmpStm.Seek( 0L ); + rOutStm << aTmpStm; + + return TRUE; +} +*/ + +/************************************************************************* +|* SvIdlWorkingBase::WriteOdl() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteOdl( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->Write( *this, rOutStm, 0, WRITE_ODL ); + } + return TRUE; +} + +/************************************************************************* +|* OdlWorkingBase::WriteSrc() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteSrc( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + Table aIdTable; + ULONG n; + for( n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + //if( !pModule->IsImported() ) + pModule->WriteSrc( *this, rOutStm, &aIdTable ); + } + const SvMetaAttributeMemberList & rAttrList = GetAttrList(); + for( n = 0; n < rAttrList.Count(); n++ ) + { + SvMetaAttribute * pAttr = rAttrList.GetObject( n ); + pAttr->WriteSrc( *this, rOutStm, &aIdTable ); + } + + return TRUE; +} + +/************************************************************************* +|* OdlWorkingBase::WriteCxx() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteCxx( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->WriteCxx( *this, rOutStm, 0 ); + } + + return TRUE; +} + +/************************************************************************* +|* OdlWorkingBase::WriteHxx() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteHxx( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->WriteHxx( *this, rOutStm, 0 ); + } + + return TRUE; +} + +void SvIdlDataBase::StartNewFile( const String& rName ) +{ + bExport = ( aExportFile.EqualsIgnoreCaseAscii( rName ) ); +} + +void SvIdlDataBase::AppendAttr( SvMetaAttribute *pAttr ) +{ + aAttrList.Append( pAttr ); + if ( bExport ) + pAttr->SetNewAttribute( TRUE ); +} + +BOOL SvIdlWorkingBase::WriteCSV( SvStream& rStrm ) +{ + SvMetaAttributeMemberList &rList = GetAttrList(); + ULONG nCount = rList.Count(); + for ( ULONG n=0; nIsNewAttribute() ) + { + rList.GetObject(n)->WriteCSV( *this, rStrm ); + } + } + + if ( rStrm.GetError() != SVSTREAM_OK ) + return FALSE; + else + return TRUE; +} + +/************************************************************************* +|* SvIdlWorkingBase::WriteDocumentation() +|* +|* Beschreibung +*************************************************************************/ +BOOL SvIdlWorkingBase::WriteDocumentation( SvStream & rOutStm ) +{ + if( rOutStm.GetError() != SVSTREAM_OK ) + return FALSE; + + for( ULONG n = 0; n < GetModuleList().Count(); n++ ) + { + SvMetaModule * pModule = GetModuleList().GetObject( n ); + if( !pModule->IsImported() ) + pModule->Write( *this, rOutStm, 0, WRITE_DOCU ); + } + return TRUE; +} + + + +#endif // IDL_COMPILER + diff --git a/idl/source/prj/globals.cxx b/idl/source/prj/globals.cxx new file mode 100644 index 000000000000..9e3468439842 --- /dev/null +++ b/idl/source/prj/globals.cxx @@ -0,0 +1,233 @@ +/************************************************************************* + * + * $RCSfile: globals.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +/****************** I N C L U D E S **************************************/ + +#ifndef _SHL_HXX //autogen +#include +#endif + +#include +#include +#pragma hdrstop + +/****************** G L O B A L S ****************************************/ +#ifdef DOS +static IdlDll * pApp = NULL; +IdlDll * GetIdlApp() +{ + if( !pApp ) + pApp = new IdlDll(); + return pApp; +} +#else +IdlDll * GetIdlApp() +{ + if( !(*(IdlDll**)GetAppData(SHL_IDL)) ) + { + (*(IdlDll**)GetAppData(SHL_IDL)) = new IdlDll(); + // Temporaer, sonst nur wenn Compiler + //GetIdlApp()->pHashTable = new SvStringHashTable( 2801 ); + //GetIdlApp()->pGlobalNames = new SvGlobalHashNames(); + } + return (*(IdlDll**)GetAppData(SHL_IDL)); +} +#endif + +IdlDll::IdlDll() + : pHashTable( NULL ) + , pGlobalNames( NULL ) + , pClassMgr( NULL ) + +{ + pClassMgr = new SvClassManager(); + // File OBJECT.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaAttribute ); + pClassMgr->SV_CLASS_REGISTER( SvMetaClass ); + //File SLOT.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaSlot ); + //File MODULE.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaModule ); + //File BASOBJ.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaObject ); + pClassMgr->SV_CLASS_REGISTER( SvMetaName ); + pClassMgr->SV_CLASS_REGISTER( SvMetaExtern ); + pClassMgr->SV_CLASS_REGISTER( SvMetaReference ); + //File TYPES.HXX: + pClassMgr->SV_CLASS_REGISTER( SvMetaType ); + pClassMgr->SV_CLASS_REGISTER( SvMetaTypeString ); + pClassMgr->SV_CLASS_REGISTER( SvMetaEnumValue ); + pClassMgr->SV_CLASS_REGISTER( SvMetaTypeEnum ); + pClassMgr->SV_CLASS_REGISTER( SvMetaTypevoid ); + pClassMgr->SV_CLASS_REGISTER( SvClassElement ); +} + +IdlDll::~IdlDll() +{ + delete pGlobalNames; + delete pClassMgr; + delete pHashTable; +} + +/************************************************************************* +|* +|* SvGlobalHashNames::SvGlobalHashNames() +|* +|* Beschreibung +|* Ersterstellung MM 08.08.91 +|* Letzte Aenderung MM 08.08.91 +|* +*************************************************************************/ +inline SvStringHashEntry * INS( const ByteString & rName ) +{ + UINT32 nIdx; + IDLAPP->pHashTable->Insert( rName, &nIdx ); + return (SvStringHashEntry * )IDLAPP->pHashTable->Get( nIdx ); +} +#define A_ENTRY( Name ) , MM_##Name( INS( #Name ) ) + +SvGlobalHashNames::SvGlobalHashNames() + : MM_Name( INS( "Name" ) ) + , MM_module( INS( "module" ) ) + , MM_interface( INS( "interface" ) ) + , MM_in( INS( "in" ) ) + , MM_out( INS( "out" ) ) + , MM_inout( INS( "inout" ) ) + , MM_String( INS( "String" ) ) + , MM_UCHAR( INS( "UCHAR" ) ) + , MM_USHORT( INS( "USHORT" ) ) + , MM_uuid( INS( "uuid" ) ) + , MM_HelpContext( INS( "HelpContext" ) ) + , MM_HelpText( INS( "HelpText" ) ) + , MM_void( INS( "void" ) ) + , MM_shell( INS( "shell" ) ) + , MM_Get( INS( "Get" ) ) + , MM_Set( INS( "Set" ) ) + , MM_SlotId( INS( "SlotId" ) ) + , MM_HasCoreId( INS( "HasCoreId" ) ) + , MM_Cachable( INS( "Cachable" ) ) + , MM_Volatile( INS( "Volatile" ) ) + , MM_Toggle( INS( "Toggle" ) ) + , MM_AutoUpdate( INS( "AutoUpdate" ) ) + , MM_Synchron( INS( "Synchron" ) ) + , MM_Asynchron( INS( "Asynchron" ) ) + A_ENTRY(RecordPerItem) + A_ENTRY(RecordPerSet) + A_ENTRY(RecordManual) + A_ENTRY(NoRecord) + A_ENTRY(RecordAbsolute) + A_ENTRY(enum) + A_ENTRY(UINT16) + A_ENTRY(INT16) + A_ENTRY(UINT32) + A_ENTRY(INT32) + A_ENTRY(int) + A_ENTRY(BOOL) + A_ENTRY(char) + A_ENTRY(BYTE) + A_ENTRY(float) + A_ENTRY(double) + A_ENTRY(item) + A_ENTRY(PseudoSlots) + A_ENTRY(map) + A_ENTRY(Default) + A_ENTRY(HelpFile) + A_ENTRY(Version) + A_ENTRY(import) + A_ENTRY(SlotIdFile) + A_ENTRY(SvName) + A_ENTRY(SbxName) + A_ENTRY(ItemName) + A_ENTRY(OdlName) + A_ENTRY(include) + A_ENTRY(ExecMethod) + A_ENTRY(StateMethod) + A_ENTRY(GroupId) + A_ENTRY(HasDialog) + A_ENTRY(MenuConfig) + A_ENTRY(ToolBoxConfig) + A_ENTRY(StatusBarConfig) + A_ENTRY(AccelConfig) + A_ENTRY(AllConfig) + A_ENTRY(FastCall) + A_ENTRY(TypeLibFile) + A_ENTRY(Export) + A_ENTRY(Automation) + A_ENTRY(PseudoPrefix) + A_ENTRY(define) + A_ENTRY(SbxObject) + A_ENTRY(Container) + A_ENTRY(PlugComm) + A_ENTRY(IsCollection) + A_ENTRY(ReadOnlyDoc) + A_ENTRY(ConfigName) + A_ENTRY(struct) + A_ENTRY(union) + A_ENTRY(typedef) + A_ENTRY(Readonly) + A_ENTRY(SlotType) + A_ENTRY(ModulePrefix) + A_ENTRY(DisableFlags) + A_ENTRY(Hidden) + A_ENTRY(Description) + A_ENTRY(UnoName) +{} + diff --git a/idl/source/prj/idldll.cxx b/idl/source/prj/idldll.cxx new file mode 100644 index 000000000000..b0862cd6f335 --- /dev/null +++ b/idl/source/prj/idldll.cxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * $RCSfile: idldll.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#pragma hdrstop + +#ifdef WIN + +#ifndef _SVWIN_H +#include +#endif + +#ifndef _SYSDEP_HXX +#include +#endif + +// Statische DLL-Verwaltungs-Variablen +static HINSTANCE hDLLInst = 0; // HANDLE der DLL + + +/*************************************************************************** +|* +|* LibMain() +|* +|* Beschreibung Initialisierungsfunktion der DLL +|* Ersterstellung TH 05.05.93 +|* Letzte Aenderung TH 05.05.93 +|* +***************************************************************************/ + +extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR ) +{ +#ifndef WNT + if ( nHeap ) + UnlockData( 0 ); +#endif + + hDLLInst = hDLL; + + return TRUE; +} + +/*************************************************************************** +|* +|* WEP() +|* +|* Beschreibung DLL-Deinitialisierung +|* Ersterstellung TH 05.05.93 +|* Letzte Aenderung TH 05.05.93 +|* +***************************************************************************/ + +extern "C" int CALLBACK WEP( int ) +{ + return 1; +} + +#endif diff --git a/idl/source/prj/makefile.mk b/idl/source/prj/makefile.mk new file mode 100644 index 000000000000..e142121cdd68 --- /dev/null +++ b/idl/source/prj/makefile.mk @@ -0,0 +1,101 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=..$/.. + +PROJECTPCH4DLL=TRUE +PROJECTPCH=idlpch +PROJECTPCHSOURCE=$(PRJ)$/util$/idlpch + +PRJNAME=SVIDL +TARGET=prj + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +.IF "$(COM)"=="WTC" +CFLAGS+=-od +.ENDIF + +CDEFS+=-DIDL_COMPILER +# --- Files -------------------------------------------------------------- + +CXXFILES= command.cxx \ + globals.cxx \ + database.cxx \ + svidl.cxx \ + idldll.cxx \ + $(PROJECTPCHSOURCE).cxx + +OBJFILES= $(OBJ)$/command.obj \ + $(OBJ)$/svidl.obj \ + $(OBJ)$/globals.obj \ + $(OBJ)$/idldll.obj \ + $(OBJ)$/database.obj + +# --- Targets ------------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/idl/source/prj/svidl.cxx b/idl/source/prj/svidl.cxx new file mode 100644 index 000000000000..6bd36f4b4fdb --- /dev/null +++ b/idl/source/prj/svidl.cxx @@ -0,0 +1,463 @@ +/************************************************************************* + * + * $RCSfile: svidl.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#include +#include +#include +#include +#include + +#ifndef _FSYS_HXX //autogen +#include +#endif + +#ifndef _STRING_HXX //autogen +#include +#endif + +#pragma hdrstop + +#define BR 0x8000 +BOOL FileMove_Impl( const String & rFile1, const String & rFile2, BOOL bImmerVerschieben ) +{ + //printf( "Move from %s to %s\n", rFile2.GetStr(), rFile1.GetStr() ); + ULONG nC1 = 0; + ULONG nC2 = 1; + if( !bImmerVerschieben ) + { + SvFileStream aOutStm1( rFile1, STREAM_STD_READ ); + SvFileStream aOutStm2( rFile2, STREAM_STD_READ ); + if( aOutStm1.GetError() == SVSTREAM_OK ) + { + void * pBuf1 = new BYTE[ BR ]; + void * pBuf2 = new BYTE[ BR ]; + nC1 = aOutStm1.Read( pBuf1, BR ); + nC2 = aOutStm2.Read( pBuf2, BR ); + BOOL bOk = TRUE; + while( nC1 == nC2 ) + { + if( memcmp( pBuf1, pBuf2, nC1 ) ) + { + nC1++; + break; + } + else + { + if( 0x8000 != nC1 ) + break; + nC1 = aOutStm1.Read( pBuf1, BR ); + nC2 = aOutStm2.Read( pBuf2, BR ); + } + } + delete pBuf1; + delete pBuf2; + } + } + DirEntry aF2( rFile2 ); + if( nC1 != nC2 ) + {// es hat sich etwas geaendert + DirEntry aF1( rFile1 ); + aF1.Kill(); + // Datei verschieben + if( aF2.MoveTo( aF1 ) ) + { + // Beide Dateien loeschen + aF1.Kill(); + aF2.Kill(); + return FALSE; + } +/* + else + { + printf( "%s to %s moved\n", + rFile2.GetStr(), rFile1.GetStr() ); + } +*/ + return TRUE; + } + return 0 == aF2.Kill(); +} + +/************************************************************************* +|* main() +|* +|* Beschreibung +*************************************************************************/ +#if defined( UNX ) || (defined( PM2 ) && defined( CSET )) || defined (WTC) || defined (MAC) || defined (MTW) +int main ( int argc, char ** argv) +{ +#else +int cdecl main ( int argc, char ** argv) +{ +#endif + + printf( "StarView Interface Definition Language (IDL) Compiler 3.0\n" ); + +/* + pStr = ::ResponseFile( &aCmdLine, argv, argc ); + if( pStr ) + { + printf( "Cannot open response file <%s>\n", pStr ); + return( 1 ); + }; +*/ + + String aTmpListFile; + String aTmpSlotMapFile; + String aTmpSfxItemFile; + String aTmpDataBaseFile; + String aTmpCallingFile; + String aTmpSrcFile; + String aTmpCxxFile; + String aTmpHxxFile; + String aTmpHelpIdFile; + String aTmpCSVFile; + String aTmpDocuFile; + + SvCommand aCommand( argc, argv ); + Init( aCommand ); + SvIdlWorkingBase * pDataBase = new SvIdlWorkingBase(); + + int nExit = 0; + if( aCommand.aExportFile.Len() ) + { + DirEntry aDE( aCommand.aExportFile ); + pDataBase->SetExportFile( aDE.GetName() ); + } + + if( ReadIdl( pDataBase, aCommand ) ) + { + if( nExit == 0 && aCommand.aDocuFile.Len() ) + { + DirEntry aDE( aCommand.aDocuFile ); + aDE.ToAbs(); + aTmpDocuFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpDocuFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteDocumentation( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write documentation file: "; + aStr += ByteString( aCommand.aDocuFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aListFile.Len() ) + { + DirEntry aDE( aCommand.aListFile ); + aDE.ToAbs(); + aTmpListFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpListFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteSvIdl( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write list file: "; + aStr += ByteString( aCommand.aListFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aSlotMapFile.Len() ) + { + DirEntry aDE( aCommand.aSlotMapFile ); + aDE.ToAbs(); + aTmpSlotMapFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpSlotMapFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteSfx( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write slotmap file: "; + aStr += ByteString( aCommand.aSlotMapFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aHelpIdFile.Len() ) + { + DirEntry aDE( aCommand.aHelpIdFile ); + aDE.ToAbs(); + aTmpHelpIdFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aStm( aTmpHelpIdFile, STREAM_READWRITE | STREAM_TRUNC ); + if (!pDataBase->WriteHelpIds( aStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write help ID file: "; + aStr += ByteString( aCommand.aHelpIdFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aCSVFile.Len() ) + { + DirEntry aDE( aCommand.aCSVFile ); + aDE.ToAbs(); + aTmpCSVFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aStm( aTmpCSVFile, STREAM_READWRITE | STREAM_TRUNC ); + if (!pDataBase->WriteCSV( aStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write CSV file: "; + aStr += ByteString( aCommand.aCSVFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aSfxItemFile.Len() ) + { + DirEntry aDE( aCommand.aSfxItemFile ); + aDE.ToAbs(); + aTmpSfxItemFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpSfxItemFile, STREAM_READWRITE | STREAM_TRUNC ); + if( !pDataBase->WriteSfxItem( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write item file: "; + aStr += ByteString( aCommand.aSfxItemFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aDataBaseFile.Len() ) + { + DirEntry aDE( aCommand.aDataBaseFile ); + aDE.ToAbs(); + aTmpDataBaseFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpDataBaseFile, STREAM_READWRITE | STREAM_TRUNC ); + pDataBase->Save( aOutStm, aCommand.nFlags ); + if( aOutStm.GetError() != SVSTREAM_OK ) + { + nExit = -1; + ByteString aStr = "cannot write database file: "; + aStr += ByteString( aCommand.aDataBaseFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } +/* + if( nExit == 0 && aCommand.aCallingFile.Len() ) + { + DirEntry aDE( aCommand.aCallingFile ); + aDE.ToAbs(); + aTmpCallingFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpCallingFile, STREAM_READWRITE | STREAM_TRUNC ); + pDataBase->WriteSbx( aOutStm ); + //pDataBase->Save( aOutStm, aCommand.nFlags | IDL_WRITE_CALLING ); + if( aOutStm.GetError() != SVSTREAM_OK ) + { + nExit = -1; + ByteString aStr = "cannot write calling file: "; + aStr += aCommand.aCallingFile; + fprintf( stderr, "%s\n", aStr.GetStr() ); + } + } + if( nExit == 0 && aCommand.aCxxFile.Len() ) + { + DirEntry aDE( aCommand.aCxxFile ); + aDE.ToAbs(); + aTmpCxxFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpCxxFile, STREAM_READWRITE | STREAM_TRUNC ); + + aOutStm << "#pragma hdrstop" << endl; + aOutStm << "#include <"; + if( aCommand.aHxxFile.Len() ) + aOutStm << DirEntry(aCommand.aHxxFile).GetName().GetBuffer(); + else + { + DirEntry aDE( aCommand.aCxxFile ); + aDE.SetExtension( "hxx" ); + aOutStm << aDE.GetName().GetBuffer); + } + aOutStm << '>' << endl; + if( !pDataBase->WriteCxx( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write cxx file: "; + aStr += ByteString( aCommand.aCxxFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + if( nExit == 0 && aCommand.aHxxFile.Len() ) + { + DirEntry aDE( aCommand.aHxxFile ); + aDE.ToAbs(); + aTmpHxxFile = aDE.GetPath().TempName().GetFull(); + SvFileStream aOutStm( aTmpHxxFile, STREAM_READWRITE | STREAM_TRUNC ); + + aOutStm << "#include " << endl; + if( !pDataBase->WriteHxx( aOutStm ) ) + { + nExit = -1; + ByteString aStr = "cannot write cxx file: "; + aStr += ByteString( aCommand.aHxxFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + } + */ + } + else + nExit = -1; + + if( nExit == 0 ) + { + BOOL bErr = FALSE; + BOOL bDoMove = aCommand.aTargetFile.Len() == 0; + String aErrFile; + if( !bErr && aCommand.aListFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aListFile, aTmpListFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aListFile; + } + if( !bErr && aCommand.aSlotMapFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aSlotMapFile, aTmpSlotMapFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aSlotMapFile; + } + if( !bErr && aCommand.aSfxItemFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aSfxItemFile, aTmpSfxItemFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aSfxItemFile; + } + if( !bErr && aCommand.aDataBaseFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aDataBaseFile, aTmpDataBaseFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aDataBaseFile; + } + if( !bErr && aCommand.aCallingFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aCallingFile, aTmpCallingFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aCallingFile; + } + if( !bErr && aCommand.aCxxFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aCxxFile, aTmpCxxFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aCxxFile; + } + if( !bErr && aCommand.aHxxFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aHxxFile, aTmpHxxFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aHxxFile; + } + if( !bErr && aCommand.aHelpIdFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aHelpIdFile, aTmpHelpIdFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aHelpIdFile; + } + if( !bErr && aCommand.aCSVFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aCSVFile, aTmpCSVFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aCSVFile; + } + if( !bErr && aCommand.aDocuFile.Len() ) + { + bErr |= !FileMove_Impl( aCommand.aDocuFile, aTmpDocuFile, bDoMove ); + if( bErr ) + aErrFile = aCommand.aDocuFile; + } + + if( bErr ) + { + nExit = -1; + ByteString aStr = "cannot write file: "; + aStr += ByteString( aErrFile, RTL_TEXTENCODING_UTF8 ); + fprintf( stderr, "%s\n", aStr.GetBuffer() ); + } + else + { + if( aCommand.aTargetFile.Len() ) + { +#ifdef ICC + DirEntry aT(aCommand.aTargetFile); + aT.Kill(); +#endif + // Datei stempeln, da idl korrekt durchlaufen wurde + SvFileStream aOutStm( aCommand.aTargetFile, + STREAM_READWRITE | STREAM_TRUNC ); + } + } + } + + if( nExit != 0 ) + { + if( aCommand.aListFile.Len() ) + DirEntry( aTmpListFile ).Kill(); + if( aCommand.aSlotMapFile.Len() ) + DirEntry( aTmpSlotMapFile ).Kill(); + if( aCommand.aSfxItemFile.Len() ) + DirEntry( aTmpSfxItemFile ).Kill(); + if( aCommand.aDataBaseFile.Len() ) + DirEntry( aTmpDataBaseFile ).Kill(); + if( aCommand.aCallingFile.Len() ) + DirEntry( aTmpCallingFile ).Kill(); + if( aCommand.aCxxFile.Len() ) + DirEntry( aTmpCxxFile ).Kill(); + if( aCommand.aHxxFile.Len() ) + DirEntry( aTmpHxxFile ).Kill(); + } + + delete pDataBase; + DeInit(); + if( nExit != 0 ) + fprintf( stderr, "svidl terminated with errors\n" ); + return nExit; +} + diff --git a/idl/source/svidl.dat b/idl/source/svidl.dat new file mode 100644 index 000000000000..4750475c7462 Binary files /dev/null and b/idl/source/svidl.dat differ diff --git a/idl/util/idlpch.cxx b/idl/util/idlpch.cxx new file mode 100644 index 000000000000..66b80a176971 --- /dev/null +++ b/idl/util/idlpch.cxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * $RCSfile: idlpch.cxx,v $ + * + * $Revision: 1.1.1.1 $ + * + * last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ +#ifdef MAC +#include +#else +#include +#endif +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma hdrstop diff --git a/idl/util/makefile.mk b/idl/util/makefile.mk new file mode 100644 index 000000000000..b4161ec45e82 --- /dev/null +++ b/idl/util/makefile.mk @@ -0,0 +1,151 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1.1.1 $ +# +# last change: $Author: hr $ $Date: 2000-09-18 16:30:41 $ +# +# The Contents of this file are made available subject to the terms of +# either of the following licenses +# +# - GNU Lesser General Public License Version 2.1 +# - Sun Industry Standards Source License Version 1.1 +# +# Sun Microsystems Inc., October, 2000 +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2000 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +# +# Sun Industry Standards Source License Version 1.1 +# ================================================= +# The contents of this file are subject to the Sun Industry Standards +# Source License Version 1.1 (the "License"); You may not use this file +# except in compliance with the License. You may obtain a copy of the +# License at http://www.openoffice.org/license.html. +# +# Software provided under this License is provided on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, +# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. +# See the License for the specific provisions governing your rights and +# obligations concerning the Software. +# +# The Initial Developer of the Original Code is: Sun Microsystems, Inc. +# +# Copyright: 2000 by Sun Microsystems, Inc. +# +# All Rights Reserved. +# +# Contributor(s): _______________________________________ +# +# +# +#************************************************************************* + +PRJ=.. + +PRJPCH= + +PRJNAME=SVIDL +TARGET=idl +VERSION=$(UPD) + +TARGETTYPE=CUI + +# --- Settings ----------------------------------------------------------- + +.INCLUDE : svpre.mk +.INCLUDE : settings.mk +.INCLUDE : sv.mk + +# --- Files -------------------------------------------------------------- + +LIB1TARGET= $(LB)$/$(TARGET).lib +LIB1FILES = $(LB)$/prj.lib \ + $(LB)$/objects.lib \ + $(LB)$/cmptools.lib + +.IF "$(GUI)" != "WIN" +APP1TARGET= svidl + +.IF "$(GUI)" != "MAC" +APP1DEPN= $(L)$/itools.lib +.ENDIF + +APP1STDLIBS=\ + $(TOOLSLIB) + +APP1LIBS= $(LIBPRE) $(LB)$/$(TARGET).lib +.IF "$(GUI)" != "UNX" +.IF "$(COM)"=="WTC" +APP1OBJS= $(OBJ)$/svidl.obj +.ELSE +APP1OBJS= $(OBJ)$/svidl.obj \ + $(OBJ)$/command.obj +.ENDIF +.ENDIF +.IF "$(COM)" == "WTC" +APP1STACK=32768 +.ENDIF +.IF "$(GUI)" != "OS2" +APP1STACK=32768 +.ENDIF +.ENDIF + +.IF "$(OS)"=="LINUX" +APP1STDLIBS+=-lcrypt +.ENDIF + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +# ------------------------------------------------------------------- +# PM2 +# ------------------------------------------------------------------- + +.IF "$(GUI)" == "OS2" + +$(MISC)$/$(APP1TARGET).def : makefile + echo NAME SV-IDL WINDOWCOMPAT >$@ + echo DESCRIPTION 'SV-IDL-Compiler' >>$@ +.IF "$(COM)" != "BLC" + echo STUB 'os2STUB.EXE' >>$@ +.ENDIF + echo DATA MULTIPLE >>$@ + echo EXETYPE OS2 >>$@ + echo PROTMODE >>$@ + echo HEAPSIZE 16000 >>$@ + echo STACKSIZE 48000 >>$@ +.ENDIF + +# --- Filter-Datei --- + +.IF "$(GUI)" != "DOS" +$(MISC)$/$(SHL1TARGET).flt: makefile + @echo ------------------------------ + @echo Making: $@ + @echo WEP>$@ + @echo LIBMAIN>>$@ + @echo LibMain>>$@ + @echo Stg>>$@ +.ENDIF + diff --git a/idl/util/svidl.hdb b/idl/util/svidl.hdb new file mode 100644 index 000000000000..d57bedb45373 --- /dev/null +++ b/idl/util/svidl.hdb @@ -0,0 +1,25 @@ +write "/*************************************************************************" +write "* SV.HXX" +write "* __DATE__" +write "* (c) 1992-1994 STAR DIVISION" +write "*************************************************************************/" +write "#ifndef _SVIDL_HXX" +write "#define _SVIDL_HXX" +write "#ifndef _PSTREAM_HXX" +write "#include " +write "#endif" +write "#ifndef _SBX_HXX" +write "#include " +write "#endif" +write "#define IDL_COMPILER /*vorlaeufig immer */" +file char.hxx +file hash.hxx +file lex.hxx +file bastype.hxx +file basobj.hxx +file types.hxx +file object.hxx +file slot.hxx +file module.hxx +file database.hxx +write "#endif" -- cgit