1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: types.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_idl.hxx"
37 #include <tools/debug.hxx>
41 #include <globals.hxx>
42 #include <database.hxx>
44 /****************** SvMetaAttribute *************************************/
45 /************************************************************************/
46 SV_IMPL_META_FACTORY1( SvMetaAttribute
, SvMetaReference
);
47 /*************************************************************************
48 |* SvMetaAttribute::SvMetaAttribute()
51 *************************************************************************/
52 SvMetaAttribute::SvMetaAttribute()
53 : aAutomation( TRUE
, FALSE
)
54 , aExport( TRUE
, FALSE
)
55 , aIsCollection ( FALSE
, FALSE
)
56 , aReadOnlyDoc ( TRUE
, FALSE
)
57 , aHidden( FALSE
, FALSE
)
62 SvMetaAttribute::SvMetaAttribute( SvMetaType
* pType
)
64 , aAutomation( TRUE
, FALSE
)
65 , aExport( TRUE
, FALSE
)
66 , aIsCollection ( FALSE
, FALSE
)
67 , aReadOnlyDoc ( TRUE
, FALSE
)
68 , aHidden( FALSE
, FALSE
)
73 /*************************************************************************
74 |* SvMetaAttribute::Load()
75 |* SvMetaAttribute::Save()
78 *************************************************************************/
79 void SvMetaAttribute::Load( SvPersistStream
& rStm
)
81 SvMetaReference::Load( rStm
);
91 if( nMask
& 0x02 ) rStm
>> aSlotId
;
92 if( nMask
& 0x04 ) rStm
>> aExport
;
93 if( nMask
& 0x08 ) rStm
>> aReadonly
;
94 if( nMask
& 0x10 ) rStm
>> aAutomation
;
95 if( nMask
& 0x20 ) rStm
>> aIsCollection
;
96 if( nMask
& 0x40 ) rStm
>> aReadOnlyDoc
;
97 if( nMask
& 0x80 ) rStm
>> aHidden
;
100 void SvMetaAttribute::Save( SvPersistStream
& rStm
)
102 SvMetaReference::Save( rStm
);
106 if( aType
.Is() ) nMask
|= 0x1;
107 if( aSlotId
.IsSet() ) nMask
|= 0x2;
108 if( aExport
.IsSet() ) nMask
|= 0x4;
109 if( aReadonly
.IsSet() ) nMask
|= 0x8;
110 if( aAutomation
.IsSet() ) nMask
|= 0x10;
111 if( aIsCollection
.IsSet() ) nMask
|= 0x20;
112 if( aReadOnlyDoc
.IsSet() ) nMask
|= 0x40;
113 if( aHidden
.IsSet() ) nMask
|= 0x80;
117 if( nMask
& 0x1 ) rStm
<< aType
;
118 if( nMask
& 0x2 ) rStm
<< aSlotId
;
119 if( nMask
& 0x4 ) rStm
<< aExport
;
120 if( nMask
& 0x8 ) rStm
<< aReadonly
;
121 if( nMask
& 0x10 ) rStm
<< aAutomation
;
122 if( nMask
& 0x20 ) rStm
<< aIsCollection
;
123 if( nMask
& 0x40 ) rStm
<< aReadOnlyDoc
;
124 if( nMask
& 0x80 ) rStm
<< aHidden
;
127 /*************************************************************************
128 |* SvMetaAttribute::GetType()
131 *************************************************************************/
132 SvMetaType
* SvMetaAttribute::GetType() const
134 if( aType
.Is() || !GetRef() ) return aType
;
135 return ((SvMetaAttribute
*)GetRef())->GetType();
138 /*************************************************************************
139 |* SvMetaAttribute::GetSlotId()
142 *************************************************************************/
143 const SvNumberIdentifier
& SvMetaAttribute::GetSlotId() const
145 if( aSlotId
.IsSet() || !GetRef() ) return aSlotId
;
146 return ((SvMetaAttribute
*)GetRef())->GetSlotId();
149 /*************************************************************************
150 |* SvMetaAttribute::GetReadonly()
153 *************************************************************************/
154 BOOL
SvMetaAttribute::GetReadonly() const
156 if( aReadonly
.IsSet() || !GetRef() ) return aReadonly
;
157 return ((SvMetaAttribute
*)GetRef())->GetReadonly();
160 /*************************************************************************
161 |* SvMetaAttribute::GetExport()
164 *************************************************************************/
165 BOOL
SvMetaAttribute::GetExport() const
167 if( aExport
.IsSet() || !GetRef() ) return aExport
;
168 return ((SvMetaAttribute
*)GetRef())->GetExport();
171 /*************************************************************************
172 |* SvMetaAttribute::GetHidden()
175 *************************************************************************/
176 BOOL
SvMetaAttribute::GetHidden() const
178 // Wenn Export gesetzt wurde, aber Hidden nicht, gilt der Default
179 // aHidden = !aExport
180 if ( aExport
.IsSet() && !aHidden
.IsSet() )
182 else if( aHidden
.IsSet() || !GetRef() )
185 return ((SvMetaAttribute
*)GetRef())->GetHidden();
188 /*************************************************************************
189 |* SvMetaAttribute::GetAutomation()
192 *************************************************************************/
193 BOOL
SvMetaAttribute::GetAutomation() const
195 if( aAutomation
.IsSet() || !GetRef() ) return aAutomation
;
196 return ((SvMetaAttribute
*)GetRef())->GetAutomation();
199 BOOL
SvMetaAttribute::GetIsCollection() const
202 if( aIsCollection
.IsSet() || !GetRef() )
204 if ( aIsCollection
.IsSet() )
206 bRet
= aIsCollection
;
210 return aIsCollection
;
213 return ((SvMetaSlot
*)GetRef())->GetIsCollection();
216 BOOL
SvMetaAttribute::GetReadOnlyDoc() const
218 if( aReadOnlyDoc
.IsSet() || !GetRef() ) return aReadOnlyDoc
;
219 return ((SvMetaSlot
*)GetRef())->GetReadOnlyDoc();
222 /*************************************************************************
223 |* SvMetaAttribute::IsMethod()
224 |* SvMetaAttribute::IsVariable()
225 |* SvMetaAttribute::GetMangleName()
228 *************************************************************************/
229 BOOL
SvMetaAttribute::IsMethod() const
231 SvMetaType
* pType
= GetType();
232 DBG_ASSERT( pType
, "no type for attribute" );
233 return pType
->GetType() == TYPE_METHOD
;
236 BOOL
SvMetaAttribute::IsVariable() const
238 SvMetaType
* pType
= GetType();
239 return pType
->GetType() != TYPE_METHOD
;
242 ByteString
SvMetaAttribute::GetMangleName( BOOL
) const
247 /*************************************************************************
248 |* SvMetaAttribute::FillSbxObject()
251 *************************************************************************/
253 void SvMetaAttribute::FillSbxObject( SbxInfo * pInfo, USHORT nSbxFlags )
255 SvMetaType * pType = GetType();
256 DBG_ASSERT( pType, "no type for attribute" );
258 { // Flags koennen vom Aufrufer ueberschrieben werden
259 if( pType->GetOut() )
261 nSbxFlags |= SBX_WRITE;
263 nSbxFlags |= SBX_READ;
266 nSbxFlags |= SBX_READ;
268 SvMetaType * pBaseType = pType->GetBaseType();
269 DBG_ASSERT( pBaseType, "no base type for attribute" );
270 if( pBaseType->GetType() == TYPE_STRUCT )
272 const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
273 ULONG nCount = rList.Count();
274 for( ULONG i = 0; i < nCount; i++ )
275 rList.GetObject( i )->FillSbxObject( pInfo, nSbxFlags );
278 //MI: pInfo->AddParam( GetName(), pBaseType->GetSbxDataType(), nSbxFlags );
279 pInfo->AddParam( GetName(), SbxVARIANT, nSbxFlags );
283 /*************************************************************************
284 |* SvMetaAttribute::FillSbxObject()
287 *************************************************************************/
289 void SvMetaAttribute::FillSbxObject( SvIdlDataBase & rBase,
290 SbxObject * pObj, BOOL bVariable )
292 // keine Attribut fuer Automation
293 if( !GetAutomation() || !GetExport() )
296 if( bVariable && IsVariable() )
298 SvMetaType * pType = GetType();
299 DBG_ASSERT( pType, "no type for attribute" );
300 SvMetaType * pBaseType = pType->GetBaseType();
301 DBG_ASSERT( pBaseType, "no base type for attribute" );
303 if( pBaseType->GetType() == TYPE_STRUCT )
305 SvNumberIdentifier aSlotId = rBase.aStructSlotId;
306 if ( GetSlotId().Len() )
307 rBase.aStructSlotId = GetSlotId();
308 const SvMetaAttributeMemberList & rList = pBaseType->GetAttrList();
309 ULONG nCount = rList.Count();
310 for( ULONG i = 0; i < nCount; i++ )
311 rList.GetObject( i )->FillSbxObject( rBase, pObj, bVariable );
312 rBase.aStructSlotId = aSlotId;
316 SbxPropertyRef xProp = new SbxProperty( GetName(), SbxVARIANT );
317 //MI: pBaseType->GetSbxDataType() );
318 if ( GetReadonly() || IsMethod() )
319 xProp->ResetFlag( SBX_WRITE );
320 xProp->SetUserData( MakeSlotValue( rBase, TRUE ) );
321 pType->FillSbxObject( xProp, bVariable );
323 pObj->Insert( &xProp );
326 else if( !bVariable && IsMethod() )
328 SvMetaType * pType = GetType();
329 SvMetaType * pRetBaseType = GetType()->GetReturnType()->GetBaseType();
330 SbxMethodRef xMeth = new SbxMethod( GetName(),
331 pRetBaseType->GetSbxDataType() );
332 xMeth->ResetFlag( SBX_WRITE );
333 xMeth->SetUserData( MakeSlotValue( rBase, FALSE ) );
334 pType->FillSbxObject( xMeth, bVariable );
336 pObj->Insert( &xMeth );
341 /*************************************************************************
342 |* SvMetaAttribute::Test()
345 *************************************************************************/
346 BOOL
SvMetaAttribute::Test( SvIdlDataBase
& rBase
,
347 SvTokenStream
& rInStm
)
350 if( GetType()->IsItem() && !GetSlotId().IsSet() )
352 rBase
.SetError( "slot without id declared", rInStm
.GetToken() );
353 rBase
.WriteError( rInStm
);
357 if( !GetType()->IsItem() && GetSlotId().IsSet() )
359 rBase.SetError( "slot without item declared", rInStm.GetToken() );
360 rBase.WriteError( rInStm );
367 /*************************************************************************
368 |* SvMetaAttribute::ReadSvIdl()
371 *************************************************************************/
372 BOOL
SvMetaAttribute::ReadSvIdl( SvIdlDataBase
& rBase
,
373 SvTokenStream
& rInStm
)
375 UINT32 nTokPos
= rInStm
.Tell();
377 // Es wurde kein Typ im ctor mitgegeben
378 aType
= rBase
.ReadKnownType( rInStm
);
382 ReadNameSvIdl( rBase
, rInStm
);
383 aSlotId
.ReadSvIdl( rBase
, rInStm
);
386 SvToken
* pTok
= rInStm
.GetToken();
387 if( bOk
&& pTok
->IsChar() && pTok
->GetChar() == '(' )
389 SvMetaTypeRef xT
= new SvMetaType();
390 xT
->SetRef( GetType() );
392 bOk
= aType
->ReadMethodArgs( rBase
, rInStm
);
395 bOk
= SvMetaName::ReadSvIdl( rBase
, rInStm
);
398 rBase
.SetError( "unknown type", rInStm
.GetToken() );
401 rInStm
.Seek( nTokPos
);
405 /*************************************************************************
406 |* SvMetaAttribute::WriteSvIdl()
409 *************************************************************************/
410 void SvMetaAttribute::WriteSvIdl
412 SvIdlDataBase
& rBase
,
417 SvMetaType
* pType
= GetType();
418 pType
->WriteTypePrefix( rBase
, rOutStm
, nTab
, WRITE_IDL
);
419 rOutStm
<< ' ' << GetName().GetBuffer();
420 if( aSlotId
.IsSet() )
421 rOutStm
<< ' ' << aSlotId
.GetBuffer();
422 if( pType
->GetType() == TYPE_METHOD
)
423 pType
->WriteMethodArgs( rBase
, rOutStm
, nTab
, WRITE_IDL
);
424 ULONG nPos
= rOutStm
.Tell();
426 SvMetaName::WriteSvIdl( rBase
, rOutStm
, nTab
);
427 TestAndSeekSpaceOnly( rOutStm
, nPos
);
430 /*************************************************************************
431 |* SvMetaAttribute::ReadAttributesSvIdl()
434 *************************************************************************/
435 void SvMetaAttribute::ReadAttributesSvIdl( SvIdlDataBase
& rBase
,
436 SvTokenStream
& rInStm
)
438 SvMetaReference::ReadAttributesSvIdl( rBase
, rInStm
);
439 aSlotId
.ReadSvIdl( rBase
, SvHash_SlotId(), rInStm
);
440 aExport
.ReadSvIdl( SvHash_Export(), rInStm
);
441 aHidden
.ReadSvIdl( SvHash_Hidden(), rInStm
);
442 aAutomation
.ReadSvIdl( SvHash_Automation(), rInStm
);
443 aIsCollection
.ReadSvIdl( SvHash_IsCollection(), rInStm
);
444 aReadOnlyDoc
.ReadSvIdl( SvHash_ReadOnlyDoc(), rInStm
);
445 if( aReadonly
.ReadSvIdl( SvHash_Readonly(), rInStm
) )
447 if( GetType()->GetType() == TYPE_METHOD
)
450 rBase
.SetError( "Readonly in function attribute", rInStm
.GetToken() );
451 rBase
.WriteError( rInStm
);
456 /*************************************************************************
457 |* SvMetaAttribute::WriteAttributesSvIdl()
460 *************************************************************************/
461 void SvMetaAttribute::WriteAttributesSvIdl
463 SvIdlDataBase
& rBase
,
468 SvMetaReference::WriteAttributesSvIdl( rBase
, rOutStm
, nTab
);
470 //aSlotId.WriteSvIdl( SvHash_SlotId(), rOutStm, nTab );
471 if( !aExport
|| !aAutomation
|| aReadonly
)
473 WriteTab( rOutStm
, nTab
);
474 rOutStm
<< "//class SvMetaAttribute" << endl
;
477 WriteTab( rOutStm
, nTab
);
478 aExport
.WriteSvIdl( SvHash_Export(), rOutStm
);
479 rOutStm
<< ';' << endl
;
481 if ( aHidden
!= aExport
)
483 WriteTab( rOutStm
, nTab
);
484 aExport
.WriteSvIdl( SvHash_Hidden(), rOutStm
);
485 rOutStm
<< ';' << endl
;
489 WriteTab( rOutStm
, nTab
);
490 aReadonly
.WriteSvIdl( SvHash_Readonly(), rOutStm
);
491 rOutStm
<< ';' << endl
;
495 WriteTab( rOutStm
, nTab
);
496 aAutomation
.WriteSvIdl( SvHash_Automation(), rOutStm
);
497 rOutStm
<< ';' << endl
;
501 WriteTab( rOutStm
, nTab
);
502 aIsCollection
.WriteSvIdl( SvHash_IsCollection(), rOutStm
);
503 rOutStm
<< ';' << endl
;
507 WriteTab( rOutStm
, nTab
);
508 aReadOnlyDoc
.WriteSvIdl( SvHash_ReadOnlyDoc(), rOutStm
);
509 rOutStm
<< ';' << endl
;
514 /*************************************************************************
515 |* SvMetaAttribute::WriteParam()
518 *************************************************************************/
519 void SvMetaAttribute::WriteParam( SvIdlDataBase
& rBase
,
524 SvMetaType
* pType
= GetType();
525 DBG_ASSERT( pType
, "no type for attribute" );
526 SvMetaType
* pBaseType
= pType
->GetBaseType();
527 DBG_ASSERT( pBaseType
, "no base type for attribute" );
529 if( nT
== WRITE_ODL
|| nT
== WRITE_DOCU
530 || nT
== WRITE_C_HEADER
|| nT
== WRITE_C_SOURCE
)
532 if( pBaseType
->GetType() == TYPE_STRUCT
)
534 const SvMetaAttributeMemberList
& rList
= pBaseType
->GetAttrList();
535 ULONG nCount
= rList
.Count();
536 for( ULONG i
= 0; i
< nCount
; i
++ )
538 rList
.GetObject( i
)->WriteParam( rBase
, rOutStm
, nTab
, nT
);
541 // if ( nT == WRITE_DOCU )
544 // rOutStm << ',' << endl;
550 if ( nT
!= WRITE_DOCU
)
552 WriteTab( rOutStm
, nTab
);
553 pBaseType
->WriteTypePrefix( rBase
, rOutStm
, nTab
, nT
);
556 if( GetName().Len() )
559 rOutStm
<< GetName().GetBuffer();
562 if ( nT
== WRITE_DOCU
)
564 if( pBaseType
->GetType() == TYPE_METHOD
||
565 pBaseType
->GetType() == TYPE_STRUCT
||
566 pBaseType
->GetType() == TYPE_ENUM
)
568 DBG_ERROR( "Falscher Parametertyp!" );
571 rOutStm
<< pBaseType
->GetBasicPostfix().GetBuffer();
576 else if( nT == WRITE_C_HEADER || nT == WRITE_C_SOURCE )
578 pBaseType->WriteTypePrefix( rBase, rOutStm, nTab, nT );
580 rOutStm << GetName().GetBuffer();
585 /*************************************************************************
586 |* SvMetaSlot::WriteSlotId()
589 *************************************************************************/
590 ULONG
SvMetaAttribute::MakeSlotValue( SvIdlDataBase
& rBase
, BOOL bVar
) const
592 const SvNumberIdentifier
& rId
= GetSlotId();
593 ULONG n
= rId
.GetValue();
594 if( rBase
.aStructSlotId
.Len() )
597 n
+= rBase
.aStructSlotId
.GetValue();
599 if( PTR_CAST( SvMetaSlot
, this ) )
603 else if ( GetIsCollection() )
608 /*************************************************************************
609 |* SvMetaSlot::WriteAttributes()
612 *************************************************************************/
613 void SvMetaAttribute::WriteAttributes( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
615 WriteType nT
, WriteAttribute nA
)
617 if( nT
== WRITE_ODL
)
619 const SvNumberIdentifier
& rId
= GetSlotId();
620 BOOL bReadonly
= GetReadonly() || ( nA
& WA_READONLY
);
621 if( (rId
.IsSet() && !(nA
& WA_STRUCT
)) || bReadonly
)
623 BOOL bVar
= IsVariable();
624 if( nA
& WA_VARIABLE
)
626 else if( nA
& WA_METHOD
)
629 WriteTab( rOutStm
, nTab
);
630 rOutStm
<< "//class SvMetaAttribute" << endl
;
631 if( rId
.IsSet() && !(nA
& WA_STRUCT
) )
633 WriteTab( rOutStm
, nTab
);
635 << ByteString::CreateFromInt32(MakeSlotValue( rBase
, bVar
)).GetBuffer()
638 if( bVar
&& (bReadonly
|| IsMethod()) )
640 WriteTab( rOutStm
, nTab
);
641 rOutStm
<< "readonly," << endl
;
647 /*************************************************************************
648 |* SvMetaAttribute::WriteCSource()
651 *************************************************************************/
652 void SvMetaAttribute::WriteCSource( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
656 SvMetaType
* pType
= GetType();
657 SvMetaType
* pBaseType
= pType
->GetBaseType();
659 // Bei Set ist der Return immer void
661 if( pBaseType
->GetType() == TYPE_METHOD
)
662 bVoid
= pBaseType
->GetReturnType()->GetBaseType()->GetName() == "void";
664 // Methoden/Funktions-Body ausgeben
665 rOutStm
<< '{' << endl
;
666 WriteTab( rOutStm
, 1 );
667 // rOutStm << "if( SvIPCIsConnected() )" << endl;
668 // WriteTab( rOutStm, 1 );
669 // rOutStm << '{' << endl;
670 // WriteTab( rOutStm, 2 );
674 if ( pBaseType
->GetCName() == "double" )
676 rOutStm
<< "return *(double*)";
680 rOutStm
<< "return (";
681 pType
->WriteTypePrefix( rBase
, rOutStm
, 2, WRITE_C_SOURCE
);
685 rOutStm
<< "pODKCallFunction( "
686 << ByteString::CreateFromInt32(MakeSlotValue( rBase
, IsVariable() )).GetBuffer();
687 rOutStm
<< ',' << endl
;
688 WriteTab( rOutStm
, 3 );
689 rOutStm
<< " h" << rBase
.aIFaceName
.GetBuffer() << " , ";
691 ByteString aParserStr
;
692 if( pBaseType
->GetType() == TYPE_METHOD
|| bSet
)
693 aParserStr
= pBaseType
->GetParserString();
694 if( aParserStr
.Len() )
697 rOutStm
<< aParserStr
.GetBuffer();
703 if( pBaseType
->GetType() == TYPE_METHOD
&& !bVoid
)
706 rOutStm
<< pBaseType
->GetReturnType()->GetBaseType()->GetParserChar();
712 rOutStm
<< pBaseType
->GetParserChar();
718 if( aParserStr
.Len() )
722 // void SetPosSize( C_Object *, C_Rectangle * pRect );
723 pBaseType
->WriteParamNames( rBase
, rOutStm
, ByteString() );
725 pBaseType
->WriteParamNames( rBase
, rOutStm
, GetName() );
728 rOutStm
<< " );" << endl
;
729 // WriteTab( rOutStm, 1 );
730 // rOutStm << '}' << endl;
733 // WriteTab( rOutStm, 1 );
734 // rOutStm << "return 0;" << endl;
736 rOutStm
<< '}' << endl
;
739 /*************************************************************************
740 |* SvMetaAttribute::WriteRecursiv_Impl()
743 *************************************************************************/
744 void SvMetaAttribute::WriteRecursiv_Impl( SvIdlDataBase
& rBase
,
745 SvStream
& rOutStm
, USHORT nTab
,
746 WriteType nT
, WriteAttribute nA
)
748 const SvMetaAttributeMemberList
& rList
= GetType()->GetBaseType()->GetAttrList();
749 ULONG nCount
= rList
.Count();
751 SvNumberIdentifier slotId
= rBase
.aStructSlotId
;
752 if ( GetSlotId().Len() )
753 rBase
.aStructSlotId
= GetSlotId();
755 // Offizielle Hack-Schnittstelle von MM: spezielle Schalter werden "uber
756 // die WriteAttribute "ubergeben
760 for( ULONG i
= 0; i
< nCount
; i
++ )
762 SvMetaAttribute
*pAttr
= rList
.GetObject( i
);
763 if ( nT
== WRITE_DOCU
)
764 pAttr
->SetDescription( GetDescription() );
765 pAttr
->Write( rBase
, rOutStm
, nTab
, nT
, nA
);
766 if( nT
== WRITE_ODL
&& i
+1 < nCount
)
767 rOutStm
<< ';' << endl
;
770 rBase
.aStructSlotId
= slotId
;
773 /*************************************************************************
774 |* SvMetaAttribute::Write()
777 *************************************************************************/
778 void SvMetaAttribute::Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
780 WriteType nT
, WriteAttribute nA
)
782 // keine Attribut fuer Automation
783 if( nT
== WRITE_DOCU
)
788 else if ( !GetAutomation() || !GetExport() )
792 if( nA
& WA_VARIABLE
)
794 else if( nA
& WA_METHOD
)
797 bVariable
= IsVariable();
799 SvMetaType
* pType
= GetType();
800 DBG_ASSERT( pType
, "no type for attribute" );
801 SvMetaType
* pBaseType
= pType
->GetBaseType();
802 DBG_ASSERT( pBaseType
, "no base type for attribute" );
803 int nBType
= pBaseType
->GetType();
805 if( nT
== WRITE_ODL
)
807 if( (bVariable
&& IsVariable()) || (!bVariable
&& IsMethod()) )
809 if( nBType
== TYPE_STRUCT
)
810 WriteRecursiv_Impl( rBase
, rOutStm
, nTab
, nT
, nA
);
813 SvMetaReference::Write( rBase
, rOutStm
, nTab
, nT
, nA
);
814 WriteTab( rOutStm
, nTab
);
815 pBaseType
->WriteTypePrefix( rBase
, rOutStm
, nTab
, nT
);
817 if( GetName().Len() )
820 rOutStm
<< GetName().GetBuffer();
822 if( pType
->GetType() == TYPE_METHOD
)
823 pType
->WriteMethodArgs( rBase
, rOutStm
, nTab
, nT
);
827 else if( nT
== WRITE_C_HEADER
|| nT
== WRITE_C_SOURCE
)
829 if( !bVariable
&& IsMethod() )
831 ByteString name
; // (rBase.GetActModulePrefix());
832 name
+= rBase
.aIFaceName
;
834 const char * pName
= name
.GetBuffer();
836 // void SetPosSize( C_Object *, C_Rectangle * );
837 WriteTab( rOutStm
, nTab
);
838 pBaseType
->WriteTypePrefix( rBase
, rOutStm
, nTab
, nT
);
839 // rOutStm << " SYSCALL";
840 rOutStm
<< ' ' << pName
;
841 pType
->WriteMethodArgs( rBase
, rOutStm
, nTab
, nT
);
842 if( nT
== WRITE_C_HEADER
)
843 rOutStm
<< ';' << endl
<< endl
;
845 WriteCSource( rBase
, rOutStm
, FALSE
);
847 else if ( bVariable
&& IsVariable() )
849 if( nBType
== TYPE_STRUCT
)
851 // Zur Hilfe den Namen des Properties als Kommentar ausgeben
852 rOutStm
<< "/* " << GetName().GetBuffer() << " */" << endl
;
854 WriteRecursiv_Impl( rBase
, rOutStm
, nTab
, nT
, nA
);
859 // void SetValue( C_Object *, USHORT n );
860 ByteString name
= GetName();
862 BOOL bReadonly
= GetReadonly() || ( nA
& WA_READONLY
);
863 if ( !bReadonly
&& !IsMethod() )
866 WriteTab( rOutStm
, nTab
);
868 // rOutStm << "SYSCALL ";
869 // if ( rBase.GetActModulePrefix().Len() )
870 // rOutStm << rBase.GetActModulePrefix().GetBuffer();
871 rOutStm
<< rBase
.aIFaceName
.GetBuffer()
872 << "Set" << name
.GetBuffer() << "( " << C_PREF
873 << "Object h" << rBase
.aIFaceName
.GetBuffer() << ", " << endl
;
874 WriteTab( rOutStm
, nTab
+1 );
875 pBaseType
->WriteTypePrefix( rBase
, rOutStm
, nTab
, nT
);
876 rOutStm
<< ' ' << name
.GetBuffer() << " )";
877 if( nT
== WRITE_C_HEADER
)
878 rOutStm
<< ';' << endl
<< endl
;
880 WriteCSource( rBase
, rOutStm
, TRUE
);
884 WriteTab( rOutStm
, nTab
);
885 pBaseType
->WriteTypePrefix( rBase
, rOutStm
, nTab
, nT
);
887 // rOutStm << "SYSCALL ";
888 // if ( rBase.GetActModulePrefix().Len() )
889 // rOutStm << rBase.GetActModulePrefix().GetBuffer();
890 rOutStm
<< rBase
.aIFaceName
.GetBuffer()
891 << "Get" << name
.GetBuffer() << "( " << C_PREF
892 << "Object h" << rBase
.aIFaceName
.GetBuffer() << " )";
893 if( nT
== WRITE_C_HEADER
)
894 rOutStm
<< ';' << endl
<< endl
;
896 WriteCSource( rBase
, rOutStm
, FALSE
);
900 else if ( nT
== WRITE_DOCU
)
902 if( !bVariable
&& IsMethod() )
904 rOutStm
<< "<METHOD>" << endl
905 << GetSlotId().GetBuffer() << endl
906 << GetName().GetBuffer() << endl
910 SvMetaType
* pType2
= GetType();
911 SvMetaType
* pBaseType2
= pType2
->GetBaseType();
912 rOutStm
<< pBaseType2
->GetReturnType()->GetBaseType()->GetBasicName().GetBuffer() << endl
;
914 DBG_ASSERT( pBaseType2
->GetReturnType()->GetBaseType()->GetBasicName().Len(),
915 "Leerer BasicName" );
918 rOutStm
<< GetName().GetBuffer();
919 pType2
->WriteMethodArgs( rBase
, rOutStm
, nTab
, nT
);
922 pBaseType2
->WriteTypePrefix( rBase
, rOutStm
, 0, WRITE_C_HEADER
);
925 // Bei Methoden auch C-Syntax
926 rOutStm
<< "<C-SYNTAX>" << endl
;
927 Write( rBase
, rOutStm
, 0, WRITE_C_HEADER
, nA
);
928 rOutStm
<< "</C-SYNTAX>" << endl
;
931 WriteDescription( rOutStm
);
932 rOutStm
<< "</METHOD>" << endl
<< endl
;
934 else if( bVariable
&& IsVariable() )
936 if( nBType
== TYPE_STRUCT
)
938 WriteRecursiv_Impl( rBase
, rOutStm
, nTab
, nT
, nA
);
942 rOutStm
<< "<PROPERTY>" << endl
943 << GetSlotId().GetBuffer() << endl
944 << GetName().GetBuffer() << endl
;
946 rOutStm
<< "(nur lesen)" << endl
;
950 // Bei properties Type anstelle des return value
951 rOutStm
<< pBaseType
->GetBasicName().GetBuffer() << endl
;
953 DBG_ASSERT( pBaseType
->GetBasicName().Len(),
954 "Leerer BasicName" );
956 // Bei properties keine Syntax
960 pBaseType
->WriteTypePrefix( rBase
, rOutStm
, 0, WRITE_C_HEADER
);
964 WriteDescription( rOutStm
);
965 rOutStm
<< "</PROPERTY>" << endl
<< endl
;
971 /*************************************************************************
972 |* SvMetaAttribute::MakeSfx()
975 *************************************************************************/
976 ULONG
SvMetaAttribute::MakeSfx( ByteString
* pAttrArray
)
978 SvMetaType
* pType
= GetType();
979 DBG_ASSERT( pType
, "no type for attribute" );
980 SvMetaType
* pBaseType
= pType
->GetBaseType();
981 DBG_ASSERT( pBaseType
, "no base type for attribute" );
982 if( pBaseType
->GetType() == TYPE_STRUCT
)
983 return pBaseType
->MakeSfx( pAttrArray
);
987 *pAttrArray
+= GetSlotId();
988 *pAttrArray
+= ",\"";
989 *pAttrArray
+= GetName();
990 *pAttrArray
+= "\"}";
995 void SvMetaAttribute::Insert (SvSlotElementList
&, const ByteString
&, SvIdlDataBase
&)
999 /*************************************************************************
1000 |* SvMetaAttribute::WriteSrc()
1003 *************************************************************************/
1004 void SvMetaAttribute::WriteSrc( SvIdlDataBase
&, SvStream
&, Table
* )
1008 void SvMetaAttribute::WriteHelpId( SvIdlDataBase
&, SvStream
&, Table
* )
1012 #endif // IDL_COMPILER
1014 /****************** SvMetaType *************************************/
1015 /************************************************************************/
1016 SV_IMPL_META_FACTORY1( SvMetaType
, SvMetaExtern
);
1017 /*************************************************************************
1018 |* SvMetaType::SvMetaType()
1021 *************************************************************************/
1023 : aCall0( CALL_VALUE, FALSE ) \
1024 , aCall1( CALL_VALUE, FALSE ) \
1025 , aSbxDataType( 0, FALSE ) \
1026 , pAttrList( NULL ) \
1027 , nType( TYPE_BASE ) \
1028 , bIsItem( FALSE ) \
1029 , bIsShell( FALSE ) \
1030 , cParserChar( 'h' )
1032 SvMetaType::SvMetaType()
1037 SvMetaType::SvMetaType( const ByteString
& rName
, char cPC
,
1038 const ByteString
& rCName
)
1046 SvMetaType::SvMetaType( const ByteString
& rName
,
1047 const ByteString
& rSbxName
,
1048 const ByteString
& rOdlName
,
1050 const ByteString
& rCName
,
1051 const ByteString
& rBasicName
,
1052 const ByteString
& rBasicPostfix
)
1055 // aSbxDataType = (int)nT;
1057 aSbxName
= rSbxName
;
1058 aOdlName
= rOdlName
;
1061 aBasicName
= rBasicName
;
1062 aBasicPostfix
= rBasicPostfix
;
1065 void SvMetaType::Load( SvPersistStream
& rStm
)
1067 SvMetaExtern::Load( rStm
);
1071 if( nMask
& 0x0001 ) rStm
>> aIn
;
1072 if( nMask
& 0x0002 ) rStm
>> aOut
;
1073 if( nMask
& 0x0004 ) rStm
>> aCall0
;
1074 if( nMask
& 0x0008 ) rStm
>> aCall1
;
1075 if( nMask
& 0x0010 ) rStm
>> aSbxDataType
;
1076 if( nMask
& 0x0020 ) rStm
>> aSvName
;
1077 if( nMask
& 0x0040 ) rStm
>> aSbxName
;
1078 if( nMask
& 0x0080 ) rStm
>> aOdlName
;
1079 if( nMask
& 0x0100 ) rStm
>> GetAttrList();
1080 if( nMask
& 0x0200 ) bIsItem
= TRUE
;
1081 if( nMask
& 0x0400 ) bIsShell
= TRUE
;
1082 if( nMask
& 0x0800 )
1088 if( nMask
& 0x1000 ) rStm
>> cParserChar
;
1089 if( nMask
& 0x2000 ) rStm
>> aCName
;
1090 if( nMask
& 0x4000 ) rStm
>> aBasicName
;
1091 if( nMask
& 0x8000 ) rStm
>> aBasicPostfix
;
1094 void SvMetaType::Save( SvPersistStream
& rStm
)
1096 SvMetaExtern::Save( rStm
);
1100 if( aIn
.IsSet() ) nMask
|= 0x0001;
1101 if( aOut
.IsSet() ) nMask
|= 0x0002;
1102 if( aCall0
.IsSet() ) nMask
|= 0x0004;
1103 if( aCall1
.IsSet() ) nMask
|= 0x0008;
1104 if( aSbxDataType
.IsSet() ) nMask
|= 0x0010;
1105 if( aSvName
.IsSet() ) nMask
|= 0x0020;
1106 if( aSbxName
.IsSet() ) nMask
|= 0x0040;
1107 if( aOdlName
.IsSet() ) nMask
|= 0x0080;
1108 if( GetAttrCount() ) nMask
|= 0x0100;
1109 if( bIsItem
) nMask
|= 0x0200;
1110 if( bIsShell
) nMask
|= 0x0400;
1111 if( nType
!= TYPE_BASE
) nMask
|= 0x0800;
1112 if( cParserChar
!= 'h' ) nMask
|= 0x1000;
1113 if( aCName
.IsSet() ) nMask
|= 0x2000;
1114 if( aBasicName
.IsSet() ) nMask
|= 0x4000;
1115 if( aBasicPostfix
.IsSet() ) nMask
|= 0x8000;
1119 if( nMask
& 0x0001 ) rStm
<< aIn
;
1120 if( nMask
& 0x0002 ) rStm
<< aOut
;
1121 if( nMask
& 0x0004 ) rStm
<< aCall0
;
1122 if( nMask
& 0x0008 ) rStm
<< aCall1
;
1123 if( nMask
& 0x0010 ) rStm
<< aSbxDataType
;
1124 if( nMask
& 0x0020 ) rStm
<< aSvName
;
1125 if( nMask
& 0x0040 ) rStm
<< aSbxName
;
1126 if( nMask
& 0x0080 ) rStm
<< aOdlName
;
1127 if( nMask
& 0x0100 ) rStm
<< *pAttrList
;
1128 if( nMask
& 0x0800 ) rStm
<< (USHORT
)nType
;
1129 if( nMask
& 0x1000 ) rStm
<< cParserChar
;
1130 if( nMask
& 0x2000 ) rStm
<< aCName
;
1131 if( nMask
& 0x4000 ) rStm
<< aBasicName
;
1132 if( nMask
& 0x8000 ) rStm
<< aBasicPostfix
;
1135 /*************************************************************************
1136 |* SvMetaType::GetAttrList()
1139 *************************************************************************/
1140 SvMetaAttributeMemberList
& SvMetaType::GetAttrList() const
1143 ((SvMetaType
*)this)->pAttrList
= new SvMetaAttributeMemberList();
1147 /*************************************************************************
1148 |* SvMetaType::SetType()
1151 *************************************************************************/
1152 void SvMetaType::SetType( int nT
)
1155 if( nType
== TYPE_ENUM
)
1158 // aSbxDataType = SbxINTEGER;
1160 else if( nType
== TYPE_CLASS
)
1163 aCName
+= "Object *";
1167 /*************************************************************************
1168 |* SvMetaType::GetBaseType()
1171 *************************************************************************/
1172 SvMetaType
* SvMetaType::GetBaseType() const
1174 if( GetRef() && GetType() == TYPE_BASE
)
1175 return ((SvMetaType
*)GetRef())->GetBaseType();
1176 return (SvMetaType
*)this;
1179 /*************************************************************************
1180 |* SvMetaType::GetReturnType()
1183 *************************************************************************/
1184 SvMetaType
* SvMetaType::GetReturnType() const
1186 DBG_ASSERT( GetType() == TYPE_METHOD
, "no method" );
1187 DBG_ASSERT( GetRef(), "no return type" );
1188 return (SvMetaType
*)GetRef();
1191 /*************************************************************************
1192 |* SvMetaType::GetSbxDataType()
1195 *************************************************************************/
1197 SbxDataType SvMetaType::GetSbxDataType() const
1199 if( aSbxDataType.IsSet() || !GetRef() )
1200 return (SbxDataType)(int)aSbxDataType;
1202 return ((SvMetaType *)GetRef())->GetSbxDataType();
1205 /*************************************************************************
1206 |* SvMetaType::GetBasicName()
1209 *************************************************************************/
1210 const ByteString
& SvMetaType::GetBasicName() const
1212 if( aBasicName
.IsSet() || !GetRef() )
1215 return ((SvMetaType
*)GetRef())->GetBasicName();
1218 /*************************************************************************
1219 |* SvMetaType::GetBasicPostfix()
1222 *************************************************************************/
1223 ByteString
SvMetaType::GetBasicPostfix() const
1228 // MBN und Co wollen immer "As xxx"
1230 if( aBasicPostfix.IsSet() || !GetRef() )
1231 aRet = aBasicPostfix;
1233 aRet = ((SvMetaType*)GetRef())->GetBasicPostfix();
1235 if ( !aRet.Len() && GetBasicName().Len() )
1240 aRet
+= GetBasicName();
1246 /*************************************************************************
1247 |* SvMetaType::GetIn()
1250 *************************************************************************/
1251 BOOL
SvMetaType::GetIn() const
1253 if( aIn
.IsSet() || !GetRef() )
1256 return ((SvMetaType
*)GetRef())->GetIn();
1259 /*************************************************************************
1260 |* SvMetaType::GetOut()
1263 *************************************************************************/
1264 BOOL
SvMetaType::GetOut() const
1266 if( aOut
.IsSet() || !GetRef() )
1269 return ((SvMetaType
*)GetRef())->GetOut();
1272 /*************************************************************************
1273 |* SvMetaType::SetCall0()
1276 *************************************************************************/
1277 void SvMetaType::SetCall0( int e
)
1280 if( aCall0
== CALL_VALUE
&& aCall1
== CALL_VALUE
)
1282 if( GetType() == TYPE_POINTER
)
1283 SetType( TYPE_BASE
);
1287 DBG_ASSERT( nType
== TYPE_POINTER
|| nType
== TYPE_BASE
,
1288 "set no base type to pointer" );
1289 SetType( TYPE_POINTER
);
1293 /*************************************************************************
1294 |* SvMetaType::GetCall0()
1297 *************************************************************************/
1298 int SvMetaType::GetCall0() const
1300 if( aCall0
.IsSet() || !GetRef() )
1303 return ((SvMetaType
*)GetRef())->GetCall0();
1306 /*************************************************************************
1307 |* SvMetaType::SetCall1()
1310 *************************************************************************/
1311 void SvMetaType::SetCall1( int e
)
1314 if( aCall0
== CALL_VALUE
&& aCall1
== CALL_VALUE
)
1316 if( GetType() == TYPE_POINTER
)
1317 SetType( TYPE_BASE
);
1321 DBG_ASSERT( nType
== TYPE_POINTER
|| nType
== TYPE_BASE
,
1322 "set no base type to pointer" );
1323 SetType( TYPE_POINTER
);
1327 /*************************************************************************
1328 |* SvMetaType::GetCall1()
1331 *************************************************************************/
1332 int SvMetaType::GetCall1() const
1334 if( aCall1
.IsSet() || !GetRef() )
1337 return ((SvMetaType
*)GetRef())->GetCall1();
1340 /*************************************************************************
1341 |* SvMetaType::GetSvName()
1344 *************************************************************************/
1345 const ByteString
& SvMetaType::GetSvName() const
1347 if( aSvName
.IsSet() || !GetRef() )
1350 return ((SvMetaType
*)GetRef())->GetSvName();
1353 /*************************************************************************
1354 |* SvMetaType::GetSbxName()
1357 *************************************************************************/
1358 const ByteString
& SvMetaType::GetSbxName() const
1360 if( aSbxName
.IsSet() || !GetRef() )
1363 return ((SvMetaType
*)GetRef())->GetSbxName();
1366 /*************************************************************************
1367 |* SvMetaType::GetOdlName()
1370 *************************************************************************/
1371 const ByteString
& SvMetaType::GetOdlName() const
1373 if( aOdlName
.IsSet() || !GetRef() )
1376 return ((SvMetaType
*)GetRef())->GetOdlName();
1379 /*************************************************************************
1380 |* SvMetaType::GetCName()
1383 *************************************************************************/
1384 const ByteString
& SvMetaType::GetCName() const
1386 if( aCName
.IsSet() || !GetRef() )
1389 return ((SvMetaType
*)GetRef())->GetCName();
1392 /*************************************************************************
1393 |* SvMetaType::SetName()
1396 *************************************************************************/
1397 BOOL
SvMetaType::SetName( const ByteString
& rName
, SvIdlDataBase
* pBase
)
1402 if( GetType() != TYPE_ENUM
)
1404 return SvMetaReference::SetName( rName
, pBase
);
1407 /*************************************************************************
1408 |* SvMetaType::FillSbxObject()
1411 *************************************************************************/
1413 void SvMetaType::FillSbxObject( SbxVariable * pObj, BOOL bVariable )
1415 if( PTR_CAST( SbxMethod, pObj ) )
1417 if( GetType() == TYPE_METHOD )
1419 ULONG nCount = GetAttrCount();
1422 SbxInfoRef xInfo = pObj->GetInfo();
1425 xInfo = new SbxInfo();
1426 pObj->SetInfo( xInfo );
1428 for( ULONG n = nCount; n > 0; n-- )
1429 pAttrList->GetObject( n -1 )->FillSbxObject( xInfo );
1436 /*************************************************************************
1437 |* SvMetaType::GetString()
1440 *************************************************************************/
1441 ByteString
SvMetaType::GetCString() const
1443 ByteString
out( GetSvName() );
1444 if( aCall0
== (int)CALL_POINTER
)
1446 else if( aCall0
== (int)CALL_REFERENCE
)
1448 if( aCall1
== (int)CALL_POINTER
)
1450 else if( aCall1
== (int)CALL_REFERENCE
)
1455 /*************************************************************************
1456 |* SvMetaType::ReadHeaderSvIdl()
1459 *************************************************************************/
1460 BOOL
SvMetaType::ReadHeaderSvIdl( SvIdlDataBase
& rBase
,
1461 SvTokenStream
& rInStm
)
1464 UINT32 nTokPos
= rInStm
.Tell();
1465 SvToken
* pTok
= rInStm
.GetToken_Next();
1467 if( pTok
->Is( SvHash_interface() )
1468 || pTok
->Is( SvHash_shell() ) )
1470 if( pTok
->Is( SvHash_shell() ) )
1472 SetType( TYPE_CLASS
);
1473 bOk
= ReadNamesSvIdl( rBase
, rInStm
);
1476 else if( pTok
->Is( SvHash_struct() ) )
1478 SetType( TYPE_STRUCT
);
1479 bOk
= ReadNamesSvIdl( rBase
, rInStm
);
1481 else if( pTok
->Is( SvHash_union() ) )
1483 SetType( TYPE_UNION
);
1484 if( ReadNameSvIdl( rBase
, rInStm
) )
1487 else if( pTok
->Is( SvHash_enum() ) )
1489 SetType( TYPE_ENUM
);
1490 bOk
= ReadNameSvIdl( rBase
, rInStm
);
1492 else if( pTok
->Is( SvHash_typedef() )
1493 || pTok
->Is( SvHash_item() ) )
1495 if( pTok
->Is( SvHash_item() ) )
1498 SvMetaType
* pType
= rBase
.ReadKnownType( rInStm
);
1502 if( ReadNameSvIdl( rBase
, rInStm
) )
1504 /* // um aufwaertskompatibel zu bleiben
1505 aOdlName = pType->GetOdlName();
1507 if( rInStm
.Read( '(' ) )
1509 //DoReadContextSvIdl( rBase, rInStm, ',' );
1510 DoReadContextSvIdl( rBase
, rInStm
);
1511 if( rInStm
.Read( ')' ) )
1513 SetType( TYPE_METHOD
);
1525 ByteString aStr
= "wrong typedef: ";
1526 rBase
.SetError( aStr
, rInStm
.GetToken() );
1527 rBase
.WriteError( rInStm
);
1533 rInStm
.Seek( nTokPos
);
1537 /*************************************************************************
1538 |* SvMetaType::ReadSvIdl()
1541 *************************************************************************/
1542 BOOL
SvMetaType::ReadSvIdl( SvIdlDataBase
& rBase
,
1543 SvTokenStream
& rInStm
)
1545 if( ReadHeaderSvIdl( rBase
, rInStm
) )
1548 return SvMetaExtern::ReadSvIdl( rBase
, rInStm
);
1553 /*************************************************************************
1554 |* SvMetaType::WriteSvIdl()
1557 *************************************************************************/
1558 void SvMetaType::WriteSvIdl
1560 SvIdlDataBase
& rBase
,
1565 WriteHeaderSvIdl( rBase
, rOutStm
, nTab
);
1566 if( GetType() == TYPE_METHOD
)
1567 WriteMethodArgs( rBase
, rOutStm
, nTab
, WRITE_IDL
);
1569 ULONG nOldPos
= rOutStm
.Tell();
1571 SvMetaExtern::WriteSvIdl( rBase
, rOutStm
, nTab
);
1572 if( TestAndSeekSpaceOnly( rOutStm
, nOldPos
) )
1573 // nichts geschrieben
1574 rOutStm
.Seek( nOldPos
);
1575 rOutStm
<< ';' << endl
;
1578 /*************************************************************************
1579 |* SvMetaType::WriteContext()
1582 *************************************************************************/
1583 void SvMetaType::WriteContext( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
1585 WriteType nT
, WriteAttribute nA
)
1587 if( GetAttrCount() )
1589 SvMetaAttribute
* pAttr
= pAttrList
->First();
1592 pAttr
->Write( rBase
, rOutStm
, nTab
, nT
, nA
);
1593 if( GetType() == TYPE_METHOD
)
1594 rOutStm
<< ',' << endl
;
1596 rOutStm
<< ';' << endl
;
1597 pAttr
= pAttrList
->Next();
1602 /*************************************************************************
1603 |* SvMetaType::Write()
1606 *************************************************************************/
1607 void SvMetaType::Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
1609 WriteType nT
, WriteAttribute nA
)
1611 if( nT
== WRITE_C_HEADER
&& nType
!= TYPE_ENUM
)
1612 // nur enum schreiben
1615 ByteString name
= GetName();
1616 if( nT
== WRITE_ODL
|| nT
== WRITE_C_HEADER
|| nT
== WRITE_CXX_HEADER
)
1628 WriteStars( rOutStm
);
1629 if( nType
== TYPE_STRUCT
|| nType
== TYPE_UNION
)
1632 if( nT
== WRITE_ODL
|| nT
== WRITE_C_HEADER
)
1634 if ( nT
== WRITE_C_HEADER
)
1636 ByteString aStr
= name
;
1637 aStr
.ToUpperAscii();
1638 rOutStm
<< "#ifndef " << C_PREF
<< aStr
.GetBuffer() << "_DEF " << endl
;
1639 rOutStm
<< "#define " << C_PREF
<< aStr
.GetBuffer() << "_DEF " << endl
;
1642 WriteTab( rOutStm
, nTab
);
1643 rOutStm
<< "typedef" << endl
;
1644 if ( nT
== WRITE_ODL
)
1645 SvMetaName::Write( rBase
, rOutStm
, nTab
, nT
, nA
);
1647 WriteTab( rOutStm
, nTab
);
1648 if( nType
== TYPE_STRUCT
)
1649 rOutStm
<< "struct";
1650 else if( nType
== TYPE_UNION
)
1654 if( nT
!= WRITE_ODL
&& nT
!= WRITE_C_HEADER
)
1655 rOutStm
<< ' ' << name
.GetBuffer();
1658 WriteTab( rOutStm
, nTab
);
1659 rOutStm
<< '{' << endl
;
1660 WriteContext( rBase
, rOutStm
, nTab
+1, nT
, nA
);
1661 WriteTab( rOutStm
, nTab
);
1663 if( nT
== WRITE_ODL
|| nT
== WRITE_C_HEADER
)
1665 rOutStm
<< ' ' << C_PREF
<< name
.GetBuffer();
1667 rOutStm
<< ';' << endl
;
1669 if ( nT
== WRITE_C_HEADER
)
1670 rOutStm
<< "#endif";
1687 /*************************************************************************
1688 |* SvMetaType::ReadNamesSvIdl()
1691 *************************************************************************/
1692 BOOL
SvMetaType::ReadNamesSvIdl( SvIdlDataBase
& rBase
,
1693 SvTokenStream
& rInStm
)
1695 BOOL bOk
= ReadNameSvIdl( rBase
, rInStm
);
1699 UINT32 nTokPos = rInStm.Tell();
1700 SvToken * pTok = rInStm.GetToken_Next();
1702 if( pTok->IsIdentifier() )
1704 aSbxName = pTok->GetString();
1706 nTokPos = rInStm.Tell();
1707 pTok = rInStm.GetToken_Next();
1708 if( pTok->IsIdentifier() )
1710 aItemName = pTok->GetString();
1711 nTokPos = rInStm.Tell();
1714 rInStm.Seek( nTokPos );
1720 /*************************************************************************
1721 |* SvMetaType::WriteHeaderSvIdl()
1724 *************************************************************************/
1725 void SvMetaType::WriteHeaderSvIdl( SvIdlDataBase
& rBase
,
1734 rOutStm
<< SvHash_shell()->GetName().GetBuffer();
1736 rOutStm
<< SvHash_interface()->GetName().GetBuffer();
1737 rOutStm
<< ' ' << GetName().GetBuffer();
1742 rOutStm
<< SvHash_struct()->GetName().GetBuffer()
1743 << ' ' << GetName().GetBuffer();
1748 rOutStm
<< SvHash_union()->GetName().GetBuffer()
1749 << ' ' << GetName().GetBuffer();
1754 rOutStm
<< SvHash_enum()->GetName().GetBuffer()
1755 << ' ' << GetName().GetBuffer();
1762 rOutStm
<< SvHash_item()->GetName().GetBuffer() << ' ';
1764 rOutStm
<< SvHash_typedef()->GetName().GetBuffer() << ' ';
1767 ((SvMetaType
*)GetRef())->WriteTheType( rBase
, rOutStm
, nTab
, WRITE_IDL
);
1770 rOutStm
<< GetName().GetBuffer();
1775 rOutStm
<< SvHash_typedef()->GetName().GetBuffer() << ' ';
1776 ((SvMetaType
*)GetRef())->WriteTheType( rBase
, rOutStm
, nTab
, WRITE_IDL
);
1777 rOutStm
<< ' ' << GetName().GetBuffer() << "( ";
1778 WriteContextSvIdl( rBase
, rOutStm
, nTab
);
1785 /*************************************************************************
1786 |* SvMetaType::ReadAttributesSvIdl()
1789 *************************************************************************/
1790 void SvMetaType::ReadAttributesSvIdl( SvIdlDataBase
& rBase
,
1791 SvTokenStream
& rInStm
)
1793 SvMetaExtern::ReadAttributesSvIdl( rBase
, rInStm
);
1794 aSvName
.ReadSvIdl( SvHash_SvName(), rInStm
);
1795 aSbxName
.ReadSvIdl( SvHash_SbxName(), rInStm
);
1796 aOdlName
.ReadSvIdl( SvHash_OdlName(), rInStm
);
1799 /*************************************************************************
1800 |* SvMetaType::WriteAttributesSvIdl()
1803 *************************************************************************/
1804 void SvMetaType::WriteAttributesSvIdl( SvIdlDataBase
& rBase
,
1808 SvMetaExtern::WriteAttributesSvIdl( rBase
, rOutStm
, nTab
);
1809 ByteString name
= GetName();
1810 if( aSvName
!= name
|| aSbxName
!= name
|| aOdlName
!= name
)
1812 WriteTab( rOutStm
, nTab
);
1813 rOutStm
<< "class SvMetaType" << endl
;
1814 if( aSvName
!= name
)
1816 WriteTab( rOutStm
, nTab
);
1817 aSvName
.WriteSvIdl( SvHash_SvName(), rOutStm
, nTab
);
1820 if( aSbxName
!= name
)
1822 WriteTab( rOutStm
, nTab
);
1823 aSbxName
.WriteSvIdl( SvHash_SbxName(), rOutStm
, nTab
);
1826 if( aOdlName
!= name
)
1828 WriteTab( rOutStm
, nTab
);
1829 aOdlName
.WriteSvIdl( SvHash_OdlName(), rOutStm
, nTab
);
1835 /*************************************************************************
1836 |* SvMetaType::ReadContextSvIdl()
1839 *************************************************************************/
1840 void SvMetaType::ReadContextSvIdl( SvIdlDataBase
& rBase
,
1841 SvTokenStream
& rInStm
)
1843 SvMetaAttributeRef xAttr
= new SvMetaAttribute();
1844 if( xAttr
->ReadSvIdl( rBase
, rInStm
) )
1846 if( xAttr
->Test( rBase
, rInStm
) )
1847 GetAttrList().Append( xAttr
);
1851 /*************************************************************************
1852 |* SvMetaType::WriteContextSvIdl()
1855 *************************************************************************/
1856 void SvMetaType::WriteContextSvIdl
1858 SvIdlDataBase
& rBase
,
1863 if( GetAttrCount() )
1865 SvMetaAttribute
* pAttr
= pAttrList
->First();
1868 WriteTab( rOutStm
, nTab
);
1869 pAttr
->WriteSvIdl( rBase
, rOutStm
, nTab
);
1870 if( GetType() == TYPE_METHOD
)
1871 rOutStm
<< ',' << endl
;
1873 rOutStm
<< ';' << endl
;
1874 pAttr
= pAttrList
->Next();
1879 /*************************************************************************
1880 |* SvMetaType::WriteAttributes()
1883 *************************************************************************/
1884 void SvMetaType::WriteAttributes( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
1886 WriteType nT
, WriteAttribute nA
)
1888 SvMetaExtern::WriteAttributes( rBase
, rOutStm
, nTab
, nT
, nA
);
1891 /*************************************************************************
1892 |* SvMetaType::MakeSfx()
1895 *************************************************************************/
1896 ULONG
SvMetaType::MakeSfx( ByteString
* pAttrArray
)
1900 if( GetBaseType()->GetType() == TYPE_STRUCT
)
1902 ULONG nAttrCount
= GetAttrCount();
1903 // Die einzelnen Attribute schreiben
1904 for( ULONG n
= 0; n
< nAttrCount
; n
++ )
1906 nC
+= pAttrList
->GetObject( n
)->MakeSfx( pAttrArray
);
1907 if( n
+1 < nAttrCount
)
1908 *pAttrArray
+= ", ";
1914 void SvMetaType::WriteSfxItem(
1915 const ByteString
& rItemName
, SvIdlDataBase
&, SvStream
& rOutStm
)
1917 WriteStars( rOutStm
);
1918 ByteString aVarName
= " a";
1919 aVarName
+= rItemName
;
1920 aVarName
+= "_Impl";
1922 ByteString aTypeName
= "SfxType";
1923 ByteString aAttrArray
;
1924 ULONG nAttrCount
= MakeSfx( &aAttrArray
);
1925 //ULONG nAttrCount = GetAttrCount();
1926 ByteString
aAttrCount( ByteString::CreateFromInt32( nAttrCount
) );
1927 aTypeName
+= aAttrCount
;
1929 rOutStm
<< "extern " << aTypeName
.GetBuffer()
1930 << aVarName
.GetBuffer() << ';' << endl
;
1932 // Den Implementationsteil schreiben
1933 rOutStm
<< "#ifdef SFX_TYPEMAP" << endl
1934 << aTypeName
.GetBuffer() << aVarName
.GetBuffer()
1936 rOutStm
<< '{' << endl
1937 << "\tTYPE(" << rItemName
.GetBuffer() << "), "
1938 << aAttrCount
.GetBuffer();
1942 // Die einzelnen Attribute schreiben
1943 rOutStm
<< aAttrArray
.GetBuffer();
1946 rOutStm
<< endl
<< "};" << endl
1947 << "#endif" << endl
<< endl
;
1950 /*************************************************************************
1951 |* SvMetaType::WriteSfx()
1954 *************************************************************************/
1955 void SvMetaType::WriteSfx( SvIdlDataBase
& rBase
, SvStream
& rOutStm
)
1959 if( GetBaseType()->GetType() == TYPE_STRUCT
)
1960 GetBaseType()->WriteSfxItem( GetName(), rBase
, rOutStm
);
1962 WriteSfxItem( GetName(), rBase
, rOutStm
);
1966 /*************************************************************************
1967 |* SvMetaType::ReadMethodArgs()
1970 *************************************************************************/
1971 BOOL
SvMetaType::ReadMethodArgs( SvIdlDataBase
& rBase
,
1972 SvTokenStream
& rInStm
)
1974 UINT32 nTokPos
= rInStm
.Tell();
1975 if( rInStm
.Read( '(' ) )
1977 //DoReadContextSvIdl( rBase, rInStm, ',' );
1978 DoReadContextSvIdl( rBase
, rInStm
);
1979 if( rInStm
.Read( ')' ) )
1981 SetType( TYPE_METHOD
);
1985 rInStm
.Seek( nTokPos
);
1989 /*************************************************************************
1990 |* SvMetaType::WriteMethodArgs()
1993 *************************************************************************/
1994 void SvMetaType::WriteMethodArgs
1996 SvIdlDataBase
& rBase
,
1998 USHORT nTab
, WriteType nT
2001 if( nT
== WRITE_IDL
)
2003 if( GetAttrCount() )
2006 WriteTab( rOutStm
, nTab
);
2007 rOutStm
<< '(' << endl
;
2009 SvMetaAttribute
* pAttr
= pAttrList
->First();
2012 WriteTab( rOutStm
, nTab
+1 );
2013 pAttr
->WriteSvIdl( rBase
, rOutStm
, nTab
+1 );
2014 pAttr
= pAttrList
->Next();
2016 rOutStm
<< ',' << endl
;
2019 WriteTab( rOutStm
, nTab
);
2025 else if ( nT
== WRITE_DOCU
)
2029 if( GetAttrCount() )
2031 SvMetaAttribute
* pAttr
= pAttrList
->First();
2034 pAttr
->WriteParam( rBase
, rOutStm
, nTab
+1, nT
);
2035 pAttr
= pAttrList
->Next();
2042 rOutStm
<< ')' << endl
;
2047 if( nT
== WRITE_C_HEADER
|| nT
== WRITE_C_SOURCE
)
2049 rOutStm
<< ' ' << C_PREF
<< "Object h" << rBase
.aIFaceName
.GetBuffer();
2050 if( GetAttrCount() )
2056 if( GetAttrCount() )
2059 SvMetaAttribute
* pAttr
= pAttrList
->First();
2064 case WRITE_C_HEADER
:
2065 case WRITE_C_SOURCE
:
2068 pAttr
->WriteParam( rBase
, rOutStm
, nTab
+1, nT
);
2074 DBG_ASSERT( FALSE
, "WriteType not implemented" );
2077 pAttr
= pAttrList
->Next();
2079 rOutStm
<< ',' << endl
;
2081 if( nT
!= WRITE_C_HEADER
&& nT
!= WRITE_C_SOURCE
)
2084 WriteTab( rOutStm
, nTab
+1 );
2092 /*************************************************************************
2093 |* SvMetaType::WriteTypePrefix()
2096 *************************************************************************/
2097 void SvMetaType::WriteTypePrefix( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
2098 USHORT nTab
, WriteType nT
)
2104 if( GetIn() && GetOut() )
2105 rOutStm
<< SvHash_inout()->GetName().GetBuffer() << ' ';
2107 rOutStm
<< SvHash_in()->GetName().GetBuffer() << ' ';
2109 rOutStm
<< SvHash_out()->GetName().GetBuffer() << ' ';
2110 rOutStm
<< GetCString().GetBuffer();
2117 BOOL bOut
= GetOut();
2121 rOutStm
<< "[in,out] ";
2125 rOutStm
<< "[out] ";
2129 if( GetType() == TYPE_METHOD
)
2130 out
= GetReturnType()->GetBaseType()->GetOdlName();
2133 SvMetaType
* pBType
= GetBaseType();
2134 out
= pBType
->GetOdlName();
2136 if( aCall0
== (int)CALL_POINTER
2137 || aCall0
== (int)CALL_REFERENCE
)
2139 if( aCall1
== (int)CALL_POINTER
2140 || aCall1
== (int)CALL_REFERENCE
)
2142 rOutStm
<< out
.GetBuffer();
2146 case WRITE_C_HEADER
:
2147 case WRITE_C_SOURCE
:
2148 case WRITE_CXX_HEADER
:
2149 case WRITE_CXX_SOURCE
:
2152 SvMetaType
* pBaseType
= GetBaseType();
2153 DBG_ASSERT( pBaseType
, "no base type for attribute" );
2155 if( pBaseType
->GetType() == TYPE_METHOD
)
2156 pBaseType
->GetReturnType()->WriteTypePrefix(
2157 rBase
, rOutStm
, nTab
, nT
);
2158 else if( nT
== WRITE_C_HEADER
|| nT
== WRITE_C_SOURCE
)
2160 if( TYPE_STRUCT
== pBaseType
->GetType() )
2161 rOutStm
<< C_PREF
<< pBaseType
->GetName().GetBuffer()
2165 if ( pBaseType
->GetType() == TYPE_ENUM
)
2167 rOutStm
<< pBaseType
->GetCName().GetBuffer();
2172 if( TYPE_STRUCT
== pBaseType
->GetType() )
2173 rOutStm
<< pBaseType
->GetName().GetBuffer() << " *";
2175 rOutStm
<< pBaseType
->GetName().GetBuffer();
2183 SvMetaType
* pBaseType
= GetBaseType();
2184 DBG_ASSERT( pBaseType
, "no base type for attribute" );
2186 if( pBaseType
->GetType() == TYPE_METHOD
)
2188 pBaseType
->GetReturnType()->WriteTypePrefix(
2189 rBase
, rOutStm
, nTab
, nT
);
2193 if( TYPE_STRUCT
== pBaseType
->GetType() )
2194 rOutStm
<< "VARIANT" << pBaseType
->GetName().GetBuffer();
2195 else if ( pBaseType
->GetType() == TYPE_ENUM
)
2196 rOutStm
<< "integer";
2198 rOutStm
<< pBaseType
->GetOdlName().GetBuffer();
2204 DBG_ASSERT( FALSE
, "WriteType not implemented" );
2209 /*************************************************************************
2210 |* SvMetaType::WriteTheType()
2213 *************************************************************************/
2214 void SvMetaType::WriteTheType( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
2215 USHORT nTab
, WriteType nT
)
2217 WriteTypePrefix( rBase
, rOutStm
, nTab
, nT
);
2218 if( GetType() == TYPE_METHOD
)
2219 WriteMethodArgs( rBase
, rOutStm
, nTab
+2, nT
);
2222 /*************************************************************************
2223 |* SvMetaType::GetParserString()
2226 *************************************************************************/
2227 ByteString
SvMetaType::GetParserString() const
2229 SvMetaType
* pBT
= GetBaseType();
2231 return pBT
->GetParserString();
2233 int type
= GetType();
2236 if( TYPE_METHOD
== type
|| TYPE_STRUCT
== type
)
2238 ULONG nAttrCount
= GetAttrCount();
2239 // Die einzelnen Attribute schreiben
2240 for( ULONG n
= 0; n
< nAttrCount
; n
++ )
2242 SvMetaAttribute
* pT
= pAttrList
->GetObject( n
);
2243 aPStr
+= pT
->GetType()->GetParserString();
2247 aPStr
= GetParserChar();
2251 /*************************************************************************
2252 |* SvMetaType::WriteParamNames()
2255 *************************************************************************/
2256 void SvMetaType::WriteParamNames( SvIdlDataBase
& rBase
,
2258 const ByteString
& rChief
)
2260 SvMetaType
* pBT
= GetBaseType();
2262 pBT
->WriteParamNames( rBase
, rOutStm
, rChief
);
2265 int type
= GetType();
2268 if( TYPE_METHOD
== type
|| TYPE_STRUCT
== type
)
2270 ULONG nAttrCount
= GetAttrCount();
2271 // Die einzelnen Attribute schreiben
2272 for( ULONG n
= 0; n
< nAttrCount
; n
++ )
2274 SvMetaAttribute
* pA
= pAttrList
->GetObject( n
);
2275 // Fuer Methoden ist rChief immer ""
2276 ByteString aStr
= /*rChief;
2279 aStr += */pA
->GetName();
2280 pA
->GetType()->WriteParamNames( rBase
, rOutStm
, aStr
);
2281 if( n
+1 < nAttrCount
)
2286 rOutStm
<< rChief
.GetBuffer();
2290 #endif // IDL_COMPILER
2292 /************************************************************************/
2293 /************************************************************************/
2294 SV_IMPL_META_FACTORY1( SvMetaTypeString
, SvMetaType
);
2295 /*************************************************************************
2297 |* SvMetaTypeString::SvMetaTypeString()
2301 *************************************************************************/
2302 SvMetaTypeString::SvMetaTypeString()
2303 : SvMetaType( "String", "SbxSTRING", "BSTR", 's', "char *", "String", "$" )
2307 void SvMetaTypeString::Load( SvPersistStream
& rStm
)
2309 SvMetaType::Load( rStm
);
2312 void SvMetaTypeString::Save( SvPersistStream
& rStm
)
2314 SvMetaType::Save( rStm
);
2317 /************************************************************************/
2318 /************************************************************************/
2319 SV_IMPL_META_FACTORY1( SvMetaEnumValue
, SvMetaName
);
2320 /*************************************************************************
2322 |* SvMetaEnumValue::SvMetaEnumValue()
2326 *************************************************************************/
2327 SvMetaEnumValue::SvMetaEnumValue()
2331 void SvMetaEnumValue::Load( SvPersistStream
& rStm
)
2333 SvMetaName::Load( rStm
);
2339 rStm
.SetError( SVSTREAM_FILEFORMAT_ERROR
);
2340 DBG_ERROR( "wrong format" );
2343 if( nMask
& 0x01 ) rStm
.ReadByteString( aEnumValue
);
2346 void SvMetaEnumValue::Save( SvPersistStream
& rStm
)
2348 SvMetaName::Save( rStm
);
2352 if( aEnumValue
.Len() ) nMask
|= 0x01;
2356 if( nMask
& 0x01 ) rStm
.WriteByteString( aEnumValue
);
2360 /*************************************************************************
2362 |* SvMetaEnumValue::ReadSvIdl()
2366 *************************************************************************/
2367 BOOL
SvMetaEnumValue::ReadSvIdl( SvIdlDataBase
& rBase
,
2368 SvTokenStream
& rInStm
)
2370 if( !ReadNameSvIdl( rBase
, rInStm
) )
2375 /*************************************************************************
2377 |* SvMetaEnumValue::WriteSvIdl()
2381 *************************************************************************/
2382 void SvMetaEnumValue::WriteSvIdl( SvIdlDataBase
&, SvStream
& rOutStm
, USHORT
)
2384 rOutStm
<< GetName().GetBuffer();
2387 /*************************************************************************
2389 |* SvMetaEnumValue::Write()
2393 *************************************************************************/
2394 void SvMetaEnumValue::Write( SvIdlDataBase
&, SvStream
& rOutStm
, USHORT
,
2395 WriteType nT
, WriteAttribute
)
2397 if ( nT
== WRITE_C_HEADER
|| nT
== WRITE_C_SOURCE
)
2398 rOutStm
<< C_PREF
<< GetName().GetBuffer();
2400 rOutStm
<< GetName().GetBuffer();
2402 #endif // IDL_COMPILER
2404 /************************************************************************/
2405 /************************************************************************/
2406 SV_IMPL_META_FACTORY1( SvMetaTypeEnum
, SvMetaType
);
2407 /*************************************************************************
2409 |* SvMetaTypeEnum::SvMetaTypeEnum()
2413 *************************************************************************/
2414 SvMetaTypeEnum::SvMetaTypeEnum()
2416 SetBasicName( "Integer" );
2419 void SvMetaTypeEnum::Load( SvPersistStream
& rStm
)
2421 SvMetaType::Load( rStm
);
2427 rStm
.SetError( SVSTREAM_FILEFORMAT_ERROR
);
2428 DBG_ERROR( "wrong format" );
2431 if( nMask
& 0x01 ) rStm
>> aEnumValueList
;
2432 if( nMask
& 0x02 ) rStm
.ReadByteString( aPrefix
);
2435 void SvMetaTypeEnum::Save( SvPersistStream
& rStm
)
2437 SvMetaType::Save( rStm
);
2441 if( aEnumValueList
.Count() ) nMask
|= 0x01;
2442 if( aPrefix
.Len() ) nMask
|= 0x02;
2446 if( nMask
& 0x01 ) rStm
<< aEnumValueList
;
2447 if( nMask
& 0x02 ) rStm
.WriteByteString( aPrefix
);
2450 /*************************************************************************
2452 |* SvMetaTypeEnum::GetMaxValue()
2456 *************************************************************************/
2458 USHORT SvMetaTypeEnum::GetMaxValue() const
2461 for( ULONG n = 0; n < aEnumValueList.Count(); n++ )
2463 SvMetaEnumValue * pObj = aEnumValueList.GetObject( n );
2464 if( nMax < pObj->GetValue() )
2465 nMax = pObj->GetValue();
2472 /*************************************************************************
2474 |* SvMetaTypeEnum::ReadContextSvIdl()
2478 *************************************************************************/
2479 void SvMetaTypeEnum::ReadContextSvIdl( SvIdlDataBase
& rBase
,
2480 SvTokenStream
& rInStm
)
2482 UINT32 nTokPos
= rInStm
.Tell();
2484 SvMetaEnumValueRef aEnumVal
= new SvMetaEnumValue();
2485 BOOL bOk
= aEnumVal
->ReadSvIdl( rBase
, rInStm
);
2488 if( 0 == aEnumValueList
.Count() )
2490 aPrefix
= aEnumVal
->GetName();
2493 USHORT nPos
= aPrefix
.Match( aEnumVal
->GetName() );
2494 if( nPos
!= aPrefix
.Len() && nPos
!= STRING_MATCH
)
2495 aPrefix
.Erase( nPos
);
2497 aEnumValueList
.Append( aEnumVal
);
2500 rInStm
.Seek( nTokPos
);
2503 /*************************************************************************
2505 |* SvMetaTypeEnum::WriteSvIdl()
2509 *************************************************************************/
2510 void SvMetaTypeEnum::WriteContextSvIdl( SvIdlDataBase
& rBase
,
2514 WriteTab( rOutStm
, nTab
+1 );
2515 for( ULONG n
= 0; n
< aEnumValueList
.Count(); n
++ )
2517 aEnumValueList
.GetObject( n
)->WriteSvIdl( rBase
, rOutStm
, nTab
);
2518 if( n
+1 != aEnumValueList
.Count() )
2525 /*************************************************************************
2527 |* SvMetaTypeEnum::ReadSvIdl()
2531 *************************************************************************/
2532 BOOL
SvMetaTypeEnum::ReadSvIdl( SvIdlDataBase
& rBase
,
2533 SvTokenStream
& rInStm
)
2535 UINT32 nTokPos
= rInStm
.Tell();
2536 if( SvMetaType::ReadHeaderSvIdl( rBase
, rInStm
)
2537 && GetType() == TYPE_ENUM
)
2539 if( SvMetaName::ReadSvIdl( rBase
, rInStm
) )
2542 rInStm
.Seek( nTokPos
);
2546 /*************************************************************************
2548 |* SvMetaTypeEnum::WriteSvIdl()
2552 *************************************************************************/
2553 void SvMetaTypeEnum::WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
2556 WriteHeaderSvIdl( rBase
, rOutStm
, nTab
);
2558 SvMetaName::WriteSvIdl( rBase
, rOutStm
, nTab
);
2562 /*************************************************************************
2564 |* SvMetaTypeEnum::Write()
2568 *************************************************************************/
2569 void SvMetaTypeEnum::Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
2571 WriteType nT
, WriteAttribute nA
)
2573 SvMetaType::Write( rBase
, rOutStm
, nTab
, nT
, nA
);
2576 /*************************************************************************
2577 |* SvMetaTypeEnum::WriteContext()
2580 *************************************************************************/
2581 void SvMetaTypeEnum::WriteContext( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
2583 WriteType nT
, WriteAttribute nA
)
2585 WriteTab( rOutStm
, nTab
+1 );
2586 for( ULONG n
= 0; n
< aEnumValueList
.Count(); n
++ )
2588 aEnumValueList
.GetObject( n
)->Write( rBase
, rOutStm
, nTab
+1, nT
, nA
);
2590 if( n
+1 != aEnumValueList
.Count() )
2594 rOutStm
<< ',' << endl
;
2595 WriteTab( rOutStm
, nTab
+1 );
2606 #endif // IDL_COMPILER
2608 /************************************************************************/
2609 /************************************************************************/
2610 SV_IMPL_META_FACTORY1( SvMetaTypevoid
, SvMetaType
);
2611 /*************************************************************************
2613 |* SvMetaTypevoid::SvMetaTypevoid()
2617 *************************************************************************/
2618 SvMetaTypevoid::SvMetaTypevoid()
2619 : SvMetaType( "void", "SbxVOID", "void", 'v', "void", "", "" )
2623 void SvMetaTypevoid::Load( SvPersistStream
& rStm
)
2625 SvMetaType::Load( rStm
);
2628 void SvMetaTypevoid::Save( SvPersistStream
& rStm
)
2630 SvMetaType::Save( rStm
);
2633 ByteString
SvMetaAttribute::Compare( SvMetaAttribute
* pAttr
)
2639 if ( aType
->GetType() == TYPE_METHOD
)
2641 // Nur testen, wenn das Attribut eine Methode ist, nicht wenn es
2643 if ( !pAttr
->GetType()->GetType() == TYPE_METHOD
)
2644 aStr
+= " IsMethod\n";
2645 else if ( aType
->GetReturnType() &&
2646 aType
->GetReturnType()->GetType() != pAttr
->GetType()->GetReturnType()->GetType() )
2647 aStr
+= " ReturnType\n";
2649 if ( aType
->GetAttrCount() )
2651 ULONG nCount
= aType
->GetAttrCount();
2652 SvMetaAttributeMemberList
& rList
= aType
->GetAttrList();
2653 SvMetaAttributeMemberList
& rOtherList
= pAttr
->GetType()->GetAttrList();
2654 if ( pAttr
->GetType()->GetAttrCount() != nCount
)
2656 aStr
+= " AttributeCount\n";
2660 for ( USHORT n
=0; n
<nCount
; n
++ )
2662 SvMetaAttribute
*pAttr1
= rList
.GetObject(n
);
2663 SvMetaAttribute
*pAttr2
= rOtherList
.GetObject(n
);
2664 pAttr1
->Compare( pAttr2
);
2670 if ( GetType()->GetType() != pAttr
->GetType()->GetType() )
2673 if ( !GetType()->GetSvName().Equals( pAttr
->GetType()->GetSvName() ) )
2674 aStr
+= " ItemType\n";
2677 if ( GetExport() != pAttr
->GetExport() )
2678 aStr
+= " Export\n";
2680 if ( GetAutomation() != pAttr
->GetAutomation() )
2681 aStr
+= " Automation\n";
2683 if ( GetIsCollection() != pAttr
->GetIsCollection() )
2684 aStr
+= " IsCollection\n";
2686 if ( GetReadOnlyDoc() != pAttr
->GetReadOnlyDoc() )
2687 aStr
+= " ReadOnlyDoc\n";
2689 if ( GetExport() && GetReadonly() != pAttr
->GetReadonly() )
2690 aStr
+= " Readonly\n";
2695 void SvMetaAttribute::WriteCSV( SvIdlDataBase
&, SvStream
& rStrm
)
2697 rStrm
<< GetType()->GetSvName().GetBuffer() << ' ';
2698 rStrm
<< GetName().GetBuffer() << ' ';
2699 rStrm
<< GetSlotId().GetBuffer();